// /// If the user clicks on the splash screen and the CaptureMouse style is on, this /// closes the splash screen. // void TSplashWindow::EvLButtonDown(uint /*modKeys*/, const TPoint& /*point*/) { if (HasStyle(CaptureMouse)) { if (HasStyle(MakeGauge)) if (GetGauge()->GetValue() < PercentThreshold) return; // !BB CloseWindow(); SendMessage(WM_CLOSE); } }
void CRichEditNcBorder::VerifyThemedBorderState() { BOOL bHadThemedBorder = m_bThemedBorder; m_bThemedBorder = FALSE; // First, check if the control is supposed to have a border if (bHadThemedBorder || HasStyle(WS_BORDER) || HasExStyle(WS_EX_CLIENTEDGE)) { // Check if a theme is presently active if (CThemed().AreControlsThemed()) { // Remove the border style, we don't want the control to draw its own border m_bThemedBorder = TRUE; CWnd::ModifyStyle(GetHwnd(), WS_BORDER, 0, 0); CWnd::ModifyStyleEx(GetHwnd(), WS_EX_CLIENTEDGE, 0, 0); } else // restore the border CWnd::ModifyStyleEx(GetHwnd(), 0, WS_EX_CLIENTEDGE, 0); } // Recalculate the NC area and repaint the window SetWindowPos(GetHwnd(), NULL, NULL, NULL, NULL, NULL, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); RedrawWindow(GetHwnd(), NULL, NULL, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME); }
void CRichEditNcBorder::NcDrawBorder() { Default(); if (m_bThemedBorder) { CThemed th(GetCWnd(), WC_EDIT); CWindowDC dc(GetCWnd()); CRect rBorder, rClient; GetWindowRect(rBorder); th.GetThemeBackgroundContentRect(&dc, EP_EDITTEXT, ETS_NORMAL, rBorder, rClient); // convert to window coordinates rClient.OffsetRect(-rBorder.left, -rBorder.top); rBorder.OffsetRect(-rBorder.left, -rBorder.top); dc.ExcludeClipRect(rClient); // determine the current border state int nState; if (!IsWindowEnabled()) nState = ETS_DISABLED; else if (HasStyle(ES_READONLY) || SendMessage(EM_GETOPTIONS, NULL, NULL) & ECO_READONLY) nState = ETS_READONLY; else nState = ETS_NORMAL; th.DrawBackground(&dc, EP_EDITTEXT, nState, rBorder); } }
sf::Vector2f Window::CalculateRequisition() { float visual_border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) ); float gap( Context::Get().GetEngine().GetProperty<float>( "Gap", shared_from_this() ) ); sf::Vector2f requisition( 2 * visual_border_width + 2 * gap, 2 * visual_border_width + 2 * gap ); if( HasStyle( TITLEBAR ) ) { unsigned int title_font_size( Context::Get().GetEngine().GetProperty<unsigned int>( "FontSize", shared_from_this() ) ); const sf::Font& title_font( *Context::Get().GetEngine().GetResourceManager().GetFont( Context::Get().GetEngine().GetProperty<std::string>( "FontName", shared_from_this() ) ) ); float title_height( Context::Get().GetEngine().GetFontLineHeight( title_font, title_font_size ) + 2 * Context::Get().GetEngine().GetProperty<float>( "TitlePadding", shared_from_this() ) ); requisition.y += title_height; } if( GetChild() ) { requisition += GetChild()->GetRequisition(); } else { requisition.x = std::max( 50.f, requisition.x ); requisition.y = std::max( 50.f, requisition.y * 2.f ); } return requisition; }
// /// Changes the text within the static control. If the splash screen does not have a /// static control, this doesn't do anything. // void TSplashWindow::SetText(LPCTSTR text) { if (HasStyle(MakeStatic)) if (GetStatic() && GetStatic()->IsWindow()) { GetStatic()->SetText(text); GetApplication()->PumpWaitingMessages(); } }
void Window::HandleMouseButtonEvent( sf::Mouse::Button button, bool press, int x, int y ) { if( button != sf::Mouse::Left ) { return; } if( !press ) { m_dragging = false; m_resizing = false; return; } unsigned int title_font_size( Context::Get().GetEngine().GetProperty<unsigned int>( "FontSize", shared_from_this() ) ); const sf::Font& title_font( *Context::Get().GetEngine().GetResourceManager().GetFont( Context::Get().GetEngine().GetProperty<std::string>( "FontName", shared_from_this() ) ) ); float title_height( Context::Get().GetEngine().GetFontLineHeight( title_font, title_font_size ) + 2 * Context::Get().GetEngine().GetProperty<float>( "TitlePadding", shared_from_this() ) ); // Check for mouse being inside the title area. sf::FloatRect area( GetAllocation().left, GetAllocation().top, GetAllocation().width, title_height ); if( area.contains( static_cast<float>( x ), static_cast<float>( y ) ) ) { if( HasStyle( TITLEBAR ) && !m_dragging ) { m_dragging = true; m_resizing = false; m_drag_offset = sf::Vector2f( static_cast<float>( x ) - GetAllocation().left, static_cast<float>( y ) - GetAllocation().top ); } } else { float handle_size( Context::Get().GetEngine().GetProperty<float>( "HandleSize", shared_from_this() ) ); area.left = GetAllocation().left + GetAllocation().width - handle_size; area.top = GetAllocation().top + GetAllocation().height - handle_size; area.width = handle_size; area.height = handle_size; if( area.contains( static_cast<float>( x ), static_cast<float>( y ) ) ) { m_dragging = false; m_resizing = true; m_drag_offset = sf::Vector2f( handle_size - static_cast<float>( x ) + GetAllocation().left + GetAllocation().width - handle_size, handle_size - static_cast<float>( y ) + GetAllocation().top + GetAllocation().height - handle_size ); } } }
LRESULT CTDCTaskListCtrl::OnListGetDispInfo(NMLVDISPINFO* pLVDI) { if (pLVDI->hdr.hwndFrom == m_lcTasks) { if (pLVDI->item.mask & LVIF_TEXT) // for tooltips { DWORD dwTaskID = pLVDI->item.lParam; const TODOITEM* pTDI = m_data.GetTask(dwTaskID); ASSERT(pTDI); pLVDI->item.pszText = (LPTSTR)(LPCTSTR)pTDI->sTitle; } if (pLVDI->item.mask & LVIF_IMAGE) { DWORD dwTaskID = pLVDI->item.lParam; const TODOITEM* pTDI = NULL; const TODOSTRUCTURE* pTDS = NULL; if (m_data.GetTask(dwTaskID, pTDI, pTDS)) { // user icon if (!IsColumnShowing(TDCC_ICON)) { int nImage = -1; if (!pTDI->sIcon.IsEmpty()) { nImage = m_ilTaskIcons.GetImageIndex(pTDI->sIcon); } else if (HasStyle(TDCS_SHOWPARENTSASFOLDERS) && pTDS->HasSubTasks()) { nImage = 0; } pLVDI->item.iImage = nImage; } // checkbox icon if (!IsColumnShowing(TDCC_DONE)) { pLVDI->item.mask |= LVIF_STATE; pLVDI->item.stateMask = LVIS_STATEIMAGEMASK; pLVDI->item.state = (pTDI->IsDone() ? LCHC_CHECKED : LCHC_UNCHECKED); } } } } return 0L; }
sf::FloatRect Window::GetClientRect() const { sf::FloatRect clientrect( 0, 0, GetAllocation().Width, GetAllocation().Height ); float title_height( HasStyle( Titlebar ) ? Context::Get().GetEngine().GetProperty<float>( "TitleHeight", shared_from_this() ) : 0.f ); float border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) ); clientrect.Left += border_width + GetBorderWidth(); clientrect.Top += title_height + border_width + GetBorderWidth(); clientrect.Width -= 2 * border_width + 2 * GetBorderWidth(); clientrect.Height -= title_height + 2 * border_width + 2 * GetBorderWidth(); return clientrect; }
// /// Handler for the timer event. Closes the window. // void TSplashWindow::EvTimer(uint /*timerId*/) { if (HasStyle(MakeGauge)) { if (GetGauge()->GetValue() < PercentThreshold) { // If less than 90% and has a gauge, immediately return // return; } } // !BB CloseWindow(); SendMessage(WM_CLOSE); }
void Window::HandleMouseButtonEvent( sf::Mouse::Button button, bool press, int x, int y ) { if( button != sf::Mouse::Left ) { return; } if( !press ) { m_dragging = false; m_resizing = false; return; } // Check for mouse being inside the title area. sf::FloatRect area( GetAllocation().Left, GetAllocation().Top, GetAllocation().Width, Context::Get().GetEngine().GetProperty<float>( "TitleHeight", shared_from_this() ) ); if( area.Contains( static_cast<float>( x ), static_cast<float>( y ) ) ) { if( HasStyle( Titlebar ) && !m_dragging ) { m_dragging = true; m_resizing = false; m_drag_offset = sf::Vector2f( static_cast<float>( x ) - GetAllocation().Left, static_cast<float>( y ) - GetAllocation().Top ); } } else { float handle_size( Context::Get().GetEngine().GetProperty<float>( "HandleSize", shared_from_this() ) ); area.Left = GetAllocation().Left + GetAllocation().Width - handle_size; area.Top = GetAllocation().Top + GetAllocation().Height - handle_size; area.Width = handle_size; area.Height = handle_size; if( area.Contains( static_cast<float>( x ), static_cast<float>( y ) ) ) { m_dragging = false; m_resizing = true; m_drag_offset = sf::Vector2f( handle_size - static_cast<float>( x ) + GetAllocation().Left + GetAllocation().Width - handle_size, handle_size - static_cast<float>( y ) + GetAllocation().Top + GetAllocation().Height - handle_size ); } } }
void BitmapComboxWrapper::ToXRC(wxString& text, XRC_TYPE type) const { wxString options = PropertyString(PROP_CB_CHOICES); text << XRCPrefix() << XRCStyle() << XRCSize() << XRCCommonAttributes(); BmpTextVec_t arr = BmpTextSelectorDlg::FromString(options); for(size_t i = 0; i < arr.size(); ++i) { text << "<object class=\"ownerdrawnitem\">"; text << "<text>" << wxCrafter::CDATA(arr.at(i).second) << "</text>"; text << XRCBitmap("bitmap", arr.at(i).first); text << "</object>"; } if(!HasStyle(wxCB_READONLY) && !PropertyString(PROP_HINT).empty()) { // set hint for non-readonly combobox text << "<hint>" << wxCrafter::CDATA(PropertyString(PROP_HINT)) << "</hint>"; } text << XRCSelection() << XRCSuffix(); }
// /// Sets the percentage done for the gauge control. If the splash screen does not /// have a gauge control, this doesn't do anything. // void TSplashWindow::SetPercentDone(int percent) { if (HasStyle(MakeGauge) && IsWindow()) { if (GetGauge()) GetGauge()->SetValue(percent); if (percent > PercentThreshold) { // Set up the timer // if (GetTimeOut() != 0) SetTimer(TimerId, GetTimeOut()); } // and last if (GetGauge()) GetApplication()->PumpWaitingMessages(); } }
sf::Vector2f Window::GetRequisitionImpl() const { sf::Vector2f requisition( 2 * GetBorderWidth(), 2 * GetBorderWidth() ); if( HasStyle( Titlebar ) ) { float visual_border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) ); float title_height( Context::Get().GetEngine().GetProperty<float>( "TitleHeight", shared_from_this() ) ); requisition.x += visual_border_width; requisition.y += visual_border_width + title_height; } if( GetChild() ) { requisition += GetChild()->GetRequisition(); } else { requisition.x = std::max( 50.f, requisition.x ); requisition.y = std::max( 50.f, requisition.y * 2.f ); } return requisition; }
sf::FloatRect Window::GetClientRect() const { sf::FloatRect clientrect( 0, 0, GetAllocation().width, GetAllocation().height ); float border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) ); float gap( Context::Get().GetEngine().GetProperty<float>( "Gap", shared_from_this() ) ); clientrect.left += border_width + gap; clientrect.top += border_width + gap; clientrect.width -= 2 * border_width + 2 * gap; clientrect.height -= 2 * border_width + 2 * gap; if( HasStyle( TITLEBAR ) ) { unsigned int title_font_size( Context::Get().GetEngine().GetProperty<unsigned int>( "FontSize", shared_from_this() ) ); const sf::Font& title_font( *Context::Get().GetEngine().GetResourceManager().GetFont( Context::Get().GetEngine().GetProperty<std::string>( "FontName", shared_from_this() ) ) ); float title_height( Context::Get().GetEngine().GetFontLineHeight( title_font, title_font_size ) + 2 * Context::Get().GetEngine().GetProperty<float>( "TitlePadding", shared_from_this() ) ); clientrect.top += title_height; clientrect.height -= title_height; } return clientrect; }
LRESULT CTDCTaskListCtrl::ScWindowProc(HWND hRealWnd, UINT msg, WPARAM wp, LPARAM lp) { if (!IsResyncEnabled()) return CTDCTaskCtrlBase::ScWindowProc(hRealWnd, msg, wp, lp); switch (msg) { case WM_NOTIFY: { LPNMHDR pNMHDR = (LPNMHDR)lp; HWND hwnd = pNMHDR->hwndFrom; switch (pNMHDR->code) { case HDN_ITEMCLICK: if (hwnd == m_hdrTasks) { NMHEADER* pNMH = (NMHEADER*)pNMHDR; // forward on to our parent if ((pNMH->iButton == 0) && m_hdrColumns.IsItemVisible(pNMH->iItem)) { HDITEM hdi = { HDI_LPARAM, 0 }; pNMH->pitem = &hdi; pNMH->pitem->lParam = TDCC_CLIENT; RepackageAndSendToParent(msg, wp, lp); } return 0L; } break; case TTN_NEEDTEXT: { // this has a nasty habit of redrawing the current item label // even when a tooltip is not displayed which caused any // trailing comment text to disappear, so we always invalidate // the entire item if it has comments CPoint pt(GetMessagePos()); m_lcTasks.ScreenToClient(&pt); int nItem = m_lcTasks.HitTest(pt); if (nItem != -1) { const TODOITEM* pTDI = GetTask(nItem); ASSERT(pTDI); if (!pTDI->sComments.IsEmpty()) { CRect rItem; VERIFY (m_lcTasks.GetItemRect(nItem, rItem, LVIR_BOUNDS)); m_lcTasks.InvalidateRect(rItem, FALSE); } } } break; } } break; case WM_LBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_RBUTTONDOWN: if (hRealWnd == m_lcTasks) { // let parent handle any focus changes first m_lcTasks.SetFocus(); // don't let the selection to be set to -1 // when clicking below the last item if (m_lcTasks.HitTest(lp) == -1) { CPoint pt(lp); ::ClientToScreen(hRealWnd, &pt); if (!::DragDetect(m_lcColumns, pt)) // we don't want to disable drag selecting { TRACE(_T("Ate Listview ButtonDown\n")); return 0; // eat it } } } break; case WM_LBUTTONDOWN: if (hRealWnd == m_lcTasks) { // let parent handle any focus changes first m_lcTasks.SetFocus(); UINT nFlags = 0; int nHit = m_lcTasks.HitTest(lp, &nFlags); if (nHit != -1) { if (Misc::ModKeysArePressed(0)) { // if the item is not selected we must first deal // with that before processing the click BOOL bHitSelected = IsListItemSelected(m_lcTasks, nHit); BOOL bSelChange = FALSE; if (!bHitSelected) bSelChange = SelectItem(nHit); // If multiple items are selected and no edit took place // Clear the selection to just the hit item if (!HandleClientColumnClick(lp, FALSE) && (GetSelectedCount() > 1)) bSelChange |= SelectItem(nHit); // Eat the msg to prevent a label edit if we changed the selection if (bSelChange) { NotifyParentSelChange(SC_BYMOUSE); return 0L; } } else if (Misc::IsKeyPressed(VK_SHIFT)) // bulk-selection { int nAnchor = m_lcTasks.GetSelectionMark(); m_lcColumns.SetSelectionMark(nAnchor); if (!Misc::IsKeyPressed(VK_CONTROL)) { DeselectAll(); } // prevent resyncing CTLSHoldResync hr(*this); // Add new items to tree and list int nHit = m_lcTasks.HitTest(lp); int nFrom = (nAnchor < nHit) ? nAnchor : nHit; int nTo = (nAnchor < nHit) ? nHit : nAnchor; for (int nItem = nFrom; nItem <= nTo; nItem++) { m_lcTasks.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); m_lcColumns.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); } NotifyParentSelChange(SC_BYMOUSE); return 0; // eat it } else if (CTDCTaskCtrlBase::HandleListLBtnDown(m_lcTasks, lp)) { return 0L; } } else if (CTDCTaskCtrlBase::HandleListLBtnDown(m_lcTasks, lp)) { return 0L; } } else { ASSERT(hRealWnd == m_lcColumns); // Selecting or de-selecting a lot of items can be slow // because OnListSelectionChange is called once for each. // Base class handles simple click de-selection so we // handle bulk selection here if (Misc::IsKeyPressed(VK_SHIFT)) // bulk-selection { int nAnchor = m_lcColumns.GetSelectionMark(); m_lcTasks.SetSelectionMark(nAnchor); if (!Misc::IsKeyPressed(VK_CONTROL)) { DeselectAll(); } // prevent resyncing CTLSHoldResync hr(*this); // Add new items to tree and list TDC_COLUMN nColID = TDCC_NONE; int nHit = HitTestColumnsItem(lp, TRUE, nColID); int nFrom = (nAnchor < nHit) ? nAnchor : nHit; int nTo = (nAnchor < nHit) ? nHit : nAnchor; for (int nItem = nFrom; nItem <= nTo; nItem++) { m_lcTasks.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); m_lcColumns.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); } NotifyParentSelChange(SC_BYMOUSE); return 0; // eat it } if (CTDCTaskCtrlBase::HandleListLBtnDown(m_lcColumns, lp)) return 0L; } break; case WM_KEYDOWN: if (Misc::IsKeyPressed(VK_SHIFT)) // bulk-selection { int nAnchor = ::SendMessage(hRealWnd, LVM_GETSELECTIONMARK, 0, 0); ::SendMessage(OtherWnd(hRealWnd), LVM_SETSELECTIONMARK, 0, nAnchor); int nFrom = -1, nTo = -1; switch (wp) { case VK_NEXT: nFrom = nAnchor; nTo = (m_lcTasks.GetTopIndex() + m_lcTasks.GetCountPerPage()); break; case VK_PRIOR: nFrom = m_lcTasks.GetTopIndex(); nTo = nAnchor; break; case VK_HOME: nFrom = 0; nTo = nAnchor; break; case VK_END: nFrom = nAnchor; nTo = (m_lcTasks.GetItemCount() - 1); break; } if ((nFrom != -1) && (nTo != -1)) { if (!Misc::IsKeyPressed(VK_CONTROL)) DeselectAll(); CTLSHoldResync hr(*this); for (int nItem = nFrom; nItem <= nTo; nItem++) { m_lcTasks.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); m_lcColumns.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); } NotifyParentSelChange(SC_BYKEYBOARD); } } break; case WM_KEYUP: { switch (wp) { case VK_NEXT: case VK_DOWN: case VK_UP: case VK_PRIOR: case VK_HOME: case VK_END: if (hRealWnd == m_lcTasks) NotifyParentSelChange(SC_BYKEYBOARD); break; case VK_LEFT: case VK_RIGHT: if (hRealWnd == m_lcTasks) { // see WM_MOUSEWHEEL comment below m_lcTasks.Invalidate(FALSE); } break; } } break; case WM_MOUSEWHEEL: // if horizontal scrolling with right-side tree we have to redraw // the full client width because Window's own optimised // scrolling creates artifacts otherwise. if (!HasVScrollBar() && HasHScrollBar(hRealWnd) && !HasStyle(TDCS_RIGHTSIDECOLUMNS)) { m_lcTasks.Invalidate(FALSE); } break; case WM_TIMER: // make sure the mouse is still over the item label because // with LVS_EX_FULLROWSELECT turned on the whole if (wp == TIMER_EDITLABEL) { if (CTreeListSyncer::HasStyle(hRealWnd, LVS_EDITLABELS, FALSE)) { const TODOITEM* pTDI = NULL; const TODOSTRUCTURE* pTDS = NULL; int nItem = GetSelectedItem(); DWORD dwTaskID = GetTaskID(nItem); if (m_data.GetTask(dwTaskID, pTDI, pTDS)) { CClientDC dc(&m_lcTasks); CFont* pOldFont = dc.SelectObject(GetTaskFont(pTDI, pTDS, FALSE)); CRect rLabel; if (GetItemTitleRect(nItem, TDCTR_LABEL, rLabel, &dc, pTDI->sTitle)) { CPoint pt(GetMessagePos()); m_lcTasks.ScreenToClient(&pt); if (rLabel.PtInRect(pt)) NotifyParentOfColumnEditClick(TDCC_CLIENT, GetSelectedTaskID()); } // cleanup dc.SelectObject(pOldFont); } } ::KillTimer(hRealWnd, wp); return 0L; // eat } break; } return CTDCTaskCtrlBase::ScWindowProc(hRealWnd, msg, wp, lp); }
void ListBox::SetWindow(HWND hwnd) { Control::SetWindow(hwnd); LONG style = GetWindowLong(m_hwnd, GWL_STYLE); m_bMultiSelect = HasStyle(LBS_MULTIPLESEL) || HasStyle(LBS_EXTENDEDSEL); }
bool CSkinDialog::LoadSkin(const char * szSkinPath /* = NULL */, const char * szControlName) { if(szSkinPath==NULL) { CImgSkin::Unload(); return true; } if(!CImgSkin::Load(szSkinPath, szControlName)) return false; m_dwStyle = GetStyle(); // 去掉标题栏,边框,只留客户区 // ModifyStyle(WS_CAPTION|WS_THICKFRAME, 0); ModifyStyle(WS_CAPTION, 0); CRect rcWindow; CRect rcClient; CRect rc; GetWindowRect(&rcWindow); GetClientRect(&m_rcClient); // 圆角 SetWindowRgn(CreateRoundRectRgn(0, 0, rcWindow.Width(), rcWindow.Height(), m_mapRect["RoundCorner"].Width, m_mapRect["RoundCorner"].Height), TRUE); if(!HasStyle(WS_CHILD)) { // 调整窗口自己 rcWindow.left -= m_mapRect["BorderLeft"].Width; rcWindow.right += m_mapRect["BorderRight"].Width; rcWindow.top -= m_mapRect["TitleLeft"].Height; rcWindow.bottom += m_mapRect["BorderBot"].Height; CWnd * pParent = GetParent(); if(pParent==NULL) pParent = GetDesktopWindow(); //pParent->ScreenToClient(&rcWindow); //MoveWindow(rcWindow, FALSE); GetClientRect(&rcClient); POINT ptOffset = {0}; CRect rcChild; CWnd* pWndChild; // 菜单 CMenu * pMenu = GetMenu(); if(pMenu) { m_wndMenuBar.CreateToolBar(WS_VISIBLE|WS_CHILD|CBRS_TOOLTIPS, this, ID_MENU_BAR); m_wndMenuBar.LoadMenu(pMenu); m_wndMenuBar.SetFlags(xtpFlagStretched); SetMenu(NULL); CXTPPaintManager::SetTheme(xtpThemeOffice2003); m_wndMenuBar.LoadSkin(szSkinPath); RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposDefault, NULL, &rcClient); AddAnchor(m_wndMenuBar, ANCHOR_TOPLEFT|ANCHOR_TOPRIGHT); m_wndMenuBar.GetWindowRect(&rc); ptOffset.y += rc.Height(); pWndChild = GetWindow(GW_CHILD); while (pWndChild) { if(pWndChild!=&m_wndMenuBar) { pWndChild->GetWindowRect(rcChild); rcChild.OffsetRect(ptOffset); ScreenToClient(&rcChild); pWndChild->MoveWindow(rcChild, FALSE); } pWndChild = pWndChild->GetNextWindow(); } } // 调整子窗口 /* ptOffset.x = m_mapRect["BorderLeft"].Width; ptOffset.y = m_mapRect["TitleLeft"].Height; pWndChild = GetWindow(GW_CHILD); while (pWndChild) { pWndChild->GetWindowRect(rcChild); rcChild.OffsetRect(ptOffset); ScreenToClient(&rcChild); pWndChild->MoveWindow(rcChild, FALSE); pWndChild = pWndChild->GetNextWindow(); } m_rcClient.left = ptOffset.x; m_rcClient.right = m_rcClient.left+rcClient.Width(); m_rcClient.top += ptOffset.y; m_rcClient.bottom = m_rcClient.top+rcClient.Height(); */ } return true; }
void CSkinDialog::OnNcPaint() { // TODO: Add your message handler code here if(!CImgSkin::IsLoaded()) { CXTPDialog::OnNcPaint(); return; } if(HasStyle(WS_CHILD)) { return; } /* RECT ClientRect; GetClientRect(&ClientRect); OffsetRect(&ClientRect, 100, 100); ExcludeClipRect(GetWindowDC()->GetSafeHdc(), ClientRect.left, ClientRect.top, ClientRect.right, ClientRect.bottom); */ CRect rcWindow; GetWindowRect(&rcWindow); Bitmap bmpBuf(rcWindow.Width(), rcWindow.Height()); Graphics graphics(&bmpBuf); Graphics g(GetWindowDC()->GetSafeHdc()); Rect rc, rc1; // Title Left rc = m_bActive?m_mapRect["TitleLeftActive"]:m_mapRect["TitleLeft"]; rc1.X = 0; rc1.Y = 0; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Title Center rc = m_bActive?m_mapRect["TitleCenterActive"]:m_mapRect["TitleCenter"]; rc1.X = m_mapRect["TitleLeftActive"].Width; rc1.Y = 0; rc1.Width = rcWindow.Width()-m_mapRect["TitleLeftActive"].Width-m_mapRect["TitleRightActive"].Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Title Right rc = m_bActive?m_mapRect["TitleRightActive"]:m_mapRect["TitleRight"]; rc1.X = rc1.GetRight(); rc1.Y = 0; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Border Left rc = m_bActive?m_mapRect["BorderLeftActive"]:m_mapRect["BorderLeft"]; rc1.X = 0; rc1.Y = m_mapRect["TitleLeftActive"].Height; rc1.Width = rc.Width; rc1.Height = rcWindow.Height()-m_mapRect["TitleLeftActive"].Height-m_mapRect["BorderBotActive"].Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Border Bottom rc = m_bActive?m_mapRect["BorderBotActive"]:m_mapRect["BorderBot"]; rc1.X = 0; rc1.Y = rcWindow.Height()-rc.Height-1; rc1.Width = rcWindow.Width(); rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Border Right rc = m_bActive?m_mapRect["BorderRightActive"]:m_mapRect["BorderRight"]; rc1.X = rcWindow.Width()-rc.Width-1; rc1.Y = m_mapRect["TitleLeftActive"].Height; rc1.Width = rc.Width; rc1.Height = rcWindow.Height()-m_mapRect["TitleLeftActive"].Height-m_mapRect["BorderBotActive"].Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Close Button rc = m_nButtonDown==HT_CLOSE?m_mapRect["NcBtnCloseDown"]:m_mapRect["NcBtnClose"]; rc1.X = rcWindow.Width()-m_mapRect["NcBtnClosePos"].X; rc1.Y = m_mapRect["NcBtnClosePos"].Y; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Max Button if(GetStyle()&WS_MAXIMIZEBOX) { rc = IsZoomed()?(m_nButtonDown==HT_MAX?m_mapRect["NcBtnResDown"]:m_mapRect["NcBtnRes"]):(m_nButtonDown==HT_MAX?m_mapRect["NcBtnMaxDown"]:m_mapRect["NcBtnMax"]); rc1.X = rcWindow.Width()-m_mapRect["NcBtnMaxPos"].X; rc1.Y = m_mapRect["NcBtnMaxPos"].Y; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); } // Min Button if(GetStyle()&WS_MINIMIZEBOX) { rc = m_nButtonDown==HT_MIN?m_mapRect["NcBtnMinDown"]:m_mapRect["NcBtnMin"]; rc1.X = rcWindow.Width()-m_mapRect["NcBtnMinPos"].X; rc1.Y = m_mapRect["NcBtnMinPos"].Y; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); } Font myFont(L"宋体", 9); Color col(255,0,0,0); col.SetFromCOLORREF(m_mapColor["Caption"]); SolidBrush blackBrush(col); StringFormat format; format.SetAlignment(StringAlignmentNear); RectF layoutRect(::GetSystemMetrics(SM_CYICON)+m_mapRect["TitleTextStart"].X, m_mapRect["TitleTextStart"].Y, rcWindow.Width(), rcWindow.Height()); WCHAR string[MAX_PATH] = {0}; CString str; GetWindowText(str); MultiByteToWideChar( CP_ACP, 0, str, -1, string, MAX_PATH) ; graphics.DrawString(string, -1, &myFont, layoutRect, &format, &blackBrush); g.DrawImage(&bmpBuf, 0, 0); // Do not call CXTPDialog::OnNcPaint() for painting messages }
LRESULT CTDCTaskListCtrl::OnListCustomDraw(NMLVCUSTOMDRAW* pLVCD) { HWND hwndList = pLVCD->nmcd.hdr.hwndFrom; int nItem = (int)pLVCD->nmcd.dwItemSpec; DWORD dwTaskID = pLVCD->nmcd.lItemlParam; if (hwndList == m_lcColumns) { // columns handled by base class return CTDCTaskCtrlBase::OnListCustomDraw(pLVCD); } switch (pLVCD->nmcd.dwDrawStage) { case CDDS_PREPAINT: return CDRF_NOTIFYITEMDRAW; case CDDS_ITEMPREPAINT: { CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc); BOOL bAlternate = (IsColumnLineOdd(nItem) && HasColor(m_crAltLine)); COLORREF crBack = (bAlternate ? m_crAltLine : GetSysColor(COLOR_WINDOW)); if (HasStyle(TDCS_TASKCOLORISBACKGROUND)) { GetTaskTextColors(dwTaskID, pLVCD->clrText, pLVCD->clrTextBk); if (pLVCD->clrTextBk != CLR_NONE) crBack = pLVCD->clrTextBk; } pLVCD->clrTextBk = pLVCD->clrText = crBack; if (!OsIsXP()) { GraphicsMisc::FillItemRect(pDC, &pLVCD->nmcd.rc, crBack, m_lcTasks); ListView_SetBkColor(m_lcTasks, crBack); } return (CDRF_NOTIFYPOSTPAINT | CDRF_NEWFONT); // always } break; case CDDS_ITEMPOSTPAINT: { const TODOITEM* pTDI = NULL; const TODOSTRUCTURE* pTDS = NULL; DWORD dwTaskID = GetTaskID(nItem), dwTrueID(dwTaskID); if (m_data.GetTask(dwTrueID, pTDI, pTDS)) { CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc); CFont* pOldFont = pDC->SelectObject(GetTaskFont(pTDI, pTDS, FALSE)); GM_ITEMSTATE nState = GetListItemState(nItem); BOOL bSelected = (nState != GMIS_NONE); BOOL bAlternate = (IsColumnLineOdd(nItem) && HasColor(m_crAltLine)); COLORREF crBack, crText; VERIFY(GetTaskTextColors(pTDI, pTDS, crText, crBack, (dwTaskID != dwTrueID), bSelected)); // draw background CRect rRow(pLVCD->nmcd.rc); // extra for XP if (OsIsXP()) m_lcTasks.GetItemRect(nItem, rRow, LVIR_BOUNDS); CRect rItem; GetItemTitleRect(nItem, TDCTR_LABEL, rItem, pDC, pTDI->sTitle); DrawTasksRowBackground(pDC, rRow, rItem, nState, bAlternate, crBack); // draw text DrawColumnText(pDC, pTDI->sTitle, rItem, DT_LEFT, crText, TRUE); rItem.right = (rItem.left + pDC->GetTextExtent(pTDI->sTitle).cx + LV_COLPADDING); // cleanup pDC->SelectObject(pOldFont); // render comment text DrawCommentsText(pDC, rRow, rItem, pTDI, pTDS); } // restore default back colour ListView_SetBkColor(m_lcTasks, GetSysColor(COLOR_WINDOW)); return CDRF_SKIPDEFAULT; // always } break; } return CDRF_DODEFAULT; }