Owner-draw button

This is a discussion on Owner-draw button within the Windows Programming forums, part of the Platform Specific Boards category; When you subclass a window you must use CallWindowProc with the original window procedure you got as the return value ...

  1. #16
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    When you subclass a window you must use CallWindowProc with the original window procedure you got as the return value from SetWindowLongPtr and not DefWindowProc as you have done. Also, since it's the button you are subclassing, because you want to modify its behaviour, you intercept its messages as required, not the parent window's. Taking these points into consideration, your button window procedure should be something like:
    Code:
    LRESULT CALLBACK ButtonProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
      switch (message){
            case WM_LBUTTONDBLCLK:
                return CallWindowProc(OldWndProc, hwnd, WM_LBUTTONDOWN, wParam, lParam);
            default:
                return CallWindowProc (OldWndProc, hwnd, message, wParam, lParam);
        }
    }
    All you're trying to do here is to get a double-click processed as a single click so that your owner drawn button behaves just like a normal one.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  2. #17
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Thanks, copied this code and... BOOM - it worked.

  3. #18
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    How can I draw an edit box?

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems defining classes
    By esmeco in forum C++ Programming
    Replies: 47
    Last Post: 10-24-2007, 01:13 PM
  2. My BS_OWNERDRAW button draw as white when clicked...
    By Jonathan Beaubi in forum Windows Programming
    Replies: 1
    Last Post: 08-16-2007, 10:41 AM
  3. owner draw...
    By Devil Panther in forum Windows Programming
    Replies: 6
    Last Post: 03-12-2004, 12:19 PM
  4. owner draw?
    By Devil Panther in forum Windows Programming
    Replies: 4
    Last Post: 02-29-2004, 10:08 AM
  5. Owner draw button with bitmap
    By Mithoric in forum Windows Programming
    Replies: 2
    Last Post: 11-30-2003, 02:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21