RECT rect;//LEFT,TOP,RIGHT,BOTTOM
1.ClientToScreen
GetDlgItem(IDOK)->GetClientRect(&rect);//获得按钮大小rect(0,0,101,29)
GetDlgItem(IDOK)->ClientToScreen(&rect);//获得按钮在屏幕中的坐标
// -----------------------------------------------------------------------------------------------
GetDlgItem(IDOK)->GetClientRect(&rect);//获得按钮大小坐标rect(0,0,101,29)
this->ClientToScreen(&rect);//J将dlg窗口客户区中的rect(0,0,101,29)坐标转化成屏幕坐标
//-----------------------------------------------------------------------------
2.ScreenToClient
GetDlgItem(IDOK)->GetWindowRect(&rect);//获得按钮屏幕坐标rect(100,100,201,129)
this->ScreenToClient(&rect);//将按钮屏幕坐标rect(100,100,201,129)转换成在dlg窗口客户区中的坐标
this->MoveWindow(&rect);//dlg移动到该坐标范围(0,0,101,29)
GetDlgItem(IDOK)->MoveWindow(&rect);//将按钮移动到dlg客户区中该位置
//------------------------------------------------------------------------------------------------------
GetDlgItem(IDOK)->GetWindowRect(&rect);//获得按钮屏幕坐标rect(100,100,201,129)
GetDlgItem(IDOK)->ScreenToClient(&rect);//将按钮屏幕坐标rect(100,100,201,129)转换成在按钮窗口客户区中的坐标(0,0,101,29)
rect.right += 10;
GetDlgItem(IDOK)->MoveWindow(&rect);//将按钮移动到dlg客户区中该位置
//----------------------------------------------------------------------------------------------------------
this->GetWindowRect(&rect);//获得dlg屏幕坐标rect(100,100,201,129)
this->ScreenToClient(&rect);//将按钮屏幕坐标rect(100,100,201,129)转换成在dlg窗口客户区中的坐标(-3,-22,300,100)
3.MoveWindow
//For a top-level window, the position and dimensions are relative to the upper-left corner of the screen.
//For a child window, they are relative to the upper-left corner of the parent window's client area.
this->MoveWindow(&rect);//dlg移动到该坐标范围(0,0,101,29)
GetDlgItem(IDOK)->MoveWindow(&rect);//将按钮移动到dlg客户区中该位置