PDA

Click to See Complete Forum and Search --> : Always on top


rabih
Nov 17th, 2000, 01:17 PM
Hi...
I was implenting the "Always on Top" feature using the API in a VB program I've written ... but I then releazed that, whenever the user clicks on the "About" form in the program... the program craches, due to this Always on Top thing. So I added some code to disable Always on Top when the user clicks About, then set it back on... when the user clicks Ok in About.

1. Is this the right way to do it... ?
2. How come msgboxes do not get affected by this problem and they continue to function well... Are they coded in a way that would also disabel Always on Top when they're displayed.. ?

Thanks a lot...

Nov 17th, 2000, 03:26 PM
Make your About Form an "always on top" form as well.

Code for Form1 (with a CommandButton)

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 Command1_Click()
Form2.Show 1
End Sub

Private Sub Form_Load()
SetWindowPos hwnd, -1, 0, 0, 0, 0, 3
End Sub


code for Form2.

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()
SetWindowPos hwnd, -1, 0, 0, 0, 0, 3
End Sub