Link to home
Start Free TrialLog in
Avatar of julianpointer
julianpointer

asked on

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.

   
Avatar of mcrider
mcrider

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

Cheers!
what actually you are looking for. May be there is an alternative way to do the task.
ASKER CERTIFIED SOLUTION
Avatar of ameba
ameba
Flag of Croatia 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
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.
Ameba said it. It's the WS_POPUP that'll fix your problem for you.
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
:-)
Avatar of julianpointer

ASKER

Hi ameba,
    Everything works great.....
Can you post an answer so i can give you the points.
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.
Thanks
Thanks.
Credits also to caraf_g for his contribution when making code this short (2 lines to modify one style bit).
How ca I add scrollbars to the picturebox ??
I think you can modify it's style bit, I'll try it later.
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.
Whats the best place to find out when a child is moved.. There are many 100+ child forms ????
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...