Solved

How do I get the size of the window elements?

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error 1.1 400 Bad request idhttp delphi 18 87
WPF issue with Trigger 2 106
recursion example 16 126
can i put an image from resource into image tag ? 6 25
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…
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

770 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