edvinson
asked on
subclass edit control
I am trying to learn how to subclass an edit control and intercept messages.
I am getting errors, and cant figure it out! Any ideas?
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "resource.h"
#include <Commctrl.h>
#pragma comment(lib, "Comctl32.lib")
HINSTANCE hInst;
LRESULT CALLBACK OwnerDrawButtonProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
/*
* TODO: Add code to initialize the dialog.
*/
HWND button = GetDlgItem(hwndDlg, IDC_EDIT1);
SetWindowSubclass(button, OwnerDrawButtonProc, 0, 0);
return TRUE;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
/*
* TODO: Add more control ID's, when needed.
*/
case IDC_BTN_QUIT:
EndDialog(hwndDlg, 0);
return TRUE;
case IDC_BTN_TEST:
MessageBox(hwndDlg, "You clicked \"Test\" button!", "Information", MB_ICONINFORMATION);
return TRUE;
}
}
return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
hInst = hInstance;
// The user interface is a modal dialog box
return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)DialogProc);
}
LRESULT CALLBACK OwnerDrawButtonProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
switch (uMsg)
{
case WM_PAINT:
return TRUE;
// Other cases...
}
return DefSubclassProc(hwndDlg, uMsg, wParam, lParam);
}
I am getting errors, and cant figure it out! Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you thinking about a WM_MOUSEMOVE?
ASKER
Please look for next question from me.
It is unfair to combine my questions.
Thanks.
It is unfair to combine my questions.
Thanks.
OK ;o)
ASKER
Can you please just point me to how to intercept a mouse over event on the edit?
Points will be awarded regardless, but that is ultimately my goal.
Thank you.