GuiPanelAccessDemoDlg.cpp
上传用户:wlkj888
上传日期:2022-08-01
资源大小:806k
文件大小:7k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // GuiPanelAccessDemoDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "GuiPanelAccessDemo.h"
  5. #include "GuiPanelAccessDemoDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CAboutDlg dialog used for App About
  13. #define BTN_TEST  500
  14. #define BTN_TEST1  501
  15. #define BTN_TEST2  502
  16. #define BTN_TEST3  503
  17. #define BTN_TEST4  504
  18. #define BTN_TEST5  505
  19. #define BTN_TEST6  506
  20. #define BTN_TEST7  507
  21. #define BTN_TEST8  508
  22. #define BTN_TEST9  509
  23. #define BTN_TEST10  510
  24. #define BTN_TEST11  511
  25. #define BTN_TEST12  512
  26. #define BTN_TEST13  513
  27. #define BTN_TEST14  514
  28. #define BTN_TEST15  515
  29. #define BTN_TEST16  516
  30. class CAboutDlg : public CDialog
  31. {
  32. public:
  33. CAboutDlg();
  34. // Dialog Data
  35. //{{AFX_DATA(CAboutDlg)
  36. enum { IDD = IDD_ABOUTBOX };
  37. //}}AFX_DATA
  38. // ClassWizard generated virtual function overrides
  39. //{{AFX_VIRTUAL(CAboutDlg)
  40. protected:
  41. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  42. //}}AFX_VIRTUAL
  43. // Implementation
  44. protected:
  45. //{{AFX_MSG(CAboutDlg)
  46. //}}AFX_MSG
  47. DECLARE_MESSAGE_MAP()
  48. };
  49. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  50. {
  51. //{{AFX_DATA_INIT(CAboutDlg)
  52. //}}AFX_DATA_INIT
  53. }
  54. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  55. {
  56. CDialog::DoDataExchange(pDX);
  57. //{{AFX_DATA_MAP(CAboutDlg)
  58. //}}AFX_DATA_MAP
  59. }
  60. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  61. //{{AFX_MSG_MAP(CAboutDlg)
  62. // No message handlers
  63. //}}AFX_MSG_MAP
  64. END_MESSAGE_MAP()
  65. /////////////////////////////////////////////////////////////////////////////
  66. // CGuiPanelAccessDemoDlg dialog
  67. CGuiPanelAccessDemoDlg::CGuiPanelAccessDemoDlg(CWnd* pParent /*=NULL*/)
  68. : CDialog(CGuiPanelAccessDemoDlg::IDD, pParent)
  69. {
  70. //{{AFX_DATA_INIT(CGuiPanelAccessDemoDlg)
  71. // NOTE: the ClassWizard will add member initialization here
  72. //}}AFX_DATA_INIT
  73. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  74. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  75. }
  76. void CGuiPanelAccessDemoDlg::DoDataExchange(CDataExchange* pDX)
  77. {
  78. CDialog::DoDataExchange(pDX);
  79. //{{AFX_DATA_MAP(CGuiPanelAccessDemoDlg)
  80. DDX_Control(pDX, IDC_MINITOOL, m_minitool);
  81. DDX_Control(pDX, IDC_FRAME, m_Frame);
  82. //}}AFX_DATA_MAP
  83. }
  84. BEGIN_MESSAGE_MAP(CGuiPanelAccessDemoDlg, CDialog)
  85. //{{AFX_MSG_MAP(CGuiPanelAccessDemoDlg)
  86. ON_WM_SYSCOMMAND()
  87. ON_WM_PAINT()
  88. ON_WM_QUERYDRAGICON()
  89. ON_COMMAND(BTN_TEST,  OnTest)
  90. ON_COMMAND(BTN_TEST1,  OnTest)
  91. ON_COMMAND(BTN_TEST2,  OnTest)
  92. ON_COMMAND(BTN_TEST3,  OnTest)
  93. ON_COMMAND(BTN_TEST4,  OnTest)
  94. ON_COMMAND(BTN_TEST5,  OnTest)
  95. ON_COMMAND(BTN_TEST6,  OnTest)
  96. ON_COMMAND(BTN_TEST7,  OnTest)
  97. ON_COMMAND(BTN_TEST8,  OnTest)
  98. ON_COMMAND(BTN_TEST9,  OnTest)
  99. ON_COMMAND(BTN_TEST10,  OnTest)
  100. ON_COMMAND(BTN_TEST11,  OnTest)
  101. ON_COMMAND(BTN_TEST12,  OnTest)
  102. ON_COMMAND(BTN_TEST13,  OnTest)
  103. ON_COMMAND(BTN_TEST14,  OnTest)
  104. ON_COMMAND(BTN_TEST15,  OnTest)
  105. //}}AFX_MSG_MAP
  106. END_MESSAGE_MAP()
  107. /////////////////////////////////////////////////////////////////////////////
  108. // CGuiPanelAccessDemoDlg message handlers
  109. void CGuiPanelAccessDemoDlg::OnTest()
  110. {
  111. AfxMessageBox("Test");
  112. }
  113. BOOL CGuiPanelAccessDemoDlg::OnInitDialog()
  114. {
  115. CDialog::OnInitDialog();
  116. // Add "About..." menu item to system menu.
  117. // IDM_ABOUTBOX must be in the system command range.
  118. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  119. ASSERT(IDM_ABOUTBOX < 0xF000);
  120. CMenu* pSysMenu = GetSystemMenu(FALSE);
  121. if (pSysMenu != NULL)
  122. {
  123. CString strAboutMenu;
  124. strAboutMenu.LoadString(IDS_ABOUTBOX);
  125. if (!strAboutMenu.IsEmpty())
  126. {
  127. pSysMenu->AppendMenu(MF_SEPARATOR);
  128. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  129. }
  130. }
  131. // Set the icon for this dialog.  The framework does this automatically
  132. //  when the application's main window is not a dialog
  133. SetIcon(m_hIcon, TRUE); // Set big icon
  134. SetIcon(m_hIcon, FALSE); // Set small icon
  135. if (!m_Splitter.Create(&m_Frame))
  136. return -1;
  137. if (!cf.Create(WS_VISIBLE|WS_CHILD,
  138. CRect(0,0,0,0), &m_Splitter, 0))
  139. return -1;
  140. m_Splitter.AddLeftCtrl(&cf,50);
  141. if (!m_panAcc.Create(WS_VISIBLE|WS_CHILD,CRect(0,0,0,0),&cf,1000))
  142. return -1;
  143. if (!m_panAcc1.Create(WS_VISIBLE|WS_CHILD,CRect(0,0,0,0),&cf,1001))
  144. return -1;
  145. m_panAcc1.SetColor(GuiDrawLayer::GetRGBFondoXP());
  146. m_panAcc.SetColor(GuiDrawLayer::GetRGBFondoXP());
  147. m_Splitter.AddLeftCtrl(&cf,50);
  148. m_panAcc.SetImageList(IDB_BITMAP1,16,11,RGB (255, 0, 0));
  149. m_panAcc.AddButton(BTN_TEST,0,&m_btn1,"Option 1");
  150. m_panAcc.AddButton(BTN_TEST1,1,&m_btn2,"Option 2");
  151. m_panAcc.AddButton(BTN_TEST2,2,&m_btn3,"Option 3");
  152. m_panAcc.AddButton(BTN_TEST3,3,&m_btn4,"Option 4");
  153. m_panAcc.AddButton(BTN_TEST4,4,&m_btn5,"Option 5");
  154. m_panAcc.AddButton(BTN_TEST5,5,&m_btn6,"Option 6");
  155. m_panAcc.AddButton(BTN_TEST6,6,&m_btn7,"Option 7");
  156. m_panAcc.AddButton(BTN_TEST7,7,&m_btn8,"Option 8");
  157. m_panAcc.AddButton(BTN_TEST8,0,&m_btn9,"Option 9");
  158. m_panAcc.AddButton(BTN_TEST9,4,&m_btn10,"Option 10");
  159. m_panAcc.AddButton(BTN_TEST10,5,&m_btn11,"Option 11");
  160. m_panAcc.AddButton(BTN_TEST11,6,&m_btn12,"Option 12");
  161. m_panAcc.AddButton(BTN_TEST12,7,&m_btn13,"Option 13");
  162. m_panAcc.AddButton(BTN_TEST13,0,&m_btn14,"Option 14");
  163. m_panAcc.AddButton(BTN_TEST14,7,&m_btn15,"Option 15");
  164. m_panAcc.AddButton(BTN_TEST15,0,&m_btn16,"Option 16");
  165. m_list.Create(WS_VISIBLE|WS_CHILD,CRect(0,0,0,0),&m_Splitter,509);
  166. m_Splitter.AddRightCtrl(&m_list,50);
  167. m_Splitter.SetStyleSeparator(CGuiSplitter::STYLE3D,GuiDrawLayer::GetRGBColorShadow(),GuiDrawLayer::GetRGBColorShadow());
  168. cf.AddFolder(&m_panAcc,"Access panel");
  169. m_Frame.AddChild(&m_Splitter);
  170. m_minitool.SetImageList(IDB_BITMAP1,16,11,RGB (255, 0, 0));
  171. m_minitool.AddButton(0,500);
  172. m_minitool.AddButton(1,501);
  173. m_minitool.AddButton(2,502);
  174. m_minitool.SetBorder(CGuiMiniTool::STYLE3D);
  175. m_panAcc1.SetImageList(IDB_BITMAP1,16,11,RGB (255, 0, 0));
  176. m_panAcc1.AddButton(BTN_TEST8,15,&m_btn17,"Option 1");
  177. cf.AddFolder(&m_panAcc1,"Grupos");
  178. // TODO: Add extra initialization here
  179. return TRUE;  // return TRUE  unless you set the focus to a control
  180. }
  181. void CGuiPanelAccessDemoDlg::OnSysCommand(UINT nID, LPARAM lParam)
  182. {
  183. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  184. {
  185. CAboutDlg dlgAbout;
  186. dlgAbout.DoModal();
  187. }
  188. else
  189. {
  190. CDialog::OnSysCommand(nID, lParam);
  191. }
  192. }
  193. // If you add a minimize button to your dialog, you will need the code below
  194. //  to draw the icon.  For MFC applications using the document/view model,
  195. //  this is automatically done for you by the framework.
  196. void CGuiPanelAccessDemoDlg::OnPaint() 
  197. {
  198. if (IsIconic())
  199. {
  200. CPaintDC dc(this); // device context for painting
  201. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  202. // Center icon in client rectangle
  203. int cxIcon = GetSystemMetrics(SM_CXICON);
  204. int cyIcon = GetSystemMetrics(SM_CYICON);
  205. CRect rect;
  206. GetClientRect(&rect);
  207. int x = (rect.Width() - cxIcon + 1) / 2;
  208. int y = (rect.Height() - cyIcon + 1) / 2;
  209. // Draw the icon
  210. dc.DrawIcon(x, y, m_hIcon);
  211. }
  212. else
  213. {
  214. CDialog::OnPaint();
  215. }
  216. }
  217. // The system calls this to obtain the cursor to display while the user drags
  218. //  the minimized window.
  219. HCURSOR CGuiPanelAccessDemoDlg::OnQueryDragIcon()
  220. {
  221. return (HCURSOR) m_hIcon;
  222. }