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
| 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]" <
[email protected]> schreef in
bericht
| | > 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
| >
| > | > | 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
| > |
| > |
| >
| >
|
|