VC6.0 MFC 專案中,視窗同時顯示兩個游標,相對位置固定 (如偏移 20px, 20px),僅主游標具備互動功能,副游標為視覺輔助。
SetCursor(NULL) 或載入透明游標資源。.cur 檔,分別設為主/副游標。OnMouseMove 中取得座標 (x, y)。OnPaint / OnMouseMove 中,以 DrawIconEx(hdc, x+offsetX, y+offsetY, hCursorSub, ...) 繪製副游標。BitBlt 到螢幕。void CMyView::OnMouseMove(UINT nFlags, CPoint point) {
// 主游標由系統自動處理 (若未隱藏)
// 通知另一視窗重繪副游標
pOtherView->SetSubCursorPos(point + CPoint(20, 20));
pOtherView->Invalidate(FALSE);
}
void COtherView::OnPaint() {
CPaintDC dc(this);
if (m_subCursorPos != CPoint(-1,-1)) {
DrawIconEx(dc.m_hDC, m_subCursorPos.x, m_subCursorPos.y,
m_hSubCursor, 0, 0, 0, NULL, DI_NORMAL);
}
}
ClientToScreen / ScreenToClient。