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

对话框与窗口

开发平台:

Visual C++

  1. // dialogcontrolsDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "dialogcontrols.h"
  5. #include "dialogcontrolsDlg.h"
  6. #include "GuiDrawLayer.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CAboutDlg dialog used for App About
  14. class CAboutDlg : public CDialog
  15. {
  16. public:
  17. CAboutDlg();
  18. // Dialog Data
  19. //{{AFX_DATA(CAboutDlg)
  20. enum { IDD = IDD_ABOUTBOX };
  21. //}}AFX_DATA
  22. // ClassWizard generated virtual function overrides
  23. //{{AFX_VIRTUAL(CAboutDlg)
  24. protected:
  25. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  26. //}}AFX_VIRTUAL
  27. // Implementation
  28. protected:
  29. //{{AFX_MSG(CAboutDlg)
  30. //}}AFX_MSG
  31. DECLARE_MESSAGE_MAP()
  32. };
  33. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  34. {
  35. //{{AFX_DATA_INIT(CAboutDlg)
  36. //}}AFX_DATA_INIT
  37. }
  38. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  39. {
  40. CDialog::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(CAboutDlg)
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  45. //{{AFX_MSG_MAP(CAboutDlg)
  46. // No message handlers
  47. //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CDialogcontrolsDlg dialog
  51. CDialogcontrolsDlg::CDialogcontrolsDlg(CWnd* pParent /*=NULL*/)
  52. : CDialog(CDialogcontrolsDlg::IDD, pParent)
  53. {
  54. //{{AFX_DATA_INIT(CDialogcontrolsDlg)
  55. // NOTE: the ClassWizard will add member initialization here
  56. //}}AFX_DATA_INIT
  57. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  58. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  59. }
  60. void CDialogcontrolsDlg::DoDataExchange(CDataExchange* pDX)
  61. {
  62. CDialog::DoDataExchange(pDX);
  63. //{{AFX_DATA_MAP(CDialogcontrolsDlg)
  64. DDX_Control(pDX, IDC_STATICOUTLOOK, m_outllok);
  65. DDX_Control(pDX, IDC_STATICMINITOOLS, m_minitools);
  66. //}}AFX_DATA_MAP
  67. }
  68. BEGIN_MESSAGE_MAP(CDialogcontrolsDlg, CDialog)
  69. //{{AFX_MSG_MAP(CDialogcontrolsDlg)
  70. ON_WM_SYSCOMMAND()
  71. ON_WM_PAINT()
  72. ON_WM_QUERYDRAGICON()
  73. //}}AFX_MSG_MAP
  74. END_MESSAGE_MAP()
  75. /////////////////////////////////////////////////////////////////////////////
  76. // CDialogcontrolsDlg message handlers
  77. BOOL CDialogcontrolsDlg::OnInitDialog()
  78. {
  79. CDialog::OnInitDialog();
  80. // Add "About..." menu item to system menu.
  81. // IDM_ABOUTBOX must be in the system command range.
  82. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  83. ASSERT(IDM_ABOUTBOX < 0xF000);
  84. CMenu* pSysMenu = GetSystemMenu(FALSE);
  85. if (pSysMenu != NULL)
  86. {
  87. CString strAboutMenu;
  88. strAboutMenu.LoadString(IDS_ABOUTBOX);
  89. if (!strAboutMenu.IsEmpty())
  90. {
  91. pSysMenu->AppendMenu(MF_SEPARATOR);
  92. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  93. }
  94. }
  95. // Set the icon for this dialog.  The framework does this automatically
  96. //  when the application's main window is not a dialog
  97. SetIcon(m_hIcon, TRUE); // Set big icon
  98. SetIcon(m_hIcon, FALSE); // Set small icon
  99. if (!m_Splitter.Create(&m_outllok))
  100. return -1;
  101. if (!cf.Create(WS_VISIBLE|WS_CHILD,
  102. CRect(0,0,0,0), &m_Splitter, 0))
  103. return -1;
  104. m_Splitter.AddLeftCtrl(&cf,50);
  105. if (!out.Create(WS_VISIBLE, CRect(0,0,0,0), &cf, 1))
  106. return -1;
  107. #define IDO_OUTODAY    5600
  108. #define IDO_CALENDARIO 5601
  109. #define IDO_CONTACTO   5602
  110. #define IDO_TAREAS     5603
  111. #define IDO_NOTAS    5604
  112. #define IDO_ELIMINAR   5605
  113. out.SetImageList(IDB_BITMAP1, 32, 0, RGB(255,0,0));
  114. out.AddItem(IDO_OUTODAY,"OutLook para hoy",7);
  115. out.AddItem(IDO_CALENDARIO,"Calendario",1);
  116. out.AddItem(IDO_CONTACTO,"Contactos",2);
  117. out.AddItem(IDO_TAREAS,"tareas",3);
  118. out.AddItem(IDO_NOTAS,"Notas",5);
  119. out.AddItem(IDO_ELIMINAR,"Elementos Eliminados",6);
  120. //------------------------------------------------------------------
  121. if (!tc.Create(WS_CHILD | WS_VISIBLE | TVS_HASLINES | 
  122. TVS_LINESATROOT | TVS_HASBUTTONS,
  123. CRect(0,0,0,0), &cf, 2))
  124. return -1;
  125. HTREEITEM hRoot = tc.InsertItem (_T("Opcion uno"), 0, 0);
  126. tc.SetItemState (hRoot, TVIS_BOLD, TVIS_BOLD);
  127. HTREEITEM hClass = tc.InsertItem (_T("Opcion dos"), 1, 1, hRoot);
  128. tc.InsertItem (_T("SubOpcion dos"), 3, 3, hClass);
  129. tc.InsertItem (_T("SubOpcion tres"), 4, 4, hClass);
  130. tc.Expand (hRoot, TVE_EXPAND);
  131. //--------------------------------------------------------------------
  132. if (!tc1.Create(WS_CHILD | WS_VISIBLE | TVS_HASLINES | 
  133. TVS_LINESATROOT | TVS_HASBUTTONS,
  134. CRect(0,0,0,0), &m_Splitter, 2))
  135. return -1;
  136. hRoot = tc1.InsertItem (_T("Opcion uno"), 0, 0);
  137. tc1.SetItemState (hRoot, TVIS_BOLD, TVIS_BOLD);
  138. hClass = tc1.InsertItem (_T("Opcion dos"), 1, 1, hRoot);
  139. tc1.InsertItem (_T("SubOpcion dos"), 3, 3, hClass);
  140. tc1.InsertItem (_T("SubOpcion tres"), 4, 4, hClass);
  141. tc1.Expand (hRoot, TVE_EXPAND);
  142. //-------------------------------------------------------------------
  143. // out.SetXp(TRUE);
  144. cf.AddFolder(&out,"Accesos directos de OutLook");
  145. cf.AddFolder(&tc,"Mis Accesos directos");
  146. m_Splitter.AddRightCtrl(&tc1,50);
  147. m_outllok.AddChild(&m_Splitter);
  148. m_Splitter.SetStyleSeparator(CGuiSplitter::STYLE3D,GuiDrawLayer::GetRGBColorShadow(),GuiDrawLayer::GetRGBColorShadow());
  149. // TODO: Add extra initialization here
  150. //-------------------------------------------------------------------------
  151. //caption Bar Outlook Style
  152. #define ID_VIEWCAPTION WM_USER+1
  153. #define IDT_BACK    ID_VIEWCAPTION+1
  154. #define IDT_FORW    IDT_BACK+1
  155. #define IDT_STANDAR    IDT_FORW+1
  156. #define IDT_GO     IDT_STANDAR+1
  157. #define IDT_UNDO IDT_GO+1
  158. if (!m_CapOutBar.Create (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 
  159. &m_minitools,ID_VIEWCAPTION))
  160. {
  161. TRACE0("Failed to create caption barn");
  162. return FALSE;
  163. }
  164. if (!m_CapOutBar.SetSplitter(&m_MiniSplitter))
  165. return FALSE;
  166. m_MiniSplitter.AddMiniToolLeft(&m_guiMiniToolLeft);
  167. m_MiniSplitter.AddMiniToolRight(&m_guiMiniToolRight);
  168. m_guiMiniToolLeft.SetImageList(IDB_BITMAP2,16,11,RGB (255, 0, 0));
  169. m_guiMiniToolRight.SetImageList(IDB_BITMAP2,16,11,RGB (255, 0, 0));
  170. //Left MiniTool 
  171. m_guiMiniToolLeft.AddButton(11,IDT_BACK,NULL,"Back ","Back");
  172. m_guiMiniToolLeft.AddButton(12,IDT_FORW,NULL,"Forward","Forward");
  173. m_guiMiniToolLeft.AddButton(0,IDT_STANDAR,NULL,"OutLook Today","OutLook Today");
  174. CGuiToolButton* pBtn=m_guiMiniToolLeft.GetButton(IDT_STANDAR);
  175. pBtn->SetFontColor(RGB(255,255,255));
  176. //Right MiniTool
  177. m_guiMiniToolRight.CreateCombo(&m_cb,333,100);
  178. m_guiMiniToolRight.AddButton(13,IDT_GO,NULL,"Go  ","Go  ");
  179. m_guiMiniToolRight.AddButton(15,IDT_UNDO,NULL,"Undo  ","Undo  ");
  180. m_MiniSplitter.SetColor(GuiDrawLayer::GetRGBColorShadow(),GuiDrawLayer::GetRGBColorBTNHigh());
  181. m_guiMiniToolRight.SetCaption("&Direccion:",CGuiMiniTool::ALIGN_LEFT);
  182. m_guiMiniToolRight.SetColorCaption(GuiDrawLayer::GetRGBColorBTNHigh());
  183. m_guiMiniToolRight.AutoSize(TRUE);
  184. m_cb.AddString("outlook:Tareas");
  185. m_cb.AddString("outlook:Notas");
  186. m_cb.AddString("Toolbar Combobox item four");
  187. m_cb.AddString("Toolbar Combobox item five");
  188. m_cb.AddString("Toolbar Combobox item six");
  189. m_cb.SetColor(GuiDrawLayer::GetRGBColorShadow());
  190. m_minitools.AddChild(&m_CapOutBar);
  191. //--------------------------------------------------------------------------
  192. return TRUE;  // return TRUE  unless you set the focus to a control
  193. }
  194. void CDialogcontrolsDlg::OnSysCommand(UINT nID, LPARAM lParam)
  195. {
  196. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  197. {
  198. CAboutDlg dlgAbout;
  199. dlgAbout.DoModal();
  200. }
  201. else
  202. {
  203. CDialog::OnSysCommand(nID, lParam);
  204. }
  205. }
  206. // If you add a minimize button to your dialog, you will need the code below
  207. //  to draw the icon.  For MFC applications using the document/view model,
  208. //  this is automatically done for you by the framework.
  209. void CDialogcontrolsDlg::OnPaint() 
  210. {
  211. if (IsIconic())
  212. {
  213. CPaintDC dc(this); // device context for painting
  214. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  215. // Center icon in client rectangle
  216. int cxIcon = GetSystemMetrics(SM_CXICON);
  217. int cyIcon = GetSystemMetrics(SM_CYICON);
  218. CRect rect;
  219. GetClientRect(&rect);
  220. int x = (rect.Width() - cxIcon + 1) / 2;
  221. int y = (rect.Height() - cyIcon + 1) / 2;
  222. // Draw the icon
  223. dc.DrawIcon(x, y, m_hIcon);
  224. }
  225. else
  226. {
  227. CDialog::OnPaint();
  228. }
  229. }
  230. // The system calls this to obtain the cursor to display while the user drags
  231. //  the minimized window.
  232. HCURSOR CDialogcontrolsDlg::OnQueryDragIcon()
  233. {
  234. return (HCURSOR) m_hIcon;
  235. }