Solved

How do I get the size of the window elements?

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tidtcpserver connection lost handle 2 124
Python 3.5.2 32 virtualenv problems 3 101
firemonkey keyboard covers the controls 1 83
Breakpoint doesn't stop in my variable 3 48
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

752 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