void COFSNcDlg2::OnSize(UINT nType, int cx, int cy) { OFS_NCDLG2_PARENT::OnSize(nType, cx, cy); // if(m_bRound) { RECT rw, r; GetWindowRect(&rw); OffsetRect(&rw, -rw.left, -rw.top); HRGN WinRgn; WinRgn = CreateRectRgn(0, 0, rw.right, rw.bottom); if(m_rgnTL != NULL) CombineRgn(WinRgn, WinRgn, m_rgnTL, RGN_DIFF); if(m_rgnTR != NULL) { GetRgnBox(m_rgnTR, &r); OffsetRgn(m_rgnTR, rw.right - r.right, 0); CombineRgn(WinRgn, WinRgn, m_rgnTR, RGN_DIFF); OffsetRgn(m_rgnTR, -(rw.right - r.right), 0); } if(m_rgnBL != NULL) { GetRgnBox(m_rgnBL, &r); OffsetRgn(m_rgnBL, 0, rw.bottom - r.bottom); CombineRgn(WinRgn, WinRgn, m_rgnBL, RGN_DIFF); OffsetRgn(m_rgnBL, 0, -(rw.bottom - r.bottom)); } if(m_rgnBR != NULL) { GetRgnBox(m_rgnBR, &r); OffsetRgn(m_rgnBR, rw.right - r.right, rw.bottom - r.bottom); CombineRgn(WinRgn, WinRgn, m_rgnBR, RGN_DIFF); OffsetRgn(m_rgnBR, -(rw.right - r.right), -(rw.bottom - r.bottom)); } SetWindowRgn(WinRgn, TRUE); DeleteObject(WinRgn); } // Switch maximize and restore buttons if(nType == SIZE_MAXIMIZED) { if(m_pBtnMax) m_pBtnMax->ShowWindow(FALSE); if(m_pBtnRestore) m_pBtnRestore->ShowWindow(TRUE); } if(nType == SIZE_RESTORED) { if(m_pBtnMax) m_pBtnMax->ShowWindow(TRUE); if(m_pBtnRestore) m_pBtnRestore->ShowWindow(FALSE); } Invalidate(FALSE); UpdateWindow(); }
static void test_memory_dc_clipping(void) { HDC hdc; HRGN hrgn, hrgn_empty; HBITMAP hbmp; RECT rc; int ret; hdc = CreateCompatibleDC(0); hrgn_empty = CreateRectRgn(0, 0, 0, 0); hrgn = CreateRectRgn(0, 0, 0, 0); hbmp = CreateCompatibleBitmap(hdc, 100, 100); ret = GetClipRgn(hdc, hrgn); ok(ret == 0, "expected 0, got %d\n", ret); ret = ExtSelectClipRgn(hdc, hrgn_empty, RGN_DIFF); ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret); ret = GetClipRgn(hdc, hrgn); ok(ret == 1, "expected 1, got %d\n", ret); ret = GetRgnBox(hrgn, &rc); ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret); ok(rc.left == 0 && rc.top == 0 && rc.right == 1 && rc.bottom == 1, "expected 0,0-1,1, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom); ret = ExtSelectClipRgn(hdc, 0, RGN_COPY); ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret); ret = GetClipRgn(hdc, hrgn); ok(ret == 0, "expected 0, got %d\n", ret); SelectObject(hdc, hbmp); ret = ExtSelectClipRgn(hdc, hrgn_empty, RGN_DIFF); ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret); ret = GetClipRgn(hdc, hrgn); ok(ret == 1, "expected 1, got %d\n", ret); ret = GetRgnBox(hrgn, &rc); ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret); ok(rc.left == 0 && rc.top == 0 && rc.right == 100 && rc.bottom == 100, "expected 0,0-100,100, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom); DeleteDC(hdc); DeleteObject(hrgn); DeleteObject(hrgn_empty); DeleteObject(hbmp); }
/*********************************************************************** * SetMetaRgn (GDI32.@) */ INT WINAPI SetMetaRgn( HDC hdc ) { INT ret; RECT dummy; DC *dc = DC_GetDCPtr( hdc ); if (!dc) return ERROR; if (dc->hMetaClipRgn) { /* the intersection becomes the new meta region */ DeleteObject( dc->hMetaRgn ); DeleteObject( dc->hClipRgn ); dc->hMetaRgn = dc->hMetaClipRgn; dc->hClipRgn = 0; dc->hMetaClipRgn = 0; } else if (dc->hClipRgn) { dc->hMetaRgn = dc->hClipRgn; dc->hClipRgn = 0; } /* else nothing to do */ /* Note: no need to call CLIPPING_UpdateGCRegion, the overall clip region hasn't changed */ ret = GetRgnBox( dc->hMetaRgn, &dummy ); GDI_ReleaseObj( hdc ); return ret; }
/*********************************************************************** * GetClipBox (GDI32.@) */ INT WINAPI GetClipBox( HDC hdc, LPRECT rect ) { RECT visrect; INT ret; DC *dc = get_dc_ptr( hdc ); if (!dc) return ERROR; update_dc( dc ); if (get_dc_region( dc )) { ret = GetRgnBox( get_dc_region( dc ), rect ); } else { ret = is_rect_empty( &dc->vis_rect ) ? ERROR : SIMPLEREGION; *rect = dc->vis_rect; } if (get_dc_device_rect( dc, &visrect ) && !intersect_rect( rect, rect, &visrect )) ret = NULLREGION; if (dc->layout & LAYOUT_RTL) { int tmp = rect->left; rect->left = rect->right - 1; rect->right = tmp - 1; } DPtoLP( hdc, (LPPOINT)rect, 2 ); release_dc_ptr( dc ); TRACE("%p => %d %s\n", hdc, ret, wine_dbgstr_rect( rect )); return ret; }
/*********************************************************************** * SetMetaRgn (GDI32.@) */ INT WINAPI SetMetaRgn( HDC hdc ) { INT ret; RECT dummy; DC *dc = get_dc_ptr( hdc ); if (!dc) return ERROR; if (dc->hClipRgn) { if (dc->hMetaRgn) { /* the intersection becomes the new meta region */ CombineRgn( dc->hMetaRgn, dc->hMetaRgn, dc->hClipRgn, RGN_AND ); DeleteObject( dc->hClipRgn ); dc->hClipRgn = 0; } else { dc->hMetaRgn = dc->hClipRgn; dc->hClipRgn = 0; } } /* else nothing to do */ /* Note: no need to call update_dc_clipping, the overall clip region hasn't changed */ ret = GetRgnBox( dc->hMetaRgn, &dummy ); release_dc_ptr( dc ); return ret; }
/* PA: new routine to scroll part of the content of a window. It is assumed that scrolling happens in one direction only (dx<>0 && dy==0 || dx==0 && dy<>0). The result rect (oleft,otop,oright,obottom) is the bounding box of the update area that remains to be updated. If all are zero, then nothing needs to be updated. */ void WinScrollRectangle (int left, int top, int right, int bottom, int dx, int dy, OSPictContext context, int * oleft, int * otop, int * oright, int * obottom ) { RECT scrollRect; HRGN hrgnUpdate, hrgnRect; scrollRect.left = left; scrollRect.top = top; scrollRect.right = right; scrollRect.bottom = bottom; if (dx<0) { hrgnRect = CreateRectRgn (right+dx-1,top-1,right+1,bottom+1); } else if (dx>0) { hrgnRect = CreateRectRgn (left-1,top-1,left+dx+1,bottom+1); } else if (dy<0) { hrgnRect = CreateRectRgn (left-1,bottom+dy-1,right+1,bottom+1); } else if (dy>0) { hrgnRect = CreateRectRgn (left-1,top-1,right+1,top+dy+1); } else { hrgnRect = CreateRectRgn (0,0,0,0); } hrgnUpdate = CreateRectRgn (0,0,1,1); if (!ScrollDC (context->hDC, dx,dy, &scrollRect, &scrollRect, hrgnUpdate, NULL)) { rMessageBox (NULL,MB_APPLMODAL,"WinScrollRectangle","ScrollDC failed"); } else { if (CombineRgn (hrgnUpdate, hrgnUpdate, hrgnRect, RGN_DIFF) == NULLREGION) { *oleft = 0; *otop = 0; *oright = 0; *obottom = 0; } else { RECT box; GetRgnBox (hrgnUpdate,&box); *oleft = box.left; *otop = box.top; *oright = box.right; *obottom = box.bottom; } } DeleteObject (hrgnUpdate); DeleteObject (hrgnRect); } /* WinScrollRectangle */
/* * @implemented */ int WINAPI GetWindowRgnBox( HWND hWnd, LPRECT lprc) { PWND pWnd; int Ret; if (!lprc) return ERROR; pWnd = ValidateHwnd(hWnd); if (!pWnd || !pWnd->hrgnClip || pWnd->state2 & WNDS2_MAXIMIZEDMONITORREGION) return ERROR; Ret = GetRgnBox(pWnd->hrgnClip, lprc); if (!Ret) return ERROR; /* if (hWnd != GetDesktopWindow()) // pWnd->fnid != FNID_DESKTOP) OffsetRect(lprc, -pWnd->rcWindow.left, -pWnd->rcWindow.top); */ if (pWnd->ExStyle & WS_EX_LAYOUTRTL) MirrorWindowRect(pWnd, lprc); return Ret; }
/*********************************************************************** * clip_visrect * * Clip a rectangle to the DC visible rect. */ BOOL clip_visrect( DC *dc, RECT *dst, const RECT *src ) { RECT clip; if (!clip_device_rect( dc, dst, src )) return FALSE; if (GetRgnBox( get_dc_region(dc), &clip )) return intersect_rect( dst, dst, &clip ); return TRUE; }
void KLogWindow::DumpRegion(const char * mess, HRGN hRgn, bool detail, int p1) { if ( mess ) Log(mess, p1); if ( hRgn==NULL ) Log(" NULL"); else { RECT rect; memset(& rect, 0, sizeof(rect)); switch ( GetRgnBox(hRgn, & rect) ) { case NULLREGION: Log(" NULLREGION "); break; case SIMPLEREGION: Log(" SIMPLEREGION "); break; case COMPLEXREGION: Log(" COMPLEXREGION "); break; default: Log(" Error "); break; } Log(" RgnBox=[%d, %d, %d, %d) ", rect.left, rect.top, rect.right, rect.bottom); int size = GetRegionData(hRgn, 0, NULL); int rectcount = 0; if ( size ) { RGNDATA * pRegion = (RGNDATA *) new char[size]; GetRegionData(hRgn, size, pRegion); const RECT * pRect = (const RECT *) & pRegion->Buffer; rectcount = pRegion->rdh.nCount; Log("%d rectangles", rectcount); if ( detail ) { Log("\r\n"); for (unsigned i=0; i<pRegion->rdh.nCount; i++) Log("rect %d [%d, %d, %d, %d)\r\n", i, pRect[i].left, pRect[i].top, pRect[i].right, pRect[i].bottom); } delete [] (char *) pRegion; } else Log("0 rectangle"); } Log("\r\n"); }
/*********************************************************************** * GetClipBox (GDI32.@) */ INT WINAPI GetClipBox( HDC hdc, LPRECT rect ) { INT ret; HRGN clip; DC *dc = DC_GetDCUpdate( hdc ); if (!dc) return ERROR; if ((clip = get_clip_region(dc))) { HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 ); CombineRgn( hrgn, dc->hVisRgn, clip, RGN_AND ); ret = GetRgnBox( hrgn, rect ); DeleteObject( hrgn ); } else ret = GetRgnBox( dc->hVisRgn, rect ); DPtoLP( hdc, (LPPOINT)rect, 2 ); GDI_ReleaseObj( hdc ); return ret; }
// Return bounding box FXRectangle FXRegion::bounds() const { #ifdef WIN32 RECT rect; GetRgnBox((HRGN)region,&rect); return FXRectangle((FXshort)rect.left,(FXshort)rect.top,(FXshort)(rect.right-rect.left),(FXshort)(rect.bottom-rect.top)); #else XRectangle rect; XClipBox((Region)region,&rect); return FXRectangle(rect.x,rect.y,rect.width,rect.height); #endif }
void reactangles() { RECT rect; GetRgnBox(region, &rect); left=rect.left; right=rect.right; top=rect.top; bottom=rect.bottom; Clear(); }
void add_device_bounds( X11DRV_PDEVICE *dev, const RECT *rect ) { RECT rc; if (!dev->bounds) return; if (dev->region && GetRgnBox( dev->region, &rc )) { if (IntersectRect( &rc, &rc, rect )) add_bounds_rect( dev->bounds, &rc ); } else add_bounds_rect( dev->bounds, rect ); }
static void hugsprim_GetRgnBox_2(HugsStackPtr hugs_root) { HsPtr arg1; HsPtr arg2; HsInt32 res1; arg1 = hugs->getPtr(); arg2 = hugs->getPtr(); res1 = GetRgnBox(arg1, arg2); hugs->putInt32(res1); hugs->returnIO(hugs_root,1); }
void CHTMLSectionLink::GetObjectRect( WinHelper::CRect &rcBounds ) const { HRGN rgn; if( GetRegion( rgn ) ) { GetRgnBox( rgn, rcBounds ); VAPI( DeleteObject( rgn ) ); } else { ASSERT( FALSE ); } }
static void test_window_dc_clipping(void) { HDC hdc; HRGN hrgn, hrgn_empty; HWND hwnd; RECT rc; int ret, screen_width, screen_height; /* Windows versions earlier than Win2k do not support the virtual screen metrics, * so we fall back to the primary screen metrics. */ screen_width = GetSystemMetrics(SM_CXVIRTUALSCREEN); if(!screen_width) screen_width = GetSystemMetrics(SM_CXSCREEN); screen_height = GetSystemMetrics(SM_CYVIRTUALSCREEN); if(!screen_height) screen_height = GetSystemMetrics(SM_CYSCREEN); trace("screen resolution %d x %d\n", screen_width, screen_height); hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, -100, -100, screen_width * 2, screen_height * 2, 0, 0, 0, NULL); hdc = GetWindowDC(0); hrgn_empty = CreateRectRgn(0, 0, 0, 0); hrgn = CreateRectRgn(0, 0, 0, 0); ret = GetClipRgn(hdc, hrgn); ok(ret == 0, "expected 0, got %d\n", ret); ret = ExtSelectClipRgn(hdc, hrgn_empty, RGN_DIFF); ok(ret == SIMPLEREGION || (ret == COMPLEXREGION && GetSystemMetrics(SM_CMONITORS) > 1), "expected SIMPLEREGION, got %d\n", ret); ret = GetClipRgn(hdc, hrgn); ok(ret == 1, "expected 1, got %d\n", ret); ret = GetRgnBox(hrgn, &rc); ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret); ok(rc.left == 0 && rc.top == 0 && rc.right == screen_width && rc.bottom == screen_height, "expected 0,0-%d,%d, got %d,%d-%d,%d\n", screen_width, screen_height, rc.left, rc.top, rc.right, rc.bottom); ret = ExtSelectClipRgn(hdc, 0, RGN_COPY); ok(ret == SIMPLEREGION || (ret == COMPLEXREGION && GetSystemMetrics(SM_CMONITORS) > 1), "expected SIMPLEREGION, got %d\n", ret); ret = GetClipRgn(hdc, hrgn); ok(ret == 0, "expected 0, got %d\n", ret); DeleteDC(hdc); DeleteObject(hrgn); DeleteObject(hrgn_empty); DestroyWindow(hwnd); }
static void test_CreatePolyPolygonRgn(void) { HRGN region; POINT points_zero[] = { {0, 0}, {0, 0}, {0, 0} }; POINT points_mixed[] = { {0, 0}, {0, 0}, {0, 0}, {6, 6}, {6, 6}, {6, 6} }; POINT points_six[] = { {6, 6}, {6, 6}, {6, 6} }; POINT points_line[] = { {1, 0}, {11, 0}, {21, 0}}; INT counts_single_poly[] = { 3 }; INT counts_two_poly[] = { 3, 3 }; int ret; RECT rect; /* When all polygons are just one point or line, return must not be NULL */ region = CreatePolyPolygonRgn(points_zero, counts_single_poly, ARRAY_SIZE(counts_single_poly), ALTERNATE); ok (region != NULL, "region must not be NULL\n"); ret = GetRgnBox(region, &rect); ok (ret == NULLREGION, "Expected NULLREGION, got %d\n", ret); DeleteObject(region); region = CreatePolyPolygonRgn(points_six, counts_single_poly, ARRAY_SIZE(counts_single_poly), ALTERNATE); ok (region != NULL, "region must not be NULL\n"); ret = GetRgnBox(region, &rect); ok (ret == NULLREGION, "Expected NULLREGION, got %d\n", ret); DeleteObject(region); region = CreatePolyPolygonRgn(points_line, counts_single_poly, ARRAY_SIZE(counts_single_poly), ALTERNATE); ok (region != NULL, "region must not be NULL\n"); ret = GetRgnBox(region, &rect); ok (ret == NULLREGION, "Expected NULLREGION, got %d\n", ret); DeleteObject(region); region = CreatePolyPolygonRgn(points_mixed, counts_two_poly, ARRAY_SIZE(counts_two_poly), ALTERNATE); ok (region != NULL, "region must not be NULL\n"); ret = GetRgnBox(region, &rect); ok (ret == NULLREGION, "Expected NULLREGION, got %d\n", ret); DeleteObject(region); }
void WinGetRgnBox (HRGN hrgn, int *left, int *top, int *right, int *bottom, BOOL *isrect) { int result; RECT boundbox; result = GetRgnBox (hrgn, &boundbox); *left = boundbox.left; *right = boundbox.right; *top = boundbox.top; *bottom = boundbox.bottom; *isrect = result == SIMPLEREGION; } /* WinGetRgnBox */
// Return bounding box FXRectangle FXRegion::bounds() const { FXRectangle result; #ifndef WIN32 XClipBox((Region)region,(XRectangle*)&result); #else RECT rect; GetRgnBox((HRGN)region,&rect); result.x=(FXshort)rect.left; result.y=(FXshort)rect.top; result.w=(FXshort)(rect.right-rect.left); result.h=(FXshort)(rect.bottom-rect.top); #endif return result; }
static void highlight_lines(HWND hWnd, HRGN clip) { RECT rect; WORD wTopLine = get_top_line(hWnd); WORD i, wUpdTopLine, wUpdBotLine; if (clip) GetRgnBox(clip, &rect); else GetClientRect(hWnd, &rect); wUpdTopLine = rect.top / wLHeight + wTopLine; wUpdBotLine = rect.bottom / wLHeight + 1 + wTopLine; for (i = wUpdTopLine; i < wUpdBotLine; ++i) if (GetDisplayLineBkpt(i)) draw_rect(hWnd, i - wTopLine, clip, klwDGBrush); }
void _gdk_win32_print_dc (HDC hdc) { HGDIOBJ obj; LOGBRUSH logbrush; EXTLOGPEN extlogpen; HRGN hrgn; RECT rect; int flag; g_print ("%p:\n", hdc); obj = GetCurrentObject (hdc, OBJ_BRUSH); GetObject (obj, sizeof (LOGBRUSH), &logbrush); g_print ("brush: %s color=%06lx hatch=%p\n", _gdk_win32_lbstyle_to_string (logbrush.lbStyle), logbrush.lbColor, (gpointer) logbrush.lbHatch); obj = GetCurrentObject (hdc, OBJ_PEN); GetObject (obj, sizeof (EXTLOGPEN), &extlogpen); g_print ("pen: %s %s %s %s w=%d %s\n", _gdk_win32_pstype_to_string (extlogpen.elpPenStyle), _gdk_win32_psstyle_to_string (extlogpen.elpPenStyle), _gdk_win32_psendcap_to_string (extlogpen.elpPenStyle), _gdk_win32_psjoin_to_string (extlogpen.elpPenStyle), extlogpen.elpWidth, _gdk_win32_lbstyle_to_string (extlogpen.elpBrushStyle)); g_print ("rop2: %s textcolor=%06lx\n", _gdk_win32_rop2_to_string (GetROP2 (hdc)), GetTextColor (hdc)); hrgn = CreateRectRgn (0, 0, 0, 0); if ((flag = GetClipRgn (hdc, hrgn)) == -1) WIN32_API_FAILED ("GetClipRgn"); else if (flag == 0) g_print ("no clip region\n"); else if (flag == 1) { GetRgnBox (hrgn, &rect); g_print ("clip region: %p bbox: %s\n", hrgn, _gdk_win32_rect_to_string (&rect)); } DeleteObject (hrgn); }
/***************************************************************************** * GdipGetRegionBounds [GDIPLUS.@] */ GpStatus WINGDIPAPI GdipGetRegionBounds(GpRegion *region, GpGraphics *graphics, GpRectF *rect) { HRGN hrgn; RECT r; GpStatus status; TRACE("(%p, %p, %p)\n", region, graphics, rect); if(!region || !graphics || !rect) return InvalidParameter; /* Contrary to MSDN, native ignores the graphics transform. */ status = GdipGetRegionHRgn(region, NULL, &hrgn); if(status != Ok) return status; /* infinite */ if(!hrgn){ rect->X = rect->Y = -(REAL)(1 << 22); rect->Width = rect->Height = (REAL)(1 << 23); TRACE("%p => infinite\n", region); return Ok; } if(GetRgnBox(hrgn, &r)){ rect->X = r.left; rect->Y = r.top; rect->Width = r.right - r.left; rect->Height = r.bottom - r.top; TRACE("%p => %s\n", region, debugstr_rectf(rect)); } else status = GenericError; DeleteObject(hrgn); return status; }
void main() { HWND hwndDesktop = GetDesktopWindow(); HWND hwndStart = FindWindowEx(hwndDesktop, NULL, "Button", "Start"); RECT rectDesktop; if(!GetWindowRect(hwndDesktop, &rectDesktop)) return; HRGN hrgnDesktop = CreateRectRgn(rectDesktop.left, rectDesktop.top, rectDesktop.right, rectDesktop.bottom); HRGN hrgn = CreateRectRgn(0, 0, 0, 0); HRGN hrgn_ = CreateRectRgn(0, 0, 0, 0); for(HWND hwnd_ = GetTopWindow(NULL); hwnd_ != NULL; hwnd_ = GetWindow(hwnd_, GW_HWNDNEXT)) { if(hwnd_ == hwndStart || hwnd_ == hwndDesktop || !IsWindowVisible(hwnd_) || IsIconic(hwnd_)) continue; char buffer[256]; GetWindowText(hwnd_, buffer, sizeof(buffer)); printf("GetWindowText = %s\n", buffer); RECT rect; if(!GetWindowRect(hwnd_, &rect)) continue; if(!SetRectRgn(hrgn_, rect.left, rect.top, rect.right, rect.bottom)) continue; if(hrgnDesktop) { if(CombineRgn(hrgn_, hrgn_, hrgnDesktop, RGN_AND) == NULLREGION) continue; if(GetRgnBox(hrgn_, &rect) == NULLREGION) continue; } if(CombineRgn(hrgn_, hrgn_, hrgn, RGN_DIFF) == NULLREGION) continue; if(CombineRgn(hrgn, hrgn, hrgn_, RGN_OR) == ERROR) continue; printf("RECT :: l = %d, r = %d, t = %d, b = %d\n", rect.left, rect.right, rect.top, rect.bottom); } DeleteObject(hrgn_); DeleteObject(hrgn); DeleteObject(hrgnDesktop); }
void fenum(STATE* state) { HWND hwnd = state->hwnd; HWND hwndDesktop = GetDesktopWindow(); HWND hwndStart = FindWindowEx(hwndDesktop, NULL, "Button", "Start"); RECT& rectDesktop = state->rect_list[state->rect_list_n]; if(!GetWindowRect(hwndDesktop, &rectDesktop)) return; state->rect_list_n++; HRGN hrgnDesktop = CreateRectRgn(rectDesktop.left, rectDesktop.top, rectDesktop.right, rectDesktop.bottom); HRGN hrgn = CreateRectRgn(0, 0, 0, 0); HRGN hrgn_ = CreateRectRgn(0, 0, 0, 0); for(HWND hwnd_ = GetTopWindow(NULL); hwnd_ != NULL; hwnd_ = GetWindow(hwnd_, GW_HWNDNEXT)) { if(hwnd_ == hwnd || hwnd_ == hwndStart || hwnd_ == hwndDesktop || !IsWindowVisible(hwnd_) || IsIconic(hwnd_) || IsChild(hwnd)) continue; RECT& rect = state->rect_list[state->rect_list_n]; if(!GetWindowRect(hwnd_, &rect)) continue; if(!SetRectRgn(hrgn_, rect.left, rect.top, rect.right, rect.bottom)) continue; if(hrgnDesktop) { if(CombineRgn(hrgn_, hrgn_, hrgnDesktop, RGN_AND) == NULLREGION) continue; if(GetRgnBox(hrgn_, &rect) == NULLREGION) continue; } if(CombineRgn(hrgn_, hrgn_, hrgn, RGN_DIFF) == NULLREGION) continue; if(CombineRgn(hrgn, hrgn, hrgn_, RGN_OR) == ERROR) continue; if(state->rect_list_n++ == sizeof(state->rect_list) / sizeof(RECT)) break; } DeleteObject(hrgn_); DeleteObject(hrgn); DeleteObject(hrgnDesktop); } // fenum
/************************************************************************* * ScrollDC (X11DRV.@) */ BOOL X11DRV_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *lprcScroll, const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate ) { RECT rcSrc, rcClip, offset; INT dxdev, dydev, res; HRGN DstRgn, clipRgn, visrgn; INT code = X11DRV_START_EXPOSURES; TRACE("dx,dy %d,%d rcScroll %s rcClip %s hrgnUpdate %p lprcUpdate %p\n", dx, dy, wine_dbgstr_rect(lprcScroll), wine_dbgstr_rect(lprcClip), hrgnUpdate, lprcUpdate); /* enable X-exposure events */ if (hrgnUpdate || lprcUpdate) ExtEscape( hdc, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, 0, NULL ); /* get the visible region */ visrgn=CreateRectRgn( 0, 0, 0, 0); GetRandomRgn( hdc, visrgn, SYSRGN); if( !(GetVersion() & 0x80000000)) { /* Window NT/2k/XP */ POINT org; GetDCOrgEx(hdc, &org); OffsetRgn( visrgn, -org.x, -org.y); } /* intersect with the clipping Region if the DC has one */ clipRgn = CreateRectRgn( 0, 0, 0, 0); if (GetClipRgn( hdc, clipRgn) != 1) { DeleteObject(clipRgn); clipRgn=NULL; } else CombineRgn( visrgn, visrgn, clipRgn, RGN_AND); /* only those pixels in the scroll rectangle that remain in the clipping * rect are scrolled. */ if( lprcClip) rcClip = *lprcClip; else GetClipBox( hdc, &rcClip); rcSrc = rcClip; OffsetRect( &rcClip, -dx, -dy); IntersectRect( &rcSrc, &rcSrc, &rcClip); /* if an scroll rectangle is specified, only the pixels within that * rectangle are scrolled */ if( lprcScroll) IntersectRect( &rcSrc, &rcSrc, lprcScroll); /* now convert to device coordinates */ LPtoDP(hdc, (LPPOINT)&rcSrc, 2); TRACE("source rect: %s\n", wine_dbgstr_rect(&rcSrc)); /* also dx and dy */ SetRect(&offset, 0, 0, dx, dy); LPtoDP(hdc, (LPPOINT)&offset, 2); dxdev = offset.right - offset.left; dydev = offset.bottom - offset.top; /* now intersect with the visible region to get the pixels that will * actually scroll */ DstRgn = CreateRectRgnIndirect( &rcSrc); res = CombineRgn( DstRgn, DstRgn, visrgn, RGN_AND); /* and translate, giving the destination region */ OffsetRgn( DstRgn, dxdev, dydev); if( TRACE_ON( scroll)) dump_region( "Destination scroll region: ", DstRgn); /* if there are any, do it */ if( res > NULLREGION) { RECT rect ; /* clip to the destination region, so we can BitBlt with a simple * bounding rectangle */ if( clipRgn) ExtSelectClipRgn( hdc, DstRgn, RGN_AND); else SelectClipRgn( hdc, DstRgn); GetRgnBox( DstRgn, &rect); DPtoLP(hdc, (LPPOINT)&rect, 2); TRACE("destination rect: %s\n", wine_dbgstr_rect(&rect)); BitBlt( hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, hdc, rect.left - dx, rect.top - dy, SRCCOPY); } /* compute the update areas. This is the combined clip rectangle * minus the scrolled region, and intersected with the visible * region. */ if (hrgnUpdate || lprcUpdate) { HRGN hrgn = hrgnUpdate; HRGN ExpRgn = 0; /* collect all the exposures */ code = X11DRV_END_EXPOSURES; ExtEscape( hdc, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, sizeof(ExpRgn), (LPSTR)&ExpRgn ); /* Intersect clip and scroll rectangles, allowing NULL values */ if( lprcScroll) if( lprcClip) IntersectRect( &rcClip, lprcClip, lprcScroll); else rcClip = *lprcScroll; else if( lprcClip) rcClip = *lprcClip; else GetClipBox( hdc, &rcClip); /* Convert the combined clip rectangle to device coordinates */ LPtoDP(hdc, (LPPOINT)&rcClip, 2); if( hrgn ) SetRectRgn( hrgn, rcClip.left, rcClip.top, rcClip.right, rcClip.bottom); else hrgn = CreateRectRgnIndirect( &rcClip); CombineRgn( hrgn, hrgn, visrgn, RGN_AND); CombineRgn( hrgn, hrgn, DstRgn, RGN_DIFF); /* add the exposures to this */ if( ExpRgn) { if( TRACE_ON( scroll)) dump_region( "Expose region: ", ExpRgn); CombineRgn( hrgn, hrgn, ExpRgn, RGN_OR); DeleteObject( ExpRgn); } if( TRACE_ON( scroll)) dump_region( "Update region: ", hrgn); if( lprcUpdate) { GetRgnBox( hrgn, lprcUpdate ); /* Put the lprcUpdate in logical coordinates */ DPtoLP( hdc, (LPPOINT)lprcUpdate, 2 ); TRACE("returning lprcUpdate %s\n", wine_dbgstr_rect(lprcUpdate)); } if( !hrgnUpdate) DeleteObject( hrgn); } /* restore original clipping region */ SelectClipRgn( hdc, clipRgn); DeleteObject( visrgn); DeleteObject( DstRgn); if( clipRgn) DeleteObject( clipRgn); return TRUE; }
static void test_savedc_2(void) { HWND hwnd; HDC hdc; HRGN hrgn; RECT rc, rc_clip; int ret; hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100, 0, 0, 0, NULL); assert(hwnd != 0); ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); hrgn = CreateRectRgn(0, 0, 0, 0); assert(hrgn != 0); hdc = GetDC(hwnd); ok(hdc != NULL, "GetDC failed\n"); ret = GetClipBox(hdc, &rc_clip); ok(ret == SIMPLEREGION, "GetClipBox returned %d instead of SIMPLEREGION\n", ret); ret = GetClipRgn(hdc, hrgn); ok(ret == 0, "GetClipRgn returned %d instead of 0\n", ret); ret = GetRgnBox(hrgn, &rc); ok(ret == NULLREGION, "GetRgnBox returned %d (%d,%d-%d,%d) instead of NULLREGION\n", ret, rc.left, rc.top, rc.right, rc.bottom); /*dump_region(hrgn);*/ SetRect(&rc, 0, 0, 100, 100); ok(EqualRect(&rc, &rc_clip), "rects are not equal: (%d,%d-%d,%d) - (%d,%d-%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom, rc_clip.left, rc_clip.top, rc_clip.right, rc_clip.bottom); ret = SaveDC(hdc); todo_wine { ok(ret == 1, "ret = %d\n", ret); } ret = IntersectClipRect(hdc, 0, 0, 50, 50); if (ret == COMPLEXREGION) { /* XP returns COMPLEXREGION although dump_region reports only 1 rect */ trace("Windows BUG: IntersectClipRect returned %d instead of SIMPLEREGION\n", ret); /* let's make sure that it's a simple region */ ret = GetClipRgn(hdc, hrgn); ok(ret == 1, "GetClipRgn returned %d instead of 1\n", ret); dump_region(hrgn); } else ok(ret == SIMPLEREGION, "IntersectClipRect returned %d instead of SIMPLEREGION\n", ret); ret = GetClipBox(hdc, &rc_clip); ok(ret == SIMPLEREGION, "GetClipBox returned %d instead of SIMPLEREGION\n", ret); SetRect(&rc, 0, 0, 50, 50); ok(EqualRect(&rc, &rc_clip), "rects are not equal\n"); ret = RestoreDC(hdc, 1); ok(ret, "ret = %d\n", ret); ret = GetClipBox(hdc, &rc_clip); ok(ret == SIMPLEREGION, "GetClipBox returned %d instead of SIMPLEREGION\n", ret); SetRect(&rc, 0, 0, 100, 100); ok(EqualRect(&rc, &rc_clip), "rects are not equal\n"); DeleteObject(hrgn); ReleaseDC(hwnd, hdc); DestroyWindow(hwnd); }
void Test_GetRandomRgn_RGN5() { HDC hdc; HRGN hrgn1, hrgn2; INT ret; RECT rect, rect2; HBITMAP hbmp; DBG_UNREFERENCED_LOCAL_VARIABLE(hrgn2); DBG_UNREFERENCED_LOCAL_VARIABLE(rect2); hrgn1 = CreateRectRgn(11, 17, 23, 42); if (!hrgn1) { printf("Coun't create a region\n"); return; } hdc = CreateCompatibleDC(0); if (!hdc) { printf("Coun't create a dc\n"); return; } #if 0 // this is vista+ ret = GetRandomRgn(hdc, hrgn1, RGN5); ok_int(ret, 1); GetRgnBox(hrgn1, &rect); ok_long(rect.left, 0); ok_long(rect.top, 0); ok_long(rect.right, 1); ok_long(rect.bottom, 1); hrgn2 = CreateRectRgn(1, 2, 3, 4); SelectClipRgn(hdc, hrgn2); DeleteObject(hrgn2); ret = GetRandomRgn(hdc, hrgn1, RGN5); ok_int(ret, 1); GetRgnBox(hrgn1, &rect); ok_long(rect.left, 0); ok_long(rect.top, 0); ok_long(rect.right, 1); ok_long(rect.bottom, 1); #endif hbmp = CreateCompatibleBitmap(hdc, 4, 7); SelectObject(hdc, hbmp); ret = GetRandomRgn(hdc, hrgn1, SYSRGN); ok_int(ret, 1); GetRgnBox(hrgn1, &rect); ok_long(rect.left, 0); ok_long(rect.top, 0); ok_long(rect.right, 4); ok_long(rect.bottom, 7); DeleteObject(hbmp); #if 0 // this is vista+ MoveWindow(ghwnd, 100, 100, 100, 100, 0); ret = GetRandomRgn(ghdcWindow, hrgn1, RGN5); ok_int(ret, 1); GetRgnBox(hrgn1, &rect); DPtoLP(ghdcWindow, (LPPOINT)&rect, 2); ok_long(rect.left, 104); ok_long(rect.top, 124); ok_long(rect.right, 209); ok_long(rect.bottom, 196); MoveWindow(ghwnd, 200, 400, 200, 200, 0); ret = GetRandomRgn(ghdcWindow, hrgn1, RGN5); ok_int(ret, 1); GetRgnBox(hrgn1, &rect2); DPtoLP(ghdcWindow, (LPPOINT)&rect2, 2); ok_long(rect2.left, rect.left + 100); ok_long(rect2.top, rect.top + 300); ok_long(rect2.right, rect.right + 200 - 13); ok_long(rect2.bottom, rect.bottom + 400); #endif DeleteObject(hrgn1); DeleteDC(hdc); }
void Test_GetRandomRgn_CLIPRGN() { HDC hdc; HRGN hrgn1, hrgn2; INT ret; RECT rect; hrgn1 = CreateRectRgn(11, 17, 23, 42); if (!hrgn1) { printf("Coun't create a region\n"); return; } hdc = CreateCompatibleDC(0); if (!hdc) { printf("Coun't create a dc\n"); return; } ret = GetRandomRgn(hdc, hrgn1, CLIPRGN); ok_int(ret, 0); GetRgnBox(hrgn1, &rect); ok_long(rect.left, 11); ok_long(rect.top, 17); ok_long(rect.right, 23); ok_long(rect.bottom, 42); hrgn2 = CreateRectRgn(1, 2, 3, 4); SelectClipRgn(hdc, hrgn2); DeleteObject(hrgn2); ret = GetRandomRgn(hdc, hrgn1, CLIPRGN); ok_int(ret, 1); GetRgnBox(hrgn1, &rect); ok_long(rect.left, 1); ok_long(rect.top, 2); ok_long(rect.right, 3); ok_long(rect.bottom, 4); hrgn2 = CreateRectRgn(2, 3, 4, 5); SelectClipRgn(ghdcWindow, hrgn2); DeleteObject(hrgn2); ret = GetRandomRgn(ghdcWindow, hrgn1, CLIPRGN); ok_int(ret, 1); GetRgnBox(hrgn1, &rect); ok_long(rect.left, 2); ok_long(rect.top, 3); ok_long(rect.right, 4); ok_long(rect.bottom, 5); MoveWindow(ghwnd, 200, 400, 100, 100, 0); ret = GetRandomRgn(ghdcWindow, hrgn1, CLIPRGN); ok_int(ret, 1); GetRgnBox(hrgn1, &rect); ok_long(rect.left, 2); ok_long(rect.top, 3); ok_long(rect.right, 4); ok_long(rect.bottom, 5); DeleteObject(hrgn1); DeleteDC(hdc); }
static void test_dc_layout(void) { INT ret, size_cx, size_cy, res_x, res_y, dpi_x, dpi_y; SIZE size; POINT pt; HBITMAP bitmap; RECT rc, ret_rc; HDC hdc; HRGN hrgn; if (!pGetLayout || !pSetLayout) { win_skip( "Don't have SetLayout\n" ); return; } hdc = CreateCompatibleDC(0); bitmap = CreateCompatibleBitmap( hdc, 100, 100 ); SelectObject( hdc, bitmap ); size_cx = GetDeviceCaps(hdc, HORZSIZE); size_cy = GetDeviceCaps(hdc, VERTSIZE); res_x = GetDeviceCaps(hdc, HORZRES); res_y = GetDeviceCaps(hdc, VERTRES); dpi_x = GetDeviceCaps(hdc, LOGPIXELSX); dpi_y = GetDeviceCaps(hdc, LOGPIXELSY); ret = GetMapMode( hdc ); ok(ret == MM_TEXT, "expected MM_TEXT, got %d\n", ret); expect_viewport_ext(hdc, 1, 1); expect_window_ext(hdc, 1, 1); expect_world_transform(hdc, 1.0, 1.0); expect_LPtoDP(hdc, 1000, 1000); pSetLayout( hdc, LAYOUT_RTL ); if (!pGetLayout( hdc )) { win_skip( "SetLayout not supported\n" ); DeleteDC(hdc); return; } ret = GetMapMode( hdc ); ok(ret == MM_ANISOTROPIC, "expected MM_ANISOTROPIC, got %d\n", ret); expect_viewport_ext(hdc, 1, 1); expect_window_ext(hdc, 1, 1); expect_world_transform(hdc, 1.0, 1.0); expect_LPtoDP(hdc, -1000 + 99, 1000); GetViewportOrgEx( hdc, &pt ); ok( pt.x == 0 && pt.y == 0, "wrong origin %d,%d\n", pt.x, pt.y ); GetWindowOrgEx( hdc, &pt ); ok( pt.x == 0 && pt.y == 0, "wrong origin %d,%d\n", pt.x, pt.y ); GetDCOrgEx( hdc, &pt ); ok( pt.x == 0 && pt.y == 0, "wrong origin %d,%d\n", pt.x, pt.y ); if (pGetTransform) { XFORM xform; BOOL ret = pGetTransform( hdc, 0x204, &xform ); /* World -> Device */ ok( ret, "got %d\n", ret ); ok( xform.eM11 == -1.0, "got %f\n", xform.eM11 ); ok( xform.eM12 == 0.0, "got %f\n", xform.eM12 ); ok( xform.eM21 == 0.0, "got %f\n", xform.eM21 ); ok( xform.eM22 == 1.0, "got %f\n", xform.eM22 ); ok( xform.eDx == 99.0, "got %f\n", xform.eDx ); ok( xform.eDy == 0.0, "got %f\n", xform.eDy ); } SetRect( &rc, 10, 10, 20, 20 ); IntersectClipRect( hdc, 10, 10, 20, 20 ); hrgn = CreateRectRgn( 0, 0, 0, 0 ); GetClipRgn( hdc, hrgn ); GetRgnBox( hrgn, &ret_rc ); ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom ); pSetLayout( hdc, LAYOUT_LTR ); SetRect( &rc, 80, 10, 90, 20 ); GetClipRgn( hdc, hrgn ); GetRgnBox( hrgn, &ret_rc ); ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom ); GetClipBox( hdc, &ret_rc ); ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom ); IntersectClipRect( hdc, 80, 10, 85, 20 ); pSetLayout( hdc, LAYOUT_RTL ); SetRect( &rc, 15, 10, 20, 20 ); GetClipRgn( hdc, hrgn ); GetRgnBox( hrgn, &ret_rc ); ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom ); GetClipBox( hdc, &ret_rc ); ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom ); SetRectRgn( hrgn, 60, 10, 80, 20 ); pSetLayout( hdc, LAYOUT_LTR ); ExtSelectClipRgn( hdc, hrgn, RGN_OR ); pSetLayout( hdc, LAYOUT_RTL ); SetRect( &rc, 15, 10, 40, 20 ); GetClipRgn( hdc, hrgn ); GetRgnBox( hrgn, &ret_rc ); ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom ); GetClipBox( hdc, &ret_rc ); ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom ); /* OffsetClipRgn mirrors too */ OffsetClipRgn( hdc, 5, 5 ); OffsetRect( &rc, 5, 5 ); GetClipRgn( hdc, hrgn ); GetRgnBox( hrgn, &ret_rc ); ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom ); /* GetRandomRgn returns the raw region */ if (pGetRandomRgn) { SetRect( &rc, 55, 15, 80, 25 ); pGetRandomRgn( hdc, hrgn, 1 ); GetRgnBox( hrgn, &ret_rc ); ok( EqualRect( &rc, &ret_rc ), "wrong clip box %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom ); } SetMapMode(hdc, MM_LOMETRIC); ret = GetMapMode( hdc ); ok(ret == MM_ANISOTROPIC, "expected MM_ANISOTROPIC, got %d\n", ret); expect_viewport_ext(hdc, res_x, -res_y); ok( GetWindowExtEx( hdc, &size ), "GetWindowExtEx failed\n" ); ok( rough_match( size.cx, size_cx * 10 ) || rough_match( size.cx, MulDiv( res_x, 254, dpi_x )), /* Vista uses a more precise method */ "expected cx %d or %d, got %d\n", size_cx * 10, MulDiv( res_x, 254, dpi_x ), size.cx ); ok( rough_match( size.cy, size_cy * 10 ) || rough_match( size.cy, MulDiv( res_y, 254, dpi_y )), /* Vista uses a more precise method */ "expected cy %d or %d, got %d\n", size_cy * 10, MulDiv( res_y, 254, dpi_y ), size.cy ); expect_world_transform(hdc, 1.0, 1.0); expect_LPtoDP(hdc, -MulDiv(1000 / 10, res_x, size_cx) + 99, -MulDiv(1000 / 10, res_y, size_cy)); SetMapMode(hdc, MM_TEXT); ret = GetMapMode( hdc ); ok(ret == MM_ANISOTROPIC, "expected MM_ANISOTROPIC, got %d\n", ret); pSetLayout( hdc, LAYOUT_LTR ); ret = GetMapMode( hdc ); ok(ret == MM_ANISOTROPIC, "expected MM_ANISOTROPIC, got %d\n", ret); SetMapMode(hdc, MM_TEXT); ret = GetMapMode( hdc ); ok(ret == MM_TEXT, "expected MM_TEXT, got %d\n", ret); DeleteDC(hdc); DeleteObject( bitmap ); }
static void test_GetRandomRgn(void) { HWND hwnd = CreateWindowExA(0,"BUTTON","test",WS_VISIBLE|WS_POPUP,0,0,100,100,GetDesktopWindow(),0,0,0); HDC hdc; HRGN hrgn = CreateRectRgn(0, 0, 0, 0); int ret; RECT rc, rc2; RECT ret_rc, window_rc; ok( hwnd != 0, "CreateWindow failed\n" ); SetRect(&window_rc, 400, 300, 500, 400); SetWindowPos(hwnd, HWND_TOPMOST, window_rc.left, window_rc.top, window_rc.right - window_rc.left, window_rc.bottom - window_rc.top, 0 ); hdc = GetDC(hwnd); ret = GetRandomRgn(hdc, hrgn, 1); ok(ret == 0, "GetRandomRgn rets %d\n", ret); ret = GetRandomRgn(hdc, hrgn, 2); ok(ret == 0, "GetRandomRgn rets %d\n", ret); ret = GetRandomRgn(hdc, hrgn, 3); ok(ret == 0, "GetRandomRgn rets %d\n", ret); /* Set a clip region */ SetRect(&rc, 20, 20, 80, 80); IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom); ret = GetRandomRgn(hdc, hrgn, 1); ok(ret != 0, "GetRandomRgn rets %d\n", ret); GetRgnBox(hrgn, &ret_rc); ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom); ret = GetRandomRgn(hdc, hrgn, 2); ok(ret == 0, "GetRandomRgn rets %d\n", ret); ret = GetRandomRgn(hdc, hrgn, 3); ok(ret != 0, "GetRandomRgn rets %d\n", ret); GetRgnBox(hrgn, &ret_rc); ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom); /* Move the clip to the meta and clear the clip */ SetMetaRgn(hdc); ret = GetRandomRgn(hdc, hrgn, 1); ok(ret == 0, "GetRandomRgn rets %d\n", ret); ret = GetRandomRgn(hdc, hrgn, 2); ok(ret != 0, "GetRandomRgn rets %d\n", ret); GetRgnBox(hrgn, &ret_rc); ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom); ret = GetRandomRgn(hdc, hrgn, 3); ok(ret != 0, "GetRandomRgn rets %d\n", ret); GetRgnBox(hrgn, &ret_rc); ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom); /* Set a new clip (still got the meta) */ SetRect(&rc2, 10, 30, 70, 90); IntersectClipRect(hdc, rc2.left, rc2.top, rc2.right, rc2.bottom); ret = GetRandomRgn(hdc, hrgn, 1); ok(ret != 0, "GetRandomRgn rets %d\n", ret); GetRgnBox(hrgn, &ret_rc); ok(EqualRect(&rc2, &ret_rc), "GetRandomRgn %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom); ret = GetRandomRgn(hdc, hrgn, 2); ok(ret != 0, "GetRandomRgn rets %d\n", ret); GetRgnBox(hrgn, &ret_rc); ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom); IntersectRect(&rc2, &rc, &rc2); ret = GetRandomRgn(hdc, hrgn, 3); ok(ret != 0, "GetRandomRgn rets %d\n", ret); GetRgnBox(hrgn, &ret_rc); ok(EqualRect(&rc2, &ret_rc), "GetRandomRgn %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom); ret = GetRandomRgn(hdc, hrgn, SYSRGN); ok(ret != 0, "GetRandomRgn rets %d\n", ret); GetRgnBox(hrgn, &ret_rc); if(GetVersion() & 0x80000000) OffsetRect(&window_rc, -window_rc.left, -window_rc.top); /* the window may be partially obscured so the region may be smaller */ IntersectRect( &window_rc, &ret_rc, &ret_rc ); ok(EqualRect(&window_rc, &ret_rc) || broken(IsRectEmpty(&ret_rc)), /* win95 */ "GetRandomRgn %d,%d - %d,%d\n", ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom); DeleteObject(hrgn); ReleaseDC(hwnd, hdc); DestroyWindow(hwnd); }