LOCAL void fb_setcliprect(WINDISPLAY *mod, struct TVRequest *req) { WINWINDOW *win = req->tvr_Op.ClipRect.Window; RECT *cr = &win->fbv_ClipRect; HRGN rgn; cr->left = req->tvr_Op.ClipRect.Rect[0]; cr->top = req->tvr_Op.ClipRect.Rect[1]; cr->right = cr->left + req->tvr_Op.ClipRect.Rect[2]; cr->bottom = cr->top + req->tvr_Op.ClipRect.Rect[3]; rgn = CreateRectRgnIndirect(cr); SelectClipRgn(win->fbv_HDC, rgn); DeleteObject(rgn); }
/// <param name="list">list of points</param> /// <param name="count">number of points</param> /// <param name="width">pen width for drawing line</param> /// <param name="color">pen color</param> void Printer::DrawPolyline(const rect_t &rect, const rect_t &box, point_t list[], size_t count, meter_t width, color_t color) { CPen pen; std::vector<POINT> pts; POINT pt = {0}; for (size_t i = 0; i < count; i++) { pt.x = list[i].x + rect.x - box.x; pt.y = list[i].y + rect.y - box.y; pts.push_back(pt); } pen.CreatePen(PS_SOLID, width, color); HPEN hSave = SelectPen(pen); CRgn region; region.CreateRectRgn(rect.x, rect.y, rect.x + rect.wide, rect.y + rect.high); SelectClipRgn(region); Polyline(&pts[0], pts.size()); SelectPen(hSave); SelectClipRgn(NULL); }
static HRGN mi_clip(HDC dc) { HRGN rgn; rgn = CreateRectRgn(g_clip_left + g_xoff - g_xscroll, g_clip_top + g_yoff - g_yscroll, g_clip_right + g_xoff - g_xscroll, g_clip_bottom + g_yoff - g_yscroll); SelectClipRgn(dc, rgn); IntersectClipRect(dc, g_wnd_clip.left + g_xoff, g_wnd_clip.top + g_yoff, g_wnd_clip.right + g_xoff, g_wnd_clip.bottom + g_yoff); return rgn; }
void XCopyArea( Display *display, Drawable src, Drawable dest, GC gc, int src_x, int src_y, unsigned int width, unsigned int height, int dest_x, int dest_y) { HDC srcDC, destDC; TkWinDCState srcState, destState; TkpClipMask *clipPtr = (TkpClipMask*)gc->clip_mask; srcDC = TkWinGetDrawableDC(display, src, &srcState); if (src != dest) { destDC = TkWinGetDrawableDC(display, dest, &destState); } else { destDC = srcDC; } if (clipPtr && clipPtr->type == TKP_CLIP_REGION) { SelectClipRgn(destDC, (HRGN) clipPtr->value.region); OffsetClipRgn(destDC, gc->clip_x_origin, gc->clip_y_origin); } BitBlt(destDC, dest_x, dest_y, (int) width, (int) height, srcDC, src_x, src_y, (DWORD) tkpWinBltModes[gc->function]); SelectClipRgn(destDC, NULL); if (src != dest) { TkWinReleaseDrawableDC(dest, destDC, &destState); } TkWinReleaseDrawableDC(src, srcDC, &srcState); }
void LocationDialog::displayCross(HWND hDlg, double latitude, double longitude) { short xImage, yImage; HWND hMap = GetDlgItem(hDlg, IDC_MAP_PICTURE); HDC hDC = GetDC(hMap); if (hDC == NULL) return; int oRop = SetROP2(hDC, R2_XORPEN); HPEN pen = CreatePen(PS_SOLID, 3, CROSS_COLOR); HPEN oPen = (HPEN)SelectObject(hDC, pen); HRGN hrgn = CreateRectRgn(1, 1, mapWidth, mapHeight - 1); if (hrgn != NULL) { SelectClipRgn(hDC, hrgn); DeleteObject(hrgn); } // calculation of x-coordinate differs in sign from original map, // which uses different convention for longitude. xImage = (int)((-longitude-minLongitude)*mapWidth/mapLongWidth); yImage = (int)((latitude-minLatitude)*mapHeight/mapLatHeight); if (crossVisible) { short xOld, yOld; xOld = (int) ((-crossLongitude-minLongitude)*mapWidth/mapLongWidth); yOld = (int) ((crossLatitude-minLatitude)*mapHeight/mapLatHeight); // erase. MoveToEx(hDC, xOld-CROSS_SIZE, mapHeight-yOld, NULL); LineTo(hDC, xOld+CROSS_SIZE, mapHeight-yOld); MoveToEx(hDC, xOld, mapHeight-yOld-CROSS_SIZE, NULL); LineTo(hDC, xOld,mapHeight-yOld+CROSS_SIZE); } MoveToEx(hDC, xImage-CROSS_SIZE, mapHeight-yImage, NULL); LineTo(hDC, xImage+CROSS_SIZE, mapHeight-yImage); MoveToEx(hDC, xImage, mapHeight-yImage-CROSS_SIZE, NULL); LineTo(hDC, xImage, mapHeight-yImage+CROSS_SIZE); crossVisible = TRUE; crossLatitude = latitude; crossLongitude = longitude; SetROP2(hDC, oRop); SelectObject(hDC, oPen); DeleteObject(pen); ReleaseDC(hMap, hDC); }
void canvas_end(canvas_t *canvas) { int r; r=BitBlt(canvas->localDC, canvas->ps.rcPaint.left,canvas->ps.rcPaint.top,canvas->ps.rcPaint.right,canvas->ps.rcPaint.bottom, canvas->hdcMem, canvas->ps.rcPaint.left,canvas->ps.rcPaint.top, SRCCOPY); SelectClipRgn(canvas->hdcMem,0); if(!r)log_err("ERROR in canvas_end(): failed BitBlt\n"); r=DeleteObject(canvas->clipping); if(!r)log_err("ERROR in canvas_end(): failed DeleteObject\n"); EndPaint(canvas->hwnd,&canvas->ps); }
void DynamicDisplayItem::DrawIconOnly(HDC theDC, bool theSelected, const RECT & theContainer, const Theme * theTheme) { // Step 1. Clip the output so that no text is touched. int aWidth = theTheme->GetMetric(WIDTH_ICONSITE) + theTheme->GetMetric(WIDTH_INDENT_LEFT); IntersectClipRect(theDC, theContainer.left, theContainer.top, aWidth, theContainer.bottom); // Step 2. Redraw a part of the background. DrawBackground(theDC, theSelected, theContainer, theTheme); // Step 3. Draw icon DrawIcon(theDC, theSelected, theContainer, theTheme); // Step 4. Remove clipping SelectClipRgn(theDC, NULL); }
//extern Fl_Ext * fl_ext; void Fl_Gdi::draw(Fl_Widget * w) { Fl_Device *t = fl_current_dev; fl_current_dev = this; Fl::flush(); // cleaning ... HDC o = fl_gc; fl_gc = gc_; SelectClipRgn(fl_gc, 0); fl_push_no_clip(); //i am not sure why, but it is required... w->redraw(); // making dirty w->draw(); fl_pop_clip(); fl_gc = o; fl_current_dev = t; }
void Ctrl::WndUpdate(const Rect& r) { GuiLock __; Ctrl *top = GetTopCtrl(); if(top->IsOpen()) { HWND hwnd = top->GetHWND(); HDC hdc = GetDC(hwnd); HRGN hrgn = CreateRectRgn(0, 0, 0, 0); if(GetUpdateRgn(hwnd, hrgn, FALSE) != NULLREGION) { SelectClipRgn(hdc, hrgn); SystemDraw draw(hdc); bool hcr = focusCtrl && focusCtrl->GetTopCtrl() == top && caretRect.Intersects(r + top->GetRect().TopLeft()); if(hcr) ::HideCaret(hwnd); draw.Clip(r); top->UpdateArea(draw, r); ValidateRect(hwnd, r); SelectClipRgn(hdc, NULL); if(hcr) ::ShowCaret(hwnd); } ReleaseDC(hwnd, hdc); DeleteObject(hrgn); } }
void TextRenderGdi::Lock() { CrashIf(hdcGfxLocked); Region r; Status st = gfx->GetClip(&r); // must call before GetHDC(), which locks gfx CrashIf(st != Ok); HRGN hrgn = r.GetHRGN(gfx); hdcGfxLocked = gfx->GetHDC(); SelectClipRgn(hdcGfxLocked, hrgn); DeleteObject(hrgn); SelectFont(hdcGfxLocked, currFont); ::SetTextColor(hdcGfxLocked, textColor.ToCOLORREF()); ::SetBkColor(hdcGfxLocked, textBgColor.ToCOLORREF()); }
HDC SharedBitmap::DCProvider::getDC(SharedBitmap* bmp, unsigned* key) { if (!bmp || !bmp->ensureHandle()) return 0; HDC hdc = CreateCompatibleDC(0); if (!hdc) return 0; *key = reinterpret_cast<unsigned>(SelectObject(hdc, bmp->getHandle())); RECT rect = { 0, 0, bmp->width(), bmp->height() }; OwnPtr<HRGN> clipRgn = adoptPtr(CreateRectRgnIndirect(&rect)); SelectClipRgn(hdc, clipRgn.get()); return hdc; }
static void GB_Paint( HWND hwnd, HDC hDC, UINT action ) { RECT rc, rcFrame; HBRUSH hbr; HFONT hFont; UINT dtFlags; TEXTMETRICW tm; LONG style = GetWindowLongW( hwnd, GWL_STYLE ); HWND parent; HRGN hrgn; if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); /* GroupBox acts like static control, so it sends CTLCOLORSTATIC */ parent = GetParent(hwnd); if (!parent) parent = hwnd; hbr = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)hwnd); if (!hbr) /* did the app forget to call defwindowproc ? */ hbr = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)hwnd); GetClientRect( hwnd, &rc); rcFrame = rc; hrgn = set_control_clipping( hDC, &rc ); GetTextMetricsW (hDC, &tm); rcFrame.top += (tm.tmHeight / 2) - 1; DrawEdge (hDC, &rcFrame, EDGE_ETCHED, BF_RECT | ((style & BS_FLAT) ? BF_FLAT : 0)); InflateRect(&rc, -7, 1); dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rc); if (dtFlags != (UINT)-1) { /* Because buttons have CS_PARENTDC class style, there is a chance * that label will be drawn out of client rect. * But Windows doesn't clip label's rect, so do I. */ /* There is 1-pixel margin at the left, right, and bottom */ rc.left--; rc.right++; rc.bottom++; FillRect(hDC, &rc, hbr); rc.left++; rc.right--; rc.bottom--; BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rc); } SelectClipRgn( hDC, hrgn ); if (hrgn) DeleteObject( hrgn ); }
static void draw_rect(HWND hWnd, WORD wLine, HRGN clip, HBRUSH hBrush) { HDC hDC = GetDC(hWnd); RECT rect; GetClientRect(hWnd, &rect); rect.top = wLine * wLHeight; rect.bottom = rect.top + wLHeight; SelectObject(hDC, hBrush); if (clip) SelectClipRgn(hDC, clip); PatBlt(hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, PATINVERT); ReleaseDC(hWnd, hDC); }
static void __fastcall Repaint(HWND hWnd,RECT & updata,RECT& upbmp,HDC hdc) { PAINTSTRUCT ps={0}; HDRAWDIB hdd; HBITMAP hbmp; BITMAPINFOHEADER bi={sizeof(bi)}; void* bits=LocalAlloc(LPTR,4096*4096*5); POINTS bmprc; *((DWORD*)(&bmprc))= GetWindowLong(hWnd,FIELD_OFFSET(ShowPicClass,bmRC)); hdd=DrawDibOpen(); if(!hdc) hdc =BeginPaint(hWnd,&ps); hbmp=(HBITMAP)GetWindowLong(hWnd,FIELD_OFFSET(ShowPicClass,hbmp)); BITMAP bm; GetObject(hbmp,sizeof(bm),&bm); bi.biBitCount=32; bi.biWidth = bm.bmWidth; bi.biPlanes = 1; bi.biHeight = bm.bmHeight ; ExcludeClipRect(hdc,updata.left,updata.top,updata.right,updata.bottom); FillRect(hdc,&ps.rcPaint,(HBRUSH)1); SelectClipRgn(hdc,NULL); GetDIBits(hdc,hbmp,0,bi.biHeight,bits,(LPBITMAPINFO)&bi,DIB_RGB_COLORS); DrawDibDraw(hdd,hdc,updata.left,updata.top,updata.right-updata.left,updata.bottom-updata.top, &bi,bits,upbmp.left,upbmp.top,upbmp.right-upbmp.left,upbmp.bottom-upbmp.top,0); LocalFree(bits); DrawDibClose(hdd); if(ps.hdc) EndPaint(hWnd,&ps); }
void updateHandle(Handle handle, const SkMatrix& ctm, const SkIRect& clip_bounds) override { HDC hdc = static_cast<HDC>(handle); XFORM xf; xf.eM11 = ctm[SkMatrix::kMScaleX]; xf.eM21 = ctm[SkMatrix::kMSkewX]; xf.eDx = ctm[SkMatrix::kMTransX]; xf.eM12 = ctm[SkMatrix::kMSkewY]; xf.eM22 = ctm[SkMatrix::kMScaleY]; xf.eDy = ctm[SkMatrix::kMTransY]; SetWorldTransform(hdc, &xf); HRGN hrgn = CreateRectRgnIndirect(&toRECT(clip_bounds)); int result = SelectClipRgn(hdc, hrgn); SkASSERT(result != ERROR); result = DeleteObject(hrgn); SkASSERT(result != 0); }
/*********************************************************************** * CC_PaintCross [internal] */ static void CC_PaintCross( HWND hDlg, int x, int y) { HDC hDC; int w = GetDialogBaseUnits() - 1; int wc = GetDialogBaseUnits() * 3 / 4; HWND hwnd = GetDlgItem(hDlg, 0x2c6); LPCCPRIV lpp = GetPropW( hDlg, szColourDialogProp ); RECT rect; POINT point, p; HPEN hPen; if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */ { GetClientRect(hwnd, &rect); hDC = GetDC(hwnd); SelectClipRgn( hDC, CreateRectRgnIndirect(&rect)); point.x = ((long)rect.right * (long)x) / (long)MAXHORI; point.y = rect.bottom - ((long)rect.bottom * (long)y) / (long)MAXVERT; if ( lpp->oldcross.left != lpp->oldcross.right ) BitBlt(hDC, lpp->oldcross.left, lpp->oldcross.top, lpp->oldcross.right - lpp->oldcross.left, lpp->oldcross.bottom - lpp->oldcross.top, lpp->hdcMem, lpp->oldcross.left, lpp->oldcross.top, SRCCOPY); lpp->oldcross.left = point.x - w - 1; lpp->oldcross.right = point.x + w + 1; lpp->oldcross.top = point.y - w - 1; lpp->oldcross.bottom = point.y + w + 1; hPen = CreatePen(PS_SOLID, 3, 0x000000); /* -black- color */ hPen = SelectObject(hDC, hPen); MoveToEx(hDC, point.x - w, point.y, &p); LineTo(hDC, point.x - wc, point.y); MoveToEx(hDC, point.x + wc, point.y, &p); LineTo(hDC, point.x + w, point.y); MoveToEx(hDC, point.x, point.y - w, &p); LineTo(hDC, point.x, point.y - wc); MoveToEx(hDC, point.x, point.y + wc, &p); LineTo(hDC, point.x, point.y + w); DeleteObject( SelectObject(hDC, hPen)); ReleaseDC(hwnd, hDC); } }
static bool plot_block(COLORREF col, int x, int y, int width, int height) { HRGN clipregion; HGDIOBJ original = NULL; /* Bail early if we can */ if ((x >= plot_clip.right) || ((x + width) < plot_clip.left) || (y >= plot_clip.bottom) || ((y + height) < plot_clip.top)) { /* Image completely outside clip region */ return true; } /* ensure the plot HDC is set */ if (plot_hdc == NULL) { LOG("HDC not set on call to plotters"); return false; } clipregion = CreateRectRgnIndirect(&plot_clip); if (clipregion == NULL) { return false; } SelectClipRgn(plot_hdc, clipregion); /* Saving the original pen object */ original = SelectObject(plot_hdc,GetStockObject(DC_PEN)); SelectObject(plot_hdc, GetStockObject(DC_PEN)); SelectObject(plot_hdc, GetStockObject(DC_BRUSH)); SetDCPenColor(plot_hdc, col); SetDCBrushColor(plot_hdc, col); Rectangle(plot_hdc, x, y, width, height); SelectObject(plot_hdc,original); /* Restoring the original pen object */ DeleteObject(clipregion); return true; }
static void GB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UINT dtFlags) { static const int states[] = { GBS_NORMAL, GBS_DISABLED, GBS_NORMAL, GBS_NORMAL, GBS_NORMAL }; RECT bgRect, textRect, contentRect; HFONT font = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0); HFONT hPrevFont = font ? SelectObject(hDC, font) : NULL; int state = states[ drawState ]; WCHAR *text = get_button_text(hwnd); GetClientRect(hwnd, &bgRect); textRect = bgRect; if (text) { SIZE textExtent; GetTextExtentPoint32W(hDC, text, lstrlenW(text), &textExtent); bgRect.top += (textExtent.cy / 2); textRect.left += 10; textRect.bottom = textRect.top + textExtent.cy; textRect.right = textRect.left + textExtent.cx + 4; ExcludeClipRect(hDC, textRect.left, textRect.top, textRect.right, textRect.bottom); } GetThemeBackgroundContentRect(theme, hDC, BP_GROUPBOX, state, &bgRect, &contentRect); ExcludeClipRect(hDC, contentRect.left, contentRect.top, contentRect.right, contentRect.bottom); if (IsThemeBackgroundPartiallyTransparent(theme, BP_GROUPBOX, state)) DrawThemeParentBackground(hwnd, hDC, NULL); DrawThemeBackground(theme, hDC, BP_GROUPBOX, state, &bgRect, NULL); SelectClipRgn(hDC, NULL); if (text) { textRect.left += 2; textRect.right -= 2; DrawThemeText(theme, hDC, BP_GROUPBOX, state, text, lstrlenW(text), 0, 0, &textRect); HeapFree(GetProcessHeap(), 0, text); } if (hPrevFont) SelectObject(hDC, hPrevFont); }
void PaintClover(HWND hwnd,HRGN hRgnClip, int cxClient, int cyClient) { double fAngle, fRadius ; PAINTSTRUCT ps; HDC hdc = BeginPaint (hwnd, &ps) ; SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ; SelectClipRgn (hdc, hRgnClip) ; fRadius = _hypot (cxClient / 2.0, cyClient / 2.0) ; for (fAngle = 0.0 ; fAngle < TWOPI ; fAngle += TWOPI / 360) { MoveToEx (hdc, 0, 0, NULL) ; LineTo (hdc, (int) ( fRadius * cos (fAngle) + 0.5), (int) (-fRadius * sin (fAngle) + 0.5)) ; } EndPaint (hwnd, &ps) ; }
void CFilePreviewCtrl::DoPaintBitmap(HDC hDC) { RECT rcClient; GetClientRect(&rcClient); HRGN hRgn = CreateRectRgn(0, 0, rcClient.right, rcClient.bottom); SelectClipRgn(hDC, hRgn); FillRect(hDC, &rcClient, (HBRUSH)GetStockObject(WHITE_BRUSH)); if(m_bmp.IsValid()) { m_bmp.Draw(hDC, &rcClient); } else { DoPaintEmpty(hDC); } }
static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam, LPARAM lParam) { HICON hIcon = nullptr; /* load both icons */ HICON hLowerIcon = (HICON)ServiceLoadFlagIcon((WPARAM)lParam, 0); if (hLowerIcon == nullptr) return 0; HICON hUpperIcon = (HICON)ServiceLoadFlagIcon(wParam, 0); /* merge them */ ICONINFO icoi; if (GetIconInfo(hLowerIcon, &icoi)) { BITMAP bm; if (hUpperIcon != nullptr && GetObject(icoi.hbmColor, sizeof(bm), &bm)) { HDC hdc = CreateCompatibleDC(nullptr); if (hdc != nullptr) { POINT aptTriangle[3] = { 0 }; aptTriangle[1].y = bm.bmHeight - 1; aptTriangle[2].x = bm.bmWidth - 1; HRGN hrgn = CreatePolygonRgn(aptTriangle, _countof(aptTriangle), WINDING); if (hrgn != nullptr) { SelectClipRgn(hdc, hrgn); DeleteObject(hrgn); HBITMAP hbmPrev = (HBITMAP)SelectObject(hdc, icoi.hbmColor); if (hbmPrev != nullptr) { /* error on select? */ if (DrawIconEx(hdc, 0, 0, hUpperIcon, bm.bmWidth, bm.bmHeight, 0, nullptr, DI_NOMIRROR | DI_IMAGE)) if (SelectObject(hdc, icoi.hbmMask) != nullptr) /* error on select? */ DrawIconEx(hdc, 0, 0, hUpperIcon, bm.bmWidth, bm.bmHeight, 0, nullptr, DI_NOMIRROR | DI_MASK); SelectObject(hdc, hbmPrev); } } DeleteDC(hdc); } } /* create icon */ hIcon = CreateIconIndirect(&icoi); DeleteObject(icoi.hbmColor); DeleteObject(icoi.hbmMask); } return (INT_PTR)hIcon; }
static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam,LPARAM lParam) { //TODO: use freeimage to create merget icon and add RGB(A) support ICONINFO icoi; BITMAP bm; HICON hIcon=NULL; /* load both icons */ HICON hLowerIcon=(HICON)ServiceLoadFlagIcon((WPARAM)lParam,0); if (hLowerIcon == NULL) return NULL; HICON hUpperIcon=(HICON)ServiceLoadFlagIcon(wParam,0); /* merge them */ if (GetIconInfo(hLowerIcon,&icoi)) { if (hUpperIcon!=NULL && GetObject(icoi.hbmColor,sizeof(bm),&bm)) { HDC hdc=CreateCompatibleDC(NULL); if (hdc!=NULL) { POINT aptTriangle[3]; memset(&aptTriangle, 0, sizeof(aptTriangle)); aptTriangle[1].y=bm.bmHeight-1; aptTriangle[2].x=bm.bmWidth-1; HRGN hrgn=CreatePolygonRgn(aptTriangle,_countof(aptTriangle),WINDING); if (hrgn!=NULL) { SelectClipRgn(hdc,hrgn); HBITMAP hbmPrev=(HBITMAP)SelectObject(hdc,icoi.hbmColor); if (hbmPrev!=NULL) { /* error on select? */ if (DrawIconEx(hdc,0,0,hUpperIcon,bm.bmWidth,bm.bmHeight,0,NULL,DI_NOMIRROR|DI_IMAGE)) { if (SelectObject(hdc,icoi.hbmMask)!=NULL) /* error on select? */ DrawIconEx(hdc,0,0,hUpperIcon,bm.bmWidth,bm.bmHeight,0,NULL,DI_NOMIRROR|DI_MASK); } SelectObject(hdc,hbmPrev); } DeleteObject(hrgn); } DeleteDC(hdc); } } /* create icon */ hIcon=CreateIconIndirect(&icoi); DeleteObject(icoi.hbmColor); DeleteObject(icoi.hbmMask); } return (INT_PTR)hIcon; }
//Draws the cursor on the DC void PrecisionCursor::drawCursor(RECT cursorRct, DWORD cursorShape, bool cross) { //Save the DC state int DCState=SaveDC(m_wndDC); //Set the NOT ROP2 SetROP2(m_wndDC,R2_NOT); //Remove any clipping region SelectClipRgn(m_wndDC,NULL); //Select a null brush SelectBrush(m_wndDC,GetStockBrush(NULL_BRUSH)); //Draw the cursor switch(cursorShape) { case PS_ENDCAP_ROUND: Ellipse(m_wndDC,EXPANDRECT_C(cursorRct)); break; case PS_ENDCAP_SQUARE: Rectangle(m_wndDC,EXPANDRECT_C(cursorRct)); break; default: break; } //Eventually draw the cross if(cross) { //Find the medium point between the center and the pixel next to it POINT pos=m_position,pos2=m_position; pos2.x++; pos2.y++; DIB2IVWndPoint(&pos); DIB2IVWndPoint(&pos2); pos.x=(pos.x+pos2.x)/2; pos.y=(pos.y+pos2.y)/2; //Draw the cross MoveToEx(m_wndDC,pos.x-PREC_CURSOR_CROSS_SIZE,pos.y-PREC_CURSOR_CROSS_SIZE,NULL); LineTo(m_wndDC,pos.x+PREC_CURSOR_CROSS_SIZE,pos.y+PREC_CURSOR_CROSS_SIZE); MoveToEx(m_wndDC,pos.x+PREC_CURSOR_CROSS_SIZE,pos.y-PREC_CURSOR_CROSS_SIZE,NULL); LineTo(m_wndDC,pos.x-PREC_CURSOR_CROSS_SIZE,pos.y+PREC_CURSOR_CROSS_SIZE); } //Restore the DC state RestoreDC(m_wndDC,DCState); }
wDraw_p wPrintPageStart( void ) { char pageL[80]; if (!printStatus) return NULL; pageNumber++; if (pageCount > 0) wsprintf( pageL, "Page %d of %d", pageNumber, pageCount ); else wsprintf( pageL, "Page %d", pageNumber ); SetDlgItemText( hAbortDlgWnd, IDM_PRINTPAGE, pageL ); StartPage( printDlg.hDC ); #ifdef LATER if (mswPrintPalette) { SelectPalette( printDlg.hDC, mswPrintPalette, 0 ); RealizePalette( printDlg.hDC ); } #endif getPageDim( printDlg.hDC ); SelectClipRgn( print_d.hDc, NULL ); return &print_d; }
//----------------------------------------------------------------------------- // Purpose: Finish up //----------------------------------------------------------------------------- CDrawHelper::~CDrawHelper( void ) { SelectClipRgn( m_dcMemory, NULL ); while ( m_ClipRects.Size() > 0 ) { StopClipping(); } BitBlt( m_dcReal, m_x, m_y, m_w, m_h, m_dcMemory, 0, 0, SRCCOPY ); SetBkColor( m_dcMemory, m_clrOld ); SelectObject( m_dcMemory, m_bmOld ); DeleteObject( m_bmMemory ); DeleteObject( m_dcMemory ); ReleaseDC( m_hWnd, m_dcReal ); ValidateRect( m_hWnd, &m_rcClient ); }
void Win32Graphics::drawRect( int left, int top, int width, int height, uint32_t color ) { // Update the mask with the rectangle HRGN l1 = CreateRectRgn( left, top, left + width, top + 1 ); HRGN l2 = CreateRectRgn( left + width - 1, top, left + width, top + height ); HRGN l3 = CreateRectRgn( left, top + height - 1, left + width, top + height ); HRGN l4 = CreateRectRgn( left, top, left + 1, top + height ); CombineRgn( m_mask, m_mask, l1, RGN_OR ); CombineRgn( m_mask, m_mask, l2, RGN_OR ); CombineRgn( m_mask, m_mask, l3, RGN_OR ); CombineRgn( m_mask, m_mask, l4, RGN_OR ); DeleteObject( l1 ); DeleteObject( l2 ); DeleteObject( l3 ); DeleteObject( l4 ); SelectClipRgn( m_hDC, m_mask ); // Create a pen with the color int red = (color & 0xff0000) >> 16; int green = (color & 0xff00) >> 8; int blue = color & 0xff; HPEN hPen = CreatePen( PS_SOLID, 0, RGB( red, green, blue ) ); SelectObject( m_hDC, hPen ); // Draw the rectangle MoveToEx( m_hDC, left, top, NULL ); LineTo( m_hDC, left + width - 1, top ); LineTo( m_hDC, left + width - 1, top + height - 1 ); LineTo( m_hDC, left, top + height - 1 ); LineTo( m_hDC, left, top ); // Delete the pen DeleteObject( hPen ); }
long WMPaint (HWND hwnd, WPARAM wParam, LPARAM lParam) { double fAngle, fRadius; HDC hdc; PAINTSTRUCT ps; hdc = BeginPaint (hwnd, &ps); SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2,NULL); SelectClipRgn (hdc, hRgnClip); fRadius = hypot (cxClient / 2.0, cyClient / 2.0); for (fAngle = 0.0; fAngle < TWO_PI; fAngle += TWO_PI / 360.0) { MoveToEx (hdc, 0, 0,NULL); LineTo (hdc, (int) ( fRadius*cos (fAngle) + 0.5), (int) (-fRadius*sin (fAngle) + 0.5)); } EndPaint (hwnd, &ps); return 0; }
void CCDInfo::GetTheWindow() { // If we're windowless we still need an HWND for Direct3d if (m_bWndLess) { HDC hDC; // Get the HDC from the client m_spInPlaceSite->GetDC(NULL, OLEDC_NODRAW, &hDC); m_hTheWnd = WindowFromDC(hDC); // Code to make VB5 paint properly now it has clipped it's own hDC RECT rect; ::GetClientRect(m_hTheWnd,&rect); HRGN hRegion = CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom); SelectClipRgn(hDC,hRegion); m_spInPlaceSite->ReleaseDC(hDC); } else m_hTheWnd = m_hWnd; }
void Win32Graphics::fillRect( int left, int top, int width, int height, uint32_t color ) { // Update the mask with the rectangle area HRGN newMask = CreateRectRgn( left, top, left + width, top + height ); CombineRgn( m_mask, m_mask, newMask, RGN_OR ); SelectClipRgn( m_hDC, m_mask ); DeleteObject( newMask ); // Create a brush with the color int red = (color & 0xff0000) >> 16; int green = (color & 0xff00) >> 8; int blue = color & 0xff; HBRUSH hBrush = CreateSolidBrush( RGB( red, green, blue ) ); // Draw the rectangle RECT r; r.left = left; r.top = top; r.right = left + width; r.bottom = top + height; FillRect( m_hDC, &r, hBrush ); DeleteObject( hBrush ); }
BOOL CGifSmileyCtrl::SelectSmileyClipRgn(HDC hDC, RECT& SmileyPos, HRGN& hOldRegion, HRGN& hNewRegion, BOOL bTuneBorder) { hNewRegion=NULL; hOldRegion=NULL; if (!bTuneBorder) { hNewRegion=CreateRectRgn(SmileyPos.left, SmileyPos.top, SmileyPos.right, SmileyPos.bottom); } else if (m_hwndParent) { RECT rcParent; RECT rcVis; RECT wrc; POINT pt={0}; ::ClientToScreen(m_hwndParent, &pt); ::GetClientRect(m_hwndParent, &rcParent); ::GetWindowRect(m_hwndParent,&wrc); OffsetRect(&rcParent, pt.x-wrc.left, pt.y-wrc.top); IntersectRect(&rcVis, &rcParent, &SmileyPos); if (IsRectEmpty(&rcVis)) return FALSE; hNewRegion=CreateRectRgn(rcVis.left,rcVis.top,rcVis.right,rcVis.bottom); } else return FALSE; if (GetClipRgn(hDC,hOldRegion)!=1) { DeleteObject(hOldRegion); hOldRegion=NULL; } SelectClipRgn(hDC, hNewRegion); return TRUE; }