Thread: A little GDI/Msg type problemo

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    A little GDI/Msg type problemo

    [edit:]

    Code:
    case WM_LBUTTONDBLCLK:
            {
             cCLRBTN *clrbtn = (cCLRBTN*)GetWindowLong ( hwnd, GWL_USERDATA );
             clrbtn->down = true;
             InvalidateRect ( hwnd, NULL, TRUE );
             UpdateWindow ( hwnd );
             clrbtn->down = false;
             InvalidateRect ( hwnd, NULL, TRUE );
             UpdateWindow ( hwnd );
             SendMessage ( GetParent ( hwnd ), WM_COMMAND,
                (WPARAM)MAKEWPARAM((int)GetWindowLong ( hwnd, GWL_ID ),0 ), (LPARAM)hwnd  );
            }
            case WM_LBUTTONDOWN:
            {
             SetCapture ( hwnd );
             cCLRBTN *clrbtn = (cCLRBTN*)GetWindowLong ( hwnd, GWL_USERDATA );
             clrbtn->down = true;
             InvalidateRect ( hwnd, NULL, TRUE );
             UpdateWindow ( hwnd );
             return 0;
            }
            case WM_LBUTTONUP:
            {
             cCLRBTN *clrbtn = (cCLRBTN*)GetWindowLong ( hwnd, GWL_USERDATA );
             if ( clrbtn->down )
             {
              clrbtn->down = false;
              InvalidateRect ( hwnd, NULL, TRUE );
              UpdateWindow ( hwnd );
              SendMessage ( GetParent ( hwnd ), WM_COMMAND,
                (WPARAM)MAKEWPARAM((int)GetWindowLong ( hwnd, GWL_ID ),0 ), (LPARAM)hwnd  );
             }
             ReleaseCapture ( );
             return 0;
            }
    As you can see from that exerpt from my switch ( msg ) thingy I capture the mouse when it's down and release it when it's up, this way if you click and drag outside of my control (which is a button) it will still reset it's down status to false.

    However I'd rather that if you moved outside the control it popped up and it's down status was returned to false, just like other buttons.. This way you can drag outside of it and let go and you won't execute it's action.
    Last edited by Mithoric; 02-21-2004 at 08:16 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 03-20-2008, 07:59 AM
  2. Little Array Difficulty
    By G4B3 in forum C Programming
    Replies: 16
    Last Post: 03-19-2008, 12:59 AM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 12:22 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM