Solved

How to determine thickness of the title bar?

Posted on 2003-11-16
4
350 Views
Last Modified: 2010-05-01
My application uses a bmp interface pasted on a pictureBox control and has an irregular shape, so I use the CreateEllipticRgn API call to give the window a special shape. But the problem I have lies in the difference of thickness of the title bar in various situations:

- WinXP: the title bar is a bit thicker than the one in previous Win versions
- with DPI settings higher than 96dpi, the title bar is also thicker.

while normally, all controls are positioned on the form relative to the title bar's thickness, the CreateEllipticRgn API call calculates positions from the very top of the very window... regardless of the title bar's thickness. So if I set it right for WinXP, the graphic seems off by a few pixels vertically in other windows versions.

So I really just need to know the thickness of the title bar at run time in a given window -- or, alternatively, I need any way to determine, at run time, the position of a control relative to the very top of the window, not the end of the title bar... so I can therefore deduct the position of the rest, thus the thickness of the title bar (but again, the problem is the 0 position for controls begins after the title bar...)

Thanks in advance
0
Comment
Question by:GizmoBlaster
[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
4 Comments
 
LVL 3

Accepted Solution

by:
NBrownoh earned 100 total points
ID: 9762089
'in a declaration section of a form
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Const SM_CYCAPTION = 4 'Height of windows caption

'in some routine like form_load
TWid = GetSystemMetrics(SM_CYCAPTION)

TWid will be the width that you want in pixels
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9762198
:)
0
 

Author Comment

by:GizmoBlaster
ID: 9762201
Well, that was quick. It feels like I got the answer actually before pressing the "Submit" button, rofl...

Thanks a ton! That's exactly what I needed.
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9762203
glad i could help, come back soon.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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
MS SQL Update query with connected table data 3 81
Win 10 Automation Error with .doCmd in Access 2 93
VB6 Enviroment 3 37
2 Global Vars, 1 List Box 4 34
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

751 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