Solved

How do I get the size of the window elements?

Posted on 2011-02-10
5
424 Views
Last Modified: 2012-06-27
How do I get the size of the window border (left/right/bottom)?
How do I get the height of application's main menu?

(Delphi 7, Win XP, Win 7)
0
Comment
Question by:cubic77
[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
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:pasolo
ID: 34865700

Height, in pixels, of a single-line menu bar:
GetSystemMetrics(SM_CYMENU)

Same function with
SM_CXBORDER, SM_CYBORDER
Width and height, in pixels, of a window border
For windows with 3D look use:
SM_CXEDGE, SM_CYEDGE
0
 

Author Comment

by:cubic77
ID: 34866423
> For windows with 3D look use:

So normal windows in Win 7 have 3D look?
What about Win XP?
Or normal/3D look is dictated by the themes (enabled/disable)?
0
 

Author Comment

by:cubic77
ID: 34866642
Nope.
The SM_CYEDGE and SM_CYBORDER is not working.
They return 1 and 2 pixels while the border/frame around my windows (standard Win 7 with Aero interface) is 7.
0
 

Author Comment

by:cubic77
ID: 34866717
I think what I needed was SM_CYSIZEFRAME.
0
 
LVL 3

Accepted Solution

by:
pasolo earned 500 total points
ID: 34868938
This is the right approach:

NONCLIENTMETRICS metrics;
memset(&metrics,0,sizeof(metrics));
metrics.cbSize = sizeof(NONCLIENTMETRICS);

BOOL result = SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
                                       0,
                                       &metrics,
                                       0);
int borderWidth = metrics.iBorderWidth;
int menuHeight = metrics.iMenuHeight;

PS: I can do in Delphi but conversions is easy, let me know if necessary
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

623 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