在我的WIN32对话框中,我绘制了一个圆圈(位图资源),我希望在它附近有一个图像。 我无法强制光标在圆形图像的顶部:
我将圆圈和光标绘制为静态窗口:
界:
HWND hRingImage= CreateStatics(m_hDlg, hInst, SS_BITMAP | WS_BORDER, rc, m_ID, L"");
HANDLE hRingImage1 = LoadImage(hInst, MAKEINTRESOURCE(IDB_RING50), IMAGE_BITMAP,m_Radius*2, m_Radius*2, LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
SendMessage(hRingImage,STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hRingImage1);
m_hRingImage = hRingImage;
if (!Enabled)
ShowWindow(hRingImage, SW_HIDE);
红色光标:
m_hIndicator= CreateStatics(m_hDlg, GetModuleHandle(NULL), SS_ICON , rc, m_ID+10, L"");
HANDLE hRingImage1 = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_INDICATOR), IMAGE_CURSOR,8, 8, LR_DEFAULTSIZE|LR_SHARED );
SendMessage(m_hIndicator,STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hRingImage1);
SetWindowPos(m_hIndicator, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE);
ShowWindow(m_hIndicator, SW_SHOW);
当光标始终位于底部时,我无法看到圆圈最顶端的原因(奇怪的是,它们也位于对话框框架线下。
答案 0 :(得分:1)
您可以手动设置光标:
First load the cursor image-> HCURSOR hCursorRing = LoadCursor(...);
BOOL CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){
switch (message){
case WM_CLOSE:
DestroyWindow(hDlg);
break ;
case WM_SETCURSOR:
if((HWND)wParam == hRingImage){
SetCursor(hCursorRing);
return true;
}
break ;
default: //for messages that we don't deal with
return false;
}
return false;
}
瓦尔特
答案 1 :(得分:0)
我必须做以下事情:
ShowWindow(m_hIndicator, SW_HIDE);
MoveWindow(m_hIndicator, loc.x-3,loc.y-3,8,8, TRUE);
ShowWindow(m_hIndicator, SW_SHOW);
"光标"实际上只是一个位图,位于所有其他位图的顶部上正确。