home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / NUMEDIT.ZIP / SpinCtrlDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-05  |  2.4 KB  |  94 lines

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