Note that there are some explanatory texts on larger screens.

plurals
  1. POSubclassing Button Control within a Class
    primarykey
    data
    text
    <p>I created my own custom GUI button class for use in Windows Mobile apps. Realizing that I needed some finer control and to remove the double-click annoyance, I figured all I need to do is subclass it like I always have.</p> <p>But, being that I have encapsulated everything into a Class though, seems to have complicated the matter.</p> <p>Below is a snippet of what I want to do</p> <pre><code>// Graphic button class for Wizard(ing) dialogs. class CButtonUXnav { private: // Local subclasses of controls. WNDPROC wpOldButton; // Handle to the original callback. LRESULT CALLBACK Button_WndProc (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam); </code></pre> <p>. . .</p> <pre><code>int CButtonUXnav::CreateButton (LPCTSTR lpButtonText, int x, int y, int iWidth, int iHeight, bool gradeL2R) { xLoc = x; yLoc = y; nWidth = iWidth; nHeight = iHeight; wcscpy (wszButtonText, lpButtonText); PaintButtonInternals (x, y, iWidth, iHeight, gradeL2R); hButton = CreateWindow (L"BUTTON", wszButtonText, WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON | BS_OWNERDRAW, xLoc, yLoc, nWidth, nHeight, hWndParent, IDbutn, hInstance, NULL); // Subclass // (to remove double-click annoyance.) wpOldButton = (WNDPROC)GetWindowLong (hButton, GWL_WNDPROC); if (wpOldButton == 0) return 1; // Insert our own callback. SetWindowLong (hButton, GWL_WNDPROC, (LONG)Button_WndProc); return 0; } </code></pre> <p>But I can't seem to escape resolving this error:</p> <blockquote> <p>error C2440: 'type cast' : cannot convert from 'LRESULT (__cdecl CButtonUXnav::* )(HWND,UINT,WPARAM,LPARAM)' to 'LONG'</p> </blockquote> <p>Your thoughts?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload