Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 827
  • Last Modified:

VB6 - Selecting a form within a form makes the parent form 'inactive'

Okay, lets say I have a form, and I add a child form to appear in it.. What I mean is:

In FormMain I have a button with:
    frmChild.Show vbModeless, Me

And in frmChild, FormLoad is:

    SetParent Me.hWnd, frmMain.hWnd
    Me.Top = (Me.Height - frmMain.Height) - frmStart.Top + 4300
    Me.Left = 2190

Basicly, a form gets loaded INSIDE frmMain. The issue is, when I alt tab and try to click the form when frmChild is active, it doesn't get pushed up, basicly it doesn't reconize that frmMain should be brought up when I click frmChild.. FOR EXAMPLE: I bring up frmMain, click the button to bring up frmChild.. I open up lets say notepad, so notepad is now active. I try to click frmMain in the background without using the taskbar, basicly by trying to click frmChild, and it DOES NOT become active again! Basicly frmChild is not seen as part of frmMain is what I am guessing.. Wierd behaviour...

As well, when I click frmChild that is inside the frmMain, frmMain goes 'inactive', basicly what I mean is the top bar becomes 'inactive', so it would become gray, or a light blue in Vista to indicate the form is not the active form. This is an issue because I want to have frmChild apart of frmMain, so frmMain should be active too!
0
Valleriani
Asked:
Valleriani
  • 2
  • 2
1 Solution
 
cmrobertsonCommented:
did you set the mdichild property of the child form to true?
0
 
GrahamSkanRetiredCommented:
Yes. That sort of behaviour is best achieved in VB6 with the parent form being an MDI form with any contained forms should having their MDIChild property set.
0
 
VallerianiAuthor Commented:
How would i load a MDI child? Right now when I use frmChild.Show vbModeless, Me for example, it states No MDI form avail to load.

I use a MDI form, however, I'm wondering how to get the main form to appear. for example I'll show an example of how I'm using it via picture.

Where the white area is, the sub-forms appear when you click the buttons on the left.

I'm not sure how I can acheieve this with a MDI form, because it seems like I'd have to make the current parent form a MDI child as well?.. Confused in that sense...
test.jpg
0
 
VallerianiAuthor Commented:
Oh the above is how I have it as well, not a MDI form, just how it comes as a regular form.. How would I achieve to change this now?

The forms must move inside the main form, so when I click one of the side buttons, some info fills in at the main middle form where the white is, basicly loads a form... However, right now it moves fine and such with the current 'parent' form.
0
 
GrahamSkanRetiredCommented:
You really have to start out with the MDI model. You cannot convert a standard form into an MDI form. You might be able to copy the existing controls from the old to the new.

There are restrictions to MDI forms. You can only use certain controls directly on the form - 'bar' controls and the picture control. They are always 'docked'.  In your form, the left-hand panel could be (and possibly already is) a picture box. The bar at the button could be a label placed on to a picture box.

I used to use the Sheridan (SS) panel, but that is now deprecated.

Another possibility to using MDI is to use the API SetWindowsPos, though I haven't tried it myself in this context.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now