Simulation MDI

Hi does any body have some code that simulates mdi that works under NT4. I can set the parent of a form to a picture box of another form to simulate mdi but when I move the form within the picturebox there is an offset in the move message. The offset is the distance the simulated mdi form is from 0,0 so when i move the mdi form to the top left of the screen all's fine but as i move the mdi form to the bottom right corner things get worse & worse. I have got around the problem  by subclassing the form and hooking WM_MOVE, WM_MOVING, WM_EXITSIZEMOVE but I would like a better solution.

   
LVL 3
julianpointerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mcriderCommented:
What's wrong with just creating your program as a MDI??

Cheers!
0
VBGuruCommented:
what actually you are looking for. May be there is an alternative way to do the task.
0
amebaCommented:
Sample with only one child form (Form2).

' Form1: add button and picturebox, paste this code
Option Explicit
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_POPUP = &H80000000

Private Sub Command1_Click()
    Dim m_oldstyle As Long
    Load Form2 ' load child form
    SetParent Form2.hwnd, Me.Picture1.hwnd
   
    m_oldstyle = GetWindowLong(Form2.hwnd, GWL_STYLE)
    Call SetWindowLong(Form2.hwnd, GWL_STYLE, (m_oldstyle Or WS_POPUP))
   
    Form2.Move 0, 0
    Form2.Show
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Unload Form2  ' unload child form
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

VBGuruCommented:
I think what he expects is the scroll bars which comes in the mdi form when you move the form to the buttom of the mdi form
check out
http://vbaccelerator.com/codelib/ssubtmr/sbrclass.htm

it may be of use.
0
caraf_gCommented:
Ameba said it. It's the WS_POPUP that'll fix your problem for you.
0
amebaCommented:
or it was WS_CARAF_G_POSITION
SetParent Blues, 10 pts
http://oldlook.experts-exchange.com/bin/Q.10165031

' Here is code for child form - when focus goes to child form, main form title bar will change color to 'inactive' without this
' credits: vbpj
' Form2 code
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_NCACTIVATE = &H86

Private Sub Form_Activate()
    Call SendMessage(Form1.hWnd, WM_NCACTIVATE, 1, ByVal 0&)
End Sub
0
caraf_gCommented:
:-)
0
julianpointerAuthor Commented:
Hi ameba,
    Everything works great.....
Can you post an answer so i can give you the points.
0
caraf_gCommented:
If you look at the "title bar" over ameba's comment you'll see that there's a hotlink for accepting the comment as an answer.
0
julianpointerAuthor Commented:
Thanks
0
amebaCommented:
Thanks.
Credits also to caraf_g for his contribution when making code this short (2 lines to modify one style bit).
0
julianpointerAuthor Commented:
How ca I add scrollbars to the picturebox ??
0
amebaCommented:
I think you can modify it's style bit, I'll try it later.
0
amebaCommented:
I tried and added scrollbars, but there is more - getting events, set/getscrollinfo ...

so it's easier to use 2 scrollbar controls and 2 pictureboxes, e.g.:
http://www.vb-helper.com/HowToInt.htm
Make a scrolled window (24K)

You'll need to add some calculation - whenever child form is moved/resized, scroll range must be set.
0
julianpointerAuthor Commented:
Whats the best place to find out when a child is moved.. There are many 100+ child forms ????
0
amebaCommented:
I hate subclassing, so I would try to avoid code to subclass and catch WM_MOVE/WM_SIZE messages.
Maybe using timer, 2 seconds interval, is not bad idea...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.