Fixed wownt32.h to make it usable from inside Wine, and use it to
[wine/dcerpc.git] / dlls / user / user16.c
blob9937c8027cc805cb473f561ee05e0582f0ba64e3
1 /*
2 * Misc 16-bit USER functions
4 * Copyright 2002 Patrik Stridvall
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "wine/winuser16.h"
22 #include "winbase.h"
23 #include "wownt32.h"
24 #include "user.h"
26 /* handle to handle 16 conversions */
27 #define HANDLE_16(h32) (LOWORD(h32))
29 /* handle16 to handle conversions */
30 #define HANDLE_32(h16) ((HANDLE)(ULONG_PTR)(h16))
31 #define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
33 WORD WINAPI DestroyIcon32(HGLOBAL16, UINT16);
36 /***********************************************************************
37 * SetCursor (USER.69)
39 HCURSOR16 WINAPI SetCursor16(HCURSOR16 hCursor)
41 return HCURSOR_16(SetCursor(HCURSOR_32(hCursor)));
44 /***********************************************************************
45 * ShowCursor (USER.71)
47 INT16 WINAPI ShowCursor16(BOOL16 bShow)
49 return ShowCursor(bShow);
52 /***********************************************************************
53 * DrawIcon (USER.84)
55 BOOL16 WINAPI DrawIcon16(HDC16 hdc, INT16 x, INT16 y, HICON16 hIcon)
57 return DrawIcon(HDC_32(hdc), x, y, HICON_32(hIcon));
60 /***********************************************************************
61 * IconSize (USER.86)
63 * See "Undocumented Windows". Used by W2.0 paint.exe.
65 DWORD WINAPI IconSize16(void)
67 return MAKELONG(GetSystemMetrics(SM_CYICON), GetSystemMetrics(SM_CXICON));
70 /***********************************************************************
71 * LoadCursor (USER.173)
73 HCURSOR16 WINAPI LoadCursor16(HINSTANCE16 hInstance, LPCSTR name)
75 return HCURSOR_16(LoadCursorA(HINSTANCE_32(hInstance), name));
79 /***********************************************************************
80 * LoadIcon (USER.174)
82 HICON16 WINAPI LoadIcon16(HINSTANCE16 hInstance, LPCSTR name)
84 return HICON_16(LoadIconA(HINSTANCE_32(hInstance), name));
87 /**********************************************************************
88 * LoadBitmap (USER.175)
90 HBITMAP16 WINAPI LoadBitmap16(HINSTANCE16 hInstance, LPCSTR name)
92 return HBITMAP_16(LoadBitmapA(HINSTANCE_32(hInstance), name));
95 /***********************************************************************
96 * GetCursor (USER.247)
98 HCURSOR16 WINAPI GetCursor16(void)
100 return HCURSOR_16(GetCursor());
103 /***********************************************************************
104 * GlobalAddAtom (USER.268)
106 ATOM WINAPI GlobalAddAtom16(LPCSTR lpString)
108 return GlobalAddAtomA(lpString);
111 /***********************************************************************
112 * GlobalDeleteAtom (USER.269)
114 ATOM WINAPI GlobalDeleteAtom16(ATOM nAtom)
116 return GlobalDeleteAtom(nAtom);
119 /***********************************************************************
120 * GlobalFindAtom (USER.270)
122 ATOM WINAPI GlobalFindAtom16(LPCSTR lpString)
124 return GlobalFindAtomA(lpString);
127 /***********************************************************************
128 * GlobalGetAtomName (USER.271)
130 UINT16 WINAPI GlobalGetAtomName16(ATOM nAtom, LPSTR lpBuffer, INT16 nSize)
132 return GlobalGetAtomNameA(nAtom, lpBuffer, nSize);
135 /***********************************************************************
136 * LoadImage (USER.389)
139 HANDLE16 WINAPI LoadImage16(HINSTANCE16 hinst, LPCSTR name, UINT16 type,
140 INT16 desiredx, INT16 desiredy, UINT16 loadflags)
142 return HANDLE_16(LoadImageA(HINSTANCE_32(hinst), name, type, desiredx,
143 desiredy, loadflags));
146 /******************************************************************************
147 * CopyImage (USER.390) Creates new image and copies attributes to it
150 HICON16 WINAPI CopyImage16(HANDLE16 hnd, UINT16 type, INT16 desiredx,
151 INT16 desiredy, UINT16 flags)
153 return HICON_16(CopyImage(HANDLE_32(hnd), (UINT)type, (INT)desiredx,
154 (INT)desiredy, (UINT)flags));
157 /**********************************************************************
158 * DrawIconEx (USER.394)
160 BOOL16 WINAPI DrawIconEx16(HDC16 hdc, INT16 xLeft, INT16 yTop, HICON16 hIcon,
161 INT16 cxWidth, INT16 cyWidth, UINT16 istep,
162 HBRUSH16 hbr, UINT16 flags)
164 return DrawIconEx(HDC_32(hdc), xLeft, yTop, HICON_32(hIcon), cxWidth, cyWidth,
165 istep, HBRUSH_32(hbr), flags);
168 /**********************************************************************
169 * GetIconInfo (USER.395)
171 BOOL16 WINAPI GetIconInfo16(HICON16 hIcon, LPICONINFO16 iconinfo)
173 ICONINFO ii32;
174 BOOL16 ret = GetIconInfo(HICON_32(hIcon), &ii32);
176 iconinfo->fIcon = ii32.fIcon;
177 iconinfo->xHotspot = ii32.xHotspot;
178 iconinfo->yHotspot = ii32.yHotspot;
179 iconinfo->hbmMask = HBITMAP_16(ii32.hbmMask);
180 iconinfo->hbmColor = HBITMAP_16(ii32.hbmColor);
181 return ret;
184 /***********************************************************************
185 * CreateCursor (USER.406)
187 HCURSOR16 WINAPI CreateCursor16(HINSTANCE16 hInstance,
188 INT16 xHotSpot, INT16 yHotSpot,
189 INT16 nWidth, INT16 nHeight,
190 LPCVOID lpANDbits, LPCVOID lpXORbits)
192 CURSORICONINFO info;
194 info.ptHotSpot.x = xHotSpot;
195 info.ptHotSpot.y = yHotSpot;
196 info.nWidth = nWidth;
197 info.nHeight = nHeight;
198 info.nWidthBytes = 0;
199 info.bPlanes = 1;
200 info.bBitsPerPixel = 1;
202 return CreateCursorIconIndirect16(hInstance, &info, lpANDbits, lpXORbits);
205 /**********************************************************************
206 * CreateIconFromResourceEx (USER.450)
208 * FIXME: not sure about exact parameter types
210 HICON16 WINAPI CreateIconFromResourceEx16(LPBYTE bits, UINT16 cbSize,
211 BOOL16 bIcon, DWORD dwVersion,
212 INT16 width, INT16 height,
213 UINT16 cFlag)
215 return HICON_16(CreateIconFromResourceEx(bits, cbSize, bIcon, dwVersion,
216 width, height, cFlag));
219 /***********************************************************************
220 * DestroyIcon (USER.457)
222 BOOL16 WINAPI DestroyIcon16(HICON16 hIcon)
224 return DestroyIcon32(hIcon, 0);
227 /***********************************************************************
228 * DestroyCursor (USER.458)
230 BOOL16 WINAPI DestroyCursor16(HCURSOR16 hCursor)
232 return DestroyIcon32(hCursor, 0);