| | |
Data App With Multiple Windows
![]() |
I want to create an application that consists of several "modules", each of which would be based on a database table, and will be opened either from a menu or from a button in an Outlook-styled toolbar. Obviously I'll create a "main" window, but then there will be several windows, one for each "module", of different sizes, each with its own toolbar and controls, that I want to be constrained within the boundaries of the main window. In other words, I don't want the module window(s) to appear as Windows taskbar buttons (I can do that part), but I also don't want the windows to be draggable beyong the frame of the main window, and if minimized, I want these windows to minimize within the main window.
I have tried using MDI, but that doesn't seem suited to what I'm trying to do, unless I haven't fully explioted the functionality of that concept. As usual, I don't really need code examples (but I'll sure take 'em); if someone could just explain the concept or the general procedure I can run with it.
I have tried using MDI, but that doesn't seem suited to what I'm trying to do, unless I haven't fully explioted the functionality of that concept. As usual, I don't really need code examples (but I'll sure take 'em); if someone could just explain the concept or the general procedure I can run with it.
Well, The main idea behind what you are trying to do is completely MDI. However, I'm going to treat you to a little gem, that, depending on the app (since you are using your own forms, it's no problem) can cause troubles. This is a ... technique of sorts, that is namely taboo. Here you go, Though.
In A Code Module, Add This:
Now, in your MAIN Form Load, you just simple add this (keep in mind, that you can add this anywhere that you want to in your main form... a menu, a button... whatever). This is the code to grab your form, and stick it inside your other form.
Now, make sure to replace Form2 with the name of the form that you want inside (or however many forms you want inside) of the main window. Change the name of MainForm, To the name of your main form (don't lose the .hWnd's that follow).
In A Code Module, Add This:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Public Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Dim oldhwnd As Long
Now, in your MAIN Form Load, you just simple add this (keep in mind, that you can add this anywhere that you want to in your main form... a menu, a button... whatever). This is the code to grab your form, and stick it inside your other form.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
oldhwnd = SetParent(Form2.hWnd, MainForm.hWnd)
Now, make sure to replace Form2 with the name of the form that you want inside (or however many forms you want inside) of the main window. Change the name of MainForm, To the name of your main form (don't lose the .hWnd's that follow).
OK. Here's what I figured out:
I started a new Standard EXE project, which of course automatically creates a form (Form1). I then created a new MDI form, made it the default form in the project properties and set the "MDIChild" property of the automatically created form (Form1) to "true", which keeps it within the boundaries of the MDI form. So now the MDI form acts as the "main" window. I can now create other forms and by setting their MDIChild property to true, each of them will behave in the same manner.
Thanks for pointing me in the right direction. I think I'm well on my way to becoming a rookie programmer!
I started a new Standard EXE project, which of course automatically creates a form (Form1). I then created a new MDI form, made it the default form in the project properties and set the "MDIChild" property of the automatically created form (Form1) to "true", which keeps it within the boundaries of the MDI form. So now the MDI form acts as the "main" window. I can now create other forms and by setting their MDIChild property to true, each of them will behave in the same manner.
Thanks for pointing me in the right direction. I think I'm well on my way to becoming a rookie programmer!
![]() |
Similar Threads
- Can't Keep Multiple Windows Open (Web Browsers)
- Internet Explorer multiple windows problem - XP (Web Browsers)
- Binary data in app.config (C#)
- Urgent!!! Multiple IE windows on startup (Web Browsers)
- Close Multiple Windows (Windows tips 'n' tweaks)
- Can't close multiple IE windows (Web Browsers)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: New to VB can someone help ?
- Next Thread: Setting the command buttons Forecolor
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






