[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Docking windows in MDI

Posted on 1998-02-05
1
Medium Priority
?
1,714 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 260 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
Suggested Courses
Course of the Month17 days, 20 hours left to enroll

830 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