我遇到过这段代码:
//handler for context menu element; to move an element
void CRTS_SketcherView::OnElementMove()
{
CClientDC aDC(this);
OnPrepareDC(&aDC); //Set up the device context
GetCursorPos(&m_CursorPos); //Get cursor position in screen coords
ScreenToClient(&m_CursorPos); //convert to client coords
aDC.DPtoLP(&m_CursorPos); //Convert to logical
// ...code to initialize the moving of a shape on screen
}
我知道光标的屏幕坐标是它在屏幕上的位置,而客户端坐标是窗口客户区域中的坐标,无论窗口的位置如何。但是什么是设备坐标?我唯一知道的是它们以像素为单位 - 但它们如何连接到逻辑(客户端)和屏幕坐标?