www.pudn.com > DEM_TDS.rar > ComboToolBar.cpp, change:2007-05-27,size:1965b
// ComboToolBar.cpp : implementation file // #include "stdafx.h" #include "DEM.h" #include "ComboToolBar.h" #include "DEMView.h" #include "MainFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CComboToolBar CComboToolBar::CComboToolBar() { } CComboToolBar::~CComboToolBar() { } BEGIN_MESSAGE_MAP(CComboToolBar, CToolBar) //{{AFX_MSG_MAP(CComboToolBar) // NOTE - the ClassWizard will add and remove mapping macros here. ON_CBN_SELENDOK(IDC_SHOWSCALE, OnSelectShowScale) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CComboToolBar message handlers BOOL CComboToolBar::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN) { NMHDR nm; nm.hwndFrom = m_hWnd; nm.idFrom = GetDlgCtrlID(); nm.code = NM_RETURN; switch (pMsg->wParam) { case VK_RETURN: //发送通知消息 { if(showscalecombox.IsChild(GetFocus())) OnSelectShowScale(); GetOwner()->SendMessage(WM_NOTIFY, nm.idFrom, (LPARAM)&nm); return TRUE; } } } return CToolBar::PreTranslateMessage(pMsg); } void CComboToolBar::OnSelectShowScale() { CString cs; showscalecombox.GetWindowText(cs); float scale; int get=sscanf(cs,"%f",&scale); if(get!=1)return; scale/=100; CMainFrame *pMainFrm=(CMainFrame *)AfxGetMainWnd(); CMDIChildWnd *pChild =pMainFrm->MDIGetActive(); CDEMView *pView=(CDEMView*)pChild->GetActiveView(); CPoint point(pView->mapview.GetViewExt().x/2,pView->mapview.GetViewExt().y/2); pView->Getmapview().SetShowScale(scale/pView->Getmapview().scale,point); pView->Invalidate(); }