6 HGDIOBJ stock_objects
[NB_STOCK_OBJECTS
]; // temp location.
10 IntCreateDICW ( LPCWSTR lpwszDriver
,
16 UNICODE_STRING Device
, Output
;
18 BOOL Display
= FALSE
, Default
= TRUE
;
23 if ((!lpwszDevice
) && (!lpwszDriver
))
25 Default
= FALSE
; // Ask Win32k to set Default device.
26 Display
= TRUE
; // Most likely to be DISPLAY.
30 if (lpwszDevice
) // First
32 if (!_wcsnicmp(lpwszDevice
, L
"\\\\.\\DISPLAY",11)) Display
= TRUE
;
33 RtlInitUnicodeString(&Device
, lpwszDevice
);
37 if (lpwszDriver
) // Second
39 if ((!_wcsnicmp(lpwszDriver
, L
"DISPLAY",7)) ||
40 (!_wcsnicmp(lpwszDriver
, L
"\\\\.\\DISPLAY",11))) Display
= TRUE
;
41 RtlInitUnicodeString(&Device
, lpwszDriver
);
46 if (lpwszOutput
) RtlInitUnicodeString(&Output
, lpwszOutput
);
50 //Handle Print device or something else.
51 DPRINT1("Not a DISPLAY device! %wZ\n", &Device
);
54 hDC
= NtGdiOpenDCW( (Default
? &Device
: NULL
),
55 (PDEVMODEW
) lpInitData
,
56 (lpwszOutput
? &Output
: NULL
),
57 iType
, // DCW 0 and ICW 1.
59 (PVOID
) NULL
, // NULL for now.
62 // Handle something other than a normal dc object.
63 if (GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_DC
)
68 GdiGetHandleUserData((HGDIOBJ
) hDC
, (PVOID
) &Dc_Attr
);
70 pLDC
= LocalAlloc(LMEM_ZEROINIT
, sizeof(LDC
));
72 Dc_Attr
->pvLDC
= pLDC
;
74 pLDC
->iType
= LDC_LDC
; // 1 (init) local DC, 2 EMF LDC
75 DbgPrint("DC_ATTR Allocated -> 0x%x\n",Dc_Attr
);
87 CreateCompatibleDC ( HDC hdc
)
89 /* FIXME need sharememory if it metadc */
90 return NtGdiCreateCompatibleDC(hdc
);
102 CONST DEVMODEA
* lpdvmInit
105 ANSI_STRING DriverA
, DeviceA
, OutputA
;
106 UNICODE_STRING DriverU
, DeviceU
, OutputU
;
107 LPDEVMODEW dvmInitW
= NULL
;
111 * If needed, convert to Unicode
112 * any string parameter.
115 if (NULL
!= lpszDriver
)
117 RtlInitAnsiString(&DriverA
, (LPSTR
)lpszDriver
);
118 RtlAnsiStringToUnicodeString(&DriverU
, &DriverA
, TRUE
);
120 DriverU
.Buffer
= NULL
;
121 if (NULL
!= lpszDevice
)
123 RtlInitAnsiString(&DeviceA
, (LPSTR
)lpszDevice
);
124 RtlAnsiStringToUnicodeString(&DeviceU
, &DeviceA
, TRUE
);
126 DeviceU
.Buffer
= NULL
;
127 if (NULL
!= lpszOutput
)
129 RtlInitAnsiString(&OutputA
, (LPSTR
)lpszOutput
);
130 RtlAnsiStringToUnicodeString(&OutputU
, &OutputA
, TRUE
);
132 OutputU
.Buffer
= NULL
;
135 dvmInitW
= GdiConvertToDevmodeW((LPDEVMODEA
)lpdvmInit
);
137 hDC
= IntCreateDICW ( DriverU
.Buffer
,
140 lpdvmInit
? dvmInitW
: NULL
,
142 HEAP_free (dvmInitW
);
144 * Free Unicode parameters.
146 RtlFreeUnicodeString(&DriverU
);
147 RtlFreeUnicodeString(&DeviceU
);
148 RtlFreeUnicodeString(&OutputU
);
151 * Return the possible DC handle.
166 CONST DEVMODEW
*lpInitData
170 return IntCreateDICW ( lpwszDriver
,
173 (PDEVMODEW
) lpInitData
,
187 CONST DEVMODEW
*lpdvmInit
190 return IntCreateDICW ( lpszDriver
,
193 (PDEVMODEW
) lpdvmInit
,
207 CONST DEVMODEA
*lpdvmInit
211 LPWSTR lpszDriverW
, lpszDeviceW
, lpszOutputW
;
212 LPDEVMODEW dvmInitW
= NULL
;
215 Status
= HEAP_strdupA2W ( &lpszDriverW
, lpszDriver
);
216 if (!NT_SUCCESS (Status
))
217 SetLastError (RtlNtStatusToDosError(Status
));
220 Status
= HEAP_strdupA2W ( &lpszDeviceW
, lpszDevice
);
221 if (!NT_SUCCESS (Status
))
222 SetLastError (RtlNtStatusToDosError(Status
));
225 Status
= HEAP_strdupA2W ( &lpszOutputW
, lpszOutput
);
226 if (!NT_SUCCESS (Status
))
227 SetLastError (RtlNtStatusToDosError(Status
));
231 dvmInitW
= GdiConvertToDevmodeW((LPDEVMODEA
)lpdvmInit
);
233 rc
= IntCreateDICW ( lpszDriverW
,
236 lpdvmInit
? dvmInitW
: NULL
,
238 HEAP_free (dvmInitW
);
239 HEAP_free ( lpszOutputW
);
241 HEAP_free ( lpszDeviceW
);
243 HEAP_free ( lpszDriverW
);
261 if (!GdiGetHandleUserData((HGDIOBJ
) hDC
, (PVOID
) &Dc_Attr
)) return FALSE
;
265 pLDC
= Dc_Attr
->pvLDC
;
269 DPRINT1("Delete the Local DC structure\n");
274 Ret
= NtGdiDeleteObjectApp(hDC
);
284 DeleteObject(HGDIOBJ hObject
)
288 /* From Wine: DeleteObject does not SetLastError() on a null object */
289 if(!hObject
) return FALSE
;
291 if (0 != ((DWORD
) hObject
& GDI_HANDLE_STOCK_MASK
))
292 { // Relax! This is a normal return!
293 DPRINT("Trying to delete system object 0x%x\n", hObject
);
296 // If you dont own it?! Get OUT!
297 if(!GdiIsHandleValid(hObject
)) return FALSE
;
299 Type
= GDI_HANDLE_GET_TYPE(hObject
);
301 if ((Type
== GDI_OBJECT_TYPE_METAFILE
) ||
302 (Type
== GDI_OBJECT_TYPE_ENHMETAFILE
))
307 case GDI_OBJECT_TYPE_DC
:
308 return DeleteDC((HDC
) hObject
);
309 case GDI_OBJECT_TYPE_COLORSPACE
:
310 return NtGdiDeleteColorSpace((HCOLORSPACE
) hObject
);
311 case GDI_OBJECT_TYPE_REGION
:
312 return DeleteRegion((HRGN
) hObject
);
314 case GDI_OBJECT_TYPE_METADC
:
315 return MFDRV_DeleteObject( hObject
);
316 case GDI_OBJECT_TYPE_EMF
:
318 PLDC pLDC
= GdiGetLDC(hObject
);
319 if ( !pLDC
) return FALSE
;
320 return EMFDRV_DeleteObject( hObject
);
323 case GDI_OBJECT_TYPE_FONT
:
326 case GDI_OBJECT_TYPE_BRUSH
:
327 case GDI_OBJECT_TYPE_EXTPEN
:
328 case GDI_OBJECT_TYPE_PEN
:
330 PBRUSH_ATTR Brh_Attr
;
333 if ((!GdiGetHandleUserData(hObject
, (PVOID
) &Brh_Attr
)) ||
334 (Brh_Attr
== NULL
) ) break;
336 pTeb
= NtCurrentTeb();
338 if (pTeb
->Win32ThreadInfo
== NULL
) break;
340 if ((pTeb
->GdiTebBatch
.Offset
+ sizeof(GDIBSOBJECT
)) <= GDIBATCHBUFSIZE
)
342 PGDIBSOBJECT pgO
= (PGDIBSOBJECT
)(&pTeb
->GdiTebBatch
.Buffer
[0] +
343 pTeb
->GdiTebBatch
.Offset
);
344 pgO
->gbHdr
.Cmd
= GdiBCDelObj
;
345 pgO
->gbHdr
.Size
= sizeof(GDIBSOBJECT
);
346 pgO
->hgdiobj
= hObject
;
348 pTeb
->GdiTebBatch
.Offset
+= sizeof(GDIBSOBJECT
);
349 pTeb
->GdiBatchCount
++;
350 if (pTeb
->GdiBatchCount
>= GDI_BatchLimit
) NtGdiFlush();
355 case GDI_OBJECT_TYPE_BITMAP
:
359 return NtGdiDeleteObjectApp(hObject
);
364 GetArcDirection( HDC hdc
)
366 return GetDCDWord( hdc
, GdiGetArcDirection
, 0);
372 SetArcDirection( HDC hdc
, INT nDirection
)
374 return GetAndSetDCDWord( hdc
, GdiGetSetArcDirection
, nDirection
, 0, 0, 0 );
380 GetDCObject( HDC hDC
, INT iType
)
382 if((iType
== GDI_OBJECT_TYPE_BRUSH
) ||
383 (iType
== GDI_OBJECT_TYPE_EXTPEN
)||
384 (iType
== GDI_OBJECT_TYPE_PEN
) ||
385 (iType
== GDI_OBJECT_TYPE_COLORSPACE
))
390 if (!GdiGetHandleUserData((HGDIOBJ
) hDC
, (PVOID
) &Dc_Attr
)) return NULL
;
394 case GDI_OBJECT_TYPE_BRUSH
:
395 hGO
= Dc_Attr
->hbrush
;
398 case GDI_OBJECT_TYPE_EXTPEN
:
399 case GDI_OBJECT_TYPE_PEN
:
403 case GDI_OBJECT_TYPE_COLORSPACE
:
404 hGO
= Dc_Attr
->hColorSpace
;
409 return NtGdiGetDCObject( hDC
, iType
);
419 GetCurrentObject(HDC hdc
,
426 uObjectType
= GDI_OBJECT_TYPE_PEN
;
429 uObjectType
= GDI_OBJECT_TYPE_BRUSH
;
432 uObjectType
= GDI_OBJECT_TYPE_PALETTE
;
435 uObjectType
= GDI_OBJECT_TYPE_FONT
;
438 uObjectType
= GDI_OBJECT_TYPE_BITMAP
;
441 uObjectType
= GDI_OBJECT_TYPE_COLORSPACE
;
443 /* tests show that OBJ_REGION is explicitly ignored */
446 /* the SDK only mentions those above */
448 SetLastError(ERROR_INVALID_PARAMETER
);
451 return GetDCObject(hdc
, uObjectType
);
465 return GetDCDWord( hdc
, GdiGetRelAbs
, 0);
479 return GetAndSetDCDWord( hdc
, GdiGetSetRelAbs
, Mode
, 0, 0, 0 );
488 GetAndSetDCDWord( HDC hDC
, INT u
, DWORD dwIn
, DWORD Unk1
, DWORD Unk2
, DWORD Unk3
)
491 // Handle something other than a normal dc object.
492 if (GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_DC
)
494 if (GDI_HANDLE_GET_TYPE(hDC
) == GDI_OBJECT_TYPE_METADC
)
495 return 0; //call MFDRV
498 PLDC pLDC
= GdiGetLDC(hDC
);
501 SetLastError(ERROR_INVALID_HANDLE
);
504 if (pLDC
->iType
== LDC_EMFLDC
)
506 Ret
= TRUE
; //call EMFDRV
513 Ret
= NtGdiGetAndSetDCDword( hDC
, u
, dwIn
, (DWORD
*) &u
);
517 SetLastError(ERROR_INVALID_HANDLE
);
527 GetDCDWord( HDC hDC
, INT u
, DWORD Result
)
529 BOOL Ret
= NtGdiGetDCDword( hDC
, u
, (DWORD
*) &u
);
530 if (!Ret
) return Result
;
540 GetAspectRatioFilterEx(
545 return NtGdiGetDCPoint( hdc
, GdiGetAspectRatioFilter
, (LPPOINT
) lpAspectRatio
);
559 return NtGdiGetDCPoint( hdc
, GdiGetDCOrg
, lpPoint
);
572 // Officially obsolete by Microsoft
574 if (!GetDCOrgEx(hdc
, &Pt
))
576 return(MAKELONG(Pt
.x
, Pt
.y
));
581 GetNonFontObject(HGDIOBJ hGdiObj
, int cbSize
, LPVOID lpBuffer
)
585 hGdiObj
= (HANDLE
)GdiFixUpHandle(hGdiObj
);
586 dwType
= GDI_HANDLE_GET_TYPE(hGdiObj
);
588 if (!lpBuffer
) // Should pass it all to Win32k and let god sort it out. ;^)
592 case GDI_OBJECT_TYPE_PEN
:
593 return sizeof(LOGPEN
);
594 case GDI_OBJECT_TYPE_BRUSH
:
595 return sizeof(LOGBRUSH
);
596 case GDI_OBJECT_TYPE_BITMAP
:
597 return sizeof(BITMAP
);
598 case GDI_OBJECT_TYPE_PALETTE
:
600 case GDI_OBJECT_TYPE_EXTPEN
: /* we don't know the size, ask win32k */
607 case GDI_OBJECT_TYPE_PEN
: //Check the structures and see if A & W are the same.
608 case GDI_OBJECT_TYPE_EXTPEN
:
609 case GDI_OBJECT_TYPE_BRUSH
: // Mixing Apples and Oranges?
610 case GDI_OBJECT_TYPE_BITMAP
:
611 case GDI_OBJECT_TYPE_PALETTE
:
612 return NtGdiExtGetObjectW(hGdiObj
, cbSize
, lpBuffer
);
614 case GDI_OBJECT_TYPE_DC
:
615 case GDI_OBJECT_TYPE_REGION
:
616 case GDI_OBJECT_TYPE_METAFILE
:
617 case GDI_OBJECT_TYPE_ENHMETAFILE
:
618 case GDI_OBJECT_TYPE_EMF
:
619 SetLastError(ERROR_INVALID_HANDLE
);
630 GetObjectA(HGDIOBJ hGdiObj
, int cbSize
, LPVOID lpBuffer
)
632 ENUMLOGFONTEXDVW LogFont
;
636 dwType
= GDI_HANDLE_GET_TYPE(hGdiObj
);;
638 if(dwType
== GDI_OBJECT_TYPE_COLORSPACE
) //Stays here, processes struct A
640 SetLastError(ERROR_NOT_SUPPORTED
);
644 if (dwType
== GDI_OBJECT_TYPE_FONT
)
648 return sizeof(LOGFONTA
);
652 /* Windows does not SetLastError() */
655 // ENUMLOGFONTEXDVW is the default size and should be the structure for
656 // Entry->KernelData for Font objects.
657 Result
= NtGdiExtGetObjectW(hGdiObj
, sizeof(ENUMLOGFONTEXDVW
), &LogFont
);
666 case sizeof(ENUMLOGFONTEXDVA
):
667 // need to move more here.
668 case sizeof(ENUMLOGFONTEXA
):
669 EnumLogFontExW2A( (LPENUMLOGFONTEXA
) lpBuffer
, &LogFont
.elfEnumLogfontEx
);
672 case sizeof(ENUMLOGFONTA
):
673 // Same here, maybe? Check the structures.
674 case sizeof(EXTLOGFONTA
):
676 case sizeof(LOGFONTA
):
677 LogFontW2A((LPLOGFONTA
) lpBuffer
, &LogFont
.elfEnumLogfontEx
.elfLogFont
);
681 SetLastError(ERROR_BUFFER_OVERFLOW
);
687 return GetNonFontObject(hGdiObj
, cbSize
, lpBuffer
);
696 GetObjectW(HGDIOBJ hGdiObj
, int cbSize
, LPVOID lpBuffer
)
698 DWORD dwType
= GDI_HANDLE_GET_TYPE(hGdiObj
);
703 MSDN, "This can be a handle to one of the following: logical bitmap, a brush,
704 a font, a palette, a pen, or a device independent bitmap created by calling
705 the CreateDIBSection function."
707 if(dwType
== GDI_OBJECT_TYPE_COLORSPACE
) //Stays here, processes struct W
709 SetLastError(ERROR_NOT_SUPPORTED
); // Not supported yet.
713 if (dwType
== GDI_OBJECT_TYPE_FONT
)
717 return sizeof(LOGFONTW
);
722 /* Windows does not SetLastError() */
725 // Poorly written apps are not ReactOS problem!
726 // We fix it here if the size is larger than the default size.
727 if( cbSize
> sizeof(ENUMLOGFONTEXDVW
) ) cbSize
= sizeof(ENUMLOGFONTEXDVW
);
729 Result
= NtGdiExtGetObjectW(hGdiObj
, cbSize
, lpBuffer
); // Should handle the copy.
738 return GetNonFontObject(hGdiObj
, cbSize
, lpBuffer
);
753 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return CLR_INVALID
;
754 return (COLORREF
) Dc_Attr
->ulPenClr
;
768 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return CLR_INVALID
;
769 return (COLORREF
) Dc_Attr
->ulPenClr
;
783 COLORREF OldColor
= CLR_INVALID
;
785 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return OldColor
;
788 OldColor
= (COLORREF
) Dc_Attr
->ulBrushClr
;
789 Dc_Attr
->ulBrushClr
= (ULONG
) crColor
;
791 if ( Dc_Attr
->crBrushClr
!= crColor
) // if same, don't force a copy.
793 Dc_Attr
->ulDirty_
|= DIRTY_FILL
;
794 Dc_Attr
->crBrushClr
= crColor
;
811 COLORREF OldColor
= CLR_INVALID
;
813 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return OldColor
;
816 OldColor
= (COLORREF
) Dc_Attr
->ulPenClr
;
817 Dc_Attr
->ulPenClr
= (ULONG
) crColor
;
819 if ( Dc_Attr
->crPenClr
!= crColor
)
821 Dc_Attr
->ulDirty_
|= DIRTY_LINE
;
822 Dc_Attr
->crPenClr
= crColor
;
837 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return 0;
838 return Dc_Attr
->ulBackgroundClr
;
852 COLORREF OldColor
= CLR_INVALID
;
854 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return OldColor
;
856 if (GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_DC
)
858 if (GDI_HANDLE_GET_TYPE(hDC
) == GDI_OBJECT_TYPE_METADC
)
859 return MFDRV_SetBkColor( hDC
, crColor
);
862 PLDC pLDC
= Dc_Attr
->pvLDC
;
865 SetLastError(ERROR_INVALID_HANDLE
);
868 if (pLDC
->iType
== LDC_EMFLDC
)
870 return EMFDRV_SetBkColor( hDC
, crColor
);
875 OldColor
= (COLORREF
) Dc_Attr
->ulBackgroundClr
;
876 Dc_Attr
->ulBackgroundClr
= (ULONG
) crColor
;
878 if ( Dc_Attr
->crBackgroundClr
!= crColor
)
880 Dc_Attr
->ulDirty_
|= DIRTY_LINE
;
881 Dc_Attr
->crBackgroundClr
= crColor
;
895 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return 0;
896 return Dc_Attr
->lBkMode
;
911 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return OldMode
;
913 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
915 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
916 return MFDRV_SetBkMode( hdc
, iBkMode
)
919 PLDC pLDC
= Dc_Attr
->pvLDC
;
922 SetLastError(ERROR_INVALID_HANDLE
);
925 if (pLDC
->iType
== LDC_EMFLDC
)
927 return EMFDRV_SetBkMode( hdc
, iBkMode
)
932 OldMode
= Dc_Attr
->lBkMode
;
933 Dc_Attr
->jBkMode
= iBkMode
; // Processed
934 Dc_Attr
->lBkMode
= iBkMode
; // Raw
944 GetPolyFillMode(HDC hdc
)
947 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return 0;
948 return Dc_Attr
->lFillMode
;
956 SetPolyFillMode(HDC hdc
,
962 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
964 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
965 return MFDRV_SetPolyFillMode( hdc
, iPolyFillMode
)
968 PLDC pLDC
= GdiGetLDC(hdc
);
971 SetLastError(ERROR_INVALID_HANDLE
);
974 if (pLDC
->iType
== LDC_EMFLDC
)
976 return EMFDRV_SetPolyFillMode( hdc
, iPolyFillMode
)
981 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return 0;
983 if (NtCurrentTeb()->GdiTebBatch
.HDC
== (ULONG
)hdc
)
985 if (Dc_Attr
->ulDirty_
& DC_MODE_DIRTY
)
987 NtGdiFlush(); // Sync up Dc_Attr from Kernel space.
988 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
992 fmode
= Dc_Attr
->lFillMode
;
993 Dc_Attr
->lFillMode
= iPolyFillMode
;
1004 GetGraphicsMode(HDC hdc
)
1007 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return 0;
1008 return Dc_Attr
->iGraphicsMode
;
1016 SetGraphicsMode(HDC hdc
,
1021 if ((iMode
< GM_COMPATIBLE
) || (iMode
> GM_ADVANCED
))
1023 SetLastError(ERROR_INVALID_PARAMETER
);
1026 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return 0;
1028 if (iMode
== Dc_Attr
->iGraphicsMode
) return iMode
;
1030 if (NtCurrentTeb()->GdiTebBatch
.HDC
== (ULONG
)hdc
)
1032 if (Dc_Attr
->ulDirty_
& DC_MODE_DIRTY
)
1034 NtGdiFlush(); // Sync up Dc_Attr from Kernel space.
1035 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
1038 oMode
= Dc_Attr
->iGraphicsMode
;
1039 Dc_Attr
->iGraphicsMode
= iMode
;
1051 CONST DEVMODEW
*lpInitData
1054 NtGdiResetDC ( hdc
, (PDEVMODEW
)lpInitData
, NULL
, NULL
, NULL
);
1066 CONST DEVMODEA
*lpInitData
1069 LPDEVMODEW InitDataW
;
1071 InitDataW
= GdiConvertToDevmodeW((LPDEVMODEA
)lpInitData
);
1073 NtGdiResetDC ( hdc
, InitDataW
, NULL
, NULL
, NULL
);
1074 HEAP_free(InitDataW
);
1089 return NtGdiStartDoc ( hdc
, (DOCINFOW
*)a1
, NULL
, 0);
1104 if(GdiIsHandleValid(h
))
1106 LONG Type
= GDI_HANDLE_GET_TYPE(h
);
1109 case GDI_OBJECT_TYPE_PEN
:
1112 case GDI_OBJECT_TYPE_BRUSH
:
1115 case GDI_OBJECT_TYPE_BITMAP
:
1118 case GDI_OBJECT_TYPE_FONT
:
1121 case GDI_OBJECT_TYPE_PALETTE
:
1124 case GDI_OBJECT_TYPE_REGION
:
1127 case GDI_OBJECT_TYPE_DC
:
1128 if ( GetDCDWord( h
, GdiGetIsMemDc
, 0))
1135 case GDI_OBJECT_TYPE_COLORSPACE
:
1136 Ret
= OBJ_COLORSPACE
;
1138 case GDI_OBJECT_TYPE_METAFILE
:
1141 case GDI_OBJECT_TYPE_ENHMETAFILE
:
1142 Ret
= OBJ_ENHMETAFILE
;
1144 case GDI_OBJECT_TYPE_METADC
:
1147 case GDI_OBJECT_TYPE_EXTPEN
:
1152 DPRINT1("GetObjectType: Magic 0x%08x not implemented\n", Type
);
1157 /* From Wine: GetObjectType does SetLastError() on a null object */
1158 SetLastError(ERROR_INVALID_HANDLE
);
1173 if ((h
< 0) || (h
>= NB_STOCK_OBJECTS
)) return Ret
;
1174 Ret
= stock_objects
[h
];
1177 HGDIOBJ Obj
= NtGdiGetStockObject( h
);
1179 if (GdiIsHandleValid(Obj
))
1181 stock_objects
[h
] = Obj
;
1183 }// Returns Null anyway.
1198 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return FALSE
;
1200 if ( Dc_Attr
->flXform
& PAGE_EXTENTS_CHANGED
) // Something was updated, go to kernel.
1201 return NtGdiGetDCPoint( hdc
, GdiGetViewPortExt
, (LPPOINT
) lpSize
);
1204 lpSize
->cx
= Dc_Attr
->szlViewportExt
.cx
;
1205 lpSize
->cy
= Dc_Attr
->szlViewportExt
.cy
;
1220 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return FALSE
;
1221 lpPoint
->x
= Dc_Attr
->ptlViewportOrg
.x
;
1222 lpPoint
->x
= Dc_Attr
->ptlViewportOrg
.x
;
1224 // return NtGdiGetDCPoint( hdc, GdiGetViewPortOrg, lpPoint );
1237 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return FALSE
;
1238 lpSize
->cx
= Dc_Attr
->szlWindowExt
.cx
;
1239 lpSize
->cy
= Dc_Attr
->szlWindowExt
.cy
;
1241 // return NtGdiGetDCPoint( hdc, GdiGetWindowExt, (LPPOINT) lpSize );
1254 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return FALSE
;
1255 lpPoint
->x
= Dc_Attr
->ptlWindowOrg
.x
;
1256 lpPoint
->x
= Dc_Attr
->ptlWindowOrg
.x
;
1258 //return NtGdiGetDCPoint( hdc, GdiGetWindowOrg, lpPoint );
1266 SetViewportExtEx(HDC hdc
,
1274 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
1276 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
1277 return MFDRV_SetViewportExtEx();
1280 PLDC pLDC
= GdiGetLDC(hdc
);
1283 SetLastError(ERROR_INVALID_HANDLE
);
1286 if (pLDC
->iType
== LDC_EMFLDC
)
1288 return EMFDRV_SetViewportExtEx();
1293 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return FALSE
;
1297 lpSize
->cx
= Dc_Attr
->szlWindowExt
.cx
;
1298 lpSize
->cy
= Dc_Attr
->szlWindowExt
.cy
;
1301 if ((Dc_Attr
->iMapMode
== MM_ISOTROPIC
) && (Dc_Attr
->iMapMode
== MM_ANISOTROPIC
))
1303 if (NtCurrentTeb()->GdiTebBatch
.HDC
== (ULONG
)hdc
)
1305 if (Dc_Attr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
1307 NtGdiFlush(); // Sync up Dc_Attr from Kernel space.
1308 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
1312 Dc_Attr
->flXform
|= (PAGE_EXTENTS_CHANGED
|INVALIDATE_ATTRIBUTES
|DEVICE_TO_WORLD_INVALID
);
1313 Dc_Attr
->szlWindowExt
.cx
= nXExtent
;
1314 Dc_Attr
->szlWindowExt
.cy
= nYExtent
;
1318 return NtGdiSetViewportExtEx(hdc
, nXExtent
, nYExtent
, lpSize
);
1326 SetWindowOrgEx(HDC hdc
,
1334 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
1336 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
1337 return MFDRV_SetWindowOrgEx();
1340 PLDC pLDC
= GdiGetLDC(hdc
);
1343 SetLastError(ERROR_INVALID_HANDLE
);
1346 if (pLDC
->iType
== LDC_EMFLDC
)
1348 return EMFDRV_SetWindowOrgEx();
1353 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return FALSE
;
1357 lpPoint
->x
= Dc_Attr
->ptlWindowOrg
.x
;
1358 lpPoint
->y
= Dc_Attr
->ptlWindowOrg
.y
;
1361 if ((Dc_Attr
->ptlWindowOrg
.x
== X
) && (Dc_Attr
->ptlWindowOrg
.y
== Y
))
1364 if (NtCurrentTeb()->GdiTebBatch
.HDC
== (ULONG
)hdc
)
1366 if (Dc_Attr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
1368 NtGdiFlush(); // Sync up Dc_Attr from Kernel space.
1369 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
1373 Dc_Attr
->flXform
|= (PAGE_XLATE_CHANGED
|DEVICE_TO_WORLD_INVALID
);
1374 Dc_Attr
->ptlWindowOrg
.x
= X
;
1375 Dc_Attr
->ptlWindowOrg
.y
= Y
;
1378 return NtGdiSetWindowOrgEx(hdc
,X
,Y
,lpPoint
);
1386 SetWindowExtEx(HDC hdc
,
1394 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
1396 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
1397 return MFDRV_SetWindowExtEx();
1400 PLDC pLDC
= GdiGetLDC(hdc
);
1403 SetLastError(ERROR_INVALID_HANDLE
);
1406 if (pLDC
->iType
== LDC_EMFLDC
)
1408 return EMFDRV_SetWindowExtEx();
1413 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return FALSE
;
1417 lpSize
->cx
= Dc_Attr
->szlWindowExt
.cx
;
1418 lpSize
->cy
= Dc_Attr
->szlWindowExt
.cy
;
1421 if ((Dc_Attr
->iMapMode
== MM_ISOTROPIC
) && (Dc_Attr
->iMapMode
== MM_ANISOTROPIC
))
1423 if ((Dc_Attr
->szlWindowExt
.cx
== nXExtent
) && (Dc_Attr
->szlWindowExt
.cy
== nYExtent
))
1426 if ((!nXExtent
) && (!nYExtent
)) return FALSE
;
1428 if (NtCurrentTeb()->GdiTebBatch
.HDC
== (ULONG
)hdc
)
1430 if (Dc_Attr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
1432 NtGdiFlush(); // Sync up Dc_Attr from Kernel space.
1433 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
1437 Dc_Attr
->flXform
|= (PAGE_EXTENTS_CHANGED
|INVALIDATE_ATTRIBUTES
|DEVICE_TO_WORLD_INVALID
);
1438 Dc_Attr
->szlWindowExt
.cx
= nXExtent
;
1439 Dc_Attr
->szlWindowExt
.cy
= nYExtent
;
1443 return NtGdiSetWindowExtEx(hdc
, nXExtent
, nYExtent
, lpSize
);
1451 SetViewportOrgEx(HDC hdc
,
1459 if (GDI_HANDLE_GET_TYPE(hdc
) != GDI_OBJECT_TYPE_DC
)
1461 if (GDI_HANDLE_GET_TYPE(hdc
) == GDI_OBJECT_TYPE_METADC
)
1462 return MFDRV_SetViewportOrgEx();
1465 PLDC pLDC
= GdiGetLDC(hdc
);
1468 SetLastError(ERROR_INVALID_HANDLE
);
1471 if (pLDC
->iType
== LDC_EMFLDC
)
1473 return EMFDRV_SetViewportOrgEx();
1478 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return FALSE
;
1482 lpPoint
->x
= Dc_Attr
->ptlViewportOrg
.x
;
1483 lpPoint
->y
= Dc_Attr
->ptlViewportOrg
.y
;
1485 Dc_Attr
->flXform
|= (PAGE_XLATE_CHANGED
|DEVICE_TO_WORLD_INVALID
);
1486 Dc_Attr
->ptlViewportOrg
.x
= X
;
1487 Dc_Attr
->ptlViewportOrg
.y
= Y
;
1490 return NtGdiSetViewportOrgEx(hdc
,X
,Y
,lpPoint
);
1495 /* FIXME: include correct header */
1496 HPALETTE STDCALL
NtUserSelectPalette(HDC hDC
,
1498 BOOL ForceBackground
);
1505 BOOL bForceBackground
)
1508 if (GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_DC
)
1510 if (GDI_HANDLE_GET_TYPE(hDC
) == GDI_OBJECT_TYPE_METADC
)
1511 return MFDRV_SelectPalette( hDC
, hPal
, bForceBackground
);
1514 PLDC pLDC
= GdiGetLDC(hDC
);
1517 SetLastError(ERROR_INVALID_HANDLE
);
1520 if (pLDC
->iType
== LDC_EMFLDC
)
1522 if return EMFDRV_SelectPalette( hDC
, hPal
, bForceBackground
);
1527 return NtUserSelectPalette(hDC
, hPal
, bForceBackground
);
1539 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return 0;
1540 return Dc_Attr
->iMapMode
;
1554 if (!GdiGetHandleUserData((HGDIOBJ
) hdc
, (PVOID
) &Dc_Attr
)) return 0;
1556 if (GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_DC
)
1558 if (GDI_HANDLE_GET_TYPE(hDC
) == GDI_OBJECT_TYPE_METADC
)
1559 return MFDRV_SetMapMode(hdc
, Mode
);
1562 SetLastError(ERROR_INVALID_HANDLE
);
1566 if ((Mode
== Dc_Attr
->iMapMode
) && (Mode
!= MM_ISOTROPIC
)) return Mode
;
1567 return GetAndSetDCDWord( hdc
, GdiGetSetMapMode
, Mode
, 0, 0, 0 );