Solved

Docking windows in MDI

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Windows 10 start screen issues 9 55
Best way to parse out a json string in VB6? 10 225
Access Object Property from VBA Module in Excel 2010 2 37
vbModal 12 57
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…
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.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

829 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