Solved

Docking windows in MDI

Posted on 1998-02-05
1
1,699 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
How does CurrentUser work? 10 41
How to Add / Edit Windows Menu 4 73
Problem to With line 4 74
Copy a range from 1..n excel sheets to one destination sheet 2 66
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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…

756 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