2010-12-30 11 views
1

DlgProcWM_INITDIALOGメッセージの(ラジオボタン)コントロールの の(私が信じている)クライアント座標を決定するのに苦労しています。ここでWM_INITDIALOGメッセージ内のコントロールの座標を決定するにはどうすればよいですか?

は私がしようとするものです。

// 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: 
rectOrthoButton.top -= dlgTopLeft.y; 
rectOrthoButton.left -= dlgTopLeft.x; 

use_top_and_left(rectOrthoButton.top, rectOrthoButton.left); 

私は、ダイアログのクライアント領域に関して私のコントロールの左上の座標であることをrectOrthoButton.top.leftを期待しました。それは彼らではないことが分かり、私は確信していません 彼らはrectOrthoButton.leftと指摘するものは-40と等しいです。

編集:今、私は(私は愚かなが忘れてしまった

POINT dlgTopLeft = {0, 0}; 

とPOINT初期化するように指示されたこと:私が欲しいものを達成するために短い方法はありますか?

+1

ClientToScreenを呼び出す前に、dlgTopLeft.x/yに '0'を入れないでください。 –

+0

はい、そうでした!さて、もしあなたが答えを出したら、あなたの答えに*正しい*(あるいはそのダニが付いているもの)をチェックすることができます。とにかくありがとう。 –

答えて

1

ポイントをスクリーン座標に変換するには、ClientToScreenに渡す前に、ポイントにクライアント座標(クライアントの場合は0)を含める必要があります。