It's hard to say in few line so this example is the best way to describe:
Step to reproduce the behavior :
Create a new vb6 project, create two form named form1 and form2. Double click on form1 and paste this code :
Now press F5 to run the application, you will see both form show up.Code:Const HWND_TOP = 0 Const HWND_TOPMOST = -1 Const HWND_NOTOPMOST = -2 Const SWP_NOMOVE = &H2 Const SWP_NOSIZE = &H1 Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private Sub Form_Load() Call SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) Form2.Show End Sub
Click on Form2 to make it have focus, then click on the vb6 ide to make the IDE have focus and form2 will disappear. Form1 still appear because it's have HWND_TOPMOST, now click on Form1 to make Form1 have focus. But when you click on Form1, Form2 suddenly show up, that is very annoy. This behavior not occur if you're using vb.net with the same code. So how to prevent form2 show up when i click back to form1 in this case?




Reply With Quote