Enclose application name in double quotation marks, as it may contain
[wine] / dlls / gdi / gdi16.c
1 /*
2  * GDI 16-bit functions
3  *
4  * Copyright 2002 Alexandre Julliard
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <stdarg.h>
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wingdi.h"
26 #include "wownt32.h"
27 #include "wine/wingdi16.h"
28 #include "gdi.h"
29 #include "wine/debug.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
32
33 #define HGDIOBJ_32(handle16)    ((HGDIOBJ)(ULONG_PTR)(handle16))
34 #define HGDIOBJ_16(handle32)    ((HGDIOBJ16)(ULONG_PTR)(handle32))
35
36 struct callback16_info
37 {
38     FARPROC16 proc;
39     LPARAM    param;
40 };
41
42 /* callback for LineDDA16 */
43 static void CALLBACK linedda_callback( INT x, INT y, LPARAM param )
44 {
45     const struct callback16_info *info = (struct callback16_info *)param;
46     WORD args[4];
47
48     args[3] = x;
49     args[2] = y;
50     args[1] = HIWORD(info->param);
51     args[0] = LOWORD(info->param);
52     WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, NULL );
53 }
54
55 /* callback for EnumObjects16 */
56 static INT CALLBACK enum_pens_callback( void *ptr, LPARAM param )
57 {
58     const struct callback16_info *info = (struct callback16_info *)param;
59     LOGPEN *pen = ptr;
60     LOGPEN16 pen16;
61     SEGPTR segptr;
62     DWORD ret;
63     WORD args[4];
64
65     pen16.lopnStyle   = pen->lopnStyle;
66     pen16.lopnWidth.x = pen->lopnWidth.x;
67     pen16.lopnWidth.y = pen->lopnWidth.y;
68     pen16.lopnColor   = pen->lopnColor;
69     segptr = MapLS( &pen16 );
70     args[3] = SELECTOROF(segptr);
71     args[2] = OFFSETOF(segptr);
72     args[1] = HIWORD(info->param);
73     args[0] = LOWORD(info->param);
74     WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
75     UnMapLS( segptr );
76     return LOWORD(ret);
77 }
78
79 /* callback for EnumObjects16 */
80 static INT CALLBACK enum_brushes_callback( void *ptr, LPARAM param )
81 {
82     const struct callback16_info *info = (struct callback16_info *)param;
83     LOGBRUSH *brush = ptr;
84     LOGBRUSH16 brush16;
85     SEGPTR segptr;
86     DWORD ret;
87     WORD args[4];
88
89     brush16.lbStyle = brush->lbStyle;
90     brush16.lbColor = brush->lbColor;
91     brush16.lbHatch = brush->lbHatch;
92     segptr = MapLS( &brush16 );
93     args[3] = SELECTOROF(segptr);
94     args[2] = OFFSETOF(segptr);
95     args[1] = HIWORD(info->param);
96     args[0] = LOWORD(info->param);
97     WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
98     UnMapLS( segptr );
99     return ret;
100 }
101
102 /* convert a LOGFONT16 to a LOGFONTW */
103 static void logfont_16_to_W( const LOGFONT16 *font16, LPLOGFONTW font32 )
104 {
105     font32->lfHeight = font16->lfHeight;
106     font32->lfWidth = font16->lfWidth;
107     font32->lfEscapement = font16->lfEscapement;
108     font32->lfOrientation = font16->lfOrientation;
109     font32->lfWeight = font16->lfWeight;
110     font32->lfItalic = font16->lfItalic;
111     font32->lfUnderline = font16->lfUnderline;
112     font32->lfStrikeOut = font16->lfStrikeOut;
113     font32->lfCharSet = font16->lfCharSet;
114     font32->lfOutPrecision = font16->lfOutPrecision;
115     font32->lfClipPrecision = font16->lfClipPrecision;
116     font32->lfQuality = font16->lfQuality;
117     font32->lfPitchAndFamily = font16->lfPitchAndFamily;
118     MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE );
119     font32->lfFaceName[LF_FACESIZE-1] = 0;
120 }
121
122
123 /***********************************************************************
124  *           SetBkColor    (GDI.1)
125  */
126 COLORREF WINAPI SetBkColor16( HDC16 hdc, COLORREF color )
127 {
128     return SetBkColor( HDC_32(hdc), color );
129 }
130
131
132 /***********************************************************************
133  *              SetBkMode (GDI.2)
134  */
135 INT16 WINAPI SetBkMode16( HDC16 hdc, INT16 mode )
136 {
137     return SetBkMode( HDC_32(hdc), mode );
138 }
139
140
141 /***********************************************************************
142  *           SetMapMode    (GDI.3)
143  */
144 INT16 WINAPI SetMapMode16( HDC16 hdc, INT16 mode )
145 {
146     return SetMapMode( HDC_32(hdc), mode );
147 }
148
149
150 /***********************************************************************
151  *              SetROP2 (GDI.4)
152  */
153 INT16 WINAPI SetROP216( HDC16 hdc, INT16 mode )
154 {
155     return SetROP2( HDC_32(hdc), mode );
156 }
157
158
159 /***********************************************************************
160  *              SetRelAbs (GDI.5)
161  */
162 INT16 WINAPI SetRelAbs16( HDC16 hdc, INT16 mode )
163 {
164     return SetRelAbs( HDC_32(hdc), mode );
165 }
166
167
168 /***********************************************************************
169  *              SetPolyFillMode (GDI.6)
170  */
171 INT16 WINAPI SetPolyFillMode16( HDC16 hdc, INT16 mode )
172 {
173     return SetPolyFillMode( HDC_32(hdc), mode );
174 }
175
176
177 /***********************************************************************
178  *              SetStretchBltMode (GDI.7)
179  */
180 INT16 WINAPI SetStretchBltMode16( HDC16 hdc, INT16 mode )
181 {
182     return SetStretchBltMode( HDC_32(hdc), mode );
183 }
184
185
186 /***********************************************************************
187  *           SetTextCharacterExtra    (GDI.8)
188  */
189 INT16 WINAPI SetTextCharacterExtra16( HDC16 hdc, INT16 extra )
190 {
191     return SetTextCharacterExtra( HDC_32(hdc), extra );
192 }
193
194
195 /***********************************************************************
196  *           SetTextColor    (GDI.9)
197  */
198 COLORREF WINAPI SetTextColor16( HDC16 hdc, COLORREF color )
199 {
200     return SetTextColor( HDC_32(hdc), color );
201 }
202
203
204 /***********************************************************************
205  *           SetTextJustification    (GDI.10)
206  */
207 INT16 WINAPI SetTextJustification16( HDC16 hdc, INT16 extra, INT16 breaks )
208 {
209     return SetTextJustification( HDC_32(hdc), extra, breaks );
210 }
211
212
213 /***********************************************************************
214  *           SetWindowOrg    (GDI.11)
215  */
216 DWORD WINAPI SetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
217 {
218     POINT pt;
219     if (!SetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
220     return MAKELONG( pt.x, pt.y );
221 }
222
223
224 /***********************************************************************
225  *           SetWindowExt    (GDI.12)
226  */
227 DWORD WINAPI SetWindowExt16( HDC16 hdc, INT16 x, INT16 y )
228 {
229     SIZE size;
230     if (!SetWindowExtEx( HDC_32(hdc), x, y, &size )) return 0;
231     return MAKELONG( size.cx, size.cy );
232 }
233
234
235 /***********************************************************************
236  *           SetViewportOrg    (GDI.13)
237  */
238 DWORD WINAPI SetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
239 {
240     POINT pt;
241     if (!SetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
242     return MAKELONG( pt.x, pt.y );
243 }
244
245
246 /***********************************************************************
247  *           SetViewportExt    (GDI.14)
248  */
249 DWORD WINAPI SetViewportExt16( HDC16 hdc, INT16 x, INT16 y )
250 {
251     SIZE size;
252     if (!SetViewportExtEx( HDC_32(hdc), x, y, &size )) return 0;
253     return MAKELONG( size.cx, size.cy );
254 }
255
256
257 /***********************************************************************
258  *           OffsetWindowOrg    (GDI.15)
259  */
260 DWORD WINAPI OffsetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
261 {
262     POINT pt;
263     if (!OffsetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
264     return MAKELONG( pt.x, pt.y );
265 }
266
267
268 /***********************************************************************
269  *           ScaleWindowExt    (GDI.16)
270  */
271 DWORD WINAPI ScaleWindowExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
272                              INT16 yNum, INT16 yDenom )
273 {
274     SIZE size;
275     if (!ScaleWindowExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
276         return FALSE;
277     return MAKELONG( size.cx,  size.cy );
278 }
279
280
281 /***********************************************************************
282  *           OffsetViewportOrg    (GDI.17)
283  */
284 DWORD WINAPI OffsetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
285 {
286     POINT pt;
287     if (!OffsetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
288     return MAKELONG( pt.x, pt.y );
289 }
290
291
292 /***********************************************************************
293  *           ScaleViewportExt    (GDI.18)
294  */
295 DWORD WINAPI ScaleViewportExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
296                                INT16 yNum, INT16 yDenom )
297 {
298     SIZE size;
299     if (!ScaleViewportExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
300         return FALSE;
301     return MAKELONG( size.cx,  size.cy );
302 }
303
304
305 /***********************************************************************
306  *           LineTo    (GDI.19)
307  */
308 BOOL16 WINAPI LineTo16( HDC16 hdc, INT16 x, INT16 y )
309 {
310     return LineTo( HDC_32(hdc), x, y );
311 }
312
313
314 /***********************************************************************
315  *           MoveTo    (GDI.20)
316  */
317 DWORD WINAPI MoveTo16( HDC16 hdc, INT16 x, INT16 y )
318 {
319     POINT pt;
320
321     if (!MoveToEx( HDC_32(hdc), x, y, &pt )) return 0;
322     return MAKELONG(pt.x,pt.y);
323 }
324
325
326 /***********************************************************************
327  *           ExcludeClipRect    (GDI.21)
328  */
329 INT16 WINAPI ExcludeClipRect16( HDC16 hdc, INT16 left, INT16 top,
330                                 INT16 right, INT16 bottom )
331 {
332     return ExcludeClipRect( HDC_32(hdc), left, top, right, bottom );
333 }
334
335
336 /***********************************************************************
337  *           IntersectClipRect    (GDI.22)
338  */
339 INT16 WINAPI IntersectClipRect16( HDC16 hdc, INT16 left, INT16 top,
340                                   INT16 right, INT16 bottom )
341 {
342     return IntersectClipRect( HDC_32(hdc), left, top, right, bottom );
343 }
344
345
346 /***********************************************************************
347  *           Arc    (GDI.23)
348  */
349 BOOL16 WINAPI Arc16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
350                      INT16 bottom, INT16 xstart, INT16 ystart,
351                      INT16 xend, INT16 yend )
352 {
353     return Arc( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
354 }
355
356
357 /***********************************************************************
358  *           Ellipse    (GDI.24)
359  */
360 BOOL16 WINAPI Ellipse16( HDC16 hdc, INT16 left, INT16 top,
361                          INT16 right, INT16 bottom )
362 {
363     return Ellipse( HDC_32(hdc), left, top, right, bottom );
364 }
365
366
367 /**********************************************************************
368  *          FloodFill   (GDI.25)
369  */
370 BOOL16 WINAPI FloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
371 {
372     return ExtFloodFill( HDC_32(hdc), x, y, color, FLOODFILLBORDER );
373 }
374
375
376 /***********************************************************************
377  *           Pie    (GDI.26)
378  */
379 BOOL16 WINAPI Pie16( HDC16 hdc, INT16 left, INT16 top,
380                      INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
381                      INT16 xend, INT16 yend )
382 {
383     return Pie( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
384 }
385
386
387 /***********************************************************************
388  *           Rectangle    (GDI.27)
389  */
390 BOOL16 WINAPI Rectangle16( HDC16 hdc, INT16 left, INT16 top,
391                            INT16 right, INT16 bottom )
392 {
393     return Rectangle( HDC_32(hdc), left, top, right, bottom );
394 }
395
396
397 /***********************************************************************
398  *           RoundRect    (GDI.28)
399  */
400 BOOL16 WINAPI RoundRect16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
401                            INT16 bottom, INT16 ell_width, INT16 ell_height )
402 {
403     return RoundRect( HDC_32(hdc), left, top, right, bottom, ell_width, ell_height );
404 }
405
406
407 /***********************************************************************
408  *           PatBlt    (GDI.29)
409  */
410 BOOL16 WINAPI PatBlt16( HDC16 hdc, INT16 left, INT16 top,
411                         INT16 width, INT16 height, DWORD rop)
412 {
413     return PatBlt( HDC_32(hdc), left, top, width, height, rop );
414 }
415
416
417 /***********************************************************************
418  *           SaveDC    (GDI.30)
419  */
420 INT16 WINAPI SaveDC16( HDC16 hdc )
421 {
422     return SaveDC( HDC_32(hdc) );
423 }
424
425
426 /***********************************************************************
427  *           SetPixel    (GDI.31)
428  */
429 COLORREF WINAPI SetPixel16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
430 {
431     return SetPixel( HDC_32(hdc), x, y, color );
432 }
433
434
435 /***********************************************************************
436  *           OffsetClipRgn    (GDI.32)
437  */
438 INT16 WINAPI OffsetClipRgn16( HDC16 hdc, INT16 x, INT16 y )
439 {
440     return OffsetClipRgn( HDC_32(hdc), x, y );
441 }
442
443
444 /***********************************************************************
445  *           TextOut    (GDI.33)
446  */
447 BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
448 {
449     return TextOutA( HDC_32(hdc), x, y, str, count );
450 }
451
452
453 /***********************************************************************
454  *           BitBlt    (GDI.34)
455  */
456 BOOL16 WINAPI BitBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst, INT16 width,
457                         INT16 height, HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
458                         DWORD rop )
459 {
460     return BitBlt( HDC_32(hdcDst), xDst, yDst, width, height, HDC_32(hdcSrc), xSrc, ySrc, rop );
461 }
462
463
464 /***********************************************************************
465  *           StretchBlt    (GDI.35)
466  */
467 BOOL16 WINAPI StretchBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst,
468                             INT16 widthDst, INT16 heightDst,
469                             HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
470                             INT16 widthSrc, INT16 heightSrc, DWORD rop )
471 {
472     return StretchBlt( HDC_32(hdcDst), xDst, yDst, widthDst, heightDst,
473                        HDC_32(hdcSrc), xSrc, ySrc, widthSrc, heightSrc, rop );
474 }
475
476
477 /**********************************************************************
478  *          Polygon  (GDI.36)
479  */
480 BOOL16 WINAPI Polygon16( HDC16 hdc, const POINT16* pt, INT16 count )
481 {
482     register int i;
483     BOOL ret;
484     LPPOINT pt32 = (LPPOINT)HeapAlloc( GetProcessHeap(), 0,
485                                            count*sizeof(POINT) );
486
487     if (!pt32) return FALSE;
488     for (i=count;i--;) CONV_POINT16TO32(&(pt[i]),&(pt32[i]));
489     ret = Polygon(HDC_32(hdc),pt32,count);
490     HeapFree( GetProcessHeap(), 0, pt32 );
491     return ret;
492 }
493
494
495 /**********************************************************************
496  *          Polyline  (GDI.37)
497  */
498 BOOL16 WINAPI Polyline16( HDC16 hdc, const POINT16* pt, INT16 count )
499 {
500     register int i;
501     BOOL16 ret;
502     LPPOINT pt32 = (LPPOINT)HeapAlloc( GetProcessHeap(), 0,
503                                            count*sizeof(POINT) );
504
505     if (!pt32) return FALSE;
506     for (i=count;i--;) CONV_POINT16TO32(&(pt[i]),&(pt32[i]));
507     ret = Polyline(HDC_32(hdc),pt32,count);
508     HeapFree( GetProcessHeap(), 0, pt32 );
509     return ret;
510 }
511
512
513 /***********************************************************************
514  *            Escape   (GDI.38)
515  */
516 INT16 WINAPI Escape16( HDC16 hdc, INT16 escape, INT16 in_count, SEGPTR in_data, LPVOID out_data )
517 {
518     INT ret;
519
520     switch(escape)
521     {
522     /* Escape(hdc,CLIP_TO_PATH,LPINT16,NULL) */
523     /* Escape(hdc,DRAFTMODE,LPINT16,NULL) */
524     /* Escape(hdc,ENUMPAPERBINS,LPINT16,LPSTR); */
525     /* Escape(hdc,EPSPRINTING,LPINT16,NULL) */
526     /* Escape(hdc,EXT_DEVICE_CAPS,LPINT16,LPDWORD) */
527     /* Escape(hdc,GETCOLORTABLE,LPINT16,LPDWORD) */
528     /* Escape(hdc,MOUSETRAILS,LPINT16,NULL) */
529     /* Escape(hdc,POSTSCRIPT_IGNORE,LPINT16,NULL) */
530     /* Escape(hdc,QUERYESCSUPPORT,LPINT16,NULL) */
531     /* Escape(hdc,SET_ARC_DIRECTION,LPINT16,NULL) */
532     /* Escape(hdc,SET_POLY_MODE,LPINT16,NULL) */
533     /* Escape(hdc,SET_SCREEN_ANGLE,LPINT16,NULL) */
534     /* Escape(hdc,SET_SPREAD,LPINT16,NULL) */
535     case CLIP_TO_PATH:
536     case DRAFTMODE:
537     case ENUMPAPERBINS:
538     case EPSPRINTING:
539     case EXT_DEVICE_CAPS:
540     case GETCOLORTABLE:
541     case MOUSETRAILS:
542     case POSTSCRIPT_IGNORE:
543     case QUERYESCSUPPORT:
544     case SET_ARC_DIRECTION:
545     case SET_POLY_MODE:
546     case SET_SCREEN_ANGLE:
547     case SET_SPREAD:
548     {
549         INT16 *ptr = MapSL(in_data);
550         INT data = *ptr;
551         return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, out_data );
552     }
553
554     /* Escape(hdc,ENABLEDUPLEX,LPUINT16,NULL) */
555     case ENABLEDUPLEX:
556     {
557         UINT16 *ptr = MapSL(in_data);
558         UINT data = *ptr;
559         return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, NULL );
560     }
561
562     /* Escape(hdc,GETPHYSPAGESIZE,NULL,LPPOINT16) */
563     /* Escape(hdc,GETPRINTINGOFFSET,NULL,LPPOINT16) */
564     /* Escape(hdc,GETSCALINGFACTOR,NULL,LPPOINT16) */
565     case GETPHYSPAGESIZE:
566     case GETPRINTINGOFFSET:
567     case GETSCALINGFACTOR:
568     {
569         POINT16 *ptr = out_data;
570         POINT pt32;
571         ret = Escape( HDC_32(hdc), escape, 0, NULL, &pt32 );
572         ptr->x = pt32.x;
573         ptr->y = pt32.y;
574         return ret;
575     }
576
577     /* Escape(hdc,ENABLEPAIRKERNING,LPINT16,LPINT16); */
578     /* Escape(hdc,ENABLERELATIVEWIDTHS,LPINT16,LPINT16); */
579     /* Escape(hdc,SETCOPYCOUNT,LPINT16,LPINT16) */
580     /* Escape(hdc,SETKERNTRACK,LPINT16,LPINT16) */
581     /* Escape(hdc,SETLINECAP,LPINT16,LPINT16) */
582     /* Escape(hdc,SETLINEJOIN,LPINT16,LPINT16) */
583     /* Escape(hdc,SETMITERLIMIT,LPINT16,LPINT16) */
584     case ENABLEPAIRKERNING:
585     case ENABLERELATIVEWIDTHS:
586     case SETCOPYCOUNT:
587     case SETKERNTRACK:
588     case SETLINECAP:
589     case SETLINEJOIN:
590     case SETMITERLIMIT:
591     {
592         INT16 *new = MapSL(in_data);
593         INT16 *old = out_data;
594         INT out, in = *new;
595         ret = Escape( HDC_32(hdc), escape, sizeof(in), (LPCSTR)&in, &out );
596         *old = out;
597         return ret;
598     }
599
600     /* Escape(hdc,SETABORTPROC,ABORTPROC,NULL); */
601     case SETABORTPROC:
602         return SetAbortProc16( hdc, (ABORTPROC16)in_data );
603
604     /* Escape(hdc,STARTDOC,LPSTR,LPDOCINFO16);
605      * lpvOutData is actually a pointer to the DocInfo structure and used as
606      * a second input parameter */
607     case STARTDOC:
608         if (out_data)
609         {
610             ret = StartDoc16( hdc, out_data );
611             if (ret > 0) ret = StartPage( HDC_32(hdc) );
612             return ret;
613         }
614         return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), NULL );
615
616     /* Escape(hdc,SET_BOUNDS,LPRECT16,NULL); */
617     /* Escape(hdc,SET_CLIP_BOX,LPRECT16,NULL); */
618     case SET_BOUNDS:
619     case SET_CLIP_BOX:
620     {
621         RECT16 *rc16 = MapSL(in_data);
622         RECT rc;
623         rc.left   = rc16->left;
624         rc.top    = rc16->top;
625         rc.right  = rc16->right;
626         rc.bottom = rc16->bottom;
627         return Escape( HDC_32(hdc), escape, sizeof(rc), (LPCSTR)&rc, NULL );
628     }
629
630     /* Escape(hdc,NEXTBAND,NULL,LPRECT16); */
631     case NEXTBAND:
632     {
633         RECT rc;
634         RECT16 *rc16 = out_data;
635         ret = Escape( HDC_32(hdc), escape, 0, NULL, &rc );
636         rc16->left   = rc.left;
637         rc16->top    = rc.top;
638         rc16->right  = rc.right;
639         rc16->bottom = rc.bottom;
640         return ret;
641     }
642
643     /* Escape(hdc,ABORTDOC,NULL,NULL); */
644     /* Escape(hdc,BANDINFO,BANDINFOSTRUCT*,BANDINFOSTRUCT*); */
645     /* Escape(hdc,BEGIN_PATH,NULL,NULL); */
646     /* Escape(hdc,DRAWPATTERNRECT,PRECT_STRUCT*,NULL); */
647     /* Escape(hdc,ENDDOC,NULL,NULL); */
648     /* Escape(hdc,END_PATH,PATHINFO,NULL); */
649     /* Escape(hdc,EXTTEXTOUT,EXTTEXT_STRUCT*,NULL); */
650     /* Escape(hdc,FLUSHOUTPUT,NULL,NULL); */
651     /* Escape(hdc,GETFACENAME,NULL,LPSTR); */
652     /* Escape(hdc,GETPAIRKERNTABLE,NULL,KERNPAIR*); */
653     /* Escape(hdc,GETSETPAPERBINS,BinInfo*,BinInfo*); */
654     /* Escape(hdc,GETSETPRINTORIENT,ORIENT*,NULL); */
655     /* Escape(hdc,GETSETSCREENPARAMS,SCREENPARAMS*,SCREENPARAMS*); */
656     /* Escape(hdc,GETTECHNOLOGY,NULL,LPSTR); */
657     /* Escape(hdc,GETTRACKKERNTABLE,NULL,KERNTRACK*); */
658     /* Escape(hdc,MFCOMMENT,LPSTR,NULL); */
659     /* Escape(hdc,NEWFRAME,NULL,NULL); */
660     /* Escape(hdc,PASSTHROUGH,LPSTR,NULL); */
661     /* Escape(hdc,RESTORE_CTM,NULL,NULL); */
662     /* Escape(hdc,SAVE_CTM,NULL,NULL); */
663     /* Escape(hdc,SETALLJUSTVALUES,EXTTEXTDATA*,NULL); */
664     /* Escape(hdc,SETCOLORTABLE,COLORTABLE_STRUCT*,LPDWORD); */
665     /* Escape(hdc,SET_BACKGROUND_COLOR,LPDWORD,LPDWORD); */
666     /* Escape(hdc,TRANSFORM_CTM,LPSTR,NULL); */
667     case ABORTDOC:
668     case BANDINFO:
669     case BEGIN_PATH:
670     case DRAWPATTERNRECT:
671     case ENDDOC:
672     case END_PATH:
673     case EXTTEXTOUT:
674     case FLUSHOUTPUT:
675     case GETFACENAME:
676     case GETPAIRKERNTABLE:
677     case GETSETPAPERBINS:
678     case GETSETPRINTORIENT:
679     case GETSETSCREENPARAMS:
680     case GETTECHNOLOGY:
681     case GETTRACKKERNTABLE:
682     case MFCOMMENT:
683     case NEWFRAME:
684     case PASSTHROUGH:
685     case RESTORE_CTM:
686     case SAVE_CTM:
687     case SETALLJUSTVALUES:
688     case SETCOLORTABLE:
689     case SET_BACKGROUND_COLOR:
690     case TRANSFORM_CTM:
691         /* pass it unmodified to the 32-bit function */
692         return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
693
694     /* Escape(hdc,ENUMPAPERMETRICS,LPINT16,LPRECT16); */
695     /* Escape(hdc,GETEXTENDEDTEXTMETRICS,LPUINT16,EXTTEXTMETRIC*); */
696     /* Escape(hdc,GETEXTENTTABLE,LPSTR,LPINT16); */
697     /* Escape(hdc,GETSETPAPERMETRICS,LPRECT16,LPRECT16); */
698     /* Escape(hdc,GETVECTORBRUSHSIZE,LPLOGBRUSH16,LPPOINT16); */
699     /* Escape(hdc,GETVECTORPENSIZE,LPLOGPEN16,LPPOINT16); */
700     case ENUMPAPERMETRICS:
701     case GETEXTENDEDTEXTMETRICS:
702     case GETEXTENTTABLE:
703     case GETSETPAPERMETRICS:
704     case GETVECTORBRUSHSIZE:
705     case GETVECTORPENSIZE:
706     default:
707         FIXME("unknown/unsupported 16-bit escape %x (%d,%p,%p\n",
708               escape, in_count, MapSL(in_data), out_data );
709         return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
710     }
711 }
712
713
714 /***********************************************************************
715  *           RestoreDC    (GDI.39)
716  */
717 BOOL16 WINAPI RestoreDC16( HDC16 hdc, INT16 level )
718 {
719     return RestoreDC( HDC_32(hdc), level );
720 }
721
722
723 /***********************************************************************
724  *           FillRgn    (GDI.40)
725  */
726 BOOL16 WINAPI FillRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush )
727 {
728     return FillRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush) );
729 }
730
731
732 /***********************************************************************
733  *           FrameRgn     (GDI.41)
734  */
735 BOOL16 WINAPI FrameRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush,
736                           INT16 nWidth, INT16 nHeight )
737 {
738     return FrameRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush), nWidth, nHeight );
739 }
740
741
742 /***********************************************************************
743  *           InvertRgn    (GDI.42)
744  */
745 BOOL16 WINAPI InvertRgn16( HDC16 hdc, HRGN16 hrgn )
746 {
747     return InvertRgn( HDC_32(hdc), HRGN_32(hrgn) );
748 }
749
750
751 /***********************************************************************
752  *           PaintRgn    (GDI.43)
753  */
754 BOOL16 WINAPI PaintRgn16( HDC16 hdc, HRGN16 hrgn )
755 {
756     return PaintRgn( HDC_32(hdc), HRGN_32(hrgn) );
757 }
758
759
760 /***********************************************************************
761  *           SelectClipRgn    (GDI.44)
762  */
763 INT16 WINAPI SelectClipRgn16( HDC16 hdc, HRGN16 hrgn )
764 {
765     return SelectClipRgn( HDC_32(hdc), HRGN_32(hrgn) );
766 }
767
768
769 /***********************************************************************
770  *           SelectObject    (GDI.45)
771  */
772 HGDIOBJ16 WINAPI SelectObject16( HDC16 hdc, HGDIOBJ16 handle )
773 {
774     return HGDIOBJ_16( SelectObject( HDC_32(hdc), HGDIOBJ_32(handle) ) );
775 }
776
777
778 /***********************************************************************
779  *           CombineRgn    (GDI.47)
780  */
781 INT16 WINAPI CombineRgn16(HRGN16 hDest, HRGN16 hSrc1, HRGN16 hSrc2, INT16 mode)
782 {
783     return CombineRgn( HRGN_32(hDest), HRGN_32(hSrc1), HRGN_32(hSrc2), mode );
784 }
785
786
787 /***********************************************************************
788  *           CreateBitmap    (GDI.48)
789  */
790 HBITMAP16 WINAPI CreateBitmap16( INT16 width, INT16 height, UINT16 planes,
791                                  UINT16 bpp, LPCVOID bits )
792 {
793     return HBITMAP_16( CreateBitmap( width, height, planes, bpp, bits ) );
794 }
795
796
797 /***********************************************************************
798  *           CreateBitmapIndirect    (GDI.49)
799  */
800 HBITMAP16 WINAPI CreateBitmapIndirect16( const BITMAP16 * bmp )
801 {
802     return CreateBitmap16( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
803                            bmp->bmBitsPixel, MapSL( bmp->bmBits ) );
804 }
805
806
807 /***********************************************************************
808  *           CreateBrushIndirect    (GDI.50)
809  */
810 HBRUSH16 WINAPI CreateBrushIndirect16( const LOGBRUSH16 * brush )
811 {
812     LOGBRUSH brush32;
813
814     if (brush->lbStyle == BS_DIBPATTERN || brush->lbStyle == BS_DIBPATTERN8X8)
815         return CreateDIBPatternBrush16( brush->lbHatch, brush->lbColor );
816
817     brush32.lbStyle = brush->lbStyle;
818     brush32.lbColor = brush->lbColor;
819     brush32.lbHatch = brush->lbHatch;
820     return HBRUSH_16( CreateBrushIndirect(&brush32) );
821 }
822
823
824 /***********************************************************************
825  *           CreateCompatibleBitmap    (GDI.51)
826  */
827 HBITMAP16 WINAPI CreateCompatibleBitmap16( HDC16 hdc, INT16 width, INT16 height )
828 {
829     return HBITMAP_16( CreateCompatibleBitmap( HDC_32(hdc), width, height ) );
830 }
831
832
833 /***********************************************************************
834  *           CreateCompatibleDC    (GDI.52)
835  */
836 HDC16 WINAPI CreateCompatibleDC16( HDC16 hdc )
837 {
838     return HDC_16( CreateCompatibleDC( HDC_32(hdc) ) );
839 }
840
841
842 /***********************************************************************
843  *           CreateDC    (GDI.53)
844  */
845 HDC16 WINAPI CreateDC16( LPCSTR driver, LPCSTR device, LPCSTR output,
846                          const DEVMODEA *initData )
847 {
848     return HDC_16( CreateDCA( driver, device, output, initData ) );
849 }
850
851
852 /***********************************************************************
853  *           CreateEllipticRgn    (GDI.54)
854  */
855 HRGN16 WINAPI CreateEllipticRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
856 {
857     return HRGN_16( CreateEllipticRgn( left, top, right, bottom ) );
858 }
859
860
861 /***********************************************************************
862  *           CreateEllipticRgnIndirect    (GDI.55)
863  */
864 HRGN16 WINAPI CreateEllipticRgnIndirect16( const RECT16 *rect )
865 {
866     return HRGN_16( CreateEllipticRgn( rect->left, rect->top, rect->right, rect->bottom ) );
867 }
868
869
870 /***********************************************************************
871  *           CreateFont    (GDI.56)
872  */
873 HFONT16 WINAPI CreateFont16(INT16 height, INT16 width, INT16 esc, INT16 orient,
874                             INT16 weight, BYTE italic, BYTE underline,
875                             BYTE strikeout, BYTE charset, BYTE outpres,
876                             BYTE clippres, BYTE quality, BYTE pitch,
877                             LPCSTR name )
878 {
879     return HFONT_16( CreateFontA( height, width, esc, orient, weight, italic, underline,
880                                   strikeout, charset, outpres, clippres, quality, pitch, name ));
881 }
882
883 /***********************************************************************
884  *           CreateFontIndirect   (GDI.57)
885  */
886 HFONT16 WINAPI CreateFontIndirect16( const LOGFONT16 *plf16 )
887 {
888     HFONT ret;
889
890     if (plf16)
891     {
892         LOGFONTW lfW;
893         logfont_16_to_W( plf16, &lfW );
894         ret = CreateFontIndirectW( &lfW );
895     }
896     else ret = CreateFontIndirectW( NULL );
897     return HFONT_16(ret);
898 }
899
900
901 /***********************************************************************
902  *           CreateHatchBrush    (GDI.58)
903  */
904 HBRUSH16 WINAPI CreateHatchBrush16( INT16 style, COLORREF color )
905 {
906     return HBRUSH_16( CreateHatchBrush( style, color ) );
907 }
908
909
910 /***********************************************************************
911  *           CreatePatternBrush    (GDI.60)
912  */
913 HBRUSH16 WINAPI CreatePatternBrush16( HBITMAP16 hbitmap )
914 {
915     return HBRUSH_16( CreatePatternBrush( HBITMAP_32(hbitmap) ));
916 }
917
918
919 /***********************************************************************
920  *           CreatePen    (GDI.61)
921  */
922 HPEN16 WINAPI CreatePen16( INT16 style, INT16 width, COLORREF color )
923 {
924     LOGPEN logpen;
925
926     logpen.lopnStyle = style;
927     logpen.lopnWidth.x = width;
928     logpen.lopnWidth.y = 0;
929     logpen.lopnColor = color;
930     return HPEN_16( CreatePenIndirect( &logpen ) );
931 }
932
933
934 /***********************************************************************
935  *           CreatePenIndirect    (GDI.62)
936  */
937 HPEN16 WINAPI CreatePenIndirect16( const LOGPEN16 * pen )
938 {
939     LOGPEN logpen;
940
941     if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
942     logpen.lopnStyle   = pen->lopnStyle;
943     logpen.lopnWidth.x = pen->lopnWidth.x;
944     logpen.lopnWidth.y = pen->lopnWidth.y;
945     logpen.lopnColor   = pen->lopnColor;
946     return HPEN_16( CreatePenIndirect( &logpen ) );
947 }
948
949
950 /***********************************************************************
951  *           CreatePolygonRgn    (GDI.63)
952  */
953 HRGN16 WINAPI CreatePolygonRgn16( const POINT16 * points, INT16 count, INT16 mode )
954 {
955     return CreatePolyPolygonRgn16( points, &count, 1, mode );
956 }
957
958
959 /***********************************************************************
960  *           CreateRectRgn    (GDI.64)
961  *
962  * NOTE: cf. SetRectRgn16
963  */
964 HRGN16 WINAPI CreateRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
965 {
966     HRGN hrgn;
967
968     if (left < right) hrgn = CreateRectRgn( left, top, right, bottom );
969     else hrgn = CreateRectRgn( 0, 0, 0, 0 );
970     return HRGN_16(hrgn);
971 }
972
973
974 /***********************************************************************
975  *           CreateRectRgnIndirect    (GDI.65)
976  */
977 HRGN16 WINAPI CreateRectRgnIndirect16( const RECT16* rect )
978 {
979     return CreateRectRgn16( rect->left, rect->top, rect->right, rect->bottom );
980 }
981
982
983 /***********************************************************************
984  *           CreateSolidBrush    (GDI.66)
985  */
986 HBRUSH16 WINAPI CreateSolidBrush16( COLORREF color )
987 {
988     return HBRUSH_16( CreateSolidBrush( color ) );
989 }
990
991
992 /***********************************************************************
993  *           DeleteDC    (GDI.68)
994  */
995 BOOL16 WINAPI DeleteDC16( HDC16 hdc )
996 {
997     return DeleteDC( HDC_32(hdc) );
998 }
999
1000
1001 /***********************************************************************
1002  *           DeleteObject    (GDI.69)
1003  *           SysDeleteObject (GDI.605)
1004  */
1005 BOOL16 WINAPI DeleteObject16( HGDIOBJ16 obj )
1006 {
1007     return DeleteObject( HGDIOBJ_32(obj) );
1008 }
1009
1010
1011 /***********************************************************************
1012  *           EnumObjects    (GDI.71)
1013  */
1014 INT16 WINAPI EnumObjects16( HDC16 hdc, INT16 obj, GOBJENUMPROC16 proc, LPARAM lParam )
1015 {
1016     struct callback16_info info;
1017
1018     info.proc  = (FARPROC16)proc;
1019     info.param = lParam;
1020     switch(obj)
1021     {
1022     case OBJ_PEN:
1023         return EnumObjects( HDC_32(hdc), OBJ_PEN, enum_pens_callback, (LPARAM)&info );
1024     case OBJ_BRUSH:
1025         return EnumObjects( HDC_32(hdc), OBJ_BRUSH, enum_brushes_callback, (LPARAM)&info );
1026     }
1027     return 0;
1028 }
1029
1030
1031 /***********************************************************************
1032  *           EqualRgn    (GDI.72)
1033  */
1034 BOOL16 WINAPI EqualRgn16( HRGN16 rgn1, HRGN16 rgn2 )
1035 {
1036     return EqualRgn( HRGN_32(rgn1), HRGN_32(rgn2) );
1037 }
1038
1039
1040 /***********************************************************************
1041  *           GetBitmapBits    (GDI.74)
1042  */
1043 LONG WINAPI GetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPVOID buffer )
1044 {
1045     return GetBitmapBits( HBITMAP_32(hbitmap), count, buffer );
1046 }
1047
1048
1049 /***********************************************************************
1050  *              GetBkColor (GDI.75)
1051  */
1052 COLORREF WINAPI GetBkColor16( HDC16 hdc )
1053 {
1054     return GetBkColor( HDC_32(hdc) );
1055 }
1056
1057
1058 /***********************************************************************
1059  *              GetBkMode (GDI.76)
1060  */
1061 INT16 WINAPI GetBkMode16( HDC16 hdc )
1062 {
1063     return GetBkMode( HDC_32(hdc) );
1064 }
1065
1066
1067 /***********************************************************************
1068  *           GetClipBox    (GDI.77)
1069  */
1070 INT16 WINAPI GetClipBox16( HDC16 hdc, LPRECT16 rect )
1071 {
1072     RECT rect32;
1073     INT ret = GetClipBox( HDC_32(hdc), &rect32 );
1074
1075     if (ret != ERROR)
1076     {
1077         rect->left   = rect32.left;
1078         rect->top    = rect32.top;
1079         rect->right  = rect32.right;
1080         rect->bottom = rect32.bottom;
1081     }
1082     return ret;
1083 }
1084
1085
1086 /***********************************************************************
1087  *              GetCurrentPosition (GDI.78)
1088  */
1089 DWORD WINAPI GetCurrentPosition16( HDC16 hdc )
1090 {
1091     POINT pt32;
1092     if (!GetCurrentPositionEx( HDC_32(hdc), &pt32 )) return 0;
1093     return MAKELONG( pt32.x, pt32.y );
1094 }
1095
1096
1097 /***********************************************************************
1098  *           GetDCOrg    (GDI.79)
1099  */
1100 DWORD WINAPI GetDCOrg16( HDC16 hdc )
1101 {
1102     POINT pt;
1103     if (GetDCOrgEx( HDC_32(hdc), &pt )) return MAKELONG( pt.x, pt.y );
1104     return 0;
1105 }
1106
1107
1108 /***********************************************************************
1109  *           GetDeviceCaps    (GDI.80)
1110  */
1111 INT16 WINAPI GetDeviceCaps16( HDC16 hdc, INT16 cap )
1112 {
1113     INT16 ret = GetDeviceCaps( HDC_32(hdc), cap );
1114     /* some apps don't expect -1 and think it's a B&W screen */
1115     if ((cap == NUMCOLORS) && (ret == -1)) ret = 2048;
1116     return ret;
1117 }
1118
1119
1120 /***********************************************************************
1121  *              GetMapMode (GDI.81)
1122  */
1123 INT16 WINAPI GetMapMode16( HDC16 hdc )
1124 {
1125     return GetMapMode( HDC_32(hdc) );
1126 }
1127
1128
1129 /***********************************************************************
1130  *           GetPixel    (GDI.83)
1131  */
1132 COLORREF WINAPI GetPixel16( HDC16 hdc, INT16 x, INT16 y )
1133 {
1134     return GetPixel( HDC_32(hdc), x, y );
1135 }
1136
1137
1138 /***********************************************************************
1139  *              GetPolyFillMode (GDI.84)
1140  */
1141 INT16 WINAPI GetPolyFillMode16( HDC16 hdc )
1142 {
1143     return GetPolyFillMode( HDC_32(hdc) );
1144 }
1145
1146
1147 /***********************************************************************
1148  *              GetROP2 (GDI.85)
1149  */
1150 INT16 WINAPI GetROP216( HDC16 hdc )
1151 {
1152     return GetROP2( HDC_32(hdc) );
1153 }
1154
1155
1156 /***********************************************************************
1157  *              GetRelAbs (GDI.86)
1158  */
1159 INT16 WINAPI GetRelAbs16( HDC16 hdc )
1160 {
1161     return GetRelAbs( HDC_32(hdc), 0 );
1162 }
1163
1164
1165 /***********************************************************************
1166  *           GetStockObject    (GDI.87)
1167  */
1168 HGDIOBJ16 WINAPI GetStockObject16( INT16 obj )
1169 {
1170     return HGDIOBJ_16( GetStockObject( obj ) );
1171 }
1172
1173
1174 /***********************************************************************
1175  *              GetStretchBltMode (GDI.88)
1176  */
1177 INT16 WINAPI GetStretchBltMode16( HDC16 hdc )
1178 {
1179     return GetStretchBltMode( HDC_32(hdc) );
1180 }
1181
1182
1183 /***********************************************************************
1184  *           GetTextCharacterExtra    (GDI.89)
1185  */
1186 INT16 WINAPI GetTextCharacterExtra16( HDC16 hdc )
1187 {
1188     return GetTextCharacterExtra( HDC_32(hdc) );
1189 }
1190
1191
1192 /***********************************************************************
1193  *              GetTextColor (GDI.90)
1194  */
1195 COLORREF WINAPI GetTextColor16( HDC16 hdc )
1196 {
1197     return GetTextColor( HDC_32(hdc) );
1198 }
1199
1200
1201 /***********************************************************************
1202  *           GetTextExtent    (GDI.91)
1203  */
1204 DWORD WINAPI GetTextExtent16( HDC16 hdc, LPCSTR str, INT16 count )
1205 {
1206     SIZE size;
1207     if (!GetTextExtentPoint32A( HDC_32(hdc), str, count, &size )) return 0;
1208     return MAKELONG( size.cx, size.cy );
1209 }
1210
1211
1212 /***********************************************************************
1213  *           GetTextFace    (GDI.92)
1214  */
1215 INT16 WINAPI GetTextFace16( HDC16 hdc, INT16 count, LPSTR name )
1216 {
1217     return GetTextFaceA( HDC_32(hdc), count, name );
1218 }
1219
1220
1221 /***********************************************************************
1222  *           GetTextMetrics    (GDI.93)
1223  */
1224 BOOL16 WINAPI GetTextMetrics16( HDC16 hdc, TEXTMETRIC16 *tm )
1225 {
1226     TEXTMETRICW tm32;
1227
1228     if (!GetTextMetricsW( HDC_32(hdc), &tm32 )) return FALSE;
1229
1230     tm->tmHeight           = tm32.tmHeight;
1231     tm->tmAscent           = tm32.tmAscent;
1232     tm->tmDescent          = tm32.tmDescent;
1233     tm->tmInternalLeading  = tm32.tmInternalLeading;
1234     tm->tmExternalLeading  = tm32.tmExternalLeading;
1235     tm->tmAveCharWidth     = tm32.tmAveCharWidth;
1236     tm->tmMaxCharWidth     = tm32.tmMaxCharWidth;
1237     tm->tmWeight           = tm32.tmWeight;
1238     tm->tmOverhang         = tm32.tmOverhang;
1239     tm->tmDigitizedAspectX = tm32.tmDigitizedAspectX;
1240     tm->tmDigitizedAspectY = tm32.tmDigitizedAspectY;
1241     tm->tmFirstChar        = tm32.tmFirstChar;
1242     tm->tmLastChar         = tm32.tmLastChar;
1243     tm->tmDefaultChar      = tm32.tmDefaultChar;
1244     tm->tmBreakChar        = tm32.tmBreakChar;
1245     tm->tmItalic           = tm32.tmItalic;
1246     tm->tmUnderlined       = tm32.tmUnderlined;
1247     tm->tmStruckOut        = tm32.tmStruckOut;
1248     tm->tmPitchAndFamily   = tm32.tmPitchAndFamily;
1249     tm->tmCharSet          = tm32.tmCharSet;
1250     return TRUE;
1251 }
1252
1253
1254 /***********************************************************************
1255  *              GetViewportExt (GDI.94)
1256  */
1257 DWORD WINAPI GetViewportExt16( HDC16 hdc )
1258 {
1259     SIZE size;
1260     if (!GetViewportExtEx( HDC_32(hdc), &size )) return 0;
1261     return MAKELONG( size.cx, size.cy );
1262 }
1263
1264
1265 /***********************************************************************
1266  *              GetViewportOrg (GDI.95)
1267  */
1268 DWORD WINAPI GetViewportOrg16( HDC16 hdc )
1269 {
1270     POINT pt;
1271     if (!GetViewportOrgEx( HDC_32(hdc), &pt )) return 0;
1272     return MAKELONG( pt.x, pt.y );
1273 }
1274
1275
1276 /***********************************************************************
1277  *              GetWindowExt (GDI.96)
1278  */
1279 DWORD WINAPI GetWindowExt16( HDC16 hdc )
1280 {
1281     SIZE size;
1282     if (!GetWindowExtEx( HDC_32(hdc), &size )) return 0;
1283     return MAKELONG( size.cx, size.cy );
1284 }
1285
1286
1287 /***********************************************************************
1288  *              GetWindowOrg (GDI.97)
1289  */
1290 DWORD WINAPI GetWindowOrg16( HDC16 hdc )
1291 {
1292     POINT pt;
1293     if (!GetWindowOrgEx( HDC_32(hdc), &pt )) return 0;
1294     return MAKELONG( pt.x, pt.y );
1295 }
1296
1297
1298
1299
1300 /**********************************************************************
1301  *           LineDDA   (GDI.100)
1302  */
1303 void WINAPI LineDDA16( INT16 nXStart, INT16 nYStart, INT16 nXEnd,
1304                        INT16 nYEnd, LINEDDAPROC16 proc, LPARAM lParam )
1305 {
1306     struct callback16_info info;
1307     info.proc  = (FARPROC16)proc;
1308     info.param = lParam;
1309     LineDDA( nXStart, nYStart, nXEnd, nYEnd, linedda_callback, (LPARAM)&info );
1310 }
1311
1312
1313 /***********************************************************************
1314  *           OffsetRgn    (GDI.101)
1315  */
1316 INT16 WINAPI OffsetRgn16( HRGN16 hrgn, INT16 x, INT16 y )
1317 {
1318     return OffsetRgn( HRGN_32(hrgn), x, y );
1319 }
1320
1321
1322 /***********************************************************************
1323  *           PtVisible    (GDI.103)
1324  */
1325 BOOL16 WINAPI PtVisible16( HDC16 hdc, INT16 x, INT16 y )
1326 {
1327     return PtVisible( HDC_32(hdc), x, y );
1328 }
1329
1330
1331 /***********************************************************************
1332  *           SetBitmapBits    (GDI.106)
1333  */
1334 LONG WINAPI SetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPCVOID buffer )
1335 {
1336     return SetBitmapBits( HBITMAP_32(hbitmap), count, buffer );
1337 }
1338
1339
1340 /***********************************************************************
1341  *           AddFontResource    (GDI.119)
1342  */
1343 INT16 WINAPI AddFontResource16( LPCSTR filename )
1344 {
1345     return AddFontResourceA( filename );
1346 }
1347
1348
1349 /***********************************************************************
1350  *           Death    (GDI.121)
1351  *
1352  * Disables GDI, switches back to text mode.
1353  * We don't have to do anything here,
1354  * just let console support handle everything
1355  */
1356 void WINAPI Death16(HDC16 hdc)
1357 {
1358     MESSAGE("Death(%04x) called. Application enters text mode...\n", hdc);
1359 }
1360
1361
1362 /***********************************************************************
1363  *           Resurrection    (GDI.122)
1364  *
1365  * Restores GDI functionality
1366  */
1367 void WINAPI Resurrection16(HDC16 hdc,
1368                            WORD w1, WORD w2, WORD w3, WORD w4, WORD w5, WORD w6)
1369 {
1370     MESSAGE("Resurrection(%04x, %04x, %04x, %04x, %04x, %04x, %04x) called. Application left text mode.\n",
1371             hdc, w1, w2, w3, w4, w5, w6);
1372 }
1373
1374
1375 /**********************************************************************
1376  *           CreateMetaFile     (GDI.125)
1377  */
1378 HDC16 WINAPI CreateMetaFile16( LPCSTR filename )
1379 {
1380     return HDC_16( CreateMetaFileA( filename ) );
1381 }
1382
1383
1384 /***********************************************************************
1385  *           MulDiv   (GDI.128)
1386  */
1387 INT16 WINAPI MulDiv16( INT16 nMultiplicand, INT16 nMultiplier, INT16 nDivisor)
1388 {
1389     INT ret;
1390     if (!nDivisor) return -32768;
1391     /* We want to deal with a positive divisor to simplify the logic. */
1392     if (nDivisor < 0)
1393     {
1394       nMultiplicand = - nMultiplicand;
1395       nDivisor = -nDivisor;
1396     }
1397     /* If the result is positive, we "add" to round. else,
1398      * we subtract to round. */
1399     if ( ( (nMultiplicand <  0) && (nMultiplier <  0) ) ||
1400          ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
1401         ret = (((int)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
1402     else
1403         ret = (((int)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
1404     if ((ret > 32767) || (ret < -32767)) return -32768;
1405     return (INT16) ret;
1406 }
1407
1408
1409 /***********************************************************************
1410  *           GetRgnBox    (GDI.134)
1411  */
1412 INT16 WINAPI GetRgnBox16( HRGN16 hrgn, LPRECT16 rect )
1413 {
1414     RECT r;
1415     INT16 ret = GetRgnBox( HRGN_32(hrgn), &r );
1416     CONV_RECT32TO16( &r, rect );
1417     return ret;
1418 }
1419
1420
1421 /***********************************************************************
1422  *           RemoveFontResource    (GDI.136)
1423  */
1424 BOOL16 WINAPI RemoveFontResource16( LPCSTR str )
1425 {
1426     return RemoveFontResourceA(str);
1427 }
1428
1429
1430 /***********************************************************************
1431  *           SetBrushOrg    (GDI.148)
1432  */
1433 DWORD WINAPI SetBrushOrg16( HDC16 hdc, INT16 x, INT16 y )
1434 {
1435     POINT pt;
1436
1437     if (!SetBrushOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
1438     return MAKELONG( pt.x, pt.y );
1439 }
1440
1441
1442 /***********************************************************************
1443  *              GetBrushOrg (GDI.149)
1444  */
1445 DWORD WINAPI GetBrushOrg16( HDC16 hdc )
1446 {
1447     POINT pt;
1448     if (!GetBrushOrgEx( HDC_32(hdc), &pt )) return 0;
1449     return MAKELONG( pt.x, pt.y );
1450 }
1451
1452
1453 /***********************************************************************
1454  *           UnrealizeObject    (GDI.150)
1455  */
1456 BOOL16 WINAPI UnrealizeObject16( HGDIOBJ16 obj )
1457 {
1458     return UnrealizeObject( HGDIOBJ_32(obj) );
1459 }
1460
1461
1462 /***********************************************************************
1463  *           CreateIC    (GDI.153)
1464  */
1465 HDC16 WINAPI CreateIC16( LPCSTR driver, LPCSTR device, LPCSTR output,
1466                          const DEVMODEA* initData )
1467 {
1468     return HDC_16( CreateICA( driver, device, output, initData ) );
1469 }
1470
1471
1472 /***********************************************************************
1473  *           GetNearestColor   (GDI.154)
1474  */
1475 COLORREF WINAPI GetNearestColor16( HDC16 hdc, COLORREF color )
1476 {
1477     return GetNearestColor( HDC_32(hdc), color );
1478 }
1479
1480
1481 /***********************************************************************
1482  *           CreateDiscardableBitmap    (GDI.156)
1483  */
1484 HBITMAP16 WINAPI CreateDiscardableBitmap16( HDC16 hdc, INT16 width, INT16 height )
1485 {
1486     return HBITMAP_16( CreateDiscardableBitmap( HDC_32(hdc), width, height ) );
1487 }
1488
1489
1490 /***********************************************************************
1491  *           PtInRegion    (GDI.161)
1492  */
1493 BOOL16 WINAPI PtInRegion16( HRGN16 hrgn, INT16 x, INT16 y )
1494 {
1495     return PtInRegion( HRGN_32(hrgn), x, y );
1496 }
1497
1498
1499 /***********************************************************************
1500  *           GetBitmapDimension    (GDI.162)
1501  */
1502 DWORD WINAPI GetBitmapDimension16( HBITMAP16 hbitmap )
1503 {
1504     SIZE16 size;
1505     if (!GetBitmapDimensionEx16( hbitmap, &size )) return 0;
1506     return MAKELONG( size.cx, size.cy );
1507 }
1508
1509
1510 /***********************************************************************
1511  *           SetBitmapDimension    (GDI.163)
1512  */
1513 DWORD WINAPI SetBitmapDimension16( HBITMAP16 hbitmap, INT16 x, INT16 y )
1514 {
1515     SIZE16 size;
1516     if (!SetBitmapDimensionEx16( hbitmap, x, y, &size )) return 0;
1517     return MAKELONG( size.cx, size.cy );
1518 }
1519
1520
1521 /***********************************************************************
1522  *           SetRectRgn    (GDI.172)
1523  *
1524  * NOTE: Win 3.1 sets region to empty if left > right
1525  */
1526 void WINAPI SetRectRgn16( HRGN16 hrgn, INT16 left, INT16 top, INT16 right, INT16 bottom )
1527 {
1528     if (left < right) SetRectRgn( HRGN_32(hrgn), left, top, right, bottom );
1529     else SetRectRgn( HRGN_32(hrgn), 0, 0, 0, 0 );
1530 }
1531
1532
1533 /******************************************************************
1534  *             PlayMetaFileRecord   (GDI.176)
1535  */
1536 void WINAPI PlayMetaFileRecord16( HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr, UINT16 handles )
1537 {
1538     HANDLETABLE *ht32 = HeapAlloc( GetProcessHeap(), 0, handles * sizeof(*ht32) );
1539     unsigned int i;
1540
1541     for (i = 0; i < handles; i++) ht32->objectHandle[i] = (HGDIOBJ)(ULONG_PTR)ht->objectHandle[i];
1542     PlayMetaFileRecord( HDC_32(hdc), ht32, mr, handles );
1543     for (i = 0; i < handles; i++) ht->objectHandle[i] = LOWORD(ht32->objectHandle[i]);
1544     HeapFree( GetProcessHeap(), 0, ht32 );
1545 }
1546
1547
1548 /***********************************************************************
1549  *           GetCharABCWidths   (GDI.307)
1550  */
1551 BOOL16 WINAPI GetCharABCWidths16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar, LPABC16 abc )
1552 {
1553     BOOL ret;
1554     UINT i;
1555     LPABC abc32 = HeapAlloc( GetProcessHeap(), 0, sizeof(ABC) * (lastChar - firstChar + 1) );
1556
1557     if ((ret = GetCharABCWidthsA( HDC_32(hdc), firstChar, lastChar, abc32 )))
1558     {
1559         for (i = firstChar; i <= lastChar; i++)
1560         {
1561             abc[i-firstChar].abcA = abc32[i-firstChar].abcA;
1562             abc[i-firstChar].abcB = abc32[i-firstChar].abcB;
1563             abc[i-firstChar].abcC = abc32[i-firstChar].abcC;
1564         }
1565     }
1566     HeapFree( GetProcessHeap(), 0, abc32 );
1567     return ret;
1568 }
1569
1570
1571 /***********************************************************************
1572  *           CreateScalableFontResource   (GDI.310)
1573  */
1574 BOOL16 WINAPI CreateScalableFontResource16( UINT16 fHidden, LPCSTR lpszResourceFile,
1575                                             LPCSTR fontFile, LPCSTR path )
1576 {
1577     return CreateScalableFontResourceA( fHidden, lpszResourceFile, fontFile, path );
1578 }
1579
1580
1581 /*************************************************************************
1582  *             GetFontData    (GDI.311)
1583  *
1584  */
1585 DWORD WINAPI GetFontData16( HDC16 hdc, DWORD table, DWORD offset, LPVOID buffer, DWORD count )
1586 {
1587     return GetFontData( HDC_32(hdc), table, offset, buffer, count );
1588 }
1589
1590
1591 /*************************************************************************
1592  *             GetRasterizerCaps   (GDI.313)
1593  */
1594 BOOL16 WINAPI GetRasterizerCaps16( LPRASTERIZER_STATUS lprs, UINT16 cbNumBytes )
1595 {
1596     return GetRasterizerCaps( lprs, cbNumBytes );
1597 }
1598
1599
1600 /*************************************************************************
1601  *             GetKerningPairs   (GDI.332)
1602  *
1603  */
1604 INT16 WINAPI GetKerningPairs16( HDC16 hdc, INT16 count, LPKERNINGPAIR16 pairs )
1605 {
1606     KERNINGPAIR *pairs32;
1607     INT i, ret;
1608
1609     if (!count) return 0;
1610
1611     if (!(pairs32 = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pairs32) ))) return 0;
1612     if ((ret = GetKerningPairsA( HDC_32(hdc), count, pairs32 )))
1613     {
1614         for (i = 0; i < ret; i++)
1615         {
1616             pairs->wFirst      = pairs32->wFirst;
1617             pairs->wSecond     = pairs32->wSecond;
1618             pairs->iKernAmount = pairs32->iKernAmount;
1619         }
1620     }
1621     HeapFree( GetProcessHeap(), 0, pairs32 );
1622     return ret;
1623 }
1624
1625
1626
1627 /***********************************************************************
1628  *              GetTextAlign (GDI.345)
1629  */
1630 UINT16 WINAPI GetTextAlign16( HDC16 hdc )
1631 {
1632     return GetTextAlign( HDC_32(hdc) );
1633 }
1634
1635
1636 /***********************************************************************
1637  *           SetTextAlign    (GDI.346)
1638  */
1639 UINT16 WINAPI SetTextAlign16( HDC16 hdc, UINT16 align )
1640 {
1641     return SetTextAlign( HDC_32(hdc), align );
1642 }
1643
1644
1645 /***********************************************************************
1646  *           Chord    (GDI.348)
1647  */
1648 BOOL16 WINAPI Chord16( HDC16 hdc, INT16 left, INT16 top,
1649                        INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
1650                        INT16 xend, INT16 yend )
1651 {
1652     return Chord( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
1653 }
1654
1655
1656 /***********************************************************************
1657  *           SetMapperFlags    (GDI.349)
1658  */
1659 DWORD WINAPI SetMapperFlags16( HDC16 hdc, DWORD flags )
1660 {
1661     return SetMapperFlags( HDC_32(hdc), flags );
1662 }
1663
1664
1665 /***********************************************************************
1666  *           GetCharWidth    (GDI.350)
1667  */
1668 BOOL16 WINAPI GetCharWidth16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar, LPINT16 buffer )
1669 {
1670     BOOL retVal = FALSE;
1671
1672     if( firstChar != lastChar )
1673     {
1674         LPINT buf32 = HeapAlloc(GetProcessHeap(), 0, sizeof(INT)*(1 + (lastChar - firstChar)));
1675         if( buf32 )
1676         {
1677             LPINT obuf32 = buf32;
1678             int i;
1679
1680             retVal = GetCharWidth32A( HDC_32(hdc), firstChar, lastChar, buf32);
1681             if (retVal)
1682             {
1683                 for (i = firstChar; i <= lastChar; i++) *buffer++ = *buf32++;
1684             }
1685             HeapFree(GetProcessHeap(), 0, obuf32);
1686         }
1687     }
1688     else /* happens quite often to warrant a special treatment */
1689     {
1690         INT chWidth;
1691         retVal = GetCharWidth32A( HDC_32(hdc), firstChar, lastChar, &chWidth );
1692         *buffer = chWidth;
1693     }
1694     return retVal;
1695 }
1696
1697
1698 /***********************************************************************
1699  *           ExtTextOut   (GDI.351)
1700  */
1701 BOOL16 WINAPI ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
1702                             const RECT16 *lprect, LPCSTR str, UINT16 count,
1703                             const INT16 *lpDx )
1704 {
1705     BOOL        ret;
1706     int         i;
1707     RECT        rect32;
1708     LPINT       lpdx32 = NULL;
1709
1710     if (lpDx) {
1711         lpdx32 = (LPINT)HeapAlloc( GetProcessHeap(),0, sizeof(INT)*count );
1712         if(lpdx32 == NULL) return FALSE;
1713         for (i=count;i--;) lpdx32[i]=lpDx[i];
1714     }
1715     if (lprect) CONV_RECT16TO32(lprect,&rect32);
1716     ret = ExtTextOutA(HDC_32(hdc),x,y,flags,lprect?&rect32:NULL,str,count,lpdx32);
1717     if (lpdx32) HeapFree( GetProcessHeap(), 0, lpdx32 );
1718     return ret;
1719 }
1720
1721
1722 /***********************************************************************
1723  *           CreatePalette    (GDI.360)
1724  */
1725 HPALETTE16 WINAPI CreatePalette16( const LOGPALETTE* palette )
1726 {
1727     return HPALETTE_16( CreatePalette( palette ) );
1728 }
1729
1730
1731 /***********************************************************************
1732  *           GDISelectPalette   (GDI.361)
1733  */
1734 HPALETTE16 WINAPI GDISelectPalette16( HDC16 hdc, HPALETTE16 hpalette, WORD wBkg )
1735 {
1736     return HPALETTE_16( GDISelectPalette( HDC_32(hdc), HPALETTE_32(hpalette), wBkg ));
1737 }
1738
1739
1740 /***********************************************************************
1741  *           GDIRealizePalette   (GDI.362)
1742  */
1743 UINT16 WINAPI GDIRealizePalette16( HDC16 hdc )
1744 {
1745     return GDIRealizePalette( HDC_32(hdc) );
1746 }
1747
1748
1749 /***********************************************************************
1750  *           GetPaletteEntries    (GDI.363)
1751  */
1752 UINT16 WINAPI GetPaletteEntries16( HPALETTE16 hpalette, UINT16 start,
1753                                    UINT16 count, LPPALETTEENTRY entries )
1754 {
1755     return GetPaletteEntries( HPALETTE_32(hpalette), start, count, entries );
1756 }
1757
1758
1759 /***********************************************************************
1760  *           SetPaletteEntries    (GDI.364)
1761  */
1762 UINT16 WINAPI SetPaletteEntries16( HPALETTE16 hpalette, UINT16 start,
1763                                    UINT16 count, const PALETTEENTRY *entries )
1764 {
1765     return SetPaletteEntries( HPALETTE_32(hpalette), start, count, entries );
1766 }
1767
1768
1769 /**********************************************************************
1770  *            UpdateColors   (GDI.366)
1771  */
1772 INT16 WINAPI UpdateColors16( HDC16 hdc )
1773 {
1774     UpdateColors( HDC_32(hdc) );
1775     return TRUE;
1776 }
1777
1778
1779 /***********************************************************************
1780  *           AnimatePalette   (GDI.367)
1781  */
1782 void WINAPI AnimatePalette16( HPALETTE16 hpalette, UINT16 StartIndex,
1783                               UINT16 NumEntries, const PALETTEENTRY* PaletteColors)
1784 {
1785     AnimatePalette( HPALETTE_32(hpalette), StartIndex, NumEntries, PaletteColors );
1786 }
1787
1788
1789 /***********************************************************************
1790  *           ResizePalette   (GDI.368)
1791  */
1792 BOOL16 WINAPI ResizePalette16( HPALETTE16 hpalette, UINT16 cEntries )
1793 {
1794     return ResizePalette( HPALETTE_32(hpalette), cEntries );
1795 }
1796
1797
1798 /***********************************************************************
1799  *           GetNearestPaletteIndex   (GDI.370)
1800  */
1801 UINT16 WINAPI GetNearestPaletteIndex16( HPALETTE16 hpalette, COLORREF color )
1802 {
1803     return GetNearestPaletteIndex( HPALETTE_32(hpalette), color );
1804 }
1805
1806
1807 /**********************************************************************
1808  *          ExtFloodFill   (GDI.372)
1809  */
1810 BOOL16 WINAPI ExtFloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color,
1811                               UINT16 fillType )
1812 {
1813     return ExtFloodFill( HDC_32(hdc), x, y, color, fillType );
1814 }
1815
1816
1817 /***********************************************************************
1818  *           SetSystemPaletteUse   (GDI.373)
1819  */
1820 UINT16 WINAPI SetSystemPaletteUse16( HDC16 hdc, UINT16 use )
1821 {
1822     return SetSystemPaletteUse( HDC_32(hdc), use );
1823 }
1824
1825
1826 /***********************************************************************
1827  *           GetSystemPaletteUse   (GDI.374)
1828  */
1829 UINT16 WINAPI GetSystemPaletteUse16( HDC16 hdc )
1830 {
1831     return GetSystemPaletteUse( HDC_32(hdc) );
1832 }
1833
1834
1835 /***********************************************************************
1836  *           GetSystemPaletteEntries   (GDI.375)
1837  */
1838 UINT16 WINAPI GetSystemPaletteEntries16( HDC16 hdc, UINT16 start, UINT16 count,
1839                                          LPPALETTEENTRY entries )
1840 {
1841     return GetSystemPaletteEntries( HDC_32(hdc), start, count, entries );
1842 }
1843
1844
1845 /***********************************************************************
1846  *           ResetDC    (GDI.376)
1847  */
1848 HDC16 WINAPI ResetDC16( HDC16 hdc, const DEVMODEA *devmode )
1849 {
1850     return HDC_16( ResetDCA(HDC_32(hdc), devmode) );
1851 }
1852
1853
1854 /******************************************************************
1855  *           StartDoc   (GDI.377)
1856  */
1857 INT16 WINAPI StartDoc16( HDC16 hdc, const DOCINFO16 *lpdoc )
1858 {
1859     DOCINFOA docA;
1860
1861     docA.cbSize = lpdoc->cbSize;
1862     docA.lpszDocName = MapSL(lpdoc->lpszDocName);
1863     docA.lpszOutput = MapSL(lpdoc->lpszOutput);
1864     if(lpdoc->cbSize > offsetof(DOCINFO16,lpszDatatype))
1865         docA.lpszDatatype = MapSL(lpdoc->lpszDatatype);
1866     else
1867         docA.lpszDatatype = NULL;
1868     if(lpdoc->cbSize > offsetof(DOCINFO16,fwType))
1869         docA.fwType = lpdoc->fwType;
1870     else
1871         docA.fwType = 0;
1872     return StartDocA( HDC_32(hdc), &docA );
1873 }
1874
1875
1876 /******************************************************************
1877  *           EndDoc   (GDI.378)
1878  */
1879 INT16 WINAPI EndDoc16( HDC16 hdc )
1880 {
1881     return EndDoc( HDC_32(hdc) );
1882 }
1883
1884
1885 /******************************************************************
1886  *           StartPage   (GDI.379)
1887  */
1888 INT16 WINAPI StartPage16( HDC16 hdc )
1889 {
1890     return StartPage( HDC_32(hdc) );
1891 }
1892
1893
1894 /******************************************************************
1895  *           EndPage   (GDI.380)
1896  */
1897 INT16 WINAPI EndPage16( HDC16 hdc )
1898 {
1899     return EndPage( HDC_32(hdc) );
1900 }
1901
1902
1903 /******************************************************************************
1904  *           AbortDoc   (GDI.382)
1905  */
1906 INT16 WINAPI AbortDoc16( HDC16 hdc )
1907 {
1908     return AbortDoc( HDC_32(hdc) );
1909 }
1910
1911
1912 /***********************************************************************
1913  *           FastWindowFrame    (GDI.400)
1914  */
1915 BOOL16 WINAPI FastWindowFrame16( HDC16 hdc, const RECT16 *rect,
1916                                INT16 width, INT16 height, DWORD rop )
1917 {
1918     HDC hdc32 = HDC_32(hdc);
1919     HBRUSH hbrush = SelectObject( hdc32, GetStockObject( GRAY_BRUSH ) );
1920     PatBlt( hdc32, rect->left, rect->top,
1921             rect->right - rect->left - width, height, rop );
1922     PatBlt( hdc32, rect->left, rect->top + height, width,
1923             rect->bottom - rect->top - height, rop );
1924     PatBlt( hdc32, rect->left + width, rect->bottom - 1,
1925             rect->right - rect->left - width, -height, rop );
1926     PatBlt( hdc32, rect->right - 1, rect->top, -width,
1927             rect->bottom - rect->top - height, rop );
1928     SelectObject( hdc32, hbrush );
1929     return TRUE;
1930 }
1931
1932
1933 /***********************************************************************
1934  *           CreateUserBitmap    (GDI.407)
1935  */
1936 HBITMAP16 WINAPI CreateUserBitmap16( INT16 width, INT16 height, UINT16 planes,
1937                                      UINT16 bpp, LPCVOID bits )
1938 {
1939     return CreateBitmap16( width, height, planes, bpp, bits );
1940 }
1941
1942
1943 /***********************************************************************
1944  *           CreateUserDiscardableBitmap    (GDI.409)
1945  */
1946 HBITMAP16 WINAPI CreateUserDiscardableBitmap16( WORD dummy, INT16 width, INT16 height )
1947 {
1948     HDC hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
1949     HBITMAP ret = CreateCompatibleBitmap( hdc, width, height );
1950     DeleteDC( hdc );
1951     return HBITMAP_16(ret);
1952 }
1953
1954
1955 /***********************************************************************
1956  *              GetCurLogFont (GDI.411)
1957  */
1958 HFONT16 WINAPI GetCurLogFont16( HDC16 hdc )
1959 {
1960     return HFONT_16( GetCurrentObject( HDC_32(hdc), OBJ_FONT ) );
1961 }
1962
1963
1964 /***********************************************************************
1965  *           StretchDIBits   (GDI.439)
1966  */
1967 INT16 WINAPI StretchDIBits16( HDC16 hdc, INT16 xDst, INT16 yDst, INT16 widthDst,
1968                               INT16 heightDst, INT16 xSrc, INT16 ySrc, INT16 widthSrc,
1969                               INT16 heightSrc, const VOID *bits,
1970                               const BITMAPINFO *info, UINT16 wUsage, DWORD dwRop )
1971 {
1972     return StretchDIBits( HDC_32(hdc), xDst, yDst, widthDst, heightDst,
1973                           xSrc, ySrc, widthSrc, heightSrc, bits,
1974                           info, wUsage, dwRop );
1975 }
1976
1977
1978 /***********************************************************************
1979  *           SetDIBits    (GDI.440)
1980  */
1981 INT16 WINAPI SetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
1982                           UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
1983                           UINT16 coloruse )
1984 {
1985     return SetDIBits( HDC_32(hdc), HBITMAP_32(hbitmap), startscan, lines, bits, info, coloruse );
1986 }
1987
1988
1989 /***********************************************************************
1990  *           GetDIBits    (GDI.441)
1991  */
1992 INT16 WINAPI GetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
1993                           UINT16 lines, LPVOID bits, BITMAPINFO * info,
1994                           UINT16 coloruse )
1995 {
1996     return GetDIBits( HDC_32(hdc), HBITMAP_32(hbitmap), startscan, lines, bits, info, coloruse );
1997 }
1998
1999
2000 /***********************************************************************
2001  *           CreateDIBitmap    (GDI.442)
2002  */
2003 HBITMAP16 WINAPI CreateDIBitmap16( HDC16 hdc, const BITMAPINFOHEADER * header,
2004                                    DWORD init, LPCVOID bits, const BITMAPINFO * data,
2005                                    UINT16 coloruse )
2006 {
2007     return HBITMAP_16( CreateDIBitmap( HDC_32(hdc), header, init, bits, data, coloruse ) );
2008 }
2009
2010
2011 /***********************************************************************
2012  *           SetDIBitsToDevice    (GDI.443)
2013  */
2014 INT16 WINAPI SetDIBitsToDevice16( HDC16 hdc, INT16 xDest, INT16 yDest, INT16 cx,
2015                                   INT16 cy, INT16 xSrc, INT16 ySrc, UINT16 startscan,
2016                                   UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
2017                                   UINT16 coloruse )
2018 {
2019     return SetDIBitsToDevice( HDC_32(hdc), xDest, yDest, cx, cy, xSrc, ySrc,
2020                               startscan, lines, bits, info, coloruse );
2021 }
2022
2023
2024 /***********************************************************************
2025  *           CreateRoundRectRgn    (GDI.444)
2026  *
2027  * If either ellipse dimension is zero we call CreateRectRgn16 for its
2028  * `special' behaviour. -ve ellipse dimensions can result in GPFs under win3.1
2029  * we just let CreateRoundRectRgn convert them to +ve values.
2030  */
2031
2032 HRGN16 WINAPI CreateRoundRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom,
2033                                     INT16 ellipse_width, INT16 ellipse_height )
2034 {
2035     if( ellipse_width == 0 || ellipse_height == 0 )
2036         return CreateRectRgn16( left, top, right, bottom );
2037     else
2038         return HRGN_16( CreateRoundRectRgn( left, top, right, bottom,
2039                                             ellipse_width, ellipse_height ));
2040 }
2041
2042
2043 /***********************************************************************
2044  *           CreateDIBPatternBrush    (GDI.445)
2045  */
2046 HBRUSH16 WINAPI CreateDIBPatternBrush16( HGLOBAL16 hbitmap, UINT16 coloruse )
2047 {
2048     BITMAPINFO *bmi;
2049     HBRUSH16 ret;
2050
2051     if (!(bmi = GlobalLock16( hbitmap ))) return 0;
2052     ret = HBRUSH_16( CreateDIBPatternBrushPt( bmi, coloruse ));
2053     GlobalUnlock16( hbitmap );
2054     return ret;
2055 }
2056
2057
2058 /**********************************************************************
2059  *          PolyPolygon (GDI.450)
2060  */
2061 BOOL16 WINAPI PolyPolygon16( HDC16 hdc, const POINT16* pt, const INT16* counts,
2062                              UINT16 polygons )
2063 {
2064     int         i,nrpts;
2065     LPPOINT     pt32;
2066     LPINT       counts32;
2067     BOOL16      ret;
2068
2069     nrpts=0;
2070     for (i=polygons;i--;)
2071         nrpts+=counts[i];
2072     pt32 = (LPPOINT)HeapAlloc( GetProcessHeap(), 0, sizeof(POINT)*nrpts);
2073     if(pt32 == NULL) return FALSE;
2074     for (i=nrpts;i--;)
2075         CONV_POINT16TO32(&(pt[i]),&(pt32[i]));
2076     counts32 = (LPINT)HeapAlloc( GetProcessHeap(), 0, polygons*sizeof(INT) );
2077     if(counts32 == NULL) {
2078         HeapFree( GetProcessHeap(), 0, pt32 );
2079         return FALSE;
2080     }
2081     for (i=polygons;i--;) counts32[i]=counts[i];
2082
2083     ret = PolyPolygon(HDC_32(hdc),pt32,counts32,polygons);
2084     HeapFree( GetProcessHeap(), 0, counts32 );
2085     HeapFree( GetProcessHeap(), 0, pt32 );
2086     return ret;
2087 }
2088
2089
2090 /***********************************************************************
2091  *           CreatePolyPolygonRgn    (GDI.451)
2092  */
2093 HRGN16 WINAPI CreatePolyPolygonRgn16( const POINT16 *points,
2094                                       const INT16 *count, INT16 nbpolygons, INT16 mode )
2095 {
2096     HRGN hrgn;
2097     int i, npts = 0;
2098     INT *count32;
2099     POINT *points32;
2100
2101     for (i = 0; i < nbpolygons; i++) npts += count[i];
2102     points32 = HeapAlloc( GetProcessHeap(), 0, npts * sizeof(POINT) );
2103     for (i = 0; i < npts; i++) CONV_POINT16TO32( &(points[i]), &(points32[i]) );
2104
2105     count32 = HeapAlloc( GetProcessHeap(), 0, nbpolygons * sizeof(INT) );
2106     for (i = 0; i < nbpolygons; i++) count32[i] = count[i];
2107     hrgn = CreatePolyPolygonRgn( points32, count32, nbpolygons, mode );
2108     HeapFree( GetProcessHeap(), 0, count32 );
2109     HeapFree( GetProcessHeap(), 0, points32 );
2110     return HRGN_16(hrgn);
2111 }
2112
2113
2114 /***********************************************************************
2115  *           SetObjectOwner    (GDI.461)
2116  */
2117 void WINAPI SetObjectOwner16( HGDIOBJ16 handle, HANDLE16 owner )
2118 {
2119     /* Nothing to do */
2120 }
2121
2122
2123 /***********************************************************************
2124  *           RectVisible    (GDI.465)
2125  *           RectVisibleOld (GDI.104)
2126  */
2127 BOOL16 WINAPI RectVisible16( HDC16 hdc, const RECT16* rect16 )
2128 {
2129     RECT rect;
2130     CONV_RECT16TO32( rect16, &rect );
2131     return RectVisible( HDC_32(hdc), &rect );
2132 }
2133
2134
2135 /***********************************************************************
2136  *           RectInRegion    (GDI.466)
2137  *           RectInRegionOld (GDI.181)
2138  */
2139 BOOL16 WINAPI RectInRegion16( HRGN16 hrgn, const RECT16 *rect )
2140 {
2141     RECT r32;
2142
2143     CONV_RECT16TO32(rect, &r32);
2144     return RectInRegion( HRGN_32(hrgn), &r32 );
2145 }
2146
2147
2148 /***********************************************************************
2149  *           GetBitmapDimensionEx    (GDI.468)
2150  */
2151 BOOL16 WINAPI GetBitmapDimensionEx16( HBITMAP16 hbitmap, LPSIZE16 size )
2152 {
2153     SIZE size32;
2154     BOOL ret = GetBitmapDimensionEx( HBITMAP_32(hbitmap), &size32 );
2155
2156     if (ret)
2157     {
2158         size->cx = size32.cx;
2159         size->cy = size32.cy;
2160     }
2161     return ret;
2162 }
2163
2164
2165 /***********************************************************************
2166  *              GetBrushOrgEx (GDI.469)
2167  */
2168 BOOL16 WINAPI GetBrushOrgEx16( HDC16 hdc, LPPOINT16 pt )
2169 {
2170     POINT pt32;
2171     if (!GetBrushOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
2172     pt->x = pt32.x;
2173     pt->y = pt32.y;
2174     return TRUE;
2175 }
2176
2177
2178 /***********************************************************************
2179  *              GetCurrentPositionEx (GDI.470)
2180  */
2181 BOOL16 WINAPI GetCurrentPositionEx16( HDC16 hdc, LPPOINT16 pt )
2182 {
2183     POINT pt32;
2184     if (!GetCurrentPositionEx( HDC_32(hdc), &pt32 )) return FALSE;
2185     pt->x = pt32.x;
2186     pt->y = pt32.y;
2187     return TRUE;
2188 }
2189
2190
2191 /***********************************************************************
2192  *           GetTextExtentPoint    (GDI.471)
2193  *
2194  * FIXME: Should this have a bug for compatibility?
2195  * Original Windows versions of GetTextExtentPoint{A,W} have documented
2196  * bugs (-> MSDN KB q147647.txt).
2197  */
2198 BOOL16 WINAPI GetTextExtentPoint16( HDC16 hdc, LPCSTR str, INT16 count, LPSIZE16 size )
2199 {
2200     SIZE size32;
2201     BOOL ret = GetTextExtentPoint32A( HDC_32(hdc), str, count, &size32 );
2202
2203     if (ret)
2204     {
2205         size->cx = size32.cx;
2206         size->cy = size32.cy;
2207     }
2208     return ret;
2209 }
2210
2211
2212 /***********************************************************************
2213  *              GetViewportExtEx (GDI.472)
2214  */
2215 BOOL16 WINAPI GetViewportExtEx16( HDC16 hdc, LPSIZE16 size )
2216 {
2217     SIZE size32;
2218     if (!GetViewportExtEx( HDC_32(hdc), &size32 )) return FALSE;
2219     size->cx = size32.cx;
2220     size->cy = size32.cy;
2221     return TRUE;
2222 }
2223
2224
2225 /***********************************************************************
2226  *              GetViewportOrgEx (GDI.473)
2227  */
2228 BOOL16 WINAPI GetViewportOrgEx16( HDC16 hdc, LPPOINT16 pt )
2229 {
2230     POINT pt32;
2231     if (!GetViewportOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
2232     pt->x = pt32.x;
2233     pt->y = pt32.y;
2234     return TRUE;
2235 }
2236
2237
2238 /***********************************************************************
2239  *              GetWindowExtEx (GDI.474)
2240  */
2241 BOOL16 WINAPI GetWindowExtEx16( HDC16 hdc, LPSIZE16 size )
2242 {
2243     SIZE size32;
2244     if (!GetWindowExtEx( HDC_32(hdc), &size32 )) return FALSE;
2245     size->cx = size32.cx;
2246     size->cy = size32.cy;
2247     return TRUE;
2248 }
2249
2250
2251 /***********************************************************************
2252  *              GetWindowOrgEx (GDI.475)
2253  */
2254 BOOL16 WINAPI GetWindowOrgEx16( HDC16 hdc, LPPOINT16 pt )
2255 {
2256     POINT pt32;
2257     if (!GetWindowOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
2258     pt->x = pt32.x;
2259     pt->y = pt32.y;
2260     return TRUE;
2261 }
2262
2263
2264 /***********************************************************************
2265  *           OffsetViewportOrgEx    (GDI.476)
2266  */
2267 BOOL16 WINAPI OffsetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt)
2268 {
2269     POINT pt32;
2270     BOOL16 ret = OffsetViewportOrgEx( HDC_32(hdc), x, y, &pt32 );
2271     if (pt) CONV_POINT32TO16( &pt32, pt );
2272     return ret;
2273 }
2274
2275
2276 /***********************************************************************
2277  *           OffsetWindowOrgEx    (GDI.477)
2278  */
2279 BOOL16 WINAPI OffsetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
2280 {
2281     POINT pt32;
2282     BOOL16 ret = OffsetWindowOrgEx( HDC_32(hdc), x, y, &pt32 );
2283     if (pt) CONV_POINT32TO16( &pt32, pt );
2284     return ret;
2285 }
2286
2287
2288 /***********************************************************************
2289  *           SetBitmapDimensionEx    (GDI.478)
2290  */
2291 BOOL16 WINAPI SetBitmapDimensionEx16( HBITMAP16 hbitmap, INT16 x, INT16 y, LPSIZE16 prevSize )
2292 {
2293     SIZE size32;
2294     BOOL ret = SetBitmapDimensionEx( HBITMAP_32(hbitmap), x, y, &size32 );
2295
2296     if (ret && prevSize)
2297     {
2298         prevSize->cx = size32.cx;
2299         prevSize->cy = size32.cy;
2300     }
2301     return ret;
2302 }
2303
2304
2305 /***********************************************************************
2306  *           SetViewportExtEx    (GDI.479)
2307  */
2308 BOOL16 WINAPI SetViewportExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
2309 {
2310     SIZE size32;
2311     BOOL16 ret = SetViewportExtEx( HDC_32(hdc), x, y, &size32 );
2312     if (size) { size->cx = size32.cx; size->cy = size32.cy; }
2313     return ret;
2314 }
2315
2316
2317 /***********************************************************************
2318  *           SetViewportOrgEx    (GDI.480)
2319  */
2320 BOOL16 WINAPI SetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
2321 {
2322     POINT pt32;
2323     BOOL16 ret = SetViewportOrgEx( HDC_32(hdc), x, y, &pt32 );
2324     if (pt) CONV_POINT32TO16( &pt32, pt );
2325     return ret;
2326 }
2327
2328
2329 /***********************************************************************
2330  *           SetWindowExtEx    (GDI.481)
2331  */
2332 BOOL16 WINAPI SetWindowExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
2333 {
2334     SIZE size32;
2335     BOOL16 ret = SetWindowExtEx( HDC_32(hdc), x, y, &size32 );
2336     if (size) { size->cx = size32.cx; size->cy = size32.cy; }
2337     return ret;
2338 }
2339
2340
2341 /***********************************************************************
2342  *           SetWindowOrgEx    (GDI.482)
2343  */
2344 BOOL16 WINAPI SetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
2345 {
2346     POINT pt32;
2347     BOOL16 ret = SetWindowOrgEx( HDC_32(hdc), x, y, &pt32 );
2348     if (pt) CONV_POINT32TO16( &pt32, pt );
2349     return ret;
2350 }
2351
2352
2353 /***********************************************************************
2354  *           MoveToEx    (GDI.483)
2355  */
2356 BOOL16 WINAPI MoveToEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
2357 {
2358     POINT pt32;
2359
2360     if (!MoveToEx( HDC_32(hdc), x, y, &pt32 )) return FALSE;
2361     if (pt) CONV_POINT32TO16( &pt32, pt );
2362     return TRUE;
2363 }
2364
2365
2366 /***********************************************************************
2367  *           ScaleViewportExtEx    (GDI.484)
2368  */
2369 BOOL16 WINAPI ScaleViewportExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
2370                                     INT16 yNum, INT16 yDenom, LPSIZE16 size )
2371 {
2372     SIZE size32;
2373     BOOL16 ret = ScaleViewportExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom,
2374                                        &size32 );
2375     if (size) { size->cx = size32.cx; size->cy = size32.cy; }
2376     return ret;
2377 }
2378
2379
2380 /***********************************************************************
2381  *           ScaleWindowExtEx    (GDI.485)
2382  */
2383 BOOL16 WINAPI ScaleWindowExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
2384                                   INT16 yNum, INT16 yDenom, LPSIZE16 size )
2385 {
2386     SIZE size32;
2387     BOOL16 ret = ScaleWindowExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom,
2388                                      &size32 );
2389     if (size) { size->cx = size32.cx; size->cy = size32.cy; }
2390     return ret;
2391 }
2392
2393
2394 /******************************************************************************
2395  *           PolyBezier  (GDI.502)
2396  */
2397 BOOL16 WINAPI PolyBezier16( HDC16 hdc, const POINT16* lppt, INT16 cPoints )
2398 {
2399     int i;
2400     BOOL16 ret;
2401     LPPOINT pt32 = (LPPOINT)HeapAlloc( GetProcessHeap(), 0,
2402                                            cPoints*sizeof(POINT) );
2403     if(!pt32) return FALSE;
2404     for (i=cPoints;i--;) CONV_POINT16TO32(&(lppt[i]),&(pt32[i]));
2405     ret= PolyBezier(HDC_32(hdc), pt32, cPoints);
2406     HeapFree( GetProcessHeap(), 0, pt32 );
2407     return ret;
2408 }
2409
2410
2411 /******************************************************************************
2412  *           PolyBezierTo  (GDI.503)
2413  */
2414 BOOL16 WINAPI PolyBezierTo16( HDC16 hdc, const POINT16* lppt, INT16 cPoints )
2415 {
2416     int i;
2417     BOOL16 ret;
2418     LPPOINT pt32 = (LPPOINT)HeapAlloc( GetProcessHeap(), 0,
2419                                            cPoints*sizeof(POINT) );
2420     if(!pt32) return FALSE;
2421     for (i=cPoints;i--;) CONV_POINT16TO32(&(lppt[i]),&(pt32[i]));
2422     ret= PolyBezierTo(HDC_32(hdc), pt32, cPoints);
2423     HeapFree( GetProcessHeap(), 0, pt32 );
2424     return ret;
2425 }
2426
2427
2428 /******************************************************************************
2429  *           ExtSelectClipRgn   (GDI.508)
2430  */
2431 INT16 WINAPI ExtSelectClipRgn16( HDC16 hdc, HRGN16 hrgn, INT16 fnMode )
2432 {
2433   return ExtSelectClipRgn( HDC_32(hdc), HRGN_32(hrgn), fnMode);
2434 }
2435
2436
2437 /***********************************************************************
2438  *           AbortPath    (GDI.511)
2439  */
2440 BOOL16 WINAPI AbortPath16(HDC16 hdc)
2441 {
2442     return AbortPath( HDC_32(hdc) );
2443 }
2444
2445
2446 /***********************************************************************
2447  *           BeginPath    (GDI.512)
2448  */
2449 BOOL16 WINAPI BeginPath16(HDC16 hdc)
2450 {
2451     return BeginPath( HDC_32(hdc) );
2452 }
2453
2454
2455 /***********************************************************************
2456  *           CloseFigure    (GDI.513)
2457  */
2458 BOOL16 WINAPI CloseFigure16(HDC16 hdc)
2459 {
2460     return CloseFigure( HDC_32(hdc) );
2461 }
2462
2463
2464 /***********************************************************************
2465  *           EndPath    (GDI.514)
2466  */
2467 BOOL16 WINAPI EndPath16(HDC16 hdc)
2468 {
2469     return EndPath( HDC_32(hdc) );
2470 }
2471
2472
2473 /***********************************************************************
2474  *           FillPath    (GDI.515)
2475  */
2476 BOOL16 WINAPI FillPath16(HDC16 hdc)
2477 {
2478     return FillPath( HDC_32(hdc) );
2479 }
2480
2481
2482 /*******************************************************************
2483  *           FlattenPath    (GDI.516)
2484  */
2485 BOOL16 WINAPI FlattenPath16(HDC16 hdc)
2486 {
2487     return FlattenPath( HDC_32(hdc) );
2488 }
2489
2490
2491 /***********************************************************************
2492  *           GetPath    (GDI.517)
2493  */
2494 INT16 WINAPI GetPath16(HDC16 hdc, LPPOINT16 pPoints, LPBYTE pTypes, INT16 nSize)
2495 {
2496     FIXME("(%d,%p,%p): stub\n",hdc,pPoints,pTypes);
2497     return 0;
2498 }
2499
2500
2501 /***********************************************************************
2502  *           PathToRegion    (GDI.518)
2503  */
2504 HRGN16 WINAPI PathToRegion16(HDC16 hdc)
2505 {
2506     return HRGN_16( PathToRegion( HDC_32(hdc) ));
2507 }
2508
2509
2510 /***********************************************************************
2511  *           SelectClipPath    (GDI.519)
2512  */
2513 BOOL16 WINAPI SelectClipPath16(HDC16 hdc, INT16 iMode)
2514 {
2515     return SelectClipPath( HDC_32(hdc), iMode );
2516 }
2517
2518
2519 /*******************************************************************
2520  *           StrokeAndFillPath    (GDI.520)
2521  */
2522 BOOL16 WINAPI StrokeAndFillPath16(HDC16 hdc)
2523 {
2524     return StrokeAndFillPath( HDC_32(hdc) );
2525 }
2526
2527
2528 /*******************************************************************
2529  *           StrokePath    (GDI.521)
2530  */
2531 BOOL16 WINAPI StrokePath16(HDC16 hdc)
2532 {
2533     return StrokePath( HDC_32(hdc) );
2534 }
2535
2536
2537 /*******************************************************************
2538  *           WidenPath    (GDI.522)
2539  */
2540 BOOL16 WINAPI WidenPath16(HDC16 hdc)
2541 {
2542     return WidenPath( HDC_32(hdc) );
2543 }
2544
2545
2546 /***********************************************************************
2547  *              GetArcDirection (GDI.524)
2548  */
2549 INT16 WINAPI GetArcDirection16( HDC16 hdc )
2550 {
2551     return GetArcDirection( HDC_32(hdc) );
2552 }
2553
2554
2555 /***********************************************************************
2556  *           SetArcDirection    (GDI.525)
2557  */
2558 INT16 WINAPI SetArcDirection16( HDC16 hdc, INT16 nDirection )
2559 {
2560     return SetArcDirection( HDC_32(hdc), (INT)nDirection );
2561 }
2562
2563
2564 /***********************************************************************
2565  *           CreateHalftonePalette (GDI.529)
2566  */
2567 HPALETTE16 WINAPI CreateHalftonePalette16( HDC16 hdc )
2568 {
2569     return HPALETTE_16( CreateHalftonePalette( HDC_32(hdc) ));
2570 }
2571
2572
2573 /***********************************************************************
2574  *           SetDIBColorTable    (GDI.602)
2575  */
2576 UINT16 WINAPI SetDIBColorTable16( HDC16 hdc, UINT16 startpos, UINT16 entries, RGBQUAD *colors )
2577 {
2578     return SetDIBColorTable( HDC_32(hdc), startpos, entries, colors );
2579 }
2580
2581
2582 /***********************************************************************
2583  *           GetDIBColorTable    (GDI.603)
2584  */
2585 UINT16 WINAPI GetDIBColorTable16( HDC16 hdc, UINT16 startpos, UINT16 entries, RGBQUAD *colors )
2586 {
2587     return GetDIBColorTable( HDC_32(hdc), startpos, entries, colors );
2588 }
2589
2590
2591 /***********************************************************************
2592  *           GetRegionData   (GDI.607)
2593  *
2594  * FIXME: is LPRGNDATA the same in Win16 and Win32 ?
2595  */
2596 DWORD WINAPI GetRegionData16( HRGN16 hrgn, DWORD count, LPRGNDATA rgndata )
2597 {
2598     return GetRegionData( HRGN_32(hrgn), count, rgndata );
2599 }
2600
2601
2602 /***********************************************************************
2603  *           GetTextCharset   (GDI.612)
2604  */
2605 UINT16 WINAPI GetTextCharset16( HDC16 hdc )
2606 {
2607     return GetTextCharset( HDC_32(hdc) );
2608 }
2609
2610
2611 /*************************************************************************
2612  *             GetFontLanguageInfo   (GDI.616)
2613  */
2614 DWORD WINAPI GetFontLanguageInfo16( HDC16 hdc )
2615 {
2616     return GetFontLanguageInfo( HDC_32(hdc) );
2617 }
2618
2619
2620 /***********************************************************************
2621  *           SetLayout   (GDI.1000)
2622  *
2623  * Sets left->right or right->left text layout flags of a dc.
2624  */
2625 BOOL16 WINAPI SetLayout16( HDC16 hdc, DWORD layout )
2626 {
2627     return SetLayout( HDC_32(hdc), layout );
2628 }