Hi,
When I create a new application, with just one button, then this code works
as expected:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim f As New ColorDialog
f.ShowDialog()
End Sub
As soon as I add some controls (a PictureBox, some NumericUpDown controls,
....) the ShowDialog does not work anymore: when I press the button, the
dialog is invisible. When I switch to another application and then back to
my app, the dialog box instantly becomes visible.
I can also press the <Alt> key to make the dialog visible. The same
behaviour goes for FontDialog, OpenFileDialog, ...
Thanks,
WvH 8 5097
Pass a reference to the dialog's owner through the constructor in this case
Me.
Regards,
--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA http://groups.msn.com/desarrolladoresmiranda http://www.consein.com
"WvH" <Wv*@nospam.msn.com> escribió en el mensaje
news:42***********************@news.skynet.be... Hi,
When I create a new application, with just one button, then this code works as expected:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f As New ColorDialog f.ShowDialog() End Sub
As soon as I add some controls (a PictureBox, some NumericUpDown controls, ...) the ShowDialog does not work anymore: when I press the button, the dialog is invisible. When I switch to another application and then back to my app, the dialog box instantly becomes visible.
I can also press the <Alt> key to make the dialog visible. The same behaviour goes for FontDialog, OpenFileDialog, ...
Thanks,
WvH
WvH,
Did you only drag those buttons or add as well something as topmost?
Cor
WvH,
As Angle suggests pass the "owner" to the ShowDialog.
Something like:
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
| System.EventArgs) Handles Button1.Click
| Dim f As New ColorDialog
| f.ShowDialog(Me)
| End Sub
Note it goes on the call to ShowDialog, not the constructor.
Hope this helps
Jay
"WvH" <Wv*@nospam.msn.com> wrote in message
news:42***********************@news.skynet.be...
| Hi,
|
| When I create a new application, with just one button, then this code
works
| as expected:
|
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
| System.EventArgs) Handles Button1.Click
| Dim f As New ColorDialog
| f.ShowDialog()
| End Sub
|
| As soon as I add some controls (a PictureBox, some NumericUpDown controls,
| ...) the ShowDialog does not work anymore: when I press the button, the
| dialog is invisible. When I switch to another application and then back to
| my app, the dialog box instantly becomes visible.
|
| I can also press the <Alt> key to make the dialog visible. The same
| behaviour goes for FontDialog, OpenFileDialog, ...
|
| Thanks,
|
| WvH
|
|
Jay and Angle,
Thanks for the suggestion, but unfortunately no difference.
I'm getting closer to the cause of the problem though: there is 1 PictureBox
on the form, which has only got this code:
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim bit As Bitmap = New Bitmap(20, 20)
PictureBox1.Image = bit
End Sub
If I leave out the PictureBox1.Image = bit , the ColorDialog appears
correctly.
I'm obviously missing something...
Thanks,
WvH
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> schreef in bericht
news:uf**************@TK2MSFTNGP14.phx.gbl... WvH, As Angle suggests pass the "owner" to the ShowDialog.
Something like:
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As | System.EventArgs) Handles Button1.Click | Dim f As New ColorDialog | f.ShowDialog(Me) | End Sub
Note it goes on the call to ShowDialog, not the constructor.
Hope this helps Jay
"WvH" <Wv*@nospam.msn.com> wrote in message news:42***********************@news.skynet.be... | Hi, | | When I create a new application, with just one button, then this code works | as expected: | | Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As | System.EventArgs) Handles Button1.Click | Dim f As New ColorDialog | f.ShowDialog() | End Sub | | As soon as I add some controls (a PictureBox, some NumericUpDown controls, | ...) the ShowDialog does not work anymore: when I press the button, the | dialog is invisible. When I switch to another application and then back to | my app, the dialog box instantly becomes visible. | | I can also press the <Alt> key to make the dialog visible. The same | behaviour goes for FontDialog, OpenFileDialog, ... | | Thanks, | | WvH | |
Cor,
I just did some basic stuff:
New project, with 1 form, 1 button, 1 colordialog, 1 picturebox. There is
very little code until now (2 subs):
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
ColorDialog1.ShowDialog(Me)
End Sub
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim bit As Bitmap = New Bitmap(20, 20)
PictureBox1.Image = bit
End Sub
If I leave out PictureBox1.Image = bit, clicking the button does correctly
show the colordialog.
Thanks,
WvH
"Cor Ligthert [MVP]" <no************@planet.nl> schreef in bericht
news:um**************@tk2msftngp13.phx.gbl... WvH,
Did you only drag those buttons or add as well something as topmost?
Cor
WvH,
Your program is terrible looping in the routine where it is painting the
picturebox
Maybe you can set that picturebox.Image in another place than where it tells
that it is painting it after that it is set.
I hope this helps,
Cor
WvH,
As Cor states:
You are setting the PictureBox1.Image which is causing the PictureBox1.Paint
event to be raised which sets the PictureBox1.Image property, which is
causing the PictureBox1.Paint event to be raised which sets the
PictureBox1.Image property, which is causing the PictureBox1.Paint event to
be raised, which continues until you terminate your app.
For a demonstration of what is happening, try the following code:
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Debug.WriteLine("Begin PictureBox1_Paint")
Debug.Indent()
Debug.WriteLine("Begin set image")
Dim bit As Bitmap = New Bitmap(20, 20)
PictureBox1.Image = bit
Debug.WriteLine("End set image")
Debug.Unindent()
Debug.WriteLine("End PictureBox1_Paint")
End Sub
Private Sub PictureBox1_Invalidated(ByVal sender As Object, ByVal e As
System.Windows.Forms.InvalidateEventArgs) Handles PictureBox1.Invalidated
Debug.WriteLine("PictureBox1_Invalidated")
End Sub
As Cor suggests you need to remove setting the PictureBox1.Image in the
PictureBox1.Paint event handler.
Hope this helps
Jay
"WvH" <Wv*@nospam.msn.com> wrote in message
news:42***********************@news.skynet.be...
| Jay and Angle,
|
| Thanks for the suggestion, but unfortunately no difference.
|
| I'm getting closer to the cause of the problem though: there is 1
PictureBox
| on the form, which has only got this code:
|
| Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As
| System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
|
| Dim bit As Bitmap = New Bitmap(20, 20)
| PictureBox1.Image = bit
|
| End Sub
|
| If I leave out the PictureBox1.Image = bit , the ColorDialog appears
| correctly.
|
| I'm obviously missing something...
|
| Thanks,
| WvH
|
|
| "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> schreef in
bericht
| news:uf**************@TK2MSFTNGP14.phx.gbl...
| > WvH,
| > As Angle suggests pass the "owner" to the ShowDialog.
| >
| > Something like:
| >
| > | Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
| > | System.EventArgs) Handles Button1.Click
| > | Dim f As New ColorDialog
| > | f.ShowDialog(Me)
| > | End Sub
| >
| > Note it goes on the call to ShowDialog, not the constructor.
| >
| > Hope this helps
| > Jay
| >
| > "WvH" <Wv*@nospam.msn.com> wrote in message
| > news:42***********************@news.skynet.be...
| > | Hi,
| > |
| > | When I create a new application, with just one button, then this code
| > works
| > | as expected:
| > |
| > | Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
| > | System.EventArgs) Handles Button1.Click
| > | Dim f As New ColorDialog
| > | f.ShowDialog()
| > | End Sub
| > |
| > | As soon as I add some controls (a PictureBox, some NumericUpDown
| > controls,
| > | ...) the ShowDialog does not work anymore: when I press the button,
the
| > | dialog is invisible. When I switch to another application and then
back
| > to
| > | my app, the dialog box instantly becomes visible.
| > |
| > | I can also press the <Alt> key to make the dialog visible. The same
| > | behaviour goes for FontDialog, OpenFileDialog, ...
| > |
| > | Thanks,
| > |
| > | WvH
| > |
| > |
| >
| >
|
|
Jay & Cor,
After creating a seperate subroutine for assigning the image, everything is
working as expected.
Thanks for explaining and for my first debugging lesson ;-)
WvH
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> schreef in bericht
news:%2****************@tk2msftngp13.phx.gbl... WvH, As Cor states:
You are setting the PictureBox1.Image which is causing the PictureBox1.Paint event to be raised which sets the PictureBox1.Image property, which is causing the PictureBox1.Paint event to be raised which sets the PictureBox1.Image property, which is causing the PictureBox1.Paint event to be raised, which continues until you terminate your app.
For a demonstration of what is happening, try the following code:
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint Debug.WriteLine("Begin PictureBox1_Paint")
Debug.Indent() Debug.WriteLine("Begin set image") Dim bit As Bitmap = New Bitmap(20, 20) PictureBox1.Image = bit Debug.WriteLine("End set image") Debug.Unindent()
Debug.WriteLine("End PictureBox1_Paint") End Sub
Private Sub PictureBox1_Invalidated(ByVal sender As Object, ByVal e As System.Windows.Forms.InvalidateEventArgs) Handles PictureBox1.Invalidated Debug.WriteLine("PictureBox1_Invalidated") End Sub As Cor suggests you need to remove setting the PictureBox1.Image in the PictureBox1.Paint event handler.
Hope this helps Jay
"WvH" <Wv*@nospam.msn.com> wrote in message news:42***********************@news.skynet.be... | Jay and Angle, | | Thanks for the suggestion, but unfortunately no difference. | | I'm getting closer to the cause of the problem though: there is 1 PictureBox | on the form, which has only got this code: | | Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As | System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint | | Dim bit As Bitmap = New Bitmap(20, 20) | PictureBox1.Image = bit | | End Sub | | If I leave out the PictureBox1.Image = bit , the ColorDialog appears | correctly. | | I'm obviously missing something... | | Thanks, | WvH | | | "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> schreef in bericht | news:uf**************@TK2MSFTNGP14.phx.gbl... | > WvH, | > As Angle suggests pass the "owner" to the ShowDialog. | > | > Something like: | > | > | Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As | > | System.EventArgs) Handles Button1.Click | > | Dim f As New ColorDialog | > | f.ShowDialog(Me) | > | End Sub | > | > Note it goes on the call to ShowDialog, not the constructor. | > | > Hope this helps | > Jay | > | > "WvH" <Wv*@nospam.msn.com> wrote in message | > news:42***********************@news.skynet.be... | > | Hi, | > | | > | When I create a new application, with just one button, then this code | > works | > | as expected: | > | | > | Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As | > | System.EventArgs) Handles Button1.Click | > | Dim f As New ColorDialog | > | f.ShowDialog() | > | End Sub | > | | > | As soon as I add some controls (a PictureBox, some NumericUpDown | > controls, | > | ...) the ShowDialog does not work anymore: when I press the button, the | > | dialog is invisible. When I switch to another application and then back | > to | > | my app, the dialog box instantly becomes visible. | > | | > | I can also press the <Alt> key to make the dialog visible. The same | > | behaviour goes for FontDialog, OpenFileDialog, ... | > | | > | Thanks, | > | | > | WvH | > | | > | | > | > | |
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Richard L Rosenheim |
last post by:
I would like to detect when a form is invoked as the result of a ShowDialog
call.
Anyone have any ideas or suggestions on how to do that?
TIA,
Richard Rosenheim
|
by: Miguel Arenas |
last post by:
I developed a application, and is working fine in Windows 2000, but in WinXP...
Form1 call Form2.Showdialog, and when Form2 is closed I get a message error.
I try other way, Form2.Show and this is...
|
by: Homa |
last post by:
Hi
I'm working on a program that will have 3 forms: a main form, a status
form and a sub-form.
The main form and status form are always appear, and my sub-form is a
singleton (for performance...
|
by: Pieter |
last post by:
Hi,
I have some very specific needs, and I am not able to find a nice solution.
What I need is:
- when the user makes a choice in the Menu, the Form of his choice must
open, but:
- this Form...
|
by: osmarjunior |
last post by:
I have a sequence of commands like this:
Form1 frm = new Form1();
frm.LoadData();
Boolean confirm = (frm.ShowDialog() == DialogResult.OK);
The LoadData method loads information from...
|
by: SammyBar |
last post by:
Hi all,
I'm having troubles with a Symbol 9000 device (Compact Framework v 1.1) when
activating the barcode scanner from a window. The problem is related to the
Activated event of the form which...
|
by: Miro |
last post by:
I will try my best to ask this question correctly. I think in the end the
code will make more sence of what I am trying to accomplish. I am just not
sure of what to search for on the net.
I...
|
by: Dom |
last post by:
I have a Main form called frmMain which appears when the program
starts, and a second form called frmUserName. frmMain has a button,
btnUserName. When you click it, I have this code:
...
|
by: =?Utf-8?B?a2VubmV0aG1Abm9zcGFtLm5vc3BhbQ==?= |
last post by:
vs2005, c#
Trying to understand why one way works but the other doesnt.
I have not tried to create a simpler mdi/child/showdialog app for posting
purposes (I think even this would not be so small...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |