2 * GDI Device Context functions
4 * Copyright 1993 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #include "wine/winuser16.h"
35 #include "gdi_private.h"
36 #include "wine/unicode.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(dc
);
41 static BOOL
DC_DeleteObject( HGDIOBJ handle
, void *obj
);
43 static const struct gdi_obj_funcs dc_funcs
=
45 NULL
, /* pSelectObject */
46 NULL
, /* pGetObject16 */
47 NULL
, /* pGetObjectA */
48 NULL
, /* pGetObjectW */
49 NULL
, /* pUnrealizeObject */
50 DC_DeleteObject
/* pDeleteObject */
53 /***********************************************************************
56 DC
*DC_AllocDC( const DC_FUNCTIONS
*funcs
, WORD magic
)
61 if (!(dc
= GDI_AllocObject( sizeof(*dc
), magic
, (HGDIOBJ
*)&hdc
, &dc_funcs
))) return NULL
;
81 dc
->hPen
= GetStockObject( BLACK_PEN
);
82 dc
->hBrush
= GetStockObject( WHITE_BRUSH
);
83 dc
->hFont
= GetStockObject( SYSTEM_FONT
);
86 dc
->hPalette
= GetStockObject( DEFAULT_PALETTE
);
88 dc
->ROPmode
= R2_COPYPEN
;
89 dc
->polyFillMode
= ALTERNATE
;
90 dc
->stretchBltMode
= BLACKONWHITE
;
91 dc
->relAbsMode
= ABSOLUTE
;
92 dc
->backgroundMode
= OPAQUE
;
93 dc
->backgroundColor
= RGB( 255, 255, 255 );
94 dc
->dcBrushColor
= RGB( 255, 255, 255 );
95 dc
->dcPenColor
= RGB( 0, 0, 0 );
96 dc
->textColor
= RGB( 0, 0, 0 );
99 dc
->textAlign
= TA_LEFT
| TA_TOP
| TA_NOUPDATECP
;
104 dc
->MapMode
= MM_TEXT
;
105 dc
->GraphicsMode
= GM_COMPATIBLE
;
106 dc
->pAbortProc
= NULL
;
109 dc
->ArcDirection
= AD_COUNTERCLOCKWISE
;
110 dc
->xformWorld2Wnd
.eM11
= 1.0f
;
111 dc
->xformWorld2Wnd
.eM12
= 0.0f
;
112 dc
->xformWorld2Wnd
.eM21
= 0.0f
;
113 dc
->xformWorld2Wnd
.eM22
= 1.0f
;
114 dc
->xformWorld2Wnd
.eDx
= 0.0f
;
115 dc
->xformWorld2Wnd
.eDy
= 0.0f
;
116 dc
->xformWorld2Vport
= dc
->xformWorld2Wnd
;
117 dc
->xformVport2World
= dc
->xformWorld2Wnd
;
118 dc
->vport2WorldValid
= TRUE
;
119 PATH_InitGdiPath(&dc
->path
);
125 /***********************************************************************
128 DC
*DC_GetDCPtr( HDC hdc
)
130 GDIOBJHDR
*ptr
= GDI_GetObjPtr( hdc
, MAGIC_DONTCARE
);
131 if (!ptr
) return NULL
;
132 if ((GDIMAGIC(ptr
->wMagic
) == DC_MAGIC
) ||
133 (GDIMAGIC(ptr
->wMagic
) == MEMORY_DC_MAGIC
) ||
134 (GDIMAGIC(ptr
->wMagic
) == METAFILE_DC_MAGIC
) ||
135 (GDIMAGIC(ptr
->wMagic
) == ENHMETAFILE_DC_MAGIC
))
137 GDI_ReleaseObj( hdc
);
138 SetLastError( ERROR_INVALID_HANDLE
);
142 /***********************************************************************
145 * Retrieve a DC ptr while making sure the visRgn is updated.
146 * This function may call up to USER so the GDI lock should _not_
147 * be held when calling it.
149 DC
*DC_GetDCUpdate( HDC hdc
)
151 DC
*dc
= DC_GetDCPtr( hdc
);
152 if (!dc
) return NULL
;
153 while (dc
->flags
& DC_DIRTY
)
155 DCHOOKPROC proc
= dc
->hookThunk
;
156 dc
->flags
&= ~DC_DIRTY
;
159 DWORD data
= dc
->dwHookData
;
160 GDI_ReleaseObj( hdc
);
161 proc( HDC_16(hdc
), DCHC_INVALIDVISRGN
, data
, 0 );
162 if (!(dc
= DC_GetDCPtr( hdc
))) break;
163 /* otherwise restart the loop in case it became dirty again in the meantime */
170 /***********************************************************************
173 static BOOL
DC_DeleteObject( HGDIOBJ handle
, void *obj
)
175 GDI_ReleaseObj( handle
);
176 return DeleteDC( handle
);
180 /***********************************************************************
183 * Setup device-specific DC values for a newly created DC.
185 void DC_InitDC( DC
* dc
)
187 if (dc
->funcs
->pRealizeDefaultPalette
) dc
->funcs
->pRealizeDefaultPalette( dc
->physDev
);
188 SetTextColor( dc
->hSelf
, dc
->textColor
);
189 SetBkColor( dc
->hSelf
, dc
->backgroundColor
);
190 SelectObject( dc
->hSelf
, dc
->hPen
);
191 SelectObject( dc
->hSelf
, dc
->hBrush
);
192 SelectObject( dc
->hSelf
, dc
->hFont
);
193 CLIPPING_UpdateGCRegion( dc
);
197 /***********************************************************************
200 * Computes the inverse of the transformation xformSrc and stores it to
201 * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix
204 static BOOL
DC_InvertXform( const XFORM
*xformSrc
, XFORM
*xformDest
)
208 determinant
= xformSrc
->eM11
*xformSrc
->eM22
-
209 xformSrc
->eM12
*xformSrc
->eM21
;
210 if (determinant
> -1e-12 && determinant
< 1e-12)
213 xformDest
->eM11
= xformSrc
->eM22
/ determinant
;
214 xformDest
->eM12
= -xformSrc
->eM12
/ determinant
;
215 xformDest
->eM21
= -xformSrc
->eM21
/ determinant
;
216 xformDest
->eM22
= xformSrc
->eM11
/ determinant
;
217 xformDest
->eDx
= -xformSrc
->eDx
* xformDest
->eM11
-
218 xformSrc
->eDy
* xformDest
->eM21
;
219 xformDest
->eDy
= -xformSrc
->eDx
* xformDest
->eM12
-
220 xformSrc
->eDy
* xformDest
->eM22
;
226 /***********************************************************************
229 * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid
230 * fields of the specified DC by creating a transformation that
231 * represents the current mapping mode and combining it with the DC's
232 * world transform. This function should be called whenever the
233 * parameters associated with the mapping mode (window and viewport
234 * extents and origins) or the world transform change.
236 void DC_UpdateXforms( DC
*dc
)
238 XFORM xformWnd2Vport
, oldworld2vport
;
239 FLOAT scaleX
, scaleY
;
241 /* Construct a transformation to do the window-to-viewport conversion */
242 scaleX
= (FLOAT
)dc
->vportExtX
/ (FLOAT
)dc
->wndExtX
;
243 scaleY
= (FLOAT
)dc
->vportExtY
/ (FLOAT
)dc
->wndExtY
;
244 xformWnd2Vport
.eM11
= scaleX
;
245 xformWnd2Vport
.eM12
= 0.0;
246 xformWnd2Vport
.eM21
= 0.0;
247 xformWnd2Vport
.eM22
= scaleY
;
248 xformWnd2Vport
.eDx
= (FLOAT
)dc
->vportOrgX
-
249 scaleX
* (FLOAT
)dc
->wndOrgX
;
250 xformWnd2Vport
.eDy
= (FLOAT
)dc
->vportOrgY
-
251 scaleY
* (FLOAT
)dc
->wndOrgY
;
253 oldworld2vport
= dc
->xformWorld2Vport
;
254 /* Combine with the world transformation */
255 CombineTransform( &dc
->xformWorld2Vport
, &dc
->xformWorld2Wnd
,
258 /* Create inverse of world-to-viewport transformation */
259 dc
->vport2WorldValid
= DC_InvertXform( &dc
->xformWorld2Vport
,
260 &dc
->xformVport2World
);
262 /* Reselect the font back into the dc so that the font size
264 if(memcmp(&oldworld2vport
, &dc
->xformWorld2Vport
, sizeof(oldworld2vport
)))
265 SelectObject(dc
->hSelf
, GetCurrentObject(dc
->hSelf
, OBJ_FONT
));
269 /***********************************************************************
270 * GetDCState (Not a Windows API)
272 HDC WINAPI
GetDCState( HDC hdc
)
277 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
278 if (!(newdc
= GDI_AllocObject( sizeof(DC
), GDIMAGIC(dc
->header
.wMagic
), &handle
, &dc_funcs
)))
280 GDI_ReleaseObj( hdc
);
283 TRACE("(%p): returning %p\n", hdc
, handle
);
285 newdc
->flags
= dc
->flags
| DC_SAVED
;
286 newdc
->hPen
= dc
->hPen
;
287 newdc
->hBrush
= dc
->hBrush
;
288 newdc
->hFont
= dc
->hFont
;
289 newdc
->hBitmap
= dc
->hBitmap
;
290 newdc
->hDevice
= dc
->hDevice
;
291 newdc
->hPalette
= dc
->hPalette
;
292 newdc
->ROPmode
= dc
->ROPmode
;
293 newdc
->polyFillMode
= dc
->polyFillMode
;
294 newdc
->stretchBltMode
= dc
->stretchBltMode
;
295 newdc
->relAbsMode
= dc
->relAbsMode
;
296 newdc
->backgroundMode
= dc
->backgroundMode
;
297 newdc
->backgroundColor
= dc
->backgroundColor
;
298 newdc
->textColor
= dc
->textColor
;
299 newdc
->dcBrushColor
= dc
->dcBrushColor
;
300 newdc
->dcPenColor
= dc
->dcPenColor
;
301 newdc
->brushOrgX
= dc
->brushOrgX
;
302 newdc
->brushOrgY
= dc
->brushOrgY
;
303 newdc
->textAlign
= dc
->textAlign
;
304 newdc
->charExtra
= dc
->charExtra
;
305 newdc
->breakCount
= dc
->breakCount
;
306 newdc
->breakExtra
= dc
->breakExtra
;
307 newdc
->breakRem
= dc
->breakRem
;
308 newdc
->MapMode
= dc
->MapMode
;
309 newdc
->GraphicsMode
= dc
->GraphicsMode
;
310 newdc
->CursPosX
= dc
->CursPosX
;
311 newdc
->CursPosY
= dc
->CursPosY
;
312 newdc
->ArcDirection
= dc
->ArcDirection
;
313 newdc
->xformWorld2Wnd
= dc
->xformWorld2Wnd
;
314 newdc
->xformWorld2Vport
= dc
->xformWorld2Vport
;
315 newdc
->xformVport2World
= dc
->xformVport2World
;
316 newdc
->vport2WorldValid
= dc
->vport2WorldValid
;
317 newdc
->wndOrgX
= dc
->wndOrgX
;
318 newdc
->wndOrgY
= dc
->wndOrgY
;
319 newdc
->wndExtX
= dc
->wndExtX
;
320 newdc
->wndExtY
= dc
->wndExtY
;
321 newdc
->vportOrgX
= dc
->vportOrgX
;
322 newdc
->vportOrgY
= dc
->vportOrgY
;
323 newdc
->vportExtX
= dc
->vportExtX
;
324 newdc
->vportExtY
= dc
->vportExtY
;
326 newdc
->hSelf
= (HDC
)handle
;
327 newdc
->saveLevel
= 0;
329 PATH_InitGdiPath( &newdc
->path
);
331 newdc
->pAbortProc
= NULL
;
332 newdc
->hookThunk
= NULL
;
335 /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
340 newdc
->hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
341 CombineRgn( newdc
->hClipRgn
, dc
->hClipRgn
, 0, RGN_COPY
);
347 newdc
->gdiFont
= dc
->gdiFont
;
351 GDI_ReleaseObj( handle
);
352 GDI_ReleaseObj( hdc
);
357 /***********************************************************************
358 * SetDCState (Not a Windows API)
360 void WINAPI
SetDCState( HDC hdc
, HDC hdcs
)
364 if (!(dc
= DC_GetDCUpdate( hdc
))) return;
365 if (!(dcs
= DC_GetDCPtr( hdcs
)))
367 GDI_ReleaseObj( hdc
);
370 if (!dcs
->flags
& DC_SAVED
)
372 GDI_ReleaseObj( hdc
);
373 GDI_ReleaseObj( hdcs
);
376 TRACE("%p %p\n", hdc
, hdcs
);
378 dc
->flags
= dcs
->flags
& ~(DC_SAVED
| DC_DIRTY
);
379 dc
->hDevice
= dcs
->hDevice
;
380 dc
->ROPmode
= dcs
->ROPmode
;
381 dc
->polyFillMode
= dcs
->polyFillMode
;
382 dc
->stretchBltMode
= dcs
->stretchBltMode
;
383 dc
->relAbsMode
= dcs
->relAbsMode
;
384 dc
->backgroundMode
= dcs
->backgroundMode
;
385 dc
->backgroundColor
= dcs
->backgroundColor
;
386 dc
->textColor
= dcs
->textColor
;
387 dc
->dcBrushColor
= dcs
->dcBrushColor
;
388 dc
->dcPenColor
= dcs
->dcPenColor
;
389 dc
->brushOrgX
= dcs
->brushOrgX
;
390 dc
->brushOrgY
= dcs
->brushOrgY
;
391 dc
->textAlign
= dcs
->textAlign
;
392 dc
->charExtra
= dcs
->charExtra
;
393 dc
->breakCount
= dcs
->breakCount
;
394 dc
->breakExtra
= dcs
->breakExtra
;
395 dc
->breakRem
= dcs
->breakRem
;
396 dc
->MapMode
= dcs
->MapMode
;
397 dc
->GraphicsMode
= dcs
->GraphicsMode
;
398 dc
->CursPosX
= dcs
->CursPosX
;
399 dc
->CursPosY
= dcs
->CursPosY
;
400 dc
->ArcDirection
= dcs
->ArcDirection
;
401 dc
->xformWorld2Wnd
= dcs
->xformWorld2Wnd
;
402 dc
->xformWorld2Vport
= dcs
->xformWorld2Vport
;
403 dc
->xformVport2World
= dcs
->xformVport2World
;
404 dc
->vport2WorldValid
= dcs
->vport2WorldValid
;
406 dc
->wndOrgX
= dcs
->wndOrgX
;
407 dc
->wndOrgY
= dcs
->wndOrgY
;
408 dc
->wndExtX
= dcs
->wndExtX
;
409 dc
->wndExtY
= dcs
->wndExtY
;
410 dc
->vportOrgX
= dcs
->vportOrgX
;
411 dc
->vportOrgY
= dcs
->vportOrgY
;
412 dc
->vportExtX
= dcs
->vportExtX
;
413 dc
->vportExtY
= dcs
->vportExtY
;
417 if (!dc
->hClipRgn
) dc
->hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
418 CombineRgn( dc
->hClipRgn
, dcs
->hClipRgn
, 0, RGN_COPY
);
422 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
425 CLIPPING_UpdateGCRegion( dc
);
427 SelectObject( hdc
, dcs
->hBitmap
);
428 SelectObject( hdc
, dcs
->hBrush
);
429 SelectObject( hdc
, dcs
->hFont
);
430 SelectObject( hdc
, dcs
->hPen
);
431 SetBkColor( hdc
, dcs
->backgroundColor
);
432 SetTextColor( hdc
, dcs
->textColor
);
433 GDISelectPalette( hdc
, dcs
->hPalette
, FALSE
);
434 GDI_ReleaseObj( hdcs
);
435 GDI_ReleaseObj( hdc
);
439 /***********************************************************************
440 * GetDCState (GDI.179)
442 HDC16 WINAPI
GetDCState16( HDC16 hdc
)
444 return HDC_16( GetDCState( HDC_32(hdc
) ));
448 /***********************************************************************
449 * SetDCState (GDI.180)
451 void WINAPI
SetDCState16( HDC16 hdc
, HDC16 hdcs
)
453 SetDCState( HDC_32(hdc
), HDC_32(hdcs
) );
457 /***********************************************************************
460 INT WINAPI
SaveDC( HDC hdc
)
466 dc
= DC_GetDCPtr( hdc
);
469 if(dc
->funcs
->pSaveDC
)
471 ret
= dc
->funcs
->pSaveDC( dc
->physDev
);
472 GDI_ReleaseObj( hdc
);
476 if (!(hdcs
= GetDCState( hdc
)))
478 GDI_ReleaseObj( hdc
);
481 dcs
= DC_GetDCPtr( hdcs
);
483 /* Copy path. The reason why path saving / restoring is in SaveDC/
484 * RestoreDC and not in GetDCState/SetDCState is that the ...DCState
485 * functions are only in Win16 (which doesn't have paths) and that
486 * SetDCState doesn't allow us to signal an error (which can happen
487 * when copying paths).
489 if (!PATH_AssignGdiPath( &dcs
->path
, &dc
->path
))
491 GDI_ReleaseObj( hdc
);
492 GDI_ReleaseObj( hdcs
);
497 dcs
->header
.hNext
= dc
->header
.hNext
;
498 dc
->header
.hNext
= HDC_16(hdcs
);
499 TRACE("(%p): returning %d\n", hdc
, dc
->saveLevel
+1 );
500 ret
= ++dc
->saveLevel
;
501 GDI_ReleaseObj( hdcs
);
502 GDI_ReleaseObj( hdc
);
507 /***********************************************************************
508 * RestoreDC (GDI32.@)
510 BOOL WINAPI
RestoreDC( HDC hdc
, INT level
)
515 TRACE("%p %d\n", hdc
, level
);
516 dc
= DC_GetDCUpdate( hdc
);
517 if(!dc
) return FALSE
;
518 if(dc
->funcs
->pRestoreDC
)
520 success
= dc
->funcs
->pRestoreDC( dc
->physDev
, level
);
521 GDI_ReleaseObj( hdc
);
525 if (level
== -1) level
= dc
->saveLevel
;
527 /* This pair of checks disagrees with MSDN "Platform SDK:
528 Windows GDI" July 2000 which says all negative values
529 for level will be interpreted as an instance relative
530 to the current state. Restricting it to just -1 does
532 || (level
> dc
->saveLevel
))
534 GDI_ReleaseObj( hdc
);
539 while (dc
->saveLevel
>= level
)
541 HDC hdcs
= HDC_32(dc
->header
.hNext
);
542 if (!(dcs
= DC_GetDCPtr( hdcs
)))
544 GDI_ReleaseObj( hdc
);
547 dc
->header
.hNext
= dcs
->header
.hNext
;
548 if (--dc
->saveLevel
< level
)
550 SetDCState( hdc
, hdcs
);
551 if (!PATH_AssignGdiPath( &dc
->path
, &dcs
->path
))
552 /* FIXME: This might not be quite right, since we're
553 * returning FALSE but still destroying the saved DC state */
556 GDI_ReleaseObj( hdcs
);
557 GDI_ReleaseObj( hdc
);
559 if (!(dc
= DC_GetDCPtr( hdc
))) return FALSE
;
561 GDI_ReleaseObj( hdc
);
566 /***********************************************************************
567 * CreateDCW (GDI32.@)
569 HDC WINAPI
CreateDCW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
570 const DEVMODEW
*initData
)
574 const DC_FUNCTIONS
*funcs
;
579 if (!device
|| !DRIVER_GetDriverName( device
, buf
, 300 ))
581 if (!driver
) return 0;
582 strcpyW(buf
, driver
);
585 if (!(funcs
= DRIVER_load_driver( buf
)))
587 ERR( "no driver found for %s\n", debugstr_w(buf
) );
590 if (!(dc
= DC_AllocDC( funcs
, DC_MAGIC
)))
592 DRIVER_release_driver( funcs
);
597 dc
->hBitmap
= GetStockObject( DEFAULT_BITMAP
);
599 TRACE("(driver=%s, device=%s, output=%s): returning %p\n",
600 debugstr_w(driver
), debugstr_w(device
), debugstr_w(output
), dc
->hSelf
);
602 if (dc
->funcs
->pCreateDC
&&
603 !dc
->funcs
->pCreateDC( dc
, &dc
->physDev
, buf
, device
, output
, initData
))
605 WARN("creation aborted by device\n" );
606 GDI_FreeObject( dc
->hSelf
, dc
);
607 DRIVER_release_driver( funcs
);
611 dc
->hVisRgn
= CreateRectRgn( 0, 0, GetDeviceCaps( hdc
, HORZRES
),
612 GetDeviceCaps( hdc
, VERTRES
) );
615 GDI_ReleaseObj( hdc
);
620 /***********************************************************************
621 * CreateDCA (GDI32.@)
623 HDC WINAPI
CreateDCA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
624 const DEVMODEA
*initData
)
626 UNICODE_STRING driverW
, deviceW
, outputW
;
630 if (driver
) RtlCreateUnicodeStringFromAsciiz(&driverW
, driver
);
631 else driverW
.Buffer
= NULL
;
633 if (device
) RtlCreateUnicodeStringFromAsciiz(&deviceW
, device
);
634 else deviceW
.Buffer
= NULL
;
636 if (output
) RtlCreateUnicodeStringFromAsciiz(&outputW
, output
);
637 else outputW
.Buffer
= NULL
;
639 if (initData
) initDataW
= GdiConvertToDevmodeW(initData
);
640 else initDataW
= NULL
;
642 ret
= CreateDCW( driverW
.Buffer
, deviceW
.Buffer
, outputW
.Buffer
, initDataW
);
644 RtlFreeUnicodeString(&driverW
);
645 RtlFreeUnicodeString(&deviceW
);
646 RtlFreeUnicodeString(&outputW
);
647 if (initDataW
) HeapFree(GetProcessHeap(), 0, initDataW
);
652 /***********************************************************************
653 * CreateICA (GDI32.@)
655 HDC WINAPI
CreateICA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
656 const DEVMODEA
* initData
)
658 /* Nothing special yet for ICs */
659 return CreateDCA( driver
, device
, output
, initData
);
663 /***********************************************************************
664 * CreateICW (GDI32.@)
666 HDC WINAPI
CreateICW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
667 const DEVMODEW
* initData
)
669 /* Nothing special yet for ICs */
670 return CreateDCW( driver
, device
, output
, initData
);
674 /***********************************************************************
675 * CreateCompatibleDC (GDI32.@)
677 HDC WINAPI
CreateCompatibleDC( HDC hdc
)
680 const DC_FUNCTIONS
*funcs
;
685 if ((origDC
= GDI_GetObjPtr( hdc
, DC_MAGIC
)))
687 funcs
= origDC
->funcs
;
688 physDev
= origDC
->physDev
;
689 GDI_ReleaseObj( hdc
); /* can't hold the lock while loading the driver */
690 funcs
= DRIVER_get_driver( funcs
);
694 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
695 funcs
= DRIVER_load_driver( displayW
);
699 if (!funcs
) return 0;
701 if (!(dc
= DC_AllocDC( funcs
, MEMORY_DC_MAGIC
)))
703 DRIVER_release_driver( funcs
);
707 TRACE("(%p): returning %p\n", hdc
, dc
->hSelf
);
709 dc
->hBitmap
= GetStockObject( DEFAULT_BITMAP
);
711 /* Copy the driver-specific physical device info into
712 * the new DC. The driver may use this read-only info
713 * while creating the compatible DC below. */
714 dc
->physDev
= physDev
;
716 if (dc
->funcs
->pCreateDC
&&
717 !dc
->funcs
->pCreateDC( dc
, &dc
->physDev
, NULL
, NULL
, NULL
, NULL
))
719 WARN("creation aborted by device\n");
720 GDI_FreeObject( dc
->hSelf
, dc
);
721 DRIVER_release_driver( funcs
);
725 dc
->hVisRgn
= CreateRectRgn( 0, 0, 1, 1 ); /* default bitmap is 1x1 */
728 GDI_ReleaseObj( dc
->hSelf
);
733 /***********************************************************************
736 BOOL WINAPI
DeleteDC( HDC hdc
)
738 const DC_FUNCTIONS
*funcs
= NULL
;
745 if (!(dc
= DC_GetDCPtr( hdc
))) return FALSE
;
747 /* Call hook procedure to check whether is it OK to delete this DC */
750 DCHOOKPROC proc
= dc
->hookThunk
;
751 DWORD data
= dc
->dwHookData
;
752 GDI_ReleaseObj( hdc
);
753 if (!proc( HDC_16(hdc
), DCHC_DELETEDC
, data
, 0 )) return FALSE
;
754 if (!(dc
= DC_GetDCPtr( hdc
))) return TRUE
; /* deleted by the hook */
757 while (dc
->saveLevel
)
760 HDC hdcs
= HDC_32(dc
->header
.hNext
);
761 if (!(dcs
= DC_GetDCPtr( hdcs
))) break;
762 dc
->header
.hNext
= dcs
->header
.hNext
;
764 if (dcs
->hClipRgn
) DeleteObject( dcs
->hClipRgn
);
765 if (dcs
->hVisRgn
) DeleteObject( dcs
->hVisRgn
);
766 PATH_DestroyGdiPath(&dcs
->path
);
767 GDI_FreeObject( hdcs
, dcs
);
770 if (!(dc
->flags
& DC_SAVED
))
772 SelectObject( hdc
, GetStockObject(BLACK_PEN
) );
773 SelectObject( hdc
, GetStockObject(WHITE_BRUSH
) );
774 SelectObject( hdc
, GetStockObject(SYSTEM_FONT
) );
775 SelectObject( hdc
, GetStockObject(DEFAULT_BITMAP
) );
777 if (dc
->funcs
->pDeleteDC
) dc
->funcs
->pDeleteDC(dc
->physDev
);
781 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
782 if (dc
->hVisRgn
) DeleteObject( dc
->hVisRgn
);
783 PATH_DestroyGdiPath(&dc
->path
);
785 GDI_FreeObject( hdc
, dc
);
786 if (funcs
) DRIVER_release_driver( funcs
); /* do that after releasing the GDI lock */
791 /***********************************************************************
794 HDC WINAPI
ResetDCW( HDC hdc
, const DEVMODEW
*devmode
)
799 if ((dc
= DC_GetDCPtr( hdc
)))
801 if (dc
->funcs
->pResetDC
) ret
= dc
->funcs
->pResetDC( dc
->physDev
, devmode
);
802 GDI_ReleaseObj( hdc
);
808 /***********************************************************************
811 HDC WINAPI
ResetDCA( HDC hdc
, const DEVMODEA
*devmode
)
816 if (devmode
) devmodeW
= GdiConvertToDevmodeW(devmode
);
817 else devmodeW
= NULL
;
819 ret
= ResetDCW(hdc
, devmodeW
);
821 if (devmodeW
) HeapFree(GetProcessHeap(), 0, devmodeW
);
826 /***********************************************************************
827 * GetDeviceCaps (GDI32.@)
829 INT WINAPI
GetDeviceCaps( HDC hdc
, INT cap
)
834 if ((dc
= DC_GetDCPtr( hdc
)))
836 if (dc
->funcs
->pGetDeviceCaps
) ret
= dc
->funcs
->pGetDeviceCaps( dc
->physDev
, cap
);
837 GDI_ReleaseObj( hdc
);
843 /***********************************************************************
844 * SetBkColor (GDI32.@)
846 COLORREF WINAPI
SetBkColor( HDC hdc
, COLORREF color
)
849 DC
* dc
= DC_GetDCPtr( hdc
);
851 TRACE("hdc=%p color=0x%08lx\n", hdc
, color
);
853 if (!dc
) return CLR_INVALID
;
854 oldColor
= dc
->backgroundColor
;
855 if (dc
->funcs
->pSetBkColor
)
857 color
= dc
->funcs
->pSetBkColor(dc
->physDev
, color
);
858 if (color
== CLR_INVALID
) /* don't change it */
861 oldColor
= CLR_INVALID
;
864 dc
->backgroundColor
= color
;
865 GDI_ReleaseObj( hdc
);
870 /***********************************************************************
871 * SetTextColor (GDI32.@)
873 COLORREF WINAPI
SetTextColor( HDC hdc
, COLORREF color
)
876 DC
* dc
= DC_GetDCPtr( hdc
);
878 TRACE(" hdc=%p color=0x%08lx\n", hdc
, color
);
880 if (!dc
) return CLR_INVALID
;
881 oldColor
= dc
->textColor
;
882 if (dc
->funcs
->pSetTextColor
)
884 color
= dc
->funcs
->pSetTextColor(dc
->physDev
, color
);
885 if (color
== CLR_INVALID
) /* don't change it */
888 oldColor
= CLR_INVALID
;
891 dc
->textColor
= color
;
892 GDI_ReleaseObj( hdc
);
897 /***********************************************************************
898 * SetTextAlign (GDI32.@)
900 UINT WINAPI
SetTextAlign( HDC hdc
, UINT align
)
903 DC
*dc
= DC_GetDCPtr( hdc
);
905 TRACE("hdc=%p align=%d\n", hdc
, align
);
908 if (dc
->funcs
->pSetTextAlign
)
909 prevAlign
= dc
->funcs
->pSetTextAlign(dc
->physDev
, align
);
911 prevAlign
= dc
->textAlign
;
912 dc
->textAlign
= align
;
914 GDI_ReleaseObj( hdc
);
918 /***********************************************************************
919 * GetDCOrgEx (GDI32.@)
921 BOOL WINAPI
GetDCOrgEx( HDC hDC
, LPPOINT lpp
)
925 if (!lpp
) return FALSE
;
926 if (!(dc
= DC_GetDCPtr( hDC
))) return FALSE
;
929 if (dc
->funcs
->pGetDCOrgEx
) dc
->funcs
->pGetDCOrgEx( dc
->physDev
, lpp
);
930 GDI_ReleaseObj( hDC
);
935 /***********************************************************************
938 DWORD WINAPI
SetDCOrg16( HDC16 hdc16
, INT16 x
, INT16 y
)
941 HDC hdc
= HDC_32( hdc16
);
942 DC
*dc
= DC_GetDCPtr( hdc
);
944 if (dc
->funcs
->pSetDCOrg
) prevOrg
= dc
->funcs
->pSetDCOrg( dc
->physDev
, x
, y
);
945 GDI_ReleaseObj( hdc
);
950 /***********************************************************************
951 * SetGraphicsMode (GDI32.@)
953 INT WINAPI
SetGraphicsMode( HDC hdc
, INT mode
)
956 DC
*dc
= DC_GetDCPtr( hdc
);
958 /* One would think that setting the graphics mode to GM_COMPATIBLE
959 * would also reset the world transformation matrix to the unity
960 * matrix. However, in Windows, this is not the case. This doesn't
961 * make a lot of sense to me, but that's the way it is.
964 if ((mode
> 0) && (mode
<= GM_LAST
))
966 ret
= dc
->GraphicsMode
;
967 dc
->GraphicsMode
= mode
;
969 GDI_ReleaseObj( hdc
);
974 /***********************************************************************
975 * SetArcDirection (GDI32.@)
977 INT WINAPI
SetArcDirection( HDC hdc
, INT nDirection
)
980 INT nOldDirection
= 0;
982 if (nDirection
!=AD_COUNTERCLOCKWISE
&& nDirection
!=AD_CLOCKWISE
)
984 SetLastError(ERROR_INVALID_PARAMETER
);
988 if ((dc
= DC_GetDCPtr( hdc
)))
990 if (dc
->funcs
->pSetArcDirection
)
992 dc
->funcs
->pSetArcDirection(dc
->physDev
, nDirection
);
994 nOldDirection
= dc
->ArcDirection
;
995 dc
->ArcDirection
= nDirection
;
996 GDI_ReleaseObj( hdc
);
998 return nOldDirection
;
1002 /***********************************************************************
1003 * GetWorldTransform (GDI32.@)
1005 BOOL WINAPI
GetWorldTransform( HDC hdc
, LPXFORM xform
)
1008 if (!xform
) return FALSE
;
1009 if (!(dc
= DC_GetDCPtr( hdc
))) return FALSE
;
1010 *xform
= dc
->xformWorld2Wnd
;
1011 GDI_ReleaseObj( hdc
);
1016 /***********************************************************************
1017 * GetTransform (GDI32.@)
1019 BOOL WINAPI
GetTransform( HDC hdc
, DWORD unknown
, LPXFORM xform
)
1021 if (unknown
== 0x0203) return GetWorldTransform( hdc
, xform
);
1022 FIXME("stub: don't know what to do for code %lx\n", unknown
);
1027 /***********************************************************************
1028 * SetWorldTransform (GDI32.@)
1030 BOOL WINAPI
SetWorldTransform( HDC hdc
, const XFORM
*xform
)
1033 DC
*dc
= DC_GetDCPtr( hdc
);
1035 if (!dc
) return FALSE
;
1036 if (!xform
) goto done
;
1038 /* Check that graphics mode is GM_ADVANCED */
1039 if (dc
->GraphicsMode
!=GM_ADVANCED
) goto done
;
1041 if (dc
->funcs
->pSetWorldTransform
)
1043 ret
= dc
->funcs
->pSetWorldTransform(dc
->physDev
, xform
);
1044 if (!ret
) goto done
;
1047 dc
->xformWorld2Wnd
= *xform
;
1048 DC_UpdateXforms( dc
);
1051 GDI_ReleaseObj( hdc
);
1056 /****************************************************************************
1057 * ModifyWorldTransform [GDI32.@]
1058 * Modifies the world transformation for a device context.
1061 * hdc [I] Handle to device context
1062 * xform [I] XFORM structure that will be used to modify the world
1064 * iMode [I] Specifies in what way to modify the world transformation
1067 * Resets the world transformation to the identity matrix.
1068 * The parameter xform is ignored.
1070 * Multiplies xform into the world transformation matrix from
1073 * Multiplies xform into the world transformation matrix from
1078 * Failure: FALSE. Use GetLastError() to determine the cause.
1080 BOOL WINAPI
ModifyWorldTransform( HDC hdc
, const XFORM
*xform
,
1084 DC
*dc
= DC_GetDCPtr( hdc
);
1086 /* Check for illegal parameters */
1087 if (!dc
) return FALSE
;
1088 if (!xform
) goto done
;
1090 /* Check that graphics mode is GM_ADVANCED */
1091 if (dc
->GraphicsMode
!=GM_ADVANCED
) goto done
;
1093 if (dc
->funcs
->pModifyWorldTransform
)
1095 ret
= dc
->funcs
->pModifyWorldTransform(dc
->physDev
, xform
, iMode
);
1096 if (!ret
) goto done
;
1102 dc
->xformWorld2Wnd
.eM11
= 1.0f
;
1103 dc
->xformWorld2Wnd
.eM12
= 0.0f
;
1104 dc
->xformWorld2Wnd
.eM21
= 0.0f
;
1105 dc
->xformWorld2Wnd
.eM22
= 1.0f
;
1106 dc
->xformWorld2Wnd
.eDx
= 0.0f
;
1107 dc
->xformWorld2Wnd
.eDy
= 0.0f
;
1109 case MWT_LEFTMULTIPLY
:
1110 CombineTransform( &dc
->xformWorld2Wnd
, xform
,
1111 &dc
->xformWorld2Wnd
);
1113 case MWT_RIGHTMULTIPLY
:
1114 CombineTransform( &dc
->xformWorld2Wnd
, &dc
->xformWorld2Wnd
,
1121 DC_UpdateXforms( dc
);
1124 GDI_ReleaseObj( hdc
);
1129 /****************************************************************************
1130 * CombineTransform [GDI32.@]
1131 * Combines two transformation matrices.
1134 * xformResult [O] Stores the result of combining the two matrices
1135 * xform1 [I] Specifies the first matrix to apply
1136 * xform2 [I] Specifies the second matrix to apply
1139 * The same matrix can be passed in for more than one of the parameters.
1143 * Failure: FALSE. Use GetLastError() to determine the cause.
1145 BOOL WINAPI
CombineTransform( LPXFORM xformResult
, const XFORM
*xform1
,
1146 const XFORM
*xform2
)
1150 /* Check for illegal parameters */
1151 if (!xformResult
|| !xform1
|| !xform2
)
1154 /* Create the result in a temporary XFORM, since xformResult may be
1155 * equal to xform1 or xform2 */
1156 xformTemp
.eM11
= xform1
->eM11
* xform2
->eM11
+
1157 xform1
->eM12
* xform2
->eM21
;
1158 xformTemp
.eM12
= xform1
->eM11
* xform2
->eM12
+
1159 xform1
->eM12
* xform2
->eM22
;
1160 xformTemp
.eM21
= xform1
->eM21
* xform2
->eM11
+
1161 xform1
->eM22
* xform2
->eM21
;
1162 xformTemp
.eM22
= xform1
->eM21
* xform2
->eM12
+
1163 xform1
->eM22
* xform2
->eM22
;
1164 xformTemp
.eDx
= xform1
->eDx
* xform2
->eM11
+
1165 xform1
->eDy
* xform2
->eM21
+
1167 xformTemp
.eDy
= xform1
->eDx
* xform2
->eM12
+
1168 xform1
->eDy
* xform2
->eM22
+
1171 /* Copy the result to xformResult */
1172 *xformResult
= xformTemp
;
1178 /***********************************************************************
1179 * SetDCHook (GDI32.@)
1181 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1183 BOOL WINAPI
SetDCHook( HDC hdc
, DCHOOKPROC hookProc
, DWORD dwHookData
)
1185 DC
*dc
= GDI_GetObjPtr( hdc
, DC_MAGIC
);
1187 if (!dc
) return FALSE
;
1189 if (!(dc
->flags
& DC_SAVED
))
1191 dc
->dwHookData
= dwHookData
;
1192 dc
->hookThunk
= hookProc
;
1194 GDI_ReleaseObj( hdc
);
1199 /* relay function to call the 16-bit DC hook proc */
1200 static BOOL16 WINAPI
call_dc_hook16( HDC16 hdc16
, WORD code
, DWORD data
, LPARAM lParam
)
1204 FARPROC16 proc
= NULL
;
1205 HDC hdc
= HDC_32( hdc16
);
1206 DC
*dc
= DC_GetDCPtr( hdc
);
1208 if (!dc
) return FALSE
;
1209 proc
= dc
->hookProc
;
1210 GDI_ReleaseObj( hdc
);
1211 if (!proc
) return FALSE
;
1214 args
[3] = HIWORD(data
);
1215 args
[2] = LOWORD(data
);
1216 args
[1] = HIWORD(lParam
);
1217 args
[0] = LOWORD(lParam
);
1218 WOWCallback16Ex( (DWORD
)proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
1222 /***********************************************************************
1223 * SetDCHook (GDI.190)
1225 BOOL16 WINAPI
SetDCHook16( HDC16 hdc16
, FARPROC16 hookProc
, DWORD dwHookData
)
1227 HDC hdc
= HDC_32( hdc16
);
1228 DC
*dc
= DC_GetDCPtr( hdc
);
1229 if (!dc
) return FALSE
;
1231 dc
->hookProc
= hookProc
;
1232 GDI_ReleaseObj( hdc
);
1233 return SetDCHook( hdc
, call_dc_hook16
, dwHookData
);
1237 /***********************************************************************
1238 * GetDCHook (GDI.191)
1240 DWORD WINAPI
GetDCHook16( HDC16 hdc16
, FARPROC16
*phookProc
)
1242 HDC hdc
= HDC_32( hdc16
);
1243 DC
*dc
= DC_GetDCPtr( hdc
);
1247 *phookProc
= dc
->hookProc
;
1248 ret
= dc
->dwHookData
;
1249 GDI_ReleaseObj( hdc
);
1254 /***********************************************************************
1255 * SetHookFlags (GDI.192)
1257 WORD WINAPI
SetHookFlags16(HDC16 hdc16
, WORD flags
)
1259 HDC hdc
= HDC_32( hdc16
);
1260 DC
*dc
= DC_GetDCPtr( hdc
);
1264 WORD wRet
= dc
->flags
& DC_DIRTY
;
1266 /* "Undocumented Windows" info is slightly confusing.
1269 TRACE("hDC %p, flags %04x\n",hdc
,flags
);
1271 if( flags
& DCHF_INVALIDATEVISRGN
)
1272 dc
->flags
|= DC_DIRTY
;
1273 else if( flags
& DCHF_VALIDATEVISRGN
|| !flags
)
1274 dc
->flags
&= ~DC_DIRTY
;
1275 GDI_ReleaseObj( hdc
);
1281 /***********************************************************************
1282 * SetICMMode (GDI32.@)
1284 INT WINAPI
SetICMMode(HDC hdc
, INT iEnableICM
)
1286 /*FIXME Asuming that ICM is always off, and cannot be turned on */
1287 if (iEnableICM
== ICM_OFF
) return ICM_OFF
;
1288 if (iEnableICM
== ICM_ON
) return 0;
1289 if (iEnableICM
== ICM_QUERY
) return ICM_OFF
;
1293 /***********************************************************************
1294 * GetDeviceGammaRamp (GDI32.@)
1296 BOOL WINAPI
GetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1299 DC
*dc
= DC_GetDCPtr( hDC
);
1303 if (dc
->funcs
->pGetDeviceGammaRamp
)
1304 ret
= dc
->funcs
->pGetDeviceGammaRamp(dc
->physDev
, ptr
);
1305 GDI_ReleaseObj( hDC
);
1310 /***********************************************************************
1311 * SetDeviceGammaRamp (GDI32.@)
1313 BOOL WINAPI
SetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1316 DC
*dc
= DC_GetDCPtr( hDC
);
1320 if (dc
->funcs
->pSetDeviceGammaRamp
)
1321 ret
= dc
->funcs
->pSetDeviceGammaRamp(dc
->physDev
, ptr
);
1322 GDI_ReleaseObj( hDC
);
1327 /***********************************************************************
1328 * GetColorSpace (GDI32.@)
1330 HCOLORSPACE WINAPI
GetColorSpace(HDC hdc
)
1332 /*FIXME Need to to whatever GetColorSpace actually does */
1336 /***********************************************************************
1337 * CreateColorSpaceA (GDI32.@)
1339 HCOLORSPACE WINAPI
CreateColorSpaceA( LPLOGCOLORSPACEA lpLogColorSpace
)
1345 /***********************************************************************
1346 * CreateColorSpaceW (GDI32.@)
1348 HCOLORSPACE WINAPI
CreateColorSpaceW( LPLOGCOLORSPACEW lpLogColorSpace
)
1354 /***********************************************************************
1355 * DeleteColorSpace (GDI32.@)
1357 BOOL WINAPI
DeleteColorSpace( HCOLORSPACE hColorSpace
)
1364 /***********************************************************************
1365 * SetColorSpace (GDI32.@)
1367 HCOLORSPACE WINAPI
SetColorSpace( HDC hDC
, HCOLORSPACE hColorSpace
)
1374 /***********************************************************************
1375 * GetBoundsRect (GDI.194)
1377 UINT16 WINAPI
GetBoundsRect16(HDC16 hdc
, LPRECT16 rect
, UINT16 flags
)
1379 return DCB_RESET
| DCB_DISABLE
; /* bounding rectangle always empty and disabled*/
1382 /***********************************************************************
1383 * GetBoundsRect (GDI32.@)
1385 UINT WINAPI
GetBoundsRect(HDC hdc
, LPRECT rect
, UINT flags
)
1387 FIXME("(): stub\n");
1388 return DCB_RESET
; /* bounding rectangle always empty */
1391 /***********************************************************************
1392 * SetBoundsRect (GDI.193)
1394 UINT16 WINAPI
SetBoundsRect16(HDC16 hdc
, const RECT16
* rect
, UINT16 flags
)
1396 if ( (flags
& DCB_ACCUMULATE
) || (flags
& DCB_ENABLE
) )
1397 FIXME("(%04x, %p, %04x): stub\n", hdc
, rect
, flags
);
1399 return DCB_RESET
| DCB_DISABLE
; /* bounding rectangle always empty and disabled*/
1402 /***********************************************************************
1403 * SetBoundsRect (GDI32.@)
1405 UINT WINAPI
SetBoundsRect(HDC hdc
, const RECT
* rect
, UINT flags
)
1407 FIXME("(): stub\n");
1408 return DCB_DISABLE
; /* bounding rectangle always empty */
1412 /***********************************************************************
1413 * GetRelAbs (GDI32.@)
1415 INT WINAPI
GetRelAbs( HDC hdc
, DWORD dwIgnore
)
1418 DC
*dc
= DC_GetDCPtr( hdc
);
1419 if (dc
) ret
= dc
->relAbsMode
;
1420 GDI_ReleaseObj( hdc
);
1424 /***********************************************************************
1425 * GetLayout (GDI32.@)
1427 * Gets left->right or right->left text layout flags of a dc.
1428 * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same
1431 DWORD WINAPI
GetLayout(HDC hdc
)
1433 FIXME("(%p): stub\n", hdc
);
1434 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1438 /***********************************************************************
1439 * SetLayout (GDI32.@)
1441 * Sets left->right or right->left text layout flags of a dc.
1442 * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same
1445 DWORD WINAPI
SetLayout(HDC hdc
, DWORD layout
)
1447 FIXME("(%p,%08lx): stub\n", hdc
, layout
);
1448 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1452 /***********************************************************************
1453 * GetDCBrushColor (GDI32.@)
1455 * Retrieves the current brush color for the specified device
1459 COLORREF WINAPI
GetDCBrushColor(HDC hdc
)
1462 COLORREF dcBrushColor
= CLR_INVALID
;
1464 TRACE("hdc(%p)\n", hdc
);
1466 dc
= DC_GetDCPtr( hdc
);
1469 dcBrushColor
= dc
->dcBrushColor
;
1470 GDI_ReleaseObj( hdc
);
1473 return dcBrushColor
;
1476 /***********************************************************************
1477 * SetDCBrushColor (GDI32.@)
1479 * Sets the current device context (DC) brush color to the specified
1480 * color value. If the device cannot represent the specified color
1481 * value, the color is set to the nearest physical color.
1484 COLORREF WINAPI
SetDCBrushColor(HDC hdc
, COLORREF crColor
)
1487 COLORREF oldClr
= CLR_INVALID
;
1489 TRACE("hdc(%p) crColor(%08lx)\n", hdc
, crColor
);
1491 dc
= DC_GetDCPtr( hdc
);
1494 if (dc
->funcs
->pSetDCBrushColor
)
1495 crColor
= dc
->funcs
->pSetDCBrushColor( dc
->physDev
, crColor
);
1496 else if (dc
->hBrush
== GetStockObject( DC_BRUSH
))
1498 /* If DC_BRUSH is selected, update driver pen color */
1499 HBRUSH hBrush
= CreateSolidBrush( crColor
);
1500 dc
->funcs
->pSelectBrush( dc
->physDev
, hBrush
);
1501 DeleteObject( hBrush
);
1504 if (crColor
!= CLR_INVALID
)
1506 oldClr
= dc
->dcBrushColor
;
1507 dc
->dcBrushColor
= crColor
;
1510 GDI_ReleaseObj( hdc
);
1516 /***********************************************************************
1517 * GetDCPenColor (GDI32.@)
1519 * Retrieves the current pen color for the specified device
1523 COLORREF WINAPI
GetDCPenColor(HDC hdc
)
1526 COLORREF dcPenColor
= CLR_INVALID
;
1528 TRACE("hdc(%p)\n", hdc
);
1530 dc
= DC_GetDCPtr( hdc
);
1533 dcPenColor
= dc
->dcPenColor
;
1534 GDI_ReleaseObj( hdc
);
1540 /***********************************************************************
1541 * SetDCPenColor (GDI32.@)
1543 * Sets the current device context (DC) pen color to the specified
1544 * color value. If the device cannot represent the specified color
1545 * value, the color is set to the nearest physical color.
1548 COLORREF WINAPI
SetDCPenColor(HDC hdc
, COLORREF crColor
)
1551 COLORREF oldClr
= CLR_INVALID
;
1553 TRACE("hdc(%p) crColor(%08lx)\n", hdc
, crColor
);
1555 dc
= DC_GetDCPtr( hdc
);
1558 if (dc
->funcs
->pSetDCPenColor
)
1559 crColor
= dc
->funcs
->pSetDCPenColor( dc
->physDev
, crColor
);
1560 else if (dc
->hPen
== GetStockObject( DC_PEN
))
1562 /* If DC_PEN is selected, update the driver pen color */
1563 LOGPEN logpen
= { PS_SOLID
, { 0, 0 }, crColor
};
1564 HPEN hPen
= CreatePenIndirect( &logpen
);
1565 dc
->funcs
->pSelectPen( dc
->physDev
, hPen
);
1566 DeleteObject( hPen
);
1569 if (crColor
!= CLR_INVALID
)
1571 oldClr
= dc
->dcPenColor
;
1572 dc
->dcPenColor
= crColor
;
1575 GDI_ReleaseObj( hdc
);
1581 /***********************************************************************
1582 * SetVirtualResolution (GDI32.@)
1584 * Undocumented on msdn. Called when PowerPoint XP saves a file.
1586 DWORD WINAPI
SetVirtualResolution(HDC hdc
, DWORD dw2
, DWORD dw3
, DWORD dw4
, DWORD dw5
)
1588 FIXME("(%p %08lx %08lx %08lx %08lx): stub!\n", hdc
, dw2
, dw3
, dw4
, dw5
);