//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 缩放所有窗口 VOID CClientWnd::OnPlayZoom(UINT uCmd) { RECT rtMain; RECT rtClient; RECT rtChild; SendMessage(m_hWnd, WM_MDICASCADE, 0, 0); HWND hWnd = GetWindow(m_hWnd, GW_CHILD); for (hWnd = GetWindow(hWnd, GW_HWNDFIRST); hWnd; ) { _Assert(GetChildWnd(hWnd)); GetChildWnd(hWnd)->OnPlayZoom(uCmd, FALSE); hWnd = GetWindow(hWnd, GW_HWNDNEXT); } if (m_bScrabble) { GetWindowRect(CMainWnd::m_hWnd, &rtMain); GetClientRect(m_hWnd, &rtClient); hWnd = GetWindow(GetWindow(m_hWnd, GW_CHILD), GW_HWNDFIRST); GetWindowRect(hWnd, &rtChild); MoveWindow(CMainWnd::m_hWnd, rtMain.left, rtMain.top, _RectWidth(rtMain) - _RectWidth(rtClient) + _RectWidth(rtChild), _RectHeight(rtMain) - _RectHeight(rtClient) + _RectHeight(rtChild), TRUE); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 切换工具栏和状态栏显示 VOID CClientWnd::ToggleBar() { HWND hWnd; hWnd = GetWindow(m_hWnd, GW_CHILD); for (hWnd = GetWindow(hWnd, GW_HWNDFIRST); hWnd; ) { _Assert(GetChildWnd(hWnd)); GetChildWnd(hWnd)->OnSize(); hWnd = GetWindow(hWnd, GW_HWNDNEXT); } }
int CGuiMiniFrame::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message) { CGuiControlBar* pBar=(CGuiControlBar* )GetChildWnd(); if (nHitTest >= HTSIZEFIRST && nHitTest <= HTSIZELAST && (IsGuiControlBar==TRUE && !pBar->IsAutoHide())) // resizing return MA_ACTIVATE ; return CMiniDockFrameWnd::OnMouseActivate(pDesktopWnd, nHitTest, message); }
void CGuiMiniFrame::TypeBar() { if (IsGuiControlBar != -1) return; CWnd* pBar=GetChildWnd(); if (pBar==NULL) return; if (pBar->IsKindOf(RUNTIME_CLASS(CGuiToolBarWnd))) { //ModifyStyleEx( WS_EX_TOOLWINDOW,0 ); ModifyStyle( WS_SYSMENU,0 ); SendMessage(WM_NCLBUTTONDOWN); IsToolBar=TRUE; } else if (pBar->IsKindOf(RUNTIME_CLASS(CGuiControlBar))) { //ModifyStyleEx( WS_EX_TOOLWINDOW,0 ); ModifyStyle( 0,WS_SYSMENU ); SendMessage(WM_NCLBUTTONDOWN); IsGuiControlBar=TRUE; } else { if (pBar->IsKindOf(RUNTIME_CLASS(CMenuBar))) IsMenuBar=TRUE; //ModifyStyleEx( 0, WS_EX_TOOLWINDOW ); ModifyStyle( WS_SYSMENU, 0 ); IsGuiControlBar=FALSE; } }
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { CWnd* wnd = CWnd::FromHandle(GetChildWnd()); if (wnd && wnd->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) return TRUE; return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); }
void CGuiMiniFrame::OnNcLButtonDown(UINT nHitTest, CPoint point) { // SetTimer(1,100,NULL); if (nHitTest == HTCLOSE) { m_stateBtn=PRESSBTN; SetTimer(1,100,0); SendMessage(WM_NCPAINT); CWnd* pBar=GetChildWnd(); if (pBar== NULL) return; if (pBar->IsKindOf(RUNTIME_CLASS(CGuiToolBarWnd))) { m_stateBtn=NORMAL; KillTimer(1); GetParentFrame()->ShowControlBar((CControlBar*)pBar, FALSE, FALSE); } } else { CGuiControlBar* pBar=(CGuiControlBar* )GetChildWnd(); if (pBar) if (IsGuiControlBar==TRUE && pBar->IsAutoHide()) return; SetCursor (LoadCursor(NULL, IDC_SIZEALL)); SendMessage(WM_NCPAINT);//SendMessage(WM_NCCALCSIZE); if (pBar->IsKindOf(RUNTIME_CLASS(CGuiToolBarWnd))) { if (nHitTest != HTCAPTION) return; } } SendMessage(WM_NCPAINT); CMiniDockFrameWnd::OnNcLButtonDown(nHitTest, point); }
void CGuiMiniFrame::OnNcLButtonUp(UINT nHitTest, CPoint point) { // SetTimer(1,100,NULL); if (nHitTest == HTCLOSE) { CWnd* pBar=GetChildWnd(); if (pBar== NULL) return; if (pBar->IsKindOf(RUNTIME_CLASS(CGuiToolBarWnd))) { m_stateBtn=NORMAL; KillTimer(1); GetParentFrame()->ShowControlBar((CControlBar*)pBar, FALSE, FALSE); } } SendMessage(WM_NCPAINT); CMiniDockFrameWnd::OnNcLButtonUp(nHitTest, point); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 载入文件 BOOL CClientWnd::Load(CChildWnd *pWnd) { HWND hWnd; TCHAR tzText[MAX_PATH]; // 检查文件是否已载入 _Assert(pWnd); hWnd = GetWindow(m_hWnd, GW_CHILD); for (hWnd = GetWindow(hWnd, GW_HWNDFIRST); hWnd; hWnd = GetWindow(hWnd, GW_HWNDNEXT)) { // 如果文件已载入 GetWindowText(hWnd, tzText, MAX_PATH); if (lstrcmpi(tzText, pWnd->m_tzFileName) == 0) { CChildWnd *p = GetChildWnd(hWnd); if (p) { // 如果格式相同 if (*pWnd == *p) { delete pWnd; SendMessage(m_hWnd, WM_MDIACTIVATE, (WPARAM) hWnd, 0); return TRUE; } } // 关闭已打开的文件,然后重新用新的格式创建窗口 SendMessage(m_hWnd, WM_MDIDESTROY, (WPARAM) hWnd, 0); break; } } // 创建子窗口 if (pWnd->Create()) { OnChildOpenClose(TRUE); return TRUE; } delete pWnd; return FALSE; }
LRESULT CGuiMiniFrame::OnNcHitTest(CPoint point) { // TODO: Add your message handler code here and/or call default CRect rcWindow; //no se convierte las coordenadas de pantalla porque el punto //entregado por esta función esta dado en el mismo sentido. GetWindowRect(rcWindow); int it=0; CRect rcT=m_rcCloseBtn; ClientToScreen(rcT); CPoint pt=point; pt.y+=23; pt.x+=5; if (rcT.PtInRect(pt)) return HTCLOSE; CGuiControlBar* pBar=(CGuiControlBar* )GetChildWnd(); if (pBar) if ( IsGuiControlBar == TRUE && pBar->IsAutoHide()) return -1; return CMiniDockFrameWnd::OnNcHitTest(point); }
void CGuiMiniFrame::OnNcPaint() { CGuiControlBar* pBar=(CGuiControlBar* )GetChildWnd(); if (!pBar) return; if (IsGuiControlBar==TRUE && !pBar->IsAutoHide()) { CMiniDockFrameWnd::OnNcPaint(); return; } //if (!pBar->GetComplete()) return; CRect rcWindow; CRect rcClient; CWindowDC dc(this); CDC m_dc; //contexto de dispositivo en memoria CBitmap m_bitmap; CPen Dark(PS_SOLID,1,GuiDrawLayer::GetRGBColorShadow(GuiDrawLayer::m_Style)); //la idea es tomar el area de la ventana y area cliente , luego debemos //igualar el area de coordenadas de ventana al cliente GetWindowRect(&rcWindow); GetClientRect(&rcClient); int nSize=rcClient.right; ScreenToClient(rcWindow); rcClient.OffsetRect(-rcWindow.TopLeft()); rcWindow.OffsetRect(-rcWindow.TopLeft()); m_dc.CreateCompatibleDC(&dc); m_bitmap.CreateCompatibleBitmap(&dc,rcWindow.Width(),rcWindow.Height()); CBitmap *m_OldBitmap=m_dc.SelectObject(&m_bitmap); //aqui debe utilizarse la brocha que define GuiDrawLayer, si no hacemos la siguiente //linea usted vera un horrible color negro, a cambio del dibujo. CBrush cb; COLORREF clrBrush; if(IsGuiControlBar!=TRUE ) clrBrush= GuiDrawLayer::GetRGBColorShadow(GuiDrawLayer::m_Style); else clrBrush=GuiDrawLayer::GetRGBColorFace(GuiDrawLayer::m_Style); cb.CreateSolidBrush(clrBrush); m_dc.FillRect(rcWindow, &cb); if (IsGuiControlBar==TRUE && pBar->IsAutoHide()) { CRect m_rc=rcWindow; if (pBar->GetLastDocking() == CBRS_ALIGN_LEFT) { m_rc.left=m_rc.right-1; m_rc.top+=3; cb.DeleteObject(); cb.CreateSolidBrush(RGB(0,0,0)); } if (pBar->GetLastDocking() == CBRS_ALIGN_RIGHT) { m_rc.right=m_rc.left+1; m_rc.top+=2; cb.DeleteObject(); cb.CreateSolidBrush(GuiDrawLayer::GetRGBColorBTNHigh()); } if (pBar->GetLastDocking() == CBRS_ALIGN_TOP) { m_rc.top=m_rc.bottom-1; cb.DeleteObject(); cb.CreateSolidBrush(RGB(0,0,0)); } m_dc.FillRect(m_rc, &cb); } CRect rcCaption=rcClient; rcCaption.InflateRect(1,1); if(IsGuiControlBar!=TRUE ) dc.Draw3dRect(rcCaption,GuiDrawLayer::GetRGBColorBTNHigh(),GuiDrawLayer::GetRGBColorBTNHigh()); DrawGripper(&m_dc,&rcClient); dc.IntersectClipRect(rcWindow); dc.ExcludeClipRect(rcClient);//asi evitamos el parpadeo //rcWindow.InflateRect(1,1); dc.BitBlt(rcWindow.left,rcWindow.top,rcWindow.Width(),rcWindow.Height(),&m_dc,0,0,SRCCOPY); ReleaseDC(&dc); m_dc.SelectObject(m_OldBitmap); m_bitmap.DeleteObject(); m_dc.DeleteDC(); // SetTimer(1,200,NULL); // TODO: Add your message handler code here // Do not call CMiniDockFrameWnd::OnNcPaint() for painting messages }
void CMainFrame::OnSetFocus(CWnd* pOldWnd) { ::SetFocus(GetChildWnd()); CFrameWnd::OnSetFocus(pOldWnd); }