DlgBase.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. // Do not call CDialog::OnPaint() for painting messages
  64. }
  65. UINT CDlgBase::OnNcHitTest(CPoint point)
  66. {
  67. // TODO: Add your message handler code here and/or call default
  68. UINT nResult = CDialog::OnNcHitTest(point);
  69. return nResult == HTCLIENT ? HTCAPTION : nResult;
  70. }