Solved

How do I get the size of the window elements?

Posted on 2011-02-10
5
409 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
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:pasolo
Comment Utility

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
Comment Utility
> 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
Comment Utility
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
Comment Utility
I think what I needed was SM_CYSIZEFRAME.
0
 
LVL 3

Accepted Solution

by:
pasolo earned 500 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

772 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

12 Experts available now in Live!

Get 1:1 Help Now