TWR T windows api WRapper

- Main Page
- Classes
- Files

- File List

All Classes Functions
BaseDialog.h
1 #ifndef BASEDIALOG_H
2 #define BASEDIALOG_H
3
4 #include "TwrWnd.h"
5 #include "TwrCombobox.h"
6
7 class BaseDialog : public TwrWnd {
8 private:
9 HWND parentWindow;
10 int dialogResource;
11 bool isModeless;
12 protected:
13 static BaseDialog *modalCallback;
14 virtual INT_PTR OnInitDialog();
15 virtual INT_PTR OnCommand(WPARAM wParam);
16 TCHAR ddx_buf[512];
17 public:
18 BaseDialog();
19 BaseDialog(HWND parent, int resource);
20 virtual ‾BaseDialog();
21
22 INT_PTR showModal();
23 HWND showModeless();
24 static INT_PTR CALLBACK modalDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
25 static INT_PTR CALLBACK modelessDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
26 INT_PTR CALLBACK dialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
27 void setParent(HWND parent)
28 {
29 parentWindow = parent;
30 }
31
32 TwrWnd *GetDlgItem(int item);
33 HWND GetDlgItemRaw(int item);
34
35 virtual void UpdateData(bool toObj);
36
37 };
38
39 // MFCのDDXもどきForm Data eXchangeマクロ
40 // UpdateData関数の引数、ダイアログコントロールID、設定対象の変数
41
42 // コントロールのテキスト
43 #define DDX_Text(toObj, ctl, str) ¥
44 if (toObj) { ¥
45 GetDlgItemText(hWnd,ctl,ddx_buf,512); ¥
46 str = ddx_buf; ¥
47 } else { ¥
48 SetDlgItemText(hWnd,ctl,str.c_str()); ¥
49 }
50
51 // チェックボックスのチェック状態
52 #define DDX_Check(toObj, ctl, stat) ¥
53 if (toObj) { ¥
54 stat = SendMessage(::GetDlgItem(hWnd,ctl),BM_GETCHECK,0,0); ¥
55 } else { ¥
56 SendMessage(::GetDlgItem(hWnd,ctl),BM_SETCHECK,(WPARAM)stat,0); ¥
57 }
58
59 // コンボボックスのインデックス
60 #define DDX_CBIndex(toObj, ctl, index) ¥
61 if (toObj) { ¥
62 index = SendMessage(::GetDlgItem(hWnd,ctl),CB_GETCURSEL,0,0); ¥
63 } else { ¥
64 SendMessage(::GetDlgItem(hWnd,ctl),CB_SETCURSEL,(WPARAM)index,0); ¥
65 }
66
67
68 #endif