Advertisement
michaelwalz

Untitled

Apr 15th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.51 KB | None | 0 0
  1. // MyTestDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "MyTest.h"
  6. #include "MyTestDlg.h"
  7. #include "OtherDlg.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMyTestDlg dialog
  17.  
  18. CMyTestDlg::CMyTestDlg(CWnd* pParent /*=NULL*/)
  19.     : CDialog(CMyTestDlg::IDD, pParent)
  20. {
  21.     //{{AFX_DATA_INIT(CMyTestDlg)
  22.         // NOTE: the ClassWizard will add member initialization here
  23.     //}}AFX_DATA_INIT
  24.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  25.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  26. }
  27.  
  28. void CMyTestDlg::DoDataExchange(CDataExchange* pDX)
  29. {
  30.     CDialog::DoDataExchange(pDX);
  31.     //{{AFX_DATA_MAP(CMyTestDlg)
  32.         // NOTE: the ClassWizard will add DDX and DDV calls here
  33.     //}}AFX_DATA_MAP
  34. }
  35.  
  36. BEGIN_MESSAGE_MAP(CMyTestDlg, CDialog)
  37.     //{{AFX_MSG_MAP(CMyTestDlg)
  38.     ON_WM_PAINT()
  39.     ON_WM_QUERYDRAGICON()
  40.     //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CMyTestDlg message handlers
  45.  
  46. BOOL CMyTestDlg::OnInitDialog()
  47. {
  48.     CDialog::OnInitDialog();
  49.  
  50.     // Set the icon for this dialog.  The framework does this automatically
  51.     //  when the application's main window is not a dialog
  52.     SetIcon(m_hIcon, TRUE);         // Set big icon
  53.     SetIcon(m_hIcon, FALSE);        // Set small icon
  54.    
  55.     // TODO: Add extra initialization here
  56.    
  57.     return TRUE;  // return TRUE  unless you set the focus to a control
  58. }
  59.  
  60. // If you add a minimize button to your dialog, you will need the code below
  61. //  to draw the icon.  For MFC applications using the document/view model,
  62. //  this is automatically done for you by the framework.
  63.  
  64. void CMyTestDlg::OnPaint()
  65. {
  66.     if (IsIconic())
  67.     {
  68.         CPaintDC dc(this); // device context for painting
  69.  
  70.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  71.  
  72.         // Center icon in client rectangle
  73.         int cxIcon = GetSystemMetrics(SM_CXICON);
  74.         int cyIcon = GetSystemMetrics(SM_CYICON);
  75.         CRect rect;
  76.         GetClientRect(&rect);
  77.         int x = (rect.Width() - cxIcon + 1) / 2;
  78.         int y = (rect.Height() - cyIcon + 1) / 2;
  79.  
  80.         // Draw the icon
  81.         dc.DrawIcon(x, y, m_hIcon);
  82.     }
  83.     else
  84.     {
  85.         CDialog::OnPaint();
  86.     }
  87. }
  88.  
  89. // The system calls this to obtain the cursor to display while the user drags
  90. //  the minimized window.
  91. HCURSOR CMyTestDlg::OnQueryDragIcon()
  92. {
  93.     return (HCURSOR) m_hIcon;
  94. }
  95.  
  96. void CMyTestDlg::OnOK()
  97. {
  98.     CDialog::OnOK();
  99.  
  100.   COtherDlg Dlg ;
  101.   Dlg.DoModal() ;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement