home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / protview / demowinx / data.1 / ACDLG.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-17  |  5.1 KB  |  213 lines

  1. // allctlsDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "allctls.h"
  6. #include "acDlg.h"
  7. #include "GuiCtls.h"
  8. #include "Datainpt.h"
  9. #include "TreeDlg.h"
  10. #include "FntSlDlg.h"
  11.  
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CAboutDlg dialog used for App About
  20.  
  21. class CAboutDlg : public CDialog
  22. {
  23. public:
  24.     CAboutDlg();
  25.  
  26. // Dialog Data
  27.     //{{AFX_DATA(CAboutDlg)
  28.     enum { IDD = IDD_ABOUTBOX };
  29.     //}}AFX_DATA
  30.  
  31.     // ClassWizard generated virtual function overrides
  32.     //{{AFX_VIRTUAL(CAboutDlg)
  33.     protected:
  34.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  35.     //}}AFX_VIRTUAL
  36.  
  37. // Implementation
  38. protected:
  39.     //{{AFX_MSG(CAboutDlg)
  40.     //}}AFX_MSG
  41.     DECLARE_MESSAGE_MAP()
  42. };
  43.  
  44. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  45. {
  46.     //{{AFX_DATA_INIT(CAboutDlg)
  47.     //}}AFX_DATA_INIT
  48. }
  49.  
  50. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  51. {
  52.     CDialog::DoDataExchange(pDX);
  53.     //{{AFX_DATA_MAP(CAboutDlg)
  54.     //}}AFX_DATA_MAP
  55. }
  56.  
  57. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  58.     //{{AFX_MSG_MAP(CAboutDlg)
  59.         // No message handlers
  60.     //}}AFX_MSG_MAP
  61. END_MESSAGE_MAP()
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CAllctlsDlg dialog
  65.  
  66. CAllctlsDlg::CAllctlsDlg(CWnd* pParent /*=NULL*/)
  67.     : CDialog(CAllctlsDlg::IDD, pParent)
  68. {
  69.     //{{AFX_DATA_INIT(CAllctlsDlg)
  70.         // NOTE: the ClassWizard will add member initialization here
  71.     //}}AFX_DATA_INIT
  72.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  73.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  74. }
  75.  
  76. void CAllctlsDlg::DoDataExchange(CDataExchange* pDX)
  77. {
  78.     CDialog::DoDataExchange(pDX);
  79.     //{{AFX_DATA_MAP(CAllctlsDlg)
  80.         // NOTE: the ClassWizard will add DDX and DDV calls here
  81.     //}}AFX_DATA_MAP
  82. }
  83.  
  84. BEGIN_MESSAGE_MAP(CAllctlsDlg, CDialog)
  85.     //{{AFX_MSG_MAP(CAllctlsDlg)
  86.     ON_WM_SYSCOMMAND()
  87.     ON_WM_PAINT()
  88.     ON_WM_QUERYDRAGICON()
  89.     //}}AFX_MSG_MAP
  90. END_MESSAGE_MAP()
  91.  
  92. /////////////////////////////////////////////////////////////////////////////
  93. // CAllctlsDlg message handlers
  94.  
  95. BOOL CAllctlsDlg::OnInitDialog()
  96. {
  97.     CDialog::OnInitDialog();
  98.  
  99.     // Add "About..." menu item to system menu.
  100.  
  101.     // IDM_ABOUTBOX must be in the system command range.
  102.     ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  103.     ASSERT(IDM_ABOUTBOX < 0xF000);
  104.  
  105.     CMenu* pSysMenu = GetSystemMenu(FALSE);
  106.     CString strAboutMenu;
  107.     strAboutMenu.LoadString(IDS_ABOUTBOX);
  108.     if (!strAboutMenu.IsEmpty())
  109.     {
  110.         pSysMenu->AppendMenu(MF_SEPARATOR);
  111.         pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  112.     }
  113.  
  114.     // Set the icon for this dialog.  The framework does this automatically
  115.     //  when the application's main window is not a dialog
  116.     SetIcon(m_hIcon, TRUE);            // Set big icon
  117.     SetIcon(m_hIcon, FALSE);        // Set small icon
  118.     
  119.     // TODO: Add extra initialization here
  120.     
  121.     return TRUE;  // return TRUE  unless you set the focus to a control
  122. }
  123.  
  124. void CAllctlsDlg::OnSysCommand(UINT nID, LPARAM lParam)
  125. {
  126.     if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  127.     {
  128.         CAboutDlg dlgAbout;
  129.         dlgAbout.DoModal();
  130.     }
  131.     else
  132.     {
  133.         CDialog::OnSysCommand(nID, lParam);
  134.     }
  135. }
  136.  
  137. // If you add a minimize button to your dialog, you will need the code below
  138. //  to draw the icon.  For MFC applications using the document/view model,
  139. //  this is automatically done for you by the framework.
  140.  
  141. void CAllctlsDlg::OnPaint() 
  142. {
  143.     if (IsIconic())
  144.     {
  145.         CPaintDC dc(this); // device context for painting
  146.  
  147.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  148.  
  149.         // Center icon in client rectangle
  150.         int cxIcon = GetSystemMetrics(SM_CXICON);
  151.         int cyIcon = GetSystemMetrics(SM_CYICON);
  152.         CRect rect;
  153.         GetClientRect(&rect);
  154.         int x = (rect.Width() - cxIcon + 1) / 2;
  155.         int y = (rect.Height() - cyIcon + 1) / 2;
  156.  
  157.         // Draw the icon
  158.         dc.DrawIcon(x, y, m_hIcon);
  159.     }
  160.     else
  161.     {
  162.         CDialog::OnPaint();
  163.     }
  164. }
  165.  
  166. // The system calls this to obtain the cursor to display while the user drags
  167. //  the minimized window.
  168. HCURSOR CAllctlsDlg::OnQueryDragIcon()
  169. {
  170.     return (HCURSOR) m_hIcon;
  171. }
  172.  
  173. BEGIN_EVENTSINK_MAP(CAllctlsDlg, CDialog)
  174.     //{{AFX_EVENTSINK_MAP(CAllctlsDlg)
  175.     ON_EVENT(CAllctlsDlg, IDC_BUTTON1, -600 /* Click */, OnClickButton1, VTS_NONE)
  176.     ON_EVENT(CAllctlsDlg, IDC_BUTTON2, -600 /* Click */, OnClickButton2, VTS_NONE)
  177.     ON_EVENT(CAllctlsDlg, IDC_BUTTON3, -600 /* Click */, OnClickButton3, VTS_NONE)
  178.     ON_EVENT(CAllctlsDlg, IDC_BUTTON4, -600 /* Click */, OnClickButton4, VTS_NONE)
  179.     //}}AFX_EVENTSINK_MAP
  180. END_EVENTSINK_MAP()
  181.  
  182. void CAllctlsDlg::OnClickButton1() 
  183. {
  184.     // TODO: Add your control notification handler code here
  185.     CGraphicalControls dlg;
  186.  
  187.     dlg.DoModal();
  188. }
  189.  
  190. void CAllctlsDlg::OnClickButton2() 
  191. {
  192.     // TODO: Add your control notification handler code here
  193.     CFontSelDialog dlg;
  194.  
  195.     dlg.DoModal();
  196. }
  197.  
  198. void CAllctlsDlg::OnClickButton3() 
  199. {
  200.     // TODO: Add your control notification handler code here
  201.     CDataEntry dlg;
  202.  
  203.     dlg.DoModal();
  204. }
  205.  
  206. void CAllctlsDlg::OnClickButton4() 
  207. {
  208.     // TODO: Add your control notification handler code here
  209.     CTreeDialog dlg;
  210.  
  211.     dlg.DoModal();
  212. }
  213.