DlgBase.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // DlgBase.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "IDE.h"
  5. #include "DlgBase.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CDlgBase dialog
  13. CDlgBase::CDlgBase(UINT nID,CWnd* pParent /*=NULL*/)
  14. : CDialog(nID, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CDlgBase)
  17. // NOTE: the ClassWizard will add member initialization here
  18. //}}AFX_DATA_INIT
  19. }
  20. void CDlgBase::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. //{{AFX_DATA_MAP(CDlgBase)
  24. // NOTE: the ClassWizard will add DDX and DDV calls here
  25. //}}AFX_DATA_MAP
  26. }
  27. BEGIN_MESSAGE_MAP(CDlgBase, CDialog)
  28. //{{AFX_MSG_MAP(CDlgBase)
  29. ON_WM_PAINT()
  30. ON_WM_NCHITTEST()
  31. //}}AFX_MSG_MAP
  32. END_MESSAGE_MAP()
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CDlgBase message handlers
  35. BOOL CDlgBase::OnInitDialog()
  36. {
  37. CDialog::OnInitDialog();
  38. // TODO: Add extra initialization here
  39. /*将窗体大小调整到位图大小一样*/
  40. m_bmp.LoadBitmap(IDB_CONTROL);
  41. BITMAP bm;
  42. m_bmp.GetBitmap(&bm);
  43. CRect rtWindow;
  44. GetWindowRect(&rtWindow);
  45. rtWindow.right = rtWindow.left+bm.bmWidth;
  46. rtWindow.bottom =rtWindow.top +bm.bmHeight;
  47. MoveWindow(&rtWindow);
  48. return TRUE; // return TRUE unless you set the focus to a control
  49. // EXCEPTION: OCX Property Pages should return FALSE
  50. }
  51. void CDlgBase::OnPaint()
  52. {
  53. CPaintDC dc(this); // device context for painting
  54. // TODO: Add your message handler code here
  55. CDC picDC;
  56. picDC.CreateCompatibleDC (&dc);
  57. CBitmap *pOldBmp;
  58. pOldBmp = picDC.SelectObject (&m_bmp);
  59. BITMAP bm;
  60. m_bmp.GetBitmap(&bm);
  61. dc.BitBlt (0,0,bm.bmWidth ,bm.bmHeight,&picDC,0,0,SRCCOPY);
  62. dc.SelectObject(pOldBmp);
  63. //2011-11-02 add
  64. ReleaseDC( &picDC );
  65. ReleaseDC( &dc );
  66. // Do not call CDialog::OnPaint() for painting messages
  67. }
  68. LRESULT CDlgBase::OnNcHitTest(CPoint point)
  69. {
  70. // TODO: Add your message handler code here and/or call default
  71. LRESULT nResult = CDialog::OnNcHitTest(point);
  72. return nResult == HTCLIENT ? HTCAPTION : nResult;
  73. }