static void test_SetViewportExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy) { SIZE windowExt, windowExtAfter, viewportExt; POINT windowOrg, windowOrgAfter, viewportOrg, viewportOrgAfter; GetWindowOrgEx(hdc, &windowOrg); GetViewportOrgEx(hdc, &viewportOrg); GetWindowExtEx(hdc, &windowExt); SetViewportExtEx(hdc, cx, cy, NULL); GetViewportExtEx(hdc, &viewportExt); ok(rough_match(viewportExt.cx, expected_vp_cx) && rough_match(viewportExt.cy, expected_vp_cy), "Viewport extents have not been properly adjusted: Expected %dx%d, got %dx%d\n", expected_vp_cx, expected_vp_cy, viewportExt.cx, viewportExt.cy); GetWindowExtEx(hdc, &windowExtAfter); ok(windowExt.cx == windowExtAfter.cx && windowExt.cy == windowExtAfter.cy, "Window extension changed from %dx%d to %dx%d\n", windowExt.cx, windowExt.cy, windowExtAfter.cx, windowExtAfter.cy); GetWindowOrgEx(hdc, &windowOrgAfter); ok(windowOrg.x == windowOrgAfter.x && windowOrg.y == windowOrgAfter.y, "Window origin changed from (%d,%d) to (%d,%d)\n", windowOrg.x, windowOrg.y, windowOrgAfter.x, windowOrgAfter.y); GetViewportOrgEx(hdc, &viewportOrgAfter); ok(viewportOrg.x == viewportOrgAfter.x && viewportOrg.y == viewportOrgAfter.y, "Viewport origin changed from (%d,%d) to (%d,%d)\n", viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y); }
Rect GetWindow(HDC hdc) { Point pt; Size sz; GetWindowOrgEx(hdc, pt); GetWindowExtEx(hdc, sz); return Rect(pt, sz); }
void CDrawContext::SetClipRect( const CRect &rc ) { HRGN hrgn = CreateRectRgnIndirect( &rc ); ::SelectClipRgn( m_hdc, hrgn ); POINT pt; GetWindowOrgEx( m_hdc, &pt ); OffsetClipRgn( m_hdc, -pt.x, -pt.y ); VAPI( ::DeleteObject( hrgn ) ); }
HDC TextViewMetrics::ClientToText( HDC hdc, POINT* oldOrigin ) const { POINT clientOrigin = { 0, 0 }; clientOrigin = ClientToText( clientOrigin ); GetWindowOrgEx( hdc, oldOrigin ); SetWindowOrgEx( hdc, oldOrigin->x + clientOrigin.x, oldOrigin->y + clientOrigin.y, oldOrigin ); return hdc; }
BOOL FAR PASCAL MGetWindowOrg(HDC hdc, INT FAR * px, INT FAR * py) { DWORD dwSize; dwSize = GetWindowOrgEx(hdc); if (px != NULL) *px = (INT)LOWORD(dwSize); if (py != NULL) *py = (INT)HIWORD(dwSize); return(TRUE); }
void ExecutionLogWindow::PaintContent(HWND hwnd, PAINTSTRUCT* pps) { POINT ptOrgPrev; OffsetRect(&pps->rcPaint, 0, m_yOrigin * m_cyLine); GetWindowOrgEx(pps->hdc, &ptOrgPrev); SetWindowOrgEx(pps->hdc, ptOrgPrev.x, ptOrgPrev.y + m_yOrigin * m_cyLine, NULL); PaintSimpleContent(hwnd, pps); SetWindowOrgEx(pps->hdc, ptOrgPrev.x, ptOrgPrev.y, NULL); }
BOOL CALLBACK ProgressProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ switch(message) { case WM_INITDIALOG: SetCursor(LoadCursor(NULL,IDC_WAIT)); rcContext.hProgressWnd=hWnd; SetWindowLong(GetDlgItem(hWnd,IDC_STATIC1),GWL_WNDPROC,(LONG)Static1WndProc); hWndGif= GetDlgItem(hWnd,IDC_STATIC2); if (hWndGif) { m_wndBanner.SubclassWindow(hWndGif); if (m_wndBanner.Load(MAKEINTRESOURCE(IDR_BUSY),_T("GIF"))){ m_wndBanner.Draw(); } }; SetCursor(LoadCursor(NULL,IDC_ARROW)); return TRUE; case WM_ERASEBKGND: { RECT bgRect; GetWindowRect(hWnd,&bgRect); HRGN bgRgn=CreateRectRgnIndirect(&bgRect); HWND hIDC1=GetDlgItem(hWnd,IDC_STATIC1); RECT idc1Rect; GetWindowRect(hIDC1,&idc1Rect); HRGN idc1Rgn=CreateRectRgnIndirect(&idc1Rect); if (!CombineRgn(bgRgn, bgRgn,idc1Rgn, RGN_XOR)) return FALSE; HBRUSH hBrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE)); POINT pt; HDC hdc=(HDC)wParam; GetWindowOrgEx(hdc,&pt); SetWindowOrgEx(hdc,bgRect.left,bgRect.top,NULL); FillRgn(hdc,bgRgn,hBrush); SetWindowOrgEx(hdc,pt.x,pt.y,NULL); DeleteObject(hBrush); } return FALSE; case WM_CTLCOLORSTATIC: SetBkMode((HDC)wParam,TRANSPARENT); return (BOOL)GetStockObject(NULL_BRUSH); case WM_DESTROY: SetCursor(LoadCursor(NULL,IDC_WAIT)); CloseHandle(rcContext.hThread); rcContext.hProgressWnd=0; EndDialog(hWnd,0); SetCursor(LoadCursor(NULL,IDC_ARROW)); return TRUE; default: return FALSE; } }
BOOL EMFDRV_OffsetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) { PHYSDEV next = GET_NEXT_PHYSDEV( dev, pOffsetWindowOrgEx ); EMRSETWINDOWORGEX emr; POINT prev; GetWindowOrgEx( dev->hdc, &prev ); emr.emr.iType = EMR_SETWINDOWORGEX; emr.emr.nSize = sizeof(emr); emr.ptlOrigin.x = prev.x + x; emr.ptlOrigin.y = prev.y + y; if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE; return next->funcs->pOffsetWindowOrgEx( next, x, y, pt ); }
BOOL CDECL EMFDRV_OffsetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) { PHYSDEV next = GET_NEXT_PHYSDEV( dev, pOffsetWindowOrgEx ); EMRSETWINDOWORGEX emr; EMFDRV_PDEVICE* physDev = (EMFDRV_PDEVICE*)dev; GetWindowOrgEx(physDev->hdc, pt); emr.emr.iType = EMR_SETWINDOWORGEX; emr.emr.nSize = sizeof(emr); emr.ptlOrigin.x = pt->x + x; emr.ptlOrigin.y = pt->y + y; if (!EMFDRV_WriteRecord( dev, &emr.emr )) return 0; return next->funcs->pOffsetWindowOrgEx( next, x, y, pt ); }
void WinMoveRectangle (int left, int top, int right, int bot, int dx, int dy, OSPictContext context) { int w, h; HWND hwnd; hwnd = WindowFromDC (context->hDC); if (hwnd != NULL) { RECT r; POINT p; GetClientRect (hwnd, &r); GetWindowOrgEx (context->hDC, &p); left = max (left, r.left + p.x); top = max (top, r.top + p.y); right = min (right, r.right + p.x); bot = min (bot, r.bottom + p.y); } w = right - left; h = bot - top; WinCopyRectangle (left, top, right, bot, dx, dy, context); StartErasing (context); if (dx > w || dy > h) { Rectangle (context->hDC, left, top, right + 1, bot + 1); return; } if (dx < 0) Rectangle (context->hDC, right - dx, top, right + 1, bot + 1); else Rectangle (context->hDC, left, top, left + dx + 1, bot + 1); if (dy < 0) Rectangle (context->hDC, left, bot - dy, right + 1, bot + 1); else Rectangle (context->hDC, left, top, right + 1, top + dy + 1); } /* WinMoveRectangle */
void CToolbarWnd::OnPaint( simpledib::dib* dib, LPRECT rcDraw ) { if(m_doc) { cairo_surface_t* surface = cairo_image_surface_create_for_data((unsigned char*) dib->bits(), CAIRO_FORMAT_ARGB32, dib->width(), dib->height(), dib->width() * 4); cairo_t* cr = cairo_create(surface); POINT pt; GetWindowOrgEx(dib->hdc(), &pt); if(pt.x != 0 || pt.y != 0) { cairo_translate(cr, -pt.x, -pt.y); } cairo_set_source_rgb(cr, 1, 1, 1); cairo_paint(cr); litehtml::position clip(rcDraw->left, rcDraw->top, rcDraw->right - rcDraw->left, rcDraw->bottom - rcDraw->top); m_doc->draw((litehtml::uint_ptr) cr, 0, 0, &clip); cairo_destroy(cr); cairo_surface_destroy(surface); } }
static void DoTestEntry(HDC hDC, const TEST_ENTRY *entry) { POINT pt, ptWnd, ptView; SIZE siz, sizWnd, sizView; INT ret; SetMapMode(hDC, entry->nMapMode); ret = SetWindowOrgEx(hDC, entry->preset.xWnd, entry->preset.yWnd, NULL); ok(ret == TRUE, "Line %d: SetWindowOrgEx failed\n", entry->lineno); ret = SetWindowExtEx(hDC, entry->preset.cxWnd, entry->preset.cyWnd, NULL); ok(ret == entry->bWndExt, "Line %d: SetWindowExtEx() expected %d, was %d\n", entry->lineno, entry->bWndExt, ret); ret = SetViewportOrgEx(hDC, entry->preset.xView, entry->preset.yView, NULL); ok(ret == TRUE, "Line %d: SetViewportOrgEx failed\n", entry->lineno); ret = SetViewportExtEx(hDC, entry->preset.cxView, entry->preset.cyView, NULL); ok(ret == TRUE, "Line %d: SetViewportExtEx failed\n", entry->lineno); ok(GetWindowOrgEx(hDC, &pt) == TRUE, "Line %d: GetWindowOrgEx failed\n", entry->lineno); ptWnd = pt; ok(GetWindowExtEx(hDC, &siz) == TRUE, "Line %d: GetWindowExtEx failed\n", entry->lineno); sizWnd = siz; ok(pt.x == entry->xWndOut && pt.y == entry->yWndOut, "Line %d: Window org expected (%ld, %ld), was (%ld, %ld)\n", entry->lineno, entry->xWndOut, entry->yWndOut, pt.x, pt.y); if (entry->cxWndOut == DISPLAY_SIZE || entry->cxWndOut == NEGA_DISPLAY_SIZE) { LONG cx = GetDeviceCaps(hDC, HORZRES); LONG cy = GetDeviceCaps(hDC, VERTRES); if (entry->cxWndOut == NEGA_DISPLAY_SIZE) cx = -cx; if (entry->cyWndOut == NEGA_DISPLAY_SIZE) cy = -cy; ok(siz.cx == cx && siz.cy == cy, "Line %d: Window ext expected display size (%ld, %ld), was (%ld, %ld)\n", entry->lineno, cx, cy, siz.cx, siz.cy); } else if (entry->cxWndOut != NO_CHECK) { ok(siz.cx == entry->cxWndOut && siz.cy == entry->cyWndOut, "Line %d: Window ext expected (%ld, %ld), was (%ld, %ld)\n", entry->lineno, entry->cxWndOut, entry->cyWndOut, siz.cx, siz.cy); } ok(GetViewportOrgEx(hDC, &pt) == TRUE, "Line %d: GetViewportOrgEx failed\n", entry->lineno); ptView = pt; ok(GetViewportExtEx(hDC, &siz) == TRUE, "Line %d: GetViewportExtEx failed\n", entry->lineno); sizView = siz; ok(pt.x == entry->xViewOut && pt.y == entry->yViewOut, "Line %d: Viewport org expected (%ld, %ld), was (%ld, %ld)\n", entry->lineno, entry->xViewOut , entry->yViewOut, pt.x, pt.y); if (entry->cxViewOut == DISPLAY_SIZE || entry->cxViewOut == NEGA_DISPLAY_SIZE) { LONG cx = GetDeviceCaps(hDC, HORZRES); LONG cy = GetDeviceCaps(hDC, VERTRES); if (entry->cxViewOut == NEGA_DISPLAY_SIZE) cx = -cx; if (entry->cyViewOut == NEGA_DISPLAY_SIZE) cy = -cy; ok(siz.cx == cx && siz.cy == cy, "Line %d: Viewport ext expected display size (%ld, %ld), was (%ld, %ld)\n", entry->lineno, cx, cy, siz.cx, siz.cy); } else if (entry->cxViewOut != NO_CHECK) { ok(siz.cx == entry->cxViewOut && siz.cy == entry->cyViewOut, "Line %d: Viewport ext expected (%ld, %ld), was (%ld, %ld)\n", entry->lineno, entry->cxViewOut, entry->cyViewOut, siz.cx, siz.cy); } pt = entry->ptSrc; SetLastError(0xDEADBEEF); ret = LPtoDP(hDC, &pt, 1); ok(ret == entry->ret, "Line %d: LPtoDP() expected %d, was %d\n", entry->lineno, entry->ret, ret); ok(GetLastError() == entry->error, "Line %d: GetLastError() expected %ld, was %ld\n", entry->lineno, entry->error, GetLastError()); if (entry->ptDest.x == CALC_VALUE_1) { LONG x = MulDiv(entry->ptSrc.x - ptWnd.x, sizView.cx, sizWnd.cx) + ptView.x; LONG y = MulDiv(entry->ptSrc.y - ptWnd.y, sizView.cy, sizWnd.cy) + ptView.y; // TODO: make more accurate ok(labs(pt.x - x) <= 1 && labs(pt.y - y) <= 1, "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n", entry->lineno, x, y, pt.x, pt.y); } else if (entry->ptDest.x == CALC_VALUE_2) { XFORM xform; LONG x, y; SetXForm1(&xform); x = (LONG)((xform.eM11 * entry->ptSrc.x + xform.eM12 * entry->ptSrc.y) + xform.eDx); y = (LONG)((xform.eM21 * entry->ptSrc.x + xform.eM22 * entry->ptSrc.y) + xform.eDy); x = MulDiv(x - ptWnd.x, sizView.cx, sizWnd.cx) + ptView.x; y = MulDiv(y - ptWnd.y, sizView.cy, sizWnd.cy) + ptView.y; // TODO: make more accurate ok(labs(pt.x - x) <= 1 && labs(pt.y - y) <= 1, "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n", entry->lineno, x, y, pt.x, pt.y); } else if (entry->ptDest.x == CALC_VALUE_3) { XFORM xform; LONG x, y; SetXForm2(&xform); x = (LONG)((xform.eM11 * entry->ptSrc.x + xform.eM12 * entry->ptSrc.y) + xform.eDx); y = (LONG)((xform.eM21 * entry->ptSrc.x + xform.eM22 * entry->ptSrc.y) + xform.eDy); x = MulDiv(x - ptWnd.x, sizView.cx, sizWnd.cx) + ptView.x; y = MulDiv(y - ptWnd.y, sizView.cy, sizWnd.cy) + ptView.y; // TODO: make more accurate ok(labs(pt.x - x) <= 2 && labs(pt.y - y) <= 2, "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n", entry->lineno, x, y, pt.x, pt.y); } else if (entry->ptDest.x != NO_CHECK) { ok(pt.x == entry->ptDest.x && pt.y == entry->ptDest.y, "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n", entry->lineno, entry->ptDest.x, entry->ptDest.y, pt.x, pt.y); } }
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 ); }
void KDCAttributes::DumpDC(HDC hDC) { POINT pnt; SIZE size; m_List.DeleteAll(); Add(_T("Technology"), _T("%d"), GetDeviceCaps(hDC, TECHNOLOGY)); Add(_T("width"), _T("%d"), GetDeviceCaps(hDC, HORZRES)); Add(_T("height"), _T("%d"), GetDeviceCaps(hDC, VERTRES)); GetDCOrgEx(hDC, & pnt); Add(_T("DC Origin"), _T("{ %d, %d }"), pnt.x, pnt.y); TCHAR szTitle[MAX_PATH]; szTitle[0] = 0; GetWindowText(WindowFromDC(hDC), szTitle, MAX_PATH); Add(_T("Window"), _T("0x%X \"%s\""), WindowFromDC(hDC), szTitle); Add(_T("Bitmap"), _T("0x%X"), GetCurrentObject(hDC, OBJ_BITMAP)); Add(_T("Graphics Mode"), _T("%d"), GetGraphicsMode(hDC)); Add(_T("Mapping Mode"), _T("%d"), GetMapMode(hDC)); GetViewportExtEx(hDC, & size); Add(_T("Viewport Extent"), _T("{ %d, %d }"), size.cx, size.cy); GetViewportOrgEx(hDC, & pnt); Add(_T("Viewport Origin"), _T("{ %d, %d }"), pnt.x, pnt.y); GetWindowExtEx(hDC, & size); Add(_T("Window Extent"), _T("{ %d, %d }"), size.cx, size.cy); GetWindowOrgEx(hDC, & pnt); Add(_T("Window Origin"), _T("{ %d, %d }"), pnt.x, pnt.y); XFORM xform; GetWorldTransform(hDC, & xform); Add(_T("World transformation"), _T("{ %f, %f, %f, %f, %f, %f }"), xform.eM11, xform.eM12, xform.eM21, xform.eM22, xform.eDx, xform.eDy); // transformation Add(_T("Background Color"), _T("0x%X"), GetBkColor(hDC)); Add(_T("Text Color"), _T("0x%X"), GetTextColor(hDC)); Add(_T("Palette"), _T("0x%X"), GetCurrentObject(hDC, OBJ_PAL)); { COLORADJUSTMENT ca; GetColorAdjustment(hDC, & ca); Add(_T("Color Adjustment"), _T("{ %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d }"), ca.caSize, ca.caFlags, ca.caIlluminantIndex, ca.caRedGamma, ca.caGreenGamma, ca.caBlueGamma, ca.caReferenceBlack, ca.caReferenceWhite, ca.caContrast, ca.caBrightness, ca.caColorfulness, ca.caRedGreenTint); } Add(_T("Color Space"), _T("0x%X"), GetColorSpace(hDC)); Add(_T("ICM Mode"), _T("%d"), SetICMMode(hDC, ICM_QUERY)); { TCHAR szProfile[MAX_PATH]; DWORD dwSize = MAX_PATH; szProfile[0] = 0; GetICMProfile(hDC, & dwSize, szProfile); Add(_T("ICM Profile"), _T("%s"), szProfile); } GetCurrentPositionEx(hDC, & pnt); Add(_T("Current Position"), _T("{ %d, %d }"), pnt.x, pnt.y); Add(_T("ROP2"), _T("%d"), GetROP2(hDC)); Add(_T("Background Mode"), _T("%d"), GetBkMode(hDC)); Add(_T("Logical Pen"), _T("0x%X"), GetCurrentObject(hDC, OBJ_PEN)); Add(_T("DC Pen Color"), _T("0x%X"), GetDCPenColor(hDC)); Add(_T("Arc Direction"), _T("%d"), GetArcDirection(hDC)); FLOAT miter; GetMiterLimit(hDC, & miter); Add(_T("Miter Limit"), _T("%f"), miter); Add(_T("Logical Brush"), _T("0x%X"), GetCurrentObject(hDC, OBJ_BRUSH)); Add(_T("DC Brush Color"), _T("0x%X"), GetDCBrushColor(hDC)); GetBrushOrgEx(hDC, & pnt); Add(_T("Brush Origin"), _T("{ %d, %d }"), pnt.x, pnt.y); Add(_T("Polygon Filling Mode"), _T("%d"), GetPolyFillMode(hDC)); Add(_T("Bitmap Stretching Mode"), _T("%d"), GetStretchBltMode(hDC)); Add(_T("Logical Font"), _T("0x%X"), GetCurrentObject(hDC, OBJ_FONT)); Add(_T("Inter-character spacing"), _T("%d"), GetTextCharacterExtra(hDC)); DWORD flag = SetMapperFlags(hDC, 0); SetMapperFlags(hDC, flag); Add(_T("Font Mapper Flags"), _T("0x%X"), flag); Add(_T("Text Alignment"), _T("0x%X"), GetTextAlign(hDC)); Add(_T("Text Justification"), _T("write only"), 0); Add(_T("Layout"), _T("%d"), GetLayout(hDC)); Add(_T("Path"), _T("%d bytes"), GetPath(hDC, NULL, NULL, 0)); RECT rect; int typ = GetClipBox(hDC, & rect); HRGN hRgn = CreateRectRgn(0, 0, 1, 1); GetClipRgn(hDC, hRgn); Add(_T("Clipping"), _T("type %d clip box { %d, %d, %d, %d } size %d bytes"), typ, rect.left, rect.top, rect.right, rect.bottom, GetRegionData(hRgn, 0, NULL) ); GetMetaRgn(hDC, hRgn); GetRgnBox(hRgn, & rect); Add(_T("Meta Region"), _T("size %d bytes, rgn box { %d, %d, %d, %d }"), GetRegionData(hRgn, 0, NULL), rect.left, rect.top, rect.right, rect.bottom); for (int i=1; i<=5; i++) { int rslt = GetRandomRgn(hDC, hRgn, i); if ( rslt==1 ) { GetRgnBox(hRgn, & rect); Add(_T("Random Region"), _T("size %d bytes, rgn box { %d, %d, %d, %d }"), GetRegionData(hRgn, 0, NULL), rect.left, rect.top, rect.right, rect.bottom); } else if ( rslt==0 ) Add(_T("Random Region"), _T("NULL"), 0); else Add(_T("Random Region"), _T("FAIL"), 0); } DeleteObject(hRgn); GetBoundsRect(hDC, & rect, 0); Add(_T("Bounds Rectangle"), _T("{ %d, %d, %d, %d }"), rect.left, rect.top, rect.right, rect.bottom); }