source: trunk/Utilities/Miscellaneous/TreeViewIcon/MainDlg.h @ 275

Last change on this file since 275 was 275, checked in by roman, 10 years ago
File size: 2.5 KB
Line 
1// MainDlg.h : interface of the CMainDlg class
2//
3/////////////////////////////////////////////////////////////////////////////
4
5#pragma once
6
7class CMainDlg : public CDialogImpl<CMainDlg>
8{
9public:
10        enum { IDD = IDD_MAINDLG };
11
12        BEGIN_MSG_MAP(CMainDlg)
13                MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
14                COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
15                COMMAND_ID_HANDLER(IDOK, OnOK)
16                COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
17        END_MSG_MAP()
18
19// Handler prototypes (uncomment arguments if needed):
20//      LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
21//      LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
22//      LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
23
24        LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
25        {
26                // center the dialog on the screen
27                CenterWindow();
28
29                // set icons
30                HICON hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON));
31                SetIcon(hIcon, TRUE);
32                HICON hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
33                SetIcon(hIconSmall, FALSE);
34
35                CTreeViewCtrl Tree = GetDlgItem(IDC_TREE1);
36
37                CImageList ImageList;
38                ImageList.Create(16, 16, ILC_COLORDDB, 1, 0);
39                ImageList.AddIcon(hIconSmall);
40
41                Tree.SetImageList(ImageList);
42                ImageList.Detach();
43
44                LPCTSTR g_pszText = _T("Text");
45
46                TVINSERTSTRUCT tvis = { 0 };
47                tvis.hParent = NULL;
48                tvis.hInsertAfter = NULL;
49                tvis.item.mask = TVIF_TEXT;
50                tvis.item.pszText = (LPTSTR) g_pszText;
51                tvis.item.iImage = 0;
52                tvis.item.iSelectedImage = 0;
53                tvis.item.state = 0;
54                tvis.item.stateMask = 0;
55                tvis.item.lParam = 0;
56                Tree.SendMessage(TVM_INSERTITEM, 0, (LPARAM)&tvis);
57
58                tvis.item.mask = TVIF_TEXT | TVIF_IMAGE;
59                tvis.item.iImage = -1;
60                Tree.SendMessage(TVM_INSERTITEM, 0, (LPARAM)&tvis);
61
62                return TRUE;
63        }
64
65        LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
66        {
67                CSimpleDialog<IDD_ABOUTBOX, FALSE> dlg;
68                dlg.DoModal();
69                return 0;
70        }
71
72        LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
73        {
74                // TODO: Add validation code
75                EndDialog(wID);
76                return 0;
77        }
78
79        LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
80        {
81                EndDialog(wID);
82                return 0;
83        }
84};
Note: See TracBrowser for help on using the repository browser.