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

对话框与窗口

开发平台:

Visual C++

  1. // TestDlgDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "TestDlg.h"
  5. #include "TestDlgDlg.h"
  6. #include "resource.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. // CTestDlgDlg dialog
  51. CTestDlgDlg::CTestDlgDlg(CWnd* pParent /*=NULL*/)
  52. : CDialog(CTestDlgDlg::IDD, pParent)
  53. {
  54. //{{AFX_DATA_INIT(CTestDlgDlg)
  55. //}}AFX_DATA_INIT
  56. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  57. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  58. }
  59. void CTestDlgDlg::DoDataExchange(CDataExchange* pDX)
  60. {
  61. CDialog::DoDataExchange(pDX);
  62. //{{AFX_DATA_MAP(CTestDlgDlg)
  63. DDX_Control(pDX, IDC_LINKBUTTON, m_Link);
  64. DDX_Control(pDX, IDC_GROUPBOX, m_gbox);
  65. DDX_Control(pDX, IDCANCEL, m_cancel);
  66. DDX_Control(pDX, IDOK, m_Okbtn);
  67. DDX_Control(pDX, IDC_BTNARROW , m_btnArrow);
  68. DDX_Control(pDX, IDC_COMBO1, m_Combobox);
  69. DDX_Control(pDX, IDC_CHECK2, m_btnCheck2);
  70. DDX_Control(pDX, IDC_CHECK1, m_btnCheck1);
  71. DDX_Control(pDX, IDC_EDITFLAT, m_guiedit);
  72. DDX_Control(pDX, IDC_RADIO1, m_rd1);
  73. DDX_Control(pDX, IDC_RADIO2, m_rd2);
  74. //}}AFX_DATA_MAP
  75. }
  76. BEGIN_MESSAGE_MAP(CTestDlgDlg, CDialog)
  77. //{{AFX_MSG_MAP(CTestDlgDlg)
  78. ON_WM_SYSCOMMAND()
  79. ON_WM_PAINT()
  80. ON_WM_QUERYDRAGICON()
  81. ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
  82. //}}AFX_MSG_MAP
  83. //ON_COMMAND(ID_OPTION2, OnOption2)
  84. ON_COMMAND(ID_OPTION1, OnOption1)
  85. END_MESSAGE_MAP()
  86. /////////////////////////////////////////////////////////////////////////////
  87. // CTestDlgDlg message handlers
  88. BOOL CTestDlgDlg::OnInitDialog()
  89. {
  90. CDialog::OnInitDialog();
  91. // Add "About..." menu item to system menu.
  92. // IDM_ABOUTBOX must be in the system command range.
  93. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  94. ASSERT(IDM_ABOUTBOX < 0xF000);
  95. CMenu* pSysMenu = GetSystemMenu(FALSE);
  96. if (pSysMenu != NULL)
  97. {
  98. CString strAboutMenu;
  99. strAboutMenu.LoadString(IDS_ABOUTBOX);
  100. if (!strAboutMenu.IsEmpty())
  101. {
  102. pSysMenu->AppendMenu(MF_SEPARATOR);
  103. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  104. }
  105. }
  106. //*****************************************************************
  107. m_Link.SetLink("www.beyondata.com");
  108. m_Link.SetToolTip("Goto GuiLib Site");
  109. menu.LoadMenu(IDR_MENU1);
  110. m_Okbtn.SetCaption("&Ok");
  111. m_Okbtn.SetStyleBorder(CGuiButton::STYLEXP);
  112. // m_Okbtn.AutoSizeButton();
  113. // m_Okbtn.SetImage(IDI_ICON1);
  114. // m_Okbtn.ShowImage();
  115. m_cancel.ShowText();
  116. m_cancel.SetToolTip("Cancelar");
  117. m_cancel.SetImage(IDI_ICON1,-1,-1);
  118. m_cancel.ShowImage();
  119. // m_cancel.AutoSizeButton();
  120. m_gbox.SetWindowText("Algunos controles");
  121. m_gbox.SetStyle(CGuiGroupBox::ALING_LEFT);
  122. //*****************************************************************
  123. // Set the icon for this dialog.  The framework does this automatically
  124. //  when the application's main window is not a dialog
  125. SetIcon(m_hIcon, TRUE); // Set big icon
  126. SetIcon(m_hIcon, FALSE); // Set small icon
  127. // TODO: Add extra initialization here
  128. //********************************************************************
  129. m_guiedit.SetToolTip("test de tooltip");
  130. m_guiedit.SetMask("ID:##.###.### Ciudad:(aaaAAAa)","ID:__.___.___ Ciudad:(_______)",CGuiEdit::MASK_HOUR12);
  131. // m_guiedit.AddButton(m_imag.ExtractIcon(0),333,NULL,"Press Here");
  132. m_btnArrow.SetTypeButton(CGuiButton::TYPE_ARROW);
  133. m_btnArrow.SetAlingArrow(CGuiButton::ARROW_RIGHT);
  134. m_btnArrow.SetPopupMenu(&menu);
  135. // m_btnArrow.AutoSizeButton();
  136. return TRUE;  // return TRUE  unless you set the focus to a control
  137. }
  138. void CTestDlgDlg::OnSysCommand(UINT nID, LPARAM lParam)
  139. {
  140. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  141. {
  142. CAboutDlg dlgAbout;
  143. dlgAbout.DoModal();
  144. }
  145. else
  146. {
  147. CDialog::OnSysCommand(nID, lParam);
  148. }
  149. }
  150. // If you add a minimize button to your dialog, you will need the code below
  151. //  to draw the icon.  For MFC applications using the document/view model,
  152. //  this is automatically done for you by the framework.
  153. void CTestDlgDlg::OnPaint() 
  154. {
  155. if (IsIconic())
  156. {
  157. CPaintDC dc(this); // device context for painting
  158. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  159. // Center icon in client rectangle
  160. int cxIcon = GetSystemMetrics(SM_CXICON);
  161. int cyIcon = GetSystemMetrics(SM_CYICON);
  162. CRect rect;
  163. GetClientRect(&rect);
  164. int x = (rect.Width() - cxIcon + 1) / 2;
  165. int y = (rect.Height() - cyIcon + 1) / 2;
  166. // Draw the icon
  167. dc.DrawIcon(x, y, m_hIcon);
  168. }
  169. else
  170. {
  171. CDialog::OnPaint();
  172. }
  173. }
  174. // The system calls this to obtain the cursor to display while the user drags
  175. //  the minimized window.
  176. HCURSOR CTestDlgDlg::OnQueryDragIcon()
  177. {
  178. return (HCURSOR) m_hIcon;
  179. }
  180. void CTestDlgDlg::OnCheck1() 
  181. {
  182. // TODO: Add your control notification handler code here
  183. }
  184. void CTestDlgDlg::OnOption1()
  185. {
  186. // TODO: Add your command handler code here
  187. AfxMessageBox("Hola");
  188. }