Solved

Obtain the width and height of MDI (inner area)

Posted on 2002-03-13
6
665 Views
Last Modified: 2007-12-19
i have some Coolbar, Status Bar attached to the MDI Form.
How to obtain the inner width an height of a MDI Form?
i.e. exclude the height of those controls. (Coolbar, Status Bar)
0
Comment
Question by:chnelson
6 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
Debug.Print MDIfrmMain.ScaleHeight & " : " & MDIfrmMain.ScaleHeight - MDIfrmMain.Coolbar.Height - MDIfrmMain.Toolbar.Height - MDIfrmMain.StatusBar.Height

?
   
0
 
LVL 1

Author Comment

by:chnelson
Comment Utility
The problem is that the coolbar i m using is downloaded from:
http://vbaccelerator.com/codelib/comctl/retbar.htm

i dont know how to get the heights of all bands.
0
 

Accepted Solution

by:
segan earned 50 total points
Comment Utility
Hi Nelson,

Its nothing but ScaleHeight and ScaleWidth properties.

Selva.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 1

Author Comment

by:chnelson
Comment Utility
i think ScaleHeight is the correct property. But the it seems that ScaleHeight does not return me correct inner width of the MDI.

It may due to the 3rd party coolbar i m using. i m trying to find the height of each band and do a calculations.
0
 

Expert Comment

by:GuruVB
Comment Utility
Please use Following API:

Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

Public Const SM_CYCAPTION = 4
Public Const SM_CYMENU = 15

SM_CYCAPTION: Returns the MDI-Form Caption height
CYMENU: Returns the MDI Form  Menu height.

Now as you have coolbar and status bar : put the following code in the MDIForm_Load:

dim lTotal as long

lTotal = me.height - GetSystemMetrics(SM_CYCAPTION) -  (GetSystemMetrics(SM_CYMENU) * 2)  ' Multiply by two coz you have 2 floating objects (Status bar and cool bar)on the MDI from, if more do the appropriate.

So that lTotal will have the exact inner height of the MDI form.

For width Subtract the appropriate controls width from the me.width.
Thanks and kind regards.
I hope this will help you.
0
 
LVL 1

Author Comment

by:chnelson
Comment Utility
After i double check my code, i found that segan's method "ScaleHeight and Width" works. Simple and direct. However, thanks all great idea. Especially GuruVB, your idea is quite brilliant to me.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

762 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

11 Experts available now in Live!

Get 1:1 Help Now