views:

290

answers:

1

To recreate this behaviour, you need to create a pop-up form with the following properties:

(1) ShowInTaskBar = False

(2) Display the form with the Show method and loop until the form is not Visible.

(3) In order to close the form when the mouse is clicked out of it, override OnDeactivate, and set visible to False.

Next, create another form that will display the pop-up when a button is clicked:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As Syste
    Using pop As New PopUp
        pop.Visible = True
        Do While pop.Visible
            Application.DoEvents()
            NativeMethods.MsgWaitForMultipleObjectsEx(0, IntPtr.Zero, 250, &HFF, 4)
        Loop
        Me.Activate()
    End Using
End Sub

Start the project, expand the form to fill the screen, and click the button to open the pop-up. Next click back onto anywhere in the original form. Most times, but not always, the original form will disappear for a split second before reappearing again - thus causing a flicker effect.

Delving into reflector and System.Windows.Forms.Design.DropDownHolder I found the following in CreateParams that solves the flicker issue:

createParams.Style = (createParams.Style Or -2139095040)

Unfortunately, it also puts a black border around the form. (You'll have to set FormBorderStyle = System.Windows.Forms.FormBorderStyle.None to see this.)

Does anyone have any idea what this style does apart from putting the black border round the form?

I've searched google with the number and the hex equivalent but can find nothing.

Thanks.

ETA: I've had a look at a list of style constants at pinvoke.net but I'm non the wiser.

+2  A: 
-2139095040 = 0x80800000 = WS_POPUP | WS_BORDER

This seems to be the culprit for the border too.

wqw
Thanks, that's spot on!
Jules