CRgnedButtonDlg.cpp
上传用户:helenlwl
上传日期:2007-01-01
资源大小:14k
文件大小:3k
源码类别:

按钮控件

开发平台:

Visual C++

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