How do I determine the coordinates of controls in a WM_INITDIALOG message?

I am having troubles to determine the (what I believe to be the) client coordinates of a (radio button) control in the WM_INITDIALOG message of a DlgProc.

Here's what I try:

// Retrieve coordinates of Control with respect to the screen.
RECT rectOrthoButton;
GetWindowRect(GetDlgItem(hWnd, IDC_ORTHO), &rectOrthoButton);

// Translate coordinates to more useful coordinates: those that
// are used on the dialog.
// In order to do the translation we have to find the top left
// point (coordinates) of the dialog's client:
POINT dlgTopLeft;
ClientToScreen(hWnd, &dlgTopLeft);

// With these coordinates we can do the translation.
// We're only interested in top and left, so we skip
// bottom and right:    -= dlgTopLeft.y;
rectOrthoButton.left   -= dlgTopLeft.x;

use_top_and_left(, rectOrthoButton.left);

I expected and .left to be the top left coordinates of my control with respect to the dialog's client area. It turns out they aren't and I am not sure what they point to as rectOrthoButton.left is equal to -40.

Edit: Now that I was directed to initialize the POINT with

POINT dlgTopLeft = {0, 0};

(which I stupidly forgot): Is there a shorter way to accomplish what I want?


To convert a Point to screen coordinates, the Point should contain the client coordinates (0, 0 in case of client origin) before passing to ClientToScreen.

Need Your Help

How can I correctly modify a generated XSD to overcome a known .Net bug that causes exception “cs0030:Unable to generate a temporary class”

.net web-services visual-studio-2008 exception xsd

I have been tasked to send data to a 3rd Party web service, they have provided a test service that is proven to work with a Java client, however, it doesn't in .Net.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.