CSize vmsUiLinkWindow::getSize() const { CDC *pdc = getDC (); if (pdc == NULL) { return CSize (0,0); } CFont *pfntOld = pdc->SelectObject (m_pfntLnk ? m_pfntLnk : vmsUiFonts::Tahoma_11underline ()); CSize s; if (m_uDrawTextFormat == 0) { s = pdc->GetTextExtent (m_tstrText.c_str ()); } else { CRect rc = m_rcPos; pdc->DrawText (m_tstrText.c_str (), &rc, DT_CALCRECT | m_uDrawTextFormat); s = CSize (rc.Width (), rc.Height ()); } pdc->SelectObject (pfntOld); releaseDC (pdc); return s; }
void paintEvent(QPaintEvent *event) { HDC hdc = getDC(); SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW)); Rectangle(hdc, 0, 0, width(), height()); RECT rect = {0, 0, width(), height() }; DrawText(hdc, "Hello World!", 12, &rect, DT_SINGLELINE | DT_VCENTER | DT_CENTER); releaseDC(hdc); }
void GameSprite::DrawTo(wxDC* dc, SpriteSize sz, int start_x, int start_y, int width, int height) { if(width == -1) width = sz == SPRITE_SIZE_32x32 ? 32 : 16; if(height == -1) height= sz == SPRITE_SIZE_32x32 ? 32 : 16; wxDC* sdc = getDC(sz); if(sdc) { dc->Blit(start_x, start_y, width, height, sdc, 0, 0, wxCOPY, true); } else { const wxBrush& b = dc->GetBrush(); dc->SetBrush(*wxRED_BRUSH); dc->DrawRectangle(start_x, start_y, width, height); dc->SetBrush(b); } }
bool StickyNoteEditDialog::winEvent(MSG * msg, long * result) { POINT p = {0}; bool evtResult = QDialog::winEvent(msg, result); if (msg->message == WM_NCHITTEST) { GetCursorPos(&p); p.x -= pos().x(); p.y -= pos().y(); QWidget * widget = childAt(p.x, p.y); if (!widget) { // if we are not clicking over a child widget, fool windows into // thinking we are clicking a caption bar (to allow it to move // as if we were) if (msg->hwnd == WindowFromDC(getDC())) { *result = HTCAPTION; return true; } } } return evtResult; }