GME  13
GMEPanningWindow.cpp
Go to the documentation of this file.
00001 // GMEPanningWindow.cpp: implementation of the CGMEPanningWindow class.
00002 //
00004 
00005 #include "stdafx.h"
00006 #include "GMEPanningWindow.h"
00007 #include "GMEApp.h"
00008 #include "MainFrm.h"
00009 #include "GMEView.h"
00010 
00011 
00013 // CGMEPanningWindow
00014 
00015 CGMEPanningWindow* CGMEPanningWindow::theInstance = 0;
00017 // Construction/Destruction
00019 
00020 CGMEPanningWindow::CGMEPanningWindow()
00021 {
00022         //{{AFX_DATA_INIT(CGMEPanningWindow)
00023         //}}AFX_DATA_INIT
00024 
00025         VERIFY(theInstance == 0);
00026         theInstance = this;
00027 }
00028 
00029 
00030 BEGIN_MESSAGE_MAP(CGMEPanningWindow, CDockablePane)
00031         //{{AFX_MSG_MAP(CGMEPanningWindow)
00032         ON_WM_CREATE()
00033         ON_WM_SIZE()
00034         ON_WM_CLOSE()
00035         //}}AFX_MSG_MAP
00036 END_MESSAGE_MAP()
00037 
00038 
00039 BEGIN_EVENTSINK_MAP(CGMEPanningWindow, CDockablePane)
00040         //{{AFX_EVENTSINK_MAP(CGMEPanningWindow)
00041         //}}AFX_EVENTSINK_MAP
00042 END_EVENTSINK_MAP()
00043 
00045 // CGMEPanningWindow message handlers
00046 
00047 int CGMEPanningWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) 
00048 {
00049         lpCreateStruct->cx = lpCreateStruct->cy = 150;
00050         if (CDockablePane::OnCreate(lpCreateStruct) == -1)
00051                 return -1;
00052 
00053         if (!m_PanningWindowWrapper.Create(_T("PanningWindow"), WS_CHILD | WS_VISIBLE, CRect(0, 0, 150, 150), this, IDC_PANNINGWINDOWCTRL1))
00054                 return -1;
00055 
00056         return 0;
00057 }
00058 
00059 
00060 void CGMEPanningWindow::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
00061 {
00062         CDockablePane::OnUpdateCmdUI(pTarget, bDisableIfNoHndler);
00063 
00064         UpdateDialogControls(pTarget, bDisableIfNoHndler);
00065 }
00066 
00067 
00068 void CGMEPanningWindow::OnSize(UINT nType, int cx, int cy)
00069 {
00070         cx = cy = 100;
00071         CDockablePane::OnSize(nType, cx, cy);
00072 
00073         CRect rc;
00074         GetClientRect(rc);
00075 
00076         m_PanningWindowWrapper.MoveWindow(rc);
00077 }
00078 
00079 
00080 void CGMEPanningWindow::DoDataExchange(CDataExchange* pDX)
00081 {
00082         //{{AFX_DATA_MAP(CGMEPanningWindow)
00083         DDX_Control(pDX, IDC_PANNINGWINDOWCTRL1, m_PanningWindowWrapper);
00084         //}}AFX_DATA_MAP
00085 }
00086 
00087 
00088 /* 
00089 ActiveX controls do not have their message pump, it is owned by their containers.
00090 The container in case of GME is a kind of control bar, which is treated as a dialog.
00091 Dialog box messages are filtered by ::IsDialogMessage, which does not allow the 
00092 default dialog kestroke messages (ESC - close dialog, ENTER - push default button
00093 TAB - next item in the tab order etc...) to be propagated to the controls placed on 
00094 the dialog.
00095 
00096 Here we avoid calling the default PreTranslateMessage which filtered by 
00097 ::IsDialogMessage, dispatch it directly to the controls.
00098 
00099 Tihamer
00100 
00101 */
00102 
00103 BOOL CGMEPanningWindow::PreTranslateMessage(MSG* pMsg)
00104 {
00105         if (pMsg->message == WM_KEYDOWN) {
00106                 switch (pMsg->wParam) {
00107                         case VK_RETURN:
00108                         case VK_ESCAPE:
00109                         case VK_DELETE:
00110                         // Modification by Volgyesi (undo problems)
00111                         case VK_CONTROL:
00112                         case 'z':
00113                         case 'Z':
00114                         // Modification End
00115                                 ::TranslateMessage(pMsg);
00116                                 ::DispatchMessage(pMsg);
00117                                 return TRUE;
00118                 }
00119         }
00120 
00121         return CDockablePane::PreTranslateMessage(pMsg);
00122 }
00123 
00124 
00125 void CGMEPanningWindow::SetBitmapDC(HWND owner, HDC bdc, HBITMAP oldBmp, CRect& ori, CRect& rect, COLORREF& bkgrnd)
00126 {
00127         m_PanningWindowWrapper.SetBitmapDC((ULONGLONG)owner, (ULONGLONG)bdc, (ULONGLONG)oldBmp, ori.left, ori.top, ori.Width(), ori.Height(),
00128                                                                                 rect.left, rect.top, rect.Width(), rect.Height(), (OLE_COLOR)bkgrnd);
00129 }
00130 
00131 
00132 void CGMEPanningWindow::SetViewRect(CRect vrect)
00133 {
00134         m_PanningWindowWrapper.SetViewRect(vrect.left, vrect.top, vrect.Width(), vrect.Height());
00135 }
00136 
00137 void CGMEPanningWindow::ShowPane(BOOL bShow, BOOL bDelay, BOOL bActivate/* = TRUE*/)
00138 {
00139         CDockablePane::ShowPane(bShow, bDelay, bActivate);
00140         if (bShow)
00141         {
00142                 CMDIChildWnd *pChild  = CMainFrame::theInstance->MDIGetActive();
00143                 if (pChild) 
00144                 {
00145                         CGMEView *view = (CGMEView*)pChild->GetActiveView();
00146                         if (view) 
00147                         {
00148                                 view->DoPannWinRefresh();
00149                                 view->notifyPanning(view->GetDeviceScrollPosition());
00150                         }
00151                 }
00152         }
00153 }