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

Make MDI Child Modal? 1

Status
Not open for further replies.

mwa

Programmer
Jul 12, 2002
507
US
I have an MDI parent that has 2 child forms (frmScan and frmRoomList). I would like for frmScan to remain modal so that the user can not access frmRoomList. It is only there to show a list of items. All the work should be done on frmScan. The following returns an error:
Code:
Dim frmScan As New ScanItem
frmScan.MdiParent = Me.MdiParent
frmScan.ShowDialog()
Error: Form that is not a top-level form cannot be displayed as a modal dialog box

From what I have been reading, it is not possible to have an MDI form be the parent of a modal child. However, nothing i've read gives a workaround. So, does anyone have an idea how to accomplish this task?

Thanks in advance,

mwa
<><
 
Just think about your experience as a Windows user historically. Modal forms are not MDI child forms. If they were, it would kind of go against the definition of Multiple Document Interface. When creating Windows applications, you want to stick to the standards which have been developed so a new user won't be confused and can operate your application with a minimal learning curve as far as the GUI is concerned.

A dialog form should be a regular form.
 
OK... I understand what you are saying, and do not disagree. So maybe I am not using MDI forms in the traditional sense, but it seemed like the appropriate solution for displaying 2 forms at once, while contained within a parent form. So, let me back up a little and explain the application a bit further.

I am building an asset tracking application. All assets are tagged with a bar code sticker. The PC running the application will have a USB bar code scanner attached. When the MDI Parent opens, it loads the two child forms (frmScan and frmRoomList). frmScan will accept the scanned bar code into a textbox. frmRoomList will only display a list of assets that are supposed to be in that room. I need frmScan to remain the active/focused window at all times. If it is not this way, when the user clicks on frmRoomList, and begins scanning, no values will be recorded. They could potentially scan an entire room full of assets, and not record anything. Only frmScan can accept scans from the USB scanner.

So, should I try using something other that MDI?

mwa
<><
 
I'm not sure I understand. Are you saying you want the user to have frmRoomList up on their screen to work with, and that frmScan's only purpose is to accept a barcode scan?
 
frmRoomList is a read only list of all items in a room. As barcodes are scanned and recorded in frmScan, the item is highlighted on frmRoomList to indicate that it was scanned. frmRoomList is only there to assist the user so that they know what items are in that room, and show them which items remain to be scanned.
screenprint.png


Does that make sense now?

mwa
<><
 
You might want to look into docking the frmRoomList to the side of its parent form (the MDI). Then set the frmRoomList to give frmScan the focus if the form is loaded. when the frmScan is loaded, make sure it is set to be on the other side of the form. A splitter control may help this. If the form is not loaded, then you may want a message box or something that will let the users know that scanning is not possible at this time. That is one of the good things about windows.... more than one way to get there.

--------------------------------------------------
"...and did we give up when the Germans bombed Pearl Harbor? NO!"

"Don't stop him. He's roll'n."
--------------------------------------------------
 

Also, you can create a third "container" form, put 2 panels on it and add the scan and room forms to those panels. Then you just open up the container form and the scan and room forms are opened together. This way you don't have to worry about users closing the scan form but not the room form, as they can only be opened or closed together via the container form.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
I would just add the listview from AssetList to the ScanItem form.
 
I would do like RiverGuy suggests. Then if you want to allow them to size between one or the other put them in a SplitContainer.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
OK. I moved the ListView over to frmScan. Here is what it looks like now:

screenprint2.png


Thanks for everyone's responses.


mwa
<><
 
Yeah, I like the way it turned out. I don't care for the extra space below the buttons, but I can deal with it. Thanks for the asistance.

mwa
<><
 
It would look better if you put the buttons on the bottom (anchored to the bottom), or maybe put the entire left side in a group box.
 
This question is for mwa.

I was looking for help on another subject, but came across this thread and saw screenshots of your form. I really like the way it looks and would like to know how to make the rounded corners on your forms and buttons.

Also what colors are you using in your form? Are they a Windows theme or have you set your app to that color?

I am new to .Net and object oriented programming (I come from a COBOL background) and have not been able to find help on this. If you could point me in the right direction, I would greatly appreciate it.

Thanks,
FM
 
Yeah, nothing fancy here... The application is just using the System settings of the PC. I have my PC's Display Properties set to:
Windows and Buttons - Windows XP Style
Color Scheme - Silver
Font Size - Large Fonts

Hope that helps...

mwa
<><
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top