Solved

Docking windows in MDI

Posted on 1998-02-05
1
1,689 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

757 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

18 Experts available now in Live!

Get 1:1 Help Now