Thread: SS_NOTIFY and WM_SETCURSOR

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    68

    SS_NOTIFY and WM_SETCURSOR

    Hi All,

    I'm trying to imitate a hyperlink on a dialog using C++.

    I'm using a static control with SS_NOTIFY set so that a user can click the control and go to a webpage.

    Code:
    CONTROL "http://google.co.uk",IDC_STC_URL,"Static",WS_CHILD|WS_VISIBLE|SS_NOTIFY|SS_CENTER,3,75,78,12
    With SS_NOTIFY set I can intercept the click, as it's registered against the static:

    Code:
    case IDC_STC_URL:
    ShellExecute(NULL, "open", "http://google.co.uk", NULL, NULL, SW_SHOWNORMAL);
    return TRUE;
    I'm also changing the cursor to a hand by intercepting the WM_SETCURSOR message:

    Code:
    		case WM_SETCURSOR:
    			POINT pt;
    			RECT rect;
    
    			GetCursorPos( &pt );
    			GetWindowRect( GetDlgItem(hwnd,IDC_STC_URL), &rect );
    
    			if (PtInRect(&rect, pt))
    			{
    				SetCursor(LoadCursor(NULL, IDC_HAND));
    			}
    			else
    			{
    				SetCursor(LoadCursor(NULL, IDC_ARROW));
    			}
    			return TRUE;
    However, when SS_NOTIFY is set the cursor change doesn't work. When SS_NOTIFY is disabeled it does. But then the click isn't registered against the static so ShellExecute() doesn't get to open the URL.

    Does anyone have a suggestion as to what I'm doing wrong?

    Thanks,

    Dave

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Is the cursor in the explorer window that is opening, not the static?

    Quote Originally Posted by DaveHope View Post
    However, when SS_NOTIFY is set the cursor change doesn't work. When SS_NOTIFY is disabeled it does.
    Have you tried SS_NOTIFY set && the ShellExecute() commented out?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Dec 2003
    Posts
    68
    Quote Originally Posted by novacain View Post
    Is the cursor in the explorer window that is opening, not the static?

    Have you tried SS_NOTIFY set && the ShellExecute() commented out?
    When SS_NOTIFY is set and ShellExecute() is removed the cursor doesn't change. It appears that as soon as SS_NOTIFY is set the WM_SETCURSOR message doesn't get called.

Popular pages Recent additions subscribe to a feed