1

On my WIN32 dialog box I draw a circle (Bitmap resource) and I want to have an image located near it. I am not able to force the cursor to be on top of the circle image:

Red cursor obscured by circle image

I draw both circle and cursor as static windows:

Circle:

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);

Red Cursor:

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);

I can't see what makes the circle topmost while the cursors are always at the bottom (strange, they also under the dialog box frame lines.

Shaul
  • 437
  • 5
  • 17

2 Answers2

1

You can set the cursor manualy:

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;
}

valter

0

I had to do the following:

 ShowWindow(m_hIndicator, SW_HIDE);
 MoveWindow(m_hIndicator, loc.x-3,loc.y-3,8,8, TRUE); 
 ShowWindow(m_hIndicator, SW_SHOW);

The "cursor" which is actually just a bitmap is located correctly on top of all other bitmaps.

Shaul
  • 437
  • 5
  • 17