GME
13
|
00001 // CompassCheckDlg.cpp : implementation file 00002 // 00003 00004 #include "stdafx.h" 00005 #include "objectinspector.h" 00006 #include "CompassCheckDlg.h" 00007 #include "CompassData.h" 00008 #include "InPlaceCommon.h" 00009 00010 #ifdef _DEBUG 00011 #define new DEBUG_NEW 00012 #undef THIS_FILE 00013 static char THIS_FILE[] = __FILE__; 00014 #endif 00015 00017 // CCompassCheckDlg dialog 00018 00019 00020 CCompassCheckDlg::CCompassCheckDlg(CWnd* pParent /*=NULL*/) 00021 : CDialog(CCompassCheckDlg::IDD, pParent) 00022 { 00023 //{{AFX_DATA_INIT(CCompassCheckDlg) 00024 m_bEast = FALSE; 00025 m_bNorth = FALSE; 00026 m_bSouth = FALSE; 00027 m_bWest = FALSE; 00028 //}}AFX_DATA_INIT 00029 00030 m_bInited = true; 00031 m_bClosed = false; 00032 } 00033 00034 00035 void CCompassCheckDlg::SetParameters(const CPoint& ptRightTop, UINT uCompassVal) 00036 { 00037 m_ptRightTop = ptRightTop; 00038 m_uCompassVal = uCompassVal; 00039 } 00040 00041 00042 UINT CCompassCheckDlg::GetCompassVal(void) const 00043 { 00044 return m_uCompassVal; 00045 } 00046 00047 00048 void CCompassCheckDlg::DoDataExchange(CDataExchange* pDX) 00049 { 00050 CDialog::DoDataExchange(pDX); 00051 //{{AFX_DATA_MAP(CCompassCheckDlg) 00052 DDX_Check(pDX, IDC_EAST, m_bEast); 00053 DDX_Check(pDX, IDC_NORTH, m_bNorth); 00054 DDX_Check(pDX, IDC_SOUTH, m_bSouth); 00055 DDX_Check(pDX, IDC_WEST, m_bWest); 00056 //}}AFX_DATA_MAP 00057 } 00058 00059 00060 BEGIN_MESSAGE_MAP(CCompassCheckDlg, CDialog) 00061 //{{AFX_MSG_MAP(CCompassCheckDlg) 00062 ON_WM_NCACTIVATE() 00063 ON_WM_PAINT() 00064 //}}AFX_MSG_MAP 00065 END_MESSAGE_MAP() 00066 00068 // CCompassCheckDlg message handlers 00069 00070 00071 00072 BOOL CCompassCheckDlg::OnNcActivate(BOOL bActive) 00073 { 00074 if(m_bInited) 00075 { 00076 m_bInited=false; 00077 } 00078 else 00079 { 00080 if (!bActive && !m_bClosed) { 00081 m_bClosed = true; 00082 OnOK(); 00083 } 00084 // OnOK(); 00085 } 00086 return FALSE;//CDialog::OnNcActivate(bActive); 00087 } 00088 00089 BOOL CCompassCheckDlg::OnInitDialog() 00090 { 00091 CDialog::OnInitDialog(); 00092 00093 CRect rectWnd; 00094 GetWindowRect(rectWnd); 00095 CPoint ptLeftTop(m_ptRightTop.x-rectWnd.Width(),m_ptRightTop.y); 00096 SetWindowPos(NULL,ptLeftTop.x,ptLeftTop.y,0,0,SWP_NOSIZE|SWP_NOZORDER); 00097 00098 m_bNorth=m_bEast=m_bSouth=m_bWest=FALSE; 00099 00100 if(m_uCompassVal&CMPS_NORTH) 00101 { 00102 m_bNorth=TRUE; 00103 } 00104 00105 if(m_uCompassVal&CMPS_EAST) 00106 { 00107 m_bEast=TRUE; 00108 } 00109 00110 if(m_uCompassVal&CMPS_SOUTH) 00111 { 00112 m_bSouth=TRUE; 00113 } 00114 00115 if(m_uCompassVal&CMPS_WEST) 00116 { 00117 m_bWest=TRUE; 00118 } 00119 00120 UpdateData(FALSE); 00121 00122 m_background.LoadBitmap( IDB_COMPASS_CHECK ); 00123 00124 m_bInited=true; 00125 return TRUE; 00126 } 00127 00128 00129 void CCompassCheckDlg::OnOK() 00130 { 00131 00132 UpdateData(TRUE); 00133 00134 m_uCompassVal=0; 00135 00136 if(m_bNorth) 00137 { 00138 m_uCompassVal|=CMPS_NORTH; 00139 00140 } 00141 00142 if(m_bSouth) 00143 { 00144 m_uCompassVal|=CMPS_SOUTH; 00145 00146 } 00147 00148 if(m_bEast) 00149 { 00150 m_uCompassVal|=CMPS_EAST; 00151 00152 } 00153 00154 if(m_bWest) 00155 { 00156 m_uCompassVal|=CMPS_WEST; 00157 00158 } 00159 00160 m_bClosed = true; 00161 CDialog::OnOK(); 00162 } 00163 00164 void CCompassCheckDlg::OnCancel() 00165 { 00166 CDialog::OnCancel(); 00167 } 00168 00169 00170 void CCompassCheckDlg::OnPaint() 00171 { 00172 CPaintDC dc(this); 00173 00174 CDC memdc; 00175 CBitmap * oldbmp; 00176 CRect rect; 00177 00178 GetClientRect( &rect ); 00179 00180 memdc.CreateCompatibleDC( &dc ); 00181 oldbmp = memdc.SelectObject( &m_background ); 00182 dc.StretchBlt ( 0, 0, rect.right, rect.bottom 00183 , &memdc 00184 , 0, 0 00185 , 92, 92 //m_background.GetBitmapDimension().cx 00186 //, m_background.GetBitmapDimension().cy 00187 , SRCCOPY 00188 ); 00189 00190 memdc.SelectObject( oldbmp ); 00191 }