1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#include <windows.h>
#include "resource.h"
#include "dialog.h"
class TestDlg: public Dialog
{
public:
DLGPROC get_proc();
bool Run();
BOOL CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
};
bool TestDlg::Run()
{
DialogBoxParam(GetModuleHandle(0), MAKEINTRESOURCE(IDD_UNLOCK), NULL, StaticDlgProc,(LPARAM)this);
}
DLGPROC TestDlg::get_proc() // get_proc function implemented in derived class
{
return (DLGPROC)&Dialog::DlgProc;
}
BOOL CALLBACK TestDlg::DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
EndDialog(hwnd, 0);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDCANCEL:
EndDialog(hwnd,0);
break;
}
}
return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
TestDlg t;
t.Run();
}
|