15 UNICODE_STRING Device
, Output
;
17 BOOL Display
= FALSE
, Default
= FALSE
;
22 if ( !ghSpooler
&& !LoadTheSpoolerDrv())
24 DPRINT1("WinSpooler.Drv Did not load!\n");
28 DPRINT("WinSpooler.Drv Loaded! hMod -> 0x%p\n", ghSpooler
);
31 if ((!lpwszDevice
) && (!lpwszDriver
))
33 Default
= TRUE
; // Ask Win32k to set Default device.
34 Display
= TRUE
; // Most likely to be DISPLAY.
38 if ((lpwszDevice
) && (wcslen(lpwszDevice
) != 0)) // First
40 if (!_wcsnicmp(lpwszDevice
, L
"\\\\.\\DISPLAY",11)) Display
= TRUE
;
41 RtlInitUnicodeString(&Device
, lpwszDevice
);
45 if (lpwszDriver
) // Second
47 if ((!_wcsnicmp(lpwszDriver
, L
"DISPLAY",7)) ||
48 (!_wcsnicmp(lpwszDriver
, L
"\\\\.\\DISPLAY",11))) Display
= TRUE
;
49 RtlInitUnicodeString(&Device
, lpwszDriver
);
54 if (lpwszOutput
) RtlInitUnicodeString(&Output
, lpwszOutput
);
58 //Handle Print device or something else.
59 DPRINT1("Not a DISPLAY device! %wZ\n", &Device
);
62 hdc
= NtGdiOpenDCW((Default
? NULL
: &Device
),
63 (PDEVMODEW
) lpInitData
,
64 (lpwszOutput
? &Output
: NULL
),
65 iType
, // DCW 0 and ICW 1.
68 (PVOID
) NULL
, // NULL for now.
71 // Handle something other than a normal dc object.
72 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
77 GdiGetHandleUserData(hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
*)&Dc_Attr
);
79 pLDC
= LocalAlloc(LMEM_ZEROINIT
, sizeof(LDC
));
81 Dc_Attr
->pvLDC
= pLDC
;
83 pLDC
->iType
= LDC_LDC
; // 1 (init) local DC, 2 EMF LDC
84 DbgPrint("DC_ATTR Allocated -> 0x%x\n",Dc_Attr
);
102 hdcNew
= NtGdiCreateCompatibleDC(hdc
);
106 if (GdiGetHandleUserData(hdc
, GDI_OBJECT_TYPE_DC
, (PVOID
*)&pdcattr
))
108 if (pdcattr
->pvLIcm
) IcmCompatibleDC(hdcNew
, hdc
, pdcattr
);
125 CONST DEVMODEA
* lpdvmInit
)
127 ANSI_STRING DriverA
, DeviceA
, OutputA
;
128 UNICODE_STRING DriverU
, DeviceU
, OutputU
;
129 LPDEVMODEW dvmInitW
= NULL
;
133 * If needed, convert to Unicode
134 * any string parameter.
137 if (lpszDriver
!= NULL
)
139 RtlInitAnsiString(&DriverA
, (LPSTR
)lpszDriver
);
140 RtlAnsiStringToUnicodeString(&DriverU
, &DriverA
, TRUE
);
144 DriverU
.Buffer
= NULL
;
147 if (lpszDevice
!= NULL
)
149 RtlInitAnsiString(&DeviceA
, (LPSTR
)lpszDevice
);
150 RtlAnsiStringToUnicodeString(&DeviceU
, &DeviceA
, TRUE
);
154 DeviceU
.Buffer
= NULL
;
157 if (lpszOutput
!= NULL
)
159 RtlInitAnsiString(&OutputA
, (LPSTR
)lpszOutput
);
160 RtlAnsiStringToUnicodeString(&OutputU
, &OutputA
, TRUE
);
164 OutputU
.Buffer
= NULL
;
167 if (lpdvmInit
!= NULL
)
168 dvmInitW
= GdiConvertToDevmodeW((LPDEVMODEA
)lpdvmInit
);
170 hdc
= IntCreateDICW(DriverU
.Buffer
,
173 lpdvmInit
? dvmInitW
: NULL
,
177 /* Free Unicode parameters. */
178 RtlFreeUnicodeString(&DriverU
);
179 RtlFreeUnicodeString(&DeviceU
);
180 RtlFreeUnicodeString(&OutputU
);
182 /* Return the DC handle. */
196 CONST DEVMODEW
*lpInitData
)
198 return IntCreateDICW(lpwszDriver
,
201 (PDEVMODEW
)lpInitData
,
215 CONST DEVMODEW
*lpdvmInit
)
217 return IntCreateDICW(lpszDriver
,
220 (PDEVMODEW
)lpdvmInit
,
234 CONST DEVMODEA
*lpdvmInit
)
237 LPWSTR lpszDriverW
, lpszDeviceW
, lpszOutputW
;
238 LPDEVMODEW dvmInitW
= NULL
;
241 Status
= HEAP_strdupA2W(&lpszDriverW
, lpszDriver
);
242 if (!NT_SUCCESS(Status
))
243 SetLastError(RtlNtStatusToDosError(Status
));
246 Status
= HEAP_strdupA2W(&lpszDeviceW
, lpszDevice
);
247 if (!NT_SUCCESS(Status
))
248 SetLastError(RtlNtStatusToDosError(Status
));
251 Status
= HEAP_strdupA2W(&lpszOutputW
, lpszOutput
);
252 if (!NT_SUCCESS(Status
))
253 SetLastError(RtlNtStatusToDosError(Status
));
257 dvmInitW
= GdiConvertToDevmodeW((LPDEVMODEA
)lpdvmInit
);
259 hdc
= IntCreateDICW(lpszDriverW
,
262 lpdvmInit
? dvmInitW
: NULL
,
265 HEAP_free(lpszOutputW
);
267 HEAP_free(lpszDeviceW
);
269 HEAP_free(lpszDriverW
);
285 HANDLE hPrinter
= NULL
;
286 ULONG hType
= GDI_HANDLE_GET_TYPE(hdc
);
288 pLDC
= GdiGetLDC(hdc
);
290 if (hType
!= GDILoObjType_LO_DC_TYPE
)
293 if ( !pLDC
|| hType
== GDILoObjType_LO_METADC16_TYPE
)
295 SetLastError(ERROR_INVALID_HANDLE
);
298 if (pLDC
->Flags
& LDC_INIT_DOCUMENT
) AbortDoc(hdc
);
301 DocumentEventEx(NULL
, pLDC
->hPrinter
, hdc
, DOCUMENTEVENT_DELETEDC
, 0, NULL
, 0, NULL
);
302 hPrinter
= pLDC
->hPrinter
;
303 pLDC
->hPrinter
= NULL
;
307 bResult
= NtGdiDeleteObjectApp(hdc
);
311 DPRINT1("Delete the Local DC structure\n");
316 fpClosePrinter(hPrinter
);
329 /* FIXME Sharememory */
330 return NtGdiSaveDC(hdc
);
339 RestoreDC(IN HDC hdc
,
342 /* FIXME Sharememory */
343 return NtGdiRestoreDC(hdc
, iLevel
);
356 if (GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_DC
&&
357 GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_METADC
)
359 PLDC pLDC
= GdiGetLDC(hDC
);
362 SetLastError(ERROR_INVALID_HANDLE
);
365 /* If a document has started set it to die. */
366 if (pLDC
->Flags
& LDC_INIT_DOCUMENT
) pLDC
->Flags
|= LDC_KILL_DOCUMENT
;
368 return NtGdiCancelDC(hDC
);
371 if (GdiGetHandleUserData((HGDIOBJ
) hDC
, GDI_OBJECT_TYPE_DC
, (PVOID
) &pDc_Attr
))
373 pDc_Attr
->ulDirty_
&= ~DC_PLAYMETAFILE
;
385 return GetDCDWord( hdc
, GdiGetArcDirection
, 0);
395 return GetAndSetDCDWord(hdc
, GdiGetSetArcDirection
, nDirection
, 0, 0, 0);
403 GdiReleaseDC(HDC hdc
)
414 GdiCleanCacheDC(HDC hdc
)
416 if (GDI_HANDLE_GET_TYPE(hdc
) == GDILoObjType_LO_DC_TYPE
)
418 SetLastError(ERROR_INVALID_HANDLE
);
427 GdiConvertAndCheckDC(HDC hdc
)
430 ULONG hType
= GDI_HANDLE_GET_TYPE(hdc
);
431 if (hType
== GDILoObjType_LO_DC_TYPE
|| hType
== GDILoObjType_LO_METADC16_TYPE
)
433 pldc
= GdiGetLDC(hdc
);
436 if (pldc
->Flags
& LDC_SAPCALLBACK
) GdiSAPCallback(pldc
);
437 if (pldc
->Flags
& LDC_KILL_DOCUMENT
) return NULL
;
438 if (pldc
->Flags
& LDC_STARTPAGE
) StartPage(hdc
);
441 SetLastError(ERROR_INVALID_HANDLE
);
454 _In_ UINT uObjectType
)
456 PDC_ATTR pdcattr
= NULL
;
458 /* Check if this is a user mode object */
459 if ((uObjectType
== OBJ_PEN
) ||
460 (uObjectType
== OBJ_EXTPEN
) ||
461 (uObjectType
== OBJ_BRUSH
) ||
462 (uObjectType
== OBJ_COLORSPACE
))
464 /* Get the DC attribute */
465 pdcattr
= GdiGetDcAttr(hdc
);
472 /* Check what object was requested */
477 return pdcattr
->hpen
;
480 return pdcattr
->hbrush
;
483 return pdcattr
->hColorSpace
;
486 uObjectType
= GDI_OBJECT_TYPE_PALETTE
;
490 uObjectType
= GDI_OBJECT_TYPE_FONT
;
494 uObjectType
= GDI_OBJECT_TYPE_BITMAP
;
497 /* All others are invalid */
499 SetLastError(ERROR_INVALID_PARAMETER
);
503 /* Pass the request to win32k */
504 return NtGdiGetDCObject(hdc
, uObjectType
);
515 GOBJENUMPROC lpObjectFunc
,
521 DWORD_PTR EndOfBuffer
;
527 Size
= sizeof(LOGBRUSH
);
531 Size
= sizeof(LOGPEN
);
535 SetLastError(ERROR_INVALID_PARAMETER
);
539 ObjectsCount
= NtGdiEnumObjects(hdc
, nObjectType
, 0, NULL
);
540 if (!ObjectsCount
) return 0;
542 Buffer
= HeapAlloc(GetProcessHeap(), 0, ObjectsCount
* Size
);
545 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
549 if (!NtGdiEnumObjects(hdc
, nObjectType
, ObjectsCount
* Size
, Buffer
))
551 HeapFree(GetProcessHeap(), 0, Buffer
);
555 EndOfBuffer
= (DWORD_PTR
)Buffer
+ (ObjectsCount
* Size
);
556 while ((DWORD_PTR
)Buffer
< EndOfBuffer
)
558 Result
= lpObjectFunc(Buffer
, lParam
);
560 Buffer
= (PVOID
)((DWORD_PTR
)Buffer
+ Size
);
563 HeapFree(GetProcessHeap(), 0, Buffer
);
580 PDEVCAPS pDevCaps
= GdiDevCaps
; // Primary display device capabilities.
581 DPRINT("Device CAPS1\n");
583 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
585 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
587 if (nIndex
== TECHNOLOGY
) return DT_METAFILE
;
592 pLDC
= GdiGetLDC(hdc
);
595 SetLastError(ERROR_INVALID_HANDLE
);
598 if (!(pLDC
->Flags
& LDC_DEVCAPS
))
600 if (!NtGdiGetDeviceCapsAll(hdc
, &pLDC
->DevCaps
))
601 SetLastError(ERROR_INVALID_PARAMETER
);
602 pLDC
->Flags
|= LDC_DEVCAPS
;
604 pDevCaps
= &pLDC
->DevCaps
;
609 /* Get the DC attribute */
610 pdcattr
= GdiGetDcAttr(hdc
);
613 SetLastError(ERROR_INVALID_PARAMETER
);
617 if (!(pdcattr
->ulDirty_
& DC_PRIMARY_DISPLAY
) )
618 return NtGdiGetDeviceCaps(hdc
, nIndex
);
620 DPRINT("Device CAPS2\n");
625 return pDevCaps
->ulVersion
;
628 return pDevCaps
->ulTechnology
;
631 return pDevCaps
->ulHorzSize
;
634 return pDevCaps
->ulVertSize
;
637 return pDevCaps
->ulHorzRes
;
640 return pDevCaps
->ulVertRes
;
643 return pDevCaps
->ulLogPixelsX
;
646 return pDevCaps
->ulLogPixelsY
;
649 return pDevCaps
->ulBitsPixel
;
652 return pDevCaps
->ulPlanes
;
658 return pDevCaps
->ulNumPens
;
661 return pDevCaps
->ulNumFonts
;
664 return pDevCaps
->ulNumColors
;
667 return pDevCaps
->ulAspectX
;
670 return pDevCaps
->ulAspectY
;
673 return pDevCaps
->ulAspectXY
;
679 return pDevCaps
->ulSizePalette
;
685 return pDevCaps
->ulColorRes
;
688 return pDevCaps
->ulVertRes
;
691 return pDevCaps
->ulHorzRes
;
694 return pDevCaps
->ulBltAlignment
;
697 return pDevCaps
->ulShadeBlend
;
700 return pDevCaps
->ulColorMgmtCaps
;
703 return pDevCaps
->ulPhysicalWidth
;
706 return pDevCaps
->ulPhysicalHeight
;
708 case PHYSICALOFFSETX
:
709 return pDevCaps
->ulPhysicalOffsetX
;
711 case PHYSICALOFFSETY
:
712 return pDevCaps
->ulPhysicalOffsetY
;
715 return pDevCaps
->ulVRefresh
;
718 return pDevCaps
->ulRasterCaps
;
721 return (CC_CIRCLES
| CC_PIE
| CC_CHORD
| CC_ELLIPSES
| CC_WIDE
|
722 CC_STYLED
| CC_WIDESTYLED
| CC_INTERIORS
| CC_ROUNDRECT
);
725 return (LC_POLYLINE
| LC_MARKER
| LC_POLYMARKER
| LC_WIDE
|
726 LC_STYLED
| LC_WIDESTYLED
| LC_INTERIORS
);
729 return (PC_POLYGON
| PC_RECTANGLE
| PC_WINDPOLYGON
| PC_SCANLINE
|
730 PC_WIDE
| PC_STYLED
| PC_WIDESTYLED
| PC_INTERIORS
);
733 return pDevCaps
->ulTextCaps
;
753 return GetDCDWord(hdc
, GdiGetRelAbs
, 0);
766 return GetAndSetDCDWord(hdc
, GdiGetSetRelAbs
, Mode
, 0, 0, 0);
780 _In_ USHORT usMF16Id
,
786 /* Handle something other than a normal dc object. */
787 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
789 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
790 return 0; //call MFDRV
793 PLDC pLDC
= GdiGetLDC(hdc
);
796 SetLastError(ERROR_INVALID_HANDLE
);
799 if (pLDC
->iType
== LDC_EMFLDC
)
801 Ret
= TRUE
; //call EMFDRV
809 if (!NtGdiGetAndSetDCDword(hdc
, u
, dwIn
, &dwResult
))
811 SetLastError(ERROR_INVALID_HANDLE
);
831 if (!NtGdiGetDCDword(hdc
, u
, &dwResult
))
845 GetAspectRatioFilterEx(
847 LPSIZE lpAspectRatio
)
849 return NtGdiGetDCPoint(hdc
, GdiGetAspectRatioFilter
, (PPOINTL
)lpAspectRatio
);
864 return NtGdiGetBoundsRect(hdc
,lprcBounds
,flags
& DCB_RESET
);
873 SetBoundsRect(HDC hdc
,
877 /* FIXME add check for validate the flags */
878 return NtGdiSetBoundsRect(hdc
, (LPRECT
)prc
, flags
);
891 return NtGdiGetAppClipBox(hdc
, lprc
);
905 /* Get the DC attribute */
906 pdcattr
= GdiGetDcAttr(hdc
);
909 SetLastError(ERROR_INVALID_PARAMETER
);
913 return pdcattr
->ulBrushClr
;
926 /* Get the DC attribute */
927 pdcattr
= GdiGetDcAttr(hdc
);
930 SetLastError(ERROR_INVALID_PARAMETER
);
934 return pdcattr
->ulPenClr
;
944 _In_ COLORREF crColor
)
949 /* Get the DC attribute */
950 pdcattr
= GdiGetDcAttr(hdc
);
953 SetLastError(ERROR_INVALID_PARAMETER
);
957 /* Get old color and store the new */
958 crOldColor
= pdcattr
->ulBrushClr
;
959 pdcattr
->ulBrushClr
= crColor
;
961 if (pdcattr
->crBrushClr
!= crColor
)
963 pdcattr
->ulDirty_
|= DIRTY_FILL
;
964 pdcattr
->crBrushClr
= crColor
;
977 _In_ COLORREF crColor
)
982 /* Get the DC attribute */
983 pdcattr
= GdiGetDcAttr(hdc
);
986 SetLastError(ERROR_INVALID_PARAMETER
);
990 /* Get old color and store the new */
991 crOldColor
= pdcattr
->ulPenClr
;
992 pdcattr
->ulPenClr
= (ULONG
)crColor
;
994 if (pdcattr
->crPenClr
!= crColor
)
996 pdcattr
->ulDirty_
|= DIRTY_LINE
;
997 pdcattr
->crPenClr
= crColor
;
1014 /* Get the DC attribute */
1015 pdcattr
= GdiGetDcAttr(hdc
);
1016 if (pdcattr
== NULL
)
1018 /* Don't set LastError here! */
1022 return pdcattr
->ulBackgroundClr
;
1032 _In_ COLORREF crColor
)
1035 COLORREF crOldColor
;
1037 /* Get the DC attribute */
1038 pdcattr
= GdiGetDcAttr(hdc
);
1039 if (pdcattr
== NULL
)
1041 SetLastError(ERROR_INVALID_PARAMETER
);
1046 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
1048 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
1049 return MFDRV_SetBkColor(hdc
, crColor
);
1052 PLDC pLDC
= pdcattr
->pvLDC
;
1055 SetLastError(ERROR_INVALID_HANDLE
);
1058 if (pLDC
->iType
== LDC_EMFLDC
)
1060 return EMFDRV_SetBkColor(hdc
, crColor
);
1066 /* Get old color and store the new */
1067 crOldColor
= pdcattr
->ulBackgroundClr
;
1068 pdcattr
->ulBackgroundClr
= crColor
;
1070 if (pdcattr
->crBackgroundClr
!= crColor
)
1072 pdcattr
->ulDirty_
|= (DIRTY_BACKGROUND
|DIRTY_LINE
|DIRTY_FILL
);
1073 pdcattr
->crBackgroundClr
= crColor
;
1089 /* Get the DC attribute */
1090 pdcattr
= GdiGetDcAttr(hdc
);
1091 if (pdcattr
== NULL
)
1093 /* Don't set LastError here! */
1097 return pdcattr
->lBkMode
;
1113 /* Get the DC attribute */
1114 pdcattr
= GdiGetDcAttr(hdc
);
1115 if (pdcattr
== NULL
)
1117 SetLastError(ERROR_INVALID_PARAMETER
);
1122 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
1124 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
1125 return MFDRV_SetBkMode( hdc
, iBkMode
)
1128 PLDC pLDC
= pdcattr
->pvLDC
;
1131 SetLastError(ERROR_INVALID_HANDLE
);
1134 if (pLDC
->iType
== LDC_EMFLDC
)
1136 return EMFDRV_SetBkMode(hdc
, iBkMode
)
1142 iOldMode
= pdcattr
->lBkMode
;
1143 pdcattr
->jBkMode
= iBkMode
; // Processed
1144 pdcattr
->lBkMode
= iBkMode
; // Raw
1155 GetPolyFillMode(HDC hdc
)
1159 /* Get DC attribute */
1160 pdcattr
= GdiGetDcAttr(hdc
);
1161 if (pdcattr
== NULL
)
1163 /* Don't set LastError here! */
1167 /* Return current fill mode */
1168 return pdcattr
->lFillMode
;
1178 _In_
int iPolyFillMode
)
1180 INT iOldPolyFillMode
;
1184 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
1186 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
1187 return MFDRV_SetPolyFillMode( hdc
, iPolyFillMode
)
1190 PLDC pLDC
= GdiGetLDC(hdc
);
1193 SetLastError(ERROR_INVALID_HANDLE
);
1196 if (pLDC
->iType
== LDC_EMFLDC
)
1198 return EMFDRV_SetPolyFillMode( hdc
, iPolyFillMode
)
1204 /* Get the DC attribute */
1205 pdcattr
= GdiGetDcAttr(hdc
);
1206 if (pdcattr
== NULL
)
1208 SetLastError(ERROR_INVALID_PARAMETER
);
1212 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hdc
)
1214 if (pdcattr
->ulDirty_
& DC_MODE_DIRTY
)
1216 NtGdiFlush(); // Sync up pdcattr from Kernel space.
1217 pdcattr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
1221 iOldPolyFillMode
= pdcattr
->lFillMode
;
1222 pdcattr
->lFillMode
= iPolyFillMode
;
1224 return iOldPolyFillMode
;
1233 GetGraphicsMode(HDC hdc
)
1237 /* Get the DC attribute */
1238 pdcattr
= GdiGetDcAttr(hdc
);
1239 if (pdcattr
== NULL
)
1241 /* Don't set LastError here! */
1245 /* Return current graphics mode */
1246 return pdcattr
->iGraphicsMode
;
1261 /* Check parameters */
1262 if ((iMode
< GM_COMPATIBLE
) || (iMode
> GM_ADVANCED
))
1264 SetLastError(ERROR_INVALID_PARAMETER
);
1268 /* Get the DC attribute */
1269 pdcattr
= GdiGetDcAttr(hdc
);
1270 if (pdcattr
== NULL
)
1272 SetLastError(ERROR_INVALID_PARAMETER
);
1276 /* Check for trivial case */
1277 if (iMode
== pdcattr
->iGraphicsMode
)
1280 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hdc
)
1282 if (pdcattr
->ulDirty_
& DC_MODE_DIRTY
)
1284 NtGdiFlush(); // Sync up pdcattr from Kernel space.
1285 pdcattr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
1289 /* One would think that setting the graphics mode to GM_COMPATIBLE
1290 * would also reset the world transformation matrix to the unity
1291 * matrix. However, in Windows, this is not the case. This doesn't
1292 * make a lot of sense to me, but that's the way it is.
1294 iOldMode
= pdcattr
->iGraphicsMode
;
1295 pdcattr
->iGraphicsMode
= iMode
;
1307 _In_ CONST DEVMODEW
*lpInitData
)
1309 NtGdiResetDC ( hdc
, (PDEVMODEW
)lpInitData
, NULL
, NULL
, NULL
);
1321 _In_ CONST DEVMODEA
*lpInitData
)
1323 LPDEVMODEW InitDataW
;
1325 InitDataW
= GdiConvertToDevmodeW((LPDEVMODEA
)lpInitData
);
1327 NtGdiResetDC ( hdc
, InitDataW
, NULL
, NULL
, NULL
);
1328 HEAP_free(InitDataW
);
1333 /* FIXME: include correct header */
1334 HPALETTE WINAPI
NtUserSelectPalette(HDC hDC
,
1336 BOOL ForceBackground
);
1343 BOOL bForceBackground
)
1346 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
1348 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
1349 return MFDRV_SelectPalette(hdc
, hpal
, bForceBackground
);
1352 PLDC pLDC
= GdiGetLDC(hdc
);
1355 SetLastError(ERROR_INVALID_HANDLE
);
1358 if (pLDC
->iType
== LDC_EMFLDC
)
1360 if return EMFDRV_SelectPalette(hdc
, hpal
, bForceBackground
);
1365 return NtUserSelectPalette(hdc
, hpal
, bForceBackground
);
1374 GetStretchBltMode(HDC hdc
)
1378 /* Get the DC attribute */
1379 pdcattr
= GdiGetDcAttr(hdc
);
1380 if (pdcattr
== NULL
)
1382 /* Don't set LastError here! */
1386 return pdcattr
->lStretchBltMode
;
1396 _In_
int iStretchMode
)
1401 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
1403 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
1404 return MFDRV_SetStretchBltMode( hdc
, iStretchMode
);
1407 PLDC pLDC
= GdiGetLDC(hdc
);
1410 SetLastError(ERROR_INVALID_HANDLE
);
1413 if (pLDC
->iType
== LDC_EMFLDC
)
1415 return EMFDRV_SetStretchBltMode( hdc
, iStretchMode
);
1420 /* Get the DC attribute */
1421 pdcattr
= GdiGetDcAttr(hdc
);
1422 if (pdcattr
== NULL
)
1424 SetLastError(ERROR_INVALID_PARAMETER
);
1428 iOldMode
= pdcattr
->lStretchBltMode
;
1429 pdcattr
->lStretchBltMode
= iStretchMode
;
1431 // Wine returns an error here. We set the default.
1432 if ((iStretchMode
<= 0) || (iStretchMode
> MAXSTRETCHBLTMODE
)) iStretchMode
= WHITEONBLACK
;
1434 pdcattr
->jStretchBltMode
= iStretchMode
;
1448 /* Get the DC attribute */
1449 pdcattr
= GdiGetDcAttr(hdc
);
1450 if (pdcattr
== NULL
)
1452 /* Don't set LastError here! */
1456 /* Return the current font */
1457 return pdcattr
->hlfntNew
;
1468 return NtGdiSelectBitmap(hdc
, hbmp
);
1480 /* Get the DC attribute */
1481 pdcattr
= GdiGetDcAttr(hdc
);
1482 if (pdcattr
== NULL
)
1484 SetLastError(ERROR_INVALID_PARAMETER
);
1488 /* Get the current brush. If it matches the new brush, we're done */
1489 hbrOld
= pdcattr
->hbrush
;
1493 /* Set the new brush and update dirty flags */
1494 pdcattr
->hbrush
= hbr
;
1495 pdcattr
->ulDirty_
|= DC_BRUSH_DIRTY
;
1508 /* Get the DC attribute */
1509 pdcattr
= GdiGetDcAttr(hdc
);
1510 if (pdcattr
== NULL
)
1512 SetLastError(ERROR_INVALID_PARAMETER
);
1516 /* Get the current pen. If it matches the new pen, we're done */
1517 hpenOld
= pdcattr
->hpen
;
1518 if (hpenOld
== hpen
)
1521 /* Set the new pen and update dirty flags */
1522 pdcattr
->ulDirty_
|= DC_PEN_DIRTY
;
1523 pdcattr
->hpen
= hpen
;
1536 /* Get the DC attribute */
1537 pdcattr
= GdiGetDcAttr(hdc
);
1538 if (pdcattr
== NULL
)
1540 SetLastError(ERROR_INVALID_PARAMETER
);
1544 /* Get the current font. If it matches the new font, we're done */
1545 hfontOld
= pdcattr
->hlfntNew
;
1546 if (hfontOld
== hfont
)
1549 /* Set the new font and update dirty flags */
1550 pdcattr
->hlfntNew
= hfont
;
1551 pdcattr
->ulDirty_
&= ~SLOW_WIDTHS
;
1552 pdcattr
->ulDirty_
|= DIRTY_CHARSET
;
1554 /* If the DC does not have a DIB section selected, try a batch command */
1555 if (!(pdcattr
->ulDirty_
& DC_DIBSECTION
))
1559 pgO
= GdiAllocBatchCommand(hdc
, GdiBCSelObj
);
1562 pgO
->hgdiobj
= hfont
;
1567 /* We could not use the batch command, call win32k */
1568 return NtGdiSelectFont(hdc
, hfont
);
1582 /* Fix up 16 bit handles */
1583 hobj
= GdiFixUpHandle(hobj
);
1584 if (!GdiIsHandleValid(hobj
))
1589 /* Call the appropriate select function */
1590 switch (GDI_HANDLE_GET_TYPE(hobj
))
1592 case GDILoObjType_LO_REGION_TYPE
:
1593 return (HGDIOBJ
)ExtSelectClipRgn(hdc
, hobj
, RGN_COPY
);
1595 case GDILoObjType_LO_BITMAP_TYPE
:
1596 case GDILoObjType_LO_DIBSECTION_TYPE
:
1597 return GdiSelectBitmap(hdc
, hobj
);
1599 case GDILoObjType_LO_BRUSH_TYPE
:
1600 return GdiSelectBrush(hdc
, hobj
);
1602 case GDILoObjType_LO_PEN_TYPE
:
1603 case GDILoObjType_LO_EXTPEN_TYPE
:
1604 return GdiSelectPen(hdc
, hobj
);
1606 case GDILoObjType_LO_FONT_TYPE
:
1607 return GdiSelectFont(hdc
, hobj
);
1609 case GDILoObjType_LO_ICMLCS_TYPE
:
1610 return SetColorSpace(hdc
, hobj
);
1612 case GDILoObjType_LO_PALETTE_TYPE
:
1613 SetLastError(ERROR_INVALID_FUNCTION
);