1 | // MainDlg.h : interface of the CMainDlg class |
---|
2 | // |
---|
3 | ///////////////////////////////////////////////////////////////////////////// |
---|
4 | |
---|
5 | #pragma once |
---|
6 | |
---|
7 | #include <atlmisc.h> |
---|
8 | |
---|
9 | class CMyFileDialog : |
---|
10 | public CFileDialogImpl<CMyFileDialog> |
---|
11 | { |
---|
12 | public: |
---|
13 | |
---|
14 | BEGIN_MSG_MAP(CMyFileDialog) |
---|
15 | CHAIN_MSG_MAP(CFileDialogImpl<CMyFileDialog>) |
---|
16 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) |
---|
17 | COMMAND_HANDLER(123, BN_CLICKED, OnTestClicked) |
---|
18 | END_MSG_MAP() |
---|
19 | |
---|
20 | private: |
---|
21 | CButton m_Button; |
---|
22 | |
---|
23 | public: |
---|
24 | // CMyFileDialog |
---|
25 | CMyFileDialog() : |
---|
26 | CFileDialogImpl<CMyFileDialog>(TRUE) |
---|
27 | { |
---|
28 | } |
---|
29 | |
---|
30 | // Window Message Handler |
---|
31 | LRESULT OnInitDialog(UINT, WPARAM, LPARAM, BOOL& bHandled) |
---|
32 | { |
---|
33 | CRect Position; |
---|
34 | ATLVERIFY(GetWindowRect(Position)); |
---|
35 | ATLVERIFY(SetWindowPos(NULL, 0, 0, Position.Width(), Position.Height() + 50, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE)); |
---|
36 | CRect ButtonPosition; |
---|
37 | ButtonPosition.left = 10; |
---|
38 | ButtonPosition.top = Position.Height() + 10; |
---|
39 | ButtonPosition.right = 90; |
---|
40 | ButtonPosition.bottom = ButtonPosition.top + 20; |
---|
41 | m_Button.Create(m_hWnd, ButtonPosition, _T("Test"), CControlWinTraits::GetWndStyle(0), CControlWinTraits::GetWndExStyle(0), 123); |
---|
42 | bHandled = FALSE; |
---|
43 | return 0; |
---|
44 | } |
---|
45 | LRESULT OnTestClicked(UINT, INT, HWND, BOOL&) |
---|
46 | { |
---|
47 | AtlMessageBox(m_hWnd, _T("Test"), _T("Debug"), MB_ICONINFORMATION | MB_OK); |
---|
48 | return 0; |
---|
49 | } |
---|
50 | }; |
---|
51 | |
---|
52 | class CMainDlg : public CDialogImpl<CMainDlg> |
---|
53 | { |
---|
54 | public: |
---|
55 | enum { IDD = IDD_MAINDLG }; |
---|
56 | |
---|
57 | BEGIN_MSG_MAP(CMainDlg) |
---|
58 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) |
---|
59 | COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout) |
---|
60 | COMMAND_ID_HANDLER(IDOK, OnOK) |
---|
61 | COMMAND_ID_HANDLER(IDCANCEL, OnCancel) |
---|
62 | END_MSG_MAP() |
---|
63 | |
---|
64 | // Handler prototypes (uncomment arguments if needed): |
---|
65 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) |
---|
66 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) |
---|
67 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) |
---|
68 | |
---|
69 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) |
---|
70 | { |
---|
71 | // center the dialog on the screen |
---|
72 | CenterWindow(); |
---|
73 | |
---|
74 | // set icons |
---|
75 | HICON hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON)); |
---|
76 | SetIcon(hIcon, TRUE); |
---|
77 | HICON hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON)); |
---|
78 | SetIcon(hIconSmall, FALSE); |
---|
79 | |
---|
80 | return TRUE; |
---|
81 | } |
---|
82 | |
---|
83 | LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) |
---|
84 | { |
---|
85 | CSimpleDialog<IDD_ABOUTBOX, FALSE> dlg; |
---|
86 | dlg.DoModal(); |
---|
87 | return 0; |
---|
88 | } |
---|
89 | |
---|
90 | LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) |
---|
91 | { |
---|
92 | CMyFileDialog Dialog; |
---|
93 | Dialog.DoModal(m_hWnd); |
---|
94 | |
---|
95 | // TODO: Add validation code |
---|
96 | EndDialog(wID); |
---|
97 | return 0; |
---|
98 | } |
---|
99 | |
---|
100 | LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) |
---|
101 | { |
---|
102 | EndDialog(wID); |
---|
103 | return 0; |
---|
104 | } |
---|
105 | }; |
---|