Link to home
Start Free TrialLog in
Avatar of pumbaaca
pumbaacaFlag for United States of America

asked on

Visual Basic Forms?

I am using several forms within my VB app...none of which are MDI forms. When I call a new form up...I can get it to center OK within the Primary form, however, when I switch to a different application on my desktop and then go back to my program...the secondary form is not in the Primary form. How can I prevent this. Also, for some reason, the "Add MDI Form" option on the "Project" Menu is disabled...why is that?

Thanks,

Blake McKenna
Avatar of Kinger247
Kinger247

are you opening the last for modaly ?
and what version of vb are you using ?

vb6 would be : frmYourForm.Show vbModal
I used to belong to this site last year and subscription ran out. I was using a co-workers account that he let me use. I wanted to join myself again and realized that the system still had my old email address...so I just re-upped.

I am using VB6 and I do open them modally. What I am trying to do is keep the child form (non-mdi) within the primary form at all times. Is that possible using non-MDI forms?
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When you are dealing with non-MDI forms, then you cannot have one form inside another. So, as you are saying that you want the secondary form to be inside primary one, that is not possible. Both forms are separate ones (as they are non-MDI forms).

But, when you want your secondary form to override the primary one, means until you close(by finishing its task) the secondary form, you should not come to primary one. If this is the case, then you should open your secondary form modally. like. . .

         dim frmSecondary as new Form2
         frmSecondary.Show vbModal

I feel this should solve your problem. Second, when you are having non-MDI forms in your project, then you can anytime add one MDI form. If you are not able to do so, then there must be some other issue, please check everything again.
You can do this through following API
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