4 * Copyright 1995 Thomas Sandford
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998 Turchanov Sergey
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "wine/windef16.h"
33 #include "wine/unicode.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(win);
38 /* USER signal proc flags and codes */
39 /* See UserSignalProc for comments */
40 #define USIG_FLAGS_WIN32 0x0001
41 #define USIG_FLAGS_GUI 0x0002
42 #define USIG_FLAGS_FEEDBACK 0x0004
43 #define USIG_FLAGS_FAULT 0x0008
45 #define USIG_DLL_UNLOAD_WIN16 0x0001
46 #define USIG_DLL_UNLOAD_WIN32 0x0002
47 #define USIG_FAULT_DIALOG_PUSH 0x0003
48 #define USIG_FAULT_DIALOG_POP 0x0004
49 #define USIG_DLL_UNLOAD_ORPHANS 0x0005
50 #define USIG_THREAD_INIT 0x0010
51 #define USIG_THREAD_EXIT 0x0020
52 #define USIG_PROCESS_CREATE 0x0100
53 #define USIG_PROCESS_INIT 0x0200
54 #define USIG_PROCESS_EXIT 0x0300
55 #define USIG_PROCESS_DESTROY 0x0400
56 #define USIG_PROCESS_RUNNING 0x0500
57 #define USIG_PROCESS_LOADED 0x0600
59 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
61 /***********************************************************************
62 * SignalProc32 (USER.391)
63 * UserSignalProc (USER32.@)
65 * The exact meaning of the USER signals is undocumented, but this
66 * should cover the basic idea:
68 * USIG_DLL_UNLOAD_WIN16
69 * This is sent when a 16-bit module is unloaded.
71 * USIG_DLL_UNLOAD_WIN32
72 * This is sent when a 32-bit module is unloaded.
74 * USIG_DLL_UNLOAD_ORPHANS
75 * This is sent after the last Win3.1 module is unloaded,
76 * to allow removal of orphaned menus.
78 * USIG_FAULT_DIALOG_PUSH
79 * USIG_FAULT_DIALOG_POP
80 * These are called to allow USER to prepare for displaying a
81 * fault dialog, even though the fault might have happened while
82 * inside a USER critical section.
85 * This is called from the context of a new thread, as soon as it
89 * This is called, still in its context, just before a thread is
93 * This is called, in the parent process context, after a new process
97 * This is called in the new process context, just after the main thread
98 * has started execution (after the main thread's USIG_THREAD_INIT has
101 * USIG_PROCESS_LOADED
102 * This is called after the executable file has been loaded into the
103 * new process context.
105 * USIG_PROCESS_RUNNING
106 * This is called immediately before the main entry point is called.
109 * This is called in the context of a process that is about to
110 * terminate (but before the last thread's USIG_THREAD_EXIT has
113 * USIG_PROCESS_DESTROY
114 * This is called after a process has terminated.
117 * The meaning of the dwFlags bits is as follows:
120 * Current process is 32-bit.
123 * Current process is a (Win32) GUI process.
125 * USIG_FLAGS_FEEDBACK
126 * Current process needs 'feedback' (determined from the STARTUPINFO
127 * flags STARTF_FORCEONFEEDBACK / STARTF_FORCEOFFFEEDBACK).
130 * The signal is being sent due to a fault.
132 WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
133 DWORD dwFlags, HMODULE16 hModule )
135 FIXME("(%04x, %08lx, %04lx, %04x)\n",
136 uCode, dwThreadOrProcessID, dwFlags, hModule );
137 /* FIXME: Should chain to GdiSignalProc now. */
142 /**********************************************************************
143 * SetLastErrorEx [USER32.@]
145 * Sets the last-error code.
150 void WINAPI SetLastErrorEx(
151 DWORD error, /* [in] Per-thread error code */
152 DWORD type) /* [in] Error type */
154 TRACE("(0x%08lx, 0x%08lx)\n", error,type);
161 /* Fall through for now */
163 FIXME("(error=%08lx, type=%08lx): Unhandled type\n", error,type);
166 SetLastError( error );
169 /******************************************************************************
170 * GetAltTabInfoA [USER32.@]
172 BOOL WINAPI GetAltTabInfoA(HWND hwnd, int iItem, PALTTABINFO pati, LPSTR pszItemText, UINT cchItemText)
174 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
178 /******************************************************************************
179 * GetAltTabInfoW [USER32.@]
181 BOOL WINAPI GetAltTabInfoW(HWND hwnd, int iItem, PALTTABINFO pati, LPWSTR pszItemText, UINT cchItemText)
183 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
187 /******************************************************************************
188 * SetDebugErrorLevel [USER32.@]
189 * Sets the minimum error level for generating debugging events
192 * dwLevel [I] Debugging error level
194 VOID WINAPI SetDebugErrorLevel( DWORD dwLevel )
196 FIXME("(%ld): stub\n", dwLevel);
200 /******************************************************************************
201 * GetProcessDefaultLayout [USER32.@]
203 * Gets the default layout for parentless windows.
204 * Right now, just returns 0 (left-to-right).
213 BOOL WINAPI GetProcessDefaultLayout( DWORD *pdwDefaultLayout )
215 if ( !pdwDefaultLayout ) {
216 SetLastError( ERROR_INVALID_PARAMETER );
219 FIXME( "( %p ): No BiDi\n", pdwDefaultLayout );
220 *pdwDefaultLayout = 0;
225 /******************************************************************************
226 * SetProcessDefaultLayout [USER32.@]
228 * Sets the default layout for parentless windows.
229 * Right now, only accepts 0 (left-to-right).
238 BOOL WINAPI SetProcessDefaultLayout( DWORD dwDefaultLayout )
240 if ( dwDefaultLayout == 0 )
242 FIXME( "( %08lx ): No BiDi\n", dwDefaultLayout );
243 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
248 /***********************************************************************
249 * SetWindowStationUser (USER32.@)
251 DWORD WINAPI SetWindowStationUser(DWORD x1,DWORD x2)
253 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
257 /***********************************************************************
258 * RegisterLogonProcess (USER32.@)
260 DWORD WINAPI RegisterLogonProcess(HANDLE hprocess,BOOL x)
262 FIXME("(%p,%d),stub!\n",hprocess,x);
266 /***********************************************************************
267 * SetLogonNotifyWindow (USER32.@)
269 DWORD WINAPI SetLogonNotifyWindow(HWINSTA hwinsta,HWND hwnd)
271 FIXME("(%p,%p),stub!\n",hwinsta,hwnd);
275 static const WCHAR primary_device_name[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
276 static const WCHAR primary_device_string[] = {'X','1','1',' ','W','i','n','d','o','w','i','n','g',' ',
277 'S','y','s','t','e','m',0};
279 /***********************************************************************
280 * EnumDisplayDevicesA (USER32.@)
282 BOOL WINAPI EnumDisplayDevicesA( LPCSTR lpDevice, DWORD i, LPDISPLAY_DEVICEA lpDispDev,
285 UNICODE_STRING deviceW;
290 RtlCreateUnicodeStringFromAsciiz(&deviceW, lpDevice);
292 deviceW.Buffer = NULL;
294 ddW.cb = sizeof(ddW);
295 ret = EnumDisplayDevicesW(deviceW.Buffer, i, &ddW, dwFlags);
296 RtlFreeUnicodeString(&deviceW);
300 WideCharToMultiByte(CP_ACP, 0, ddW.DeviceName, -1, lpDispDev->DeviceName, sizeof(lpDispDev->DeviceName), NULL, NULL);
301 WideCharToMultiByte(CP_ACP, 0, ddW.DeviceString, -1, lpDispDev->DeviceString, sizeof(lpDispDev->DeviceString), NULL, NULL);
302 lpDispDev->StateFlags = ddW.StateFlags;
304 if(lpDispDev->cb >= offsetof(DISPLAY_DEVICEA, DeviceID) + sizeof(lpDispDev->DeviceID))
305 WideCharToMultiByte(CP_ACP, 0, ddW.DeviceID, -1, lpDispDev->DeviceID, sizeof(lpDispDev->DeviceID), NULL, NULL);
306 if(lpDispDev->cb >= offsetof(DISPLAY_DEVICEA, DeviceKey) + sizeof(lpDispDev->DeviceKey))
307 WideCharToMultiByte(CP_ACP, 0, ddW.DeviceKey, -1, lpDispDev->DeviceKey, sizeof(lpDispDev->DeviceKey), NULL, NULL);
312 /***********************************************************************
313 * EnumDisplayDevicesW (USER32.@)
315 BOOL WINAPI EnumDisplayDevicesW( LPCWSTR lpDevice, DWORD i, LPDISPLAY_DEVICEW lpDisplayDevice,
318 FIXME("(%s,%ld,%p,0x%08lx), stub!\n",debugstr_w(lpDevice),i,lpDisplayDevice,dwFlags);
323 memcpy(lpDisplayDevice->DeviceName, primary_device_name, sizeof(primary_device_name));
324 memcpy(lpDisplayDevice->DeviceString, primary_device_string, sizeof(primary_device_string));
326 lpDisplayDevice->StateFlags =
327 DISPLAY_DEVICE_ATTACHED_TO_DESKTOP |
328 DISPLAY_DEVICE_PRIMARY_DEVICE |
329 DISPLAY_DEVICE_VGA_COMPATIBLE;
331 if(lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceID) + sizeof(lpDisplayDevice->DeviceID))
332 lpDisplayDevice->DeviceID[0] = 0;
333 if(lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceKey) + sizeof(lpDisplayDevice->DeviceKey))
334 lpDisplayDevice->DeviceKey[0] = 0;
339 /***********************************************************************
340 * MonitorFromPoint (USER32.@)
342 HMONITOR WINAPI MonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags)
344 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
345 ((ptScreenCoords.x >= 0) &&
346 (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) &&
347 (ptScreenCoords.y >= 0) &&
348 (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN))))
350 return xPRIMARY_MONITOR;
355 /***********************************************************************
356 * MonitorFromRect (USER32.@)
358 HMONITOR WINAPI MonitorFromRect(LPRECT lprcScreenCoords, DWORD dwFlags)
360 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
361 ((lprcScreenCoords->right > 0) &&
362 (lprcScreenCoords->bottom > 0) &&
363 (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) &&
364 (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN))))
366 return xPRIMARY_MONITOR;
371 /***********************************************************************
372 * MonitorFromWindow (USER32.@)
374 HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
378 if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST))
379 return xPRIMARY_MONITOR;
382 GetWindowPlacement(hWnd, &wp) :
383 GetWindowRect(hWnd, &wp.rcNormalPosition)) {
385 return MonitorFromRect(&wp.rcNormalPosition, dwFlags);
391 /***********************************************************************
392 * GetMonitorInfoA (USER32.@)
394 BOOL WINAPI GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
397 MONITORINFOEXA *miA = (MONITORINFOEXA*)lpMonitorInfo;
400 miW.cbSize = sizeof(miW);
402 ret = GetMonitorInfoW(hMonitor, (MONITORINFO*)&miW);
405 miA->rcMonitor = miW.rcMonitor;
406 miA->rcWork = miW.rcWork;
407 miA->dwFlags = miW.dwFlags;
408 if(miA->cbSize >= offsetof(MONITORINFOEXA, szDevice) + sizeof(miA->szDevice))
409 WideCharToMultiByte(CP_ACP, 0, miW.szDevice, -1, miA->szDevice, sizeof(miA->szDevice), NULL, NULL);
413 /***********************************************************************
414 * GetMonitorInfoW (USER32.@)
416 BOOL WINAPI GetMonitorInfoW(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
420 if ((hMonitor == xPRIMARY_MONITOR) &&
422 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
423 SystemParametersInfoW(SPI_GETWORKAREA, 0, &rcWork, 0))
425 SetRect( &lpMonitorInfo->rcMonitor, 0, 0,
426 GetSystemMetrics(SM_CXSCREEN),
427 GetSystemMetrics(SM_CYSCREEN) );
428 lpMonitorInfo->rcWork = rcWork;
429 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
431 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXW))
432 strcpyW(((MONITORINFOEXW*)lpMonitorInfo)->szDevice, primary_device_name);
440 /***********************************************************************
441 * EnumDisplayMonitors (USER32.@)
443 BOOL WINAPI EnumDisplayMonitors(
444 HDC hdcOptionalForPainting,
445 LPRECT lprcEnumMonitorsThatIntersect,
446 MONITORENUMPROC lpfnEnumProc,
450 SetRect( &rcLimit, 0, 0, GetSystemMetrics(SM_CXSCREEN),
451 GetSystemMetrics(SM_CYSCREEN) );
456 if (hdcOptionalForPainting)
461 switch (GetClipBox(hdcOptionalForPainting, &rcClip))
464 if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg))
467 OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y);
468 if (IntersectRect(&rcLimit, &rcLimit, &rcClip) &&
469 (!lprcEnumMonitorsThatIntersect ||
470 IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) {
481 if ( lprcEnumMonitorsThatIntersect &&
482 !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) {
490 hdcOptionalForPainting,
495 /***********************************************************************
496 * RegisterSystemThread (USER32.@)
498 void WINAPI RegisterSystemThread(DWORD flags, DWORD reserved)
500 FIXME("(%08lx, %08lx)\n", flags, reserved);
503 /***********************************************************************
504 * RegisterShellHookWindow [USER32.@]
506 BOOL WINAPI RegisterShellHookWindow ( HWND hWnd )
508 FIXME("(%p): stub\n", hWnd);
513 /***********************************************************************
514 * DeregisterShellHookWindow [USER32.@]
516 HRESULT WINAPI DeregisterShellHookWindow ( DWORD u )
518 FIXME("0x%08lx stub\n",u);
524 /***********************************************************************
525 * RegisterTasklist [USER32.@]
527 DWORD WINAPI RegisterTasklist (DWORD x)
529 FIXME("0x%08lx\n",x);
534 /***********************************************************************
535 * RegisterDeviceNotificationA (USER32.@)
537 * See RegisterDeviceNotificationW.
539 HDEVNOTIFY WINAPI RegisterDeviceNotificationA(HANDLE hnd, LPVOID notifyfilter, DWORD flags)
541 FIXME("(hwnd=%p, filter=%p,flags=0x%08lx), STUB!\n", hnd,notifyfilter,flags );
545 /***********************************************************************
546 * RegisterDeviceNotificationW (USER32.@)
548 * Registers a window with the system so that it will receive
549 * notifications about a device.
552 * hRecepient [I] Window or service status handle that
553 * will receive notifications.
554 * pNotificationFilter [I] DEV_BROADCAST_HDR followed by some
555 * type-specific data.
556 * dwFlags [I] See notes
560 * A handle to the device notification.
564 * The dwFlags parameter can be one of two values:
565 *| DEVICE_NOTIFY_WINDOW_HANDLE - hRecepient is a window handle
566 *| DEVICE_NOTIFY_SERVICE_HANDLE - hRecepient is a service status handle
568 HDEVNOTIFY WINAPI RegisterDeviceNotificationW(HANDLE hRecepient, LPVOID pNotificationFilter, DWORD dwFlags)
570 FIXME("(hwnd=%p, filter=%p,flags=0x%08lx), STUB!\n", hRecepient,pNotificationFilter,dwFlags );
574 /***********************************************************************
575 * UnregisterDeviceNotification (USER32.@)
578 BOOL WINAPI UnregisterDeviceNotification(HDEVNOTIFY hnd)
580 FIXME("(handle=%p), STUB!\n", hnd);
584 /***********************************************************************
585 * GetAppCompatFlags (USER32.@)
587 DWORD WINAPI GetAppCompatFlags( HTASK hTask )
594 /***********************************************************************
595 * AlignRects (USER32.@)
597 BOOL WINAPI AlignRects(LPRECT rect, DWORD b, DWORD c, DWORD d)
599 FIXME("(%p, %ld, %ld, %ld): stub\n", rect, b, c, d);
601 FIXME("rect: [[%ld, %ld], [%ld, %ld]]\n", rect->left, rect->top, rect->right, rect->bottom);
602 /* Calls OffsetRect */
607 /***********************************************************************
608 * LoadLocalFonts (USER32.@)
610 VOID WINAPI LoadLocalFonts(VOID)
617 /***********************************************************************
618 * USER_489 (USER.489)
620 LONG WINAPI stub_USER_489(void) { FIXME("stub\n"); return 0; }
622 /***********************************************************************
623 * USER_490 (USER.490)
625 LONG WINAPI stub_USER_490(void) { FIXME("stub\n"); return 0; }
627 /***********************************************************************
628 * USER_492 (USER.492)
630 LONG WINAPI stub_USER_492(void) { FIXME("stub\n"); return 0; }
632 /***********************************************************************
633 * USER_496 (USER.496)
635 LONG WINAPI stub_USER_496(void) { FIXME("stub\n"); return 0; }
637 /***********************************************************************
638 * User32InitializeImmEntryTable
640 BOOL WINAPI User32InitializeImmEntryTable(LPVOID ptr)
642 FIXME("(%p): stub\n", ptr);
646 /**********************************************************************
647 * WINNLSGetIMEHotkey [USER32.@]
650 UINT WINAPI WINNLSGetIMEHotkey(HWND hUnknown1)
652 FIXME("hUnknown1 %p: stub!\n", hUnknown1);
653 return 0; /* unknown */
656 /**********************************************************************
657 * WINNLSEnableIME [USER32.@]
660 BOOL WINAPI WINNLSEnableIME(HWND hUnknown1, BOOL bUnknown2)
662 FIXME("hUnknown1 %p bUnknown2 %d: stub!\n", hUnknown1, bUnknown2);
663 return TRUE; /* success (?) */
666 /**********************************************************************
667 * WINNLSGetEnableStatus [USER32.@]
670 BOOL WINAPI WINNLSGetEnableStatus(HWND hUnknown1)
672 FIXME("hUnknown1 %p: stub!\n", hUnknown1);
673 return TRUE; /* success (?) */
676 /**********************************************************************
677 * SendIMEMessageExA [USER32.@]
680 LRESULT WINAPI SendIMEMessageExA(HWND p1, LPARAM p2)
682 FIXME("(%p,%lx): stub\n", p1, p2);
683 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
687 /**********************************************************************
688 * SendIMEMessageExW [USER32.@]
691 LRESULT WINAPI SendIMEMessageExW(HWND p1, LPARAM p2)
693 FIXME("(%p,%lx): stub\n", p1, p2);
694 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);