Solved

Docking windows in MDI

Posted on 1998-02-05
1
1,690 Views
Last Modified: 2010-08-05
Hello,
I'm building an MDI application, and I want to dock some of the child forms to the MDI (Like VB5 IDE, where you can dock the propery form to the MDI, or undock it).

How can I do that?
0
Comment
Question by:yronnen
1 Comment
 
LVL 6

Accepted Solution

by:
anthonyc earned 130 total points
ID: 1455764
You can control the form yourself.  The problem is, while you move a form, unless you do some subclassing with the SendMessage WinAPI, you can't tell where a form is WHILE it's being moved.  

One way you could implement this, although not pretty, is with a timer.  If you are using VB5, you can use the timer control or use callbacks with Settimer/killtimer.  I'll describe the timer control method.

1)  Set the timer interval to 1/5th of a second (200).
2)  Build the "dockable" form.  I would recommend using the toolbar form style for this
3)  Have the Timer event of the timer control (put the timer on the MDI form) check the position of the new form, frmDock.
4)  If frmDock is in the range where youd' want to dock it, then go ahead and dock it.  Inside the form, remember the undocked size.

Here is some of the frmDock code you need:

option explicit
dim mintUndockWidth  as integer
dim mintUndockHeight as integer
dim mintUndockLeft   as integer
dim mintUndockTop    as integer

public sub SetUndocked()
   me.move mintUndockLeft, mintUndockTop, mintUndockWidth, mintUndockHeight
end sub

public sub RememberUndocked()
  mintUndockLeft  = me.left
  mintUndockTop   = me.top
  mintUndockHeight = me.height
  mintUndockWidth = me.Width
end sub


--------------

'In the MDI forms timer control timer event
private sub timer1_timer()
   with frmDock
       if .Left <= 0 or .top <= 0 then
           'dock left
           .move 0, 0
       elseif .left >= me.scalewidth - .width then
           .move me.scalewidth - .width, 0
       elseif .top >= me.scaleheight - .height then
           .move 0, me.scaleheight - .height
       end if
    end with
end sub          
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now