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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

moving between two forms on same screen

Status
Not open for further replies.

wekkew

Programmer
Sep 28, 1998
123
GB
Hello

I have two forms and I need to display form2 ontop of form1. Form2 is displayed with statement form2.show. All ok so far - but when I now click on form1 - form2 disappears!

How can I get both forms to still show and yet still be able to click from one to the other?

Have tried using zorder, modal forms but no luck. If I have to use mdi than that's ok I just want to be able to click from one form to another - seems so straightforward but I can't get it to work!

thanks - Catherine
 
HI,

The easiest way is to use an mdi form for form1 and an mdi child form for form2.Be sure to set form2's mdichild property to TRUE.

Have a good one!
BK
 

Dear BK

ok - thanks for that. It works with MDI, but just to be awkward - can I do it without using MDI?

ta
Kate
 
I'm kind of new to this, but have you tried the simple stuff. Make the forms vbModal, or form.x.setfocus. Also, as I'm sure you know, you can set the position of where the form opens at design-time.
Just a simple thought. I did this one time but deleted the project, could not find it. I know that I set the main form to open center and positioned frm2 to the right of frmMain. Did not use MDI though. I was so new to VB at the time that MDI had'nt even came into play yet.
 
'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

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top