Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping a form focused

Status
Not open for further replies.

capone67

Programmer
Nov 6, 2000
115
CA
Hi Gang

I have an activeX control that has two forms. The second form comes up and asks if the user would like to continue. The problem is if the user clicks outside of second form the form disappears. What I want is that the second form always stays on top of the first form.

Any ideas on how to acheive this without using msgbox?

Ken
 
Hi

you can do it by defining the second form as vbmodal when you load it
the code should be:

form2.show vbmodal

yaakov
 
Make Your Form Be Top Most

'This sample will show you how to make your form to be Top Most (Like ICQ)
'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 2 CommandButtons to your form (named Command1 and Command2).
'When you will press the first button the form will be top most.
'When you will press the second button the form will back to the regular state.
'Insert this code to the module :

Declare Function SetWindowPos Lib "user32" (ByVal h%, ByVal hb%, _
ByVal x%, ByVal Y%, ByVal cx%, ByVal cy%, ByVal F%) As Integer
Global Const SWP_NOMOVE = 2
Global Const SWP_NOSIZE = 1
Global Const flags = SWP_NOMOVE Or SWP_NOSIZE
Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2

'Insert the following code to your form:

Private Sub Command1_Click()
res = SetWindowPos(Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, flags)
End Sub

Private Sub Command2_Click()
res = SetWindowPos(Form1.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, flags)
End Sub

Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX
Source CodeBook for the programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top