Solved

How do I get the size of the window elements?

Posted on 2011-02-10
5
421 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi: ForceDirectory plain function 7 50
Problem to open Excel file 15 219
Drag & Drop... Data from one grid to another 2 47
Delphi: making a BW image transparent 10 91
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

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