-
Notifications
You must be signed in to change notification settings - Fork 0
/
CDlgBase.cpp
58 lines (49 loc) · 1.16 KB
/
CDlgBase.cpp
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 "CDlgBase.h"
#include "ext.h"
CDlgBase::CDlgBase()
{
m_bCreated = FALSE;
m_pSelf = NULL;
m_hInst = NULL;
m_hWnd = NULL;
m_hDlg = NULL;
}
CDlgBase::~CDlgBase()
{
m_hDlg = NULL;
m_bCreated = FALSE;
m_hInst = NULL;
DestroyWindow(m_hWnd);
m_hWnd = NULL;
}
HWND CDlgBase::Create(HINSTANCE hInst, const TCHAR* lpTemplateName, HWND hWnd)
{
m_hDlg = CreateDialogParam(hInst, lpTemplateName, hWnd, StaticDlgProc, (LPARAM)this);
if (!m_hDlg) return FALSE;
m_pSelf = this;
m_hInst = hInst;
m_hWnd = hWnd;
m_bCreated = TRUE;
return hWnd;
}
/*static*/BOOL CALLBACK CDlgBase::StaticDlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
// 自身のポインタを取得
CDlgBase* pSelf = (CDlgBase*)GetWindowLongPtr( hDlg, GWL_USERDATA );
switch( msg ){
case WM_INITDIALOG: // ダイアログボックスが作成されたとき
// 自身のポインタを設定
SetWindowLongPtr(hDlg, GWL_USERDATA, (LONG)lp );
break;
case WM_DESTROY:
// SetWindowLongPtr(hDlg, GWL_USERDATA, 0L);
break;
}
if (pSelf)
return pSelf->MyDlgProc(hDlg, msg, wp, lp);
return FALSE;
}
BOOL CALLBACK CDlgBase::MyDlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
return DefWindowProc( hDlg, msg, wp, lp );
}