Fix some DPA functions so they pass the new tests.
[wine/multimedia.git] / dlls / user / misc.c
bloba2a972ee91b206bd1538e779b6cdc602186d374d
1 /*
2 * Misc USER functions
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
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "wine/windef16.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "winnls.h"
32 #include "wine/unicode.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(win);
37 /* USER signal proc flags and codes */
38 /* See UserSignalProc for comments */
39 #define USIG_FLAGS_WIN32 0x0001
40 #define USIG_FLAGS_GUI 0x0002
41 #define USIG_FLAGS_FEEDBACK 0x0004
42 #define USIG_FLAGS_FAULT 0x0008
44 #define USIG_DLL_UNLOAD_WIN16 0x0001
45 #define USIG_DLL_UNLOAD_WIN32 0x0002
46 #define USIG_FAULT_DIALOG_PUSH 0x0003
47 #define USIG_FAULT_DIALOG_POP 0x0004
48 #define USIG_DLL_UNLOAD_ORPHANS 0x0005
49 #define USIG_THREAD_INIT 0x0010
50 #define USIG_THREAD_EXIT 0x0020
51 #define USIG_PROCESS_CREATE 0x0100
52 #define USIG_PROCESS_INIT 0x0200
53 #define USIG_PROCESS_EXIT 0x0300
54 #define USIG_PROCESS_DESTROY 0x0400
55 #define USIG_PROCESS_RUNNING 0x0500
56 #define USIG_PROCESS_LOADED 0x0600
58 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
60 /***********************************************************************
61 * SignalProc32 (USER.391)
62 * UserSignalProc (USER32.@)
64 * The exact meaning of the USER signals is undocumented, but this
65 * should cover the basic idea:
67 * USIG_DLL_UNLOAD_WIN16
68 * This is sent when a 16-bit module is unloaded.
70 * USIG_DLL_UNLOAD_WIN32
71 * This is sent when a 32-bit module is unloaded.
73 * USIG_DLL_UNLOAD_ORPHANS
74 * This is sent after the last Win3.1 module is unloaded,
75 * to allow removal of orphaned menus.
77 * USIG_FAULT_DIALOG_PUSH
78 * USIG_FAULT_DIALOG_POP
79 * These are called to allow USER to prepare for displaying a
80 * fault dialog, even though the fault might have happened while
81 * inside a USER critical section.
83 * USIG_THREAD_INIT
84 * This is called from the context of a new thread, as soon as it
85 * has started to run.
87 * USIG_THREAD_EXIT
88 * This is called, still in its context, just before a thread is
89 * about to terminate.
91 * USIG_PROCESS_CREATE
92 * This is called, in the parent process context, after a new process
93 * has been created.
95 * USIG_PROCESS_INIT
96 * This is called in the new process context, just after the main thread
97 * has started execution (after the main thread's USIG_THREAD_INIT has
98 * been sent).
100 * USIG_PROCESS_LOADED
101 * This is called after the executable file has been loaded into the
102 * new process context.
104 * USIG_PROCESS_RUNNING
105 * This is called immediately before the main entry point is called.
107 * USIG_PROCESS_EXIT
108 * This is called in the context of a process that is about to
109 * terminate (but before the last thread's USIG_THREAD_EXIT has
110 * been sent).
112 * USIG_PROCESS_DESTROY
113 * This is called after a process has terminated.
116 * The meaning of the dwFlags bits is as follows:
118 * USIG_FLAGS_WIN32
119 * Current process is 32-bit.
121 * USIG_FLAGS_GUI
122 * Current process is a (Win32) GUI process.
124 * USIG_FLAGS_FEEDBACK
125 * Current process needs 'feedback' (determined from the STARTUPINFO
126 * flags STARTF_FORCEONFEEDBACK / STARTF_FORCEOFFFEEDBACK).
128 * USIG_FLAGS_FAULT
129 * The signal is being sent due to a fault.
131 WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
132 DWORD dwFlags, HMODULE16 hModule )
134 FIXME("(%04x, %08lx, %04lx, %04x)\n",
135 uCode, dwThreadOrProcessID, dwFlags, hModule );
136 /* FIXME: Should chain to GdiSignalProc now. */
137 return 0;
141 /**********************************************************************
142 * SetLastErrorEx [USER32.@]
144 * Sets the last-error code.
146 * RETURNS
147 * None.
149 void WINAPI SetLastErrorEx(
150 DWORD error, /* [in] Per-thread error code */
151 DWORD type) /* [in] Error type */
153 TRACE("(0x%08lx, 0x%08lx)\n", error,type);
154 switch(type) {
155 case 0:
156 break;
157 case SLE_ERROR:
158 case SLE_MINORERROR:
159 case SLE_WARNING:
160 /* Fall through for now */
161 default:
162 FIXME("(error=%08lx, type=%08lx): Unhandled type\n", error,type);
163 break;
165 SetLastError( error );
168 /******************************************************************************
169 * GetAltTabInfoA [USER32.@]
171 BOOL WINAPI GetAltTabInfoA(HWND hwnd, int iItem, PALTTABINFO pati, LPSTR pszItemText, UINT cchItemText)
173 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
174 return FALSE;
177 /******************************************************************************
178 * GetAltTabInfoW [USER32.@]
180 BOOL WINAPI GetAltTabInfoW(HWND hwnd, int iItem, PALTTABINFO pati, LPWSTR pszItemText, UINT cchItemText)
182 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
183 return FALSE;
186 /******************************************************************************
187 * SetDebugErrorLevel [USER32.@]
188 * Sets the minimum error level for generating debugging events
190 * PARAMS
191 * dwLevel [I] Debugging error level
193 VOID WINAPI SetDebugErrorLevel( DWORD dwLevel )
195 FIXME("(%ld): stub\n", dwLevel);
199 /******************************************************************************
200 * GetProcessDefaultLayout [USER32.@]
202 * Gets the default layout for parentless windows.
203 * Right now, just returns 0 (left-to-right).
205 * RETURNS
206 * Success: Nonzero
207 * Failure: Zero
209 * BUGS
210 * No RTL
212 BOOL WINAPI GetProcessDefaultLayout( DWORD *pdwDefaultLayout )
214 if ( !pdwDefaultLayout ) {
215 SetLastError( ERROR_INVALID_PARAMETER );
216 return FALSE;
218 FIXME( "( %p ): No BiDi\n", pdwDefaultLayout );
219 *pdwDefaultLayout = 0;
220 return TRUE;
224 /******************************************************************************
225 * SetProcessDefaultLayout [USER32.@]
227 * Sets the default layout for parentless windows.
228 * Right now, only accepts 0 (left-to-right).
230 * RETURNS
231 * Success: Nonzero
232 * Failure: Zero
234 * BUGS
235 * No RTL
237 BOOL WINAPI SetProcessDefaultLayout( DWORD dwDefaultLayout )
239 if ( dwDefaultLayout == 0 )
240 return TRUE;
241 FIXME( "( %08lx ): No BiDi\n", dwDefaultLayout );
242 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
243 return FALSE;
247 /***********************************************************************
248 * SetWindowStationUser (USER32.@)
250 DWORD WINAPI SetWindowStationUser(DWORD x1,DWORD x2)
252 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
253 return 1;
256 /***********************************************************************
257 * RegisterLogonProcess (USER32.@)
259 DWORD WINAPI RegisterLogonProcess(HANDLE hprocess,BOOL x)
261 FIXME("(%p,%d),stub!\n",hprocess,x);
262 return 1;
265 /***********************************************************************
266 * SetLogonNotifyWindow (USER32.@)
268 DWORD WINAPI SetLogonNotifyWindow(HWINSTA hwinsta,HWND hwnd)
270 FIXME("(%p,%p),stub!\n",hwinsta,hwnd);
271 return 1;
274 /***********************************************************************
275 * EnumDisplayDevicesA (USER32.@)
277 BOOL WINAPI EnumDisplayDevicesA( LPVOID unused, DWORD i, LPDISPLAY_DEVICEA lpDisplayDevice,
278 DWORD dwFlags )
280 if (i)
281 return FALSE;
282 FIXME("(%p,%ld,%p,0x%08lx), stub!\n",unused,i,lpDisplayDevice,dwFlags);
283 strcpy(lpDisplayDevice->DeviceName,"X11");
284 strcpy(lpDisplayDevice->DeviceString,"X 11 Windowing System");
285 lpDisplayDevice->StateFlags =
286 DISPLAY_DEVICE_ATTACHED_TO_DESKTOP |
287 DISPLAY_DEVICE_PRIMARY_DEVICE |
288 DISPLAY_DEVICE_VGA_COMPATIBLE;
289 return TRUE;
292 /***********************************************************************
293 * EnumDisplayDevicesW (USER32.@)
295 BOOL WINAPI EnumDisplayDevicesW( LPVOID unused, DWORD i, LPDISPLAY_DEVICEW lpDisplayDevice,
296 DWORD dwFlags )
298 if (i)
299 return FALSE;
300 FIXME("(%p,%ld,%p,0x%08lx), stub!\n",unused,i,lpDisplayDevice,dwFlags);
301 MultiByteToWideChar( CP_ACP, 0, "X11", -1, lpDisplayDevice->DeviceName,
302 sizeof(lpDisplayDevice->DeviceName)/sizeof(WCHAR) );
303 MultiByteToWideChar( CP_ACP, 0, "X11 Windowing System", -1, lpDisplayDevice->DeviceString,
304 sizeof(lpDisplayDevice->DeviceString)/sizeof(WCHAR) );
305 lpDisplayDevice->StateFlags =
306 DISPLAY_DEVICE_ATTACHED_TO_DESKTOP |
307 DISPLAY_DEVICE_PRIMARY_DEVICE |
308 DISPLAY_DEVICE_VGA_COMPATIBLE;
309 return TRUE;
312 /***********************************************************************
313 * MonitorFromPoint (USER32.@)
315 HMONITOR WINAPI MonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags)
317 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
318 ((ptScreenCoords.x >= 0) &&
319 (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) &&
320 (ptScreenCoords.y >= 0) &&
321 (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN))))
323 return xPRIMARY_MONITOR;
325 return NULL;
328 /***********************************************************************
329 * MonitorFromRect (USER32.@)
331 HMONITOR WINAPI MonitorFromRect(LPRECT lprcScreenCoords, DWORD dwFlags)
333 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
334 ((lprcScreenCoords->right > 0) &&
335 (lprcScreenCoords->bottom > 0) &&
336 (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) &&
337 (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN))))
339 return xPRIMARY_MONITOR;
341 return NULL;
344 /***********************************************************************
345 * MonitorFromWindow (USER32.@)
347 HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
349 WINDOWPLACEMENT wp;
351 if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST))
352 return xPRIMARY_MONITOR;
354 if (IsIconic(hWnd) ?
355 GetWindowPlacement(hWnd, &wp) :
356 GetWindowRect(hWnd, &wp.rcNormalPosition)) {
358 return MonitorFromRect(&wp.rcNormalPosition, dwFlags);
361 return NULL;
364 /***********************************************************************
365 * GetMonitorInfoA (USER32.@)
367 BOOL WINAPI GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
369 RECT rcWork;
371 if ((hMonitor == xPRIMARY_MONITOR) &&
372 lpMonitorInfo &&
373 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
374 SystemParametersInfoA(SPI_GETWORKAREA, 0, &rcWork, 0))
376 SetRect( &lpMonitorInfo->rcMonitor, 0, 0,
377 GetSystemMetrics(SM_CXSCREEN),
378 GetSystemMetrics(SM_CYSCREEN) );
379 lpMonitorInfo->rcWork = rcWork;
380 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
382 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXA))
383 strcpy(((MONITORINFOEXA*)lpMonitorInfo)->szDevice, "DISPLAY");
385 return TRUE;
388 return FALSE;
391 /***********************************************************************
392 * GetMonitorInfoW (USER32.@)
394 BOOL WINAPI GetMonitorInfoW(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
396 static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
397 RECT rcWork;
399 if ((hMonitor == xPRIMARY_MONITOR) &&
400 lpMonitorInfo &&
401 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
402 SystemParametersInfoW(SPI_GETWORKAREA, 0, &rcWork, 0))
404 SetRect( &lpMonitorInfo->rcMonitor, 0, 0,
405 GetSystemMetrics(SM_CXSCREEN),
406 GetSystemMetrics(SM_CYSCREEN) );
407 lpMonitorInfo->rcWork = rcWork;
408 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
410 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXW))
411 strcpyW(((MONITORINFOEXW*)lpMonitorInfo)->szDevice, displayW);
413 return TRUE;
416 return FALSE;
419 /***********************************************************************
420 * EnumDisplayMonitors (USER32.@)
422 BOOL WINAPI EnumDisplayMonitors(
423 HDC hdcOptionalForPainting,
424 LPRECT lprcEnumMonitorsThatIntersect,
425 MONITORENUMPROC lpfnEnumProc,
426 LPARAM dwData)
428 RECT rcLimit;
429 SetRect( &rcLimit, 0, 0, GetSystemMetrics(SM_CXSCREEN),
430 GetSystemMetrics(SM_CYSCREEN) );
432 if (!lpfnEnumProc)
433 return FALSE;
435 if (hdcOptionalForPainting)
437 RECT rcClip;
438 POINT ptOrg;
440 switch (GetClipBox(hdcOptionalForPainting, &rcClip))
442 default:
443 if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg))
444 return FALSE;
446 OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y);
447 if (IntersectRect(&rcLimit, &rcLimit, &rcClip) &&
448 (!lprcEnumMonitorsThatIntersect ||
449 IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) {
451 break;
453 /* fall through */
454 case NULLREGION:
455 return TRUE;
456 case ERROR:
457 return FALSE;
459 } else {
460 if ( lprcEnumMonitorsThatIntersect &&
461 !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) {
463 return TRUE;
467 return lpfnEnumProc(
468 xPRIMARY_MONITOR,
469 hdcOptionalForPainting,
470 &rcLimit,
471 dwData);
474 /***********************************************************************
475 * RegisterSystemThread (USER32.@)
477 void WINAPI RegisterSystemThread(DWORD flags, DWORD reserved)
479 FIXME("(%08lx, %08lx)\n", flags, reserved);
482 /***********************************************************************
483 * RegisterShellHookWindow [USER32.@]
485 BOOL WINAPI RegisterShellHookWindow ( HWND hWnd )
487 FIXME("(%p): stub\n", hWnd);
488 return 0;
492 /***********************************************************************
493 * DeregisterShellHookWindow [USER32.@]
495 HRESULT WINAPI DeregisterShellHookWindow ( DWORD u )
497 FIXME("0x%08lx stub\n",u);
498 return 0;
503 /***********************************************************************
504 * RegisterTasklist [USER32.@]
506 DWORD WINAPI RegisterTasklist (DWORD x)
508 FIXME("0x%08lx\n",x);
509 return TRUE;
513 /***********************************************************************
514 * RegisterDeviceNotificationA (USER32.@)
516 * See RegisterDeviceNotificationW.
518 HDEVNOTIFY WINAPI RegisterDeviceNotificationA(HANDLE hnd, LPVOID notifyfilter, DWORD flags)
520 FIXME("(hwnd=%p, filter=%p,flags=0x%08lx), STUB!\n", hnd,notifyfilter,flags );
521 return 0;
524 /***********************************************************************
525 * RegisterDeviceNotificationW (USER32.@)
527 * Registers a window with the system so that it will receive
528 * notifications about a device.
530 * PARAMS
531 * hRecepient [I] Window or service status handle that
532 * will receive notifications.
533 * pNotificationFilter [I] DEV_BROADCAST_HDR followed by some
534 * type-specific data.
535 * dwFlags [I] See notes
537 * RETURNS
539 * A handle to the device notification.
541 * NOTES
543 * The dwFlags parameter can be one of two values:
544 *| DEVICE_NOTIFY_WINDOW_HANDLE - hRecepient is a window handle
545 *| DEVICE_NOTIFY_SERVICE_HANDLE - hRecepient is a service status handle
547 HDEVNOTIFY WINAPI RegisterDeviceNotificationW(HANDLE hRecepient, LPVOID pNotificationFilter, DWORD dwFlags)
549 FIXME("(hwnd=%p, filter=%p,flags=0x%08lx), STUB!\n", hRecepient,pNotificationFilter,dwFlags );
550 return 0;
553 /***********************************************************************
554 * GetAppCompatFlags (USER32.@)
556 DWORD WINAPI GetAppCompatFlags( HTASK hTask )
558 FIXME("stub\n");
559 return 0;
563 /***********************************************************************
564 * AlignRects (USER32.@)
566 BOOL WINAPI AlignRects(LPRECT rect, DWORD b, DWORD c, DWORD d)
568 FIXME("(%p, %ld, %ld, %ld): stub\n", rect, b, c, d);
569 if (rect)
570 FIXME("rect: [[%ld, %ld], [%ld, %ld]]\n", rect->left, rect->top, rect->right, rect->bottom);
571 /* Calls OffsetRect */
572 return FALSE;
576 /***********************************************************************
577 * LoadLocalFonts (USER32.@)
579 VOID WINAPI LoadLocalFonts(VOID)
581 /* are loaded. */
582 return;
586 /***********************************************************************
587 * USER_489 (USER.489)
589 LONG WINAPI stub_USER_489(void) { FIXME("stub\n"); return 0; }
591 /***********************************************************************
592 * USER_490 (USER.490)
594 LONG WINAPI stub_USER_490(void) { FIXME("stub\n"); return 0; }
596 /***********************************************************************
597 * USER_492 (USER.492)
599 LONG WINAPI stub_USER_492(void) { FIXME("stub\n"); return 0; }
601 /***********************************************************************
602 * USER_496 (USER.496)
604 LONG WINAPI stub_USER_496(void) { FIXME("stub\n"); return 0; }
606 /***********************************************************************
607 * User32InitializeImmEntryTable
609 BOOL WINAPI User32InitializeImmEntryTable(LPVOID ptr)
611 FIXME("(%p): stub\n", ptr);
612 return TRUE;
615 /**********************************************************************
616 * WINNLSGetIMEHotkey [USER32.@]
619 UINT WINAPI WINNLSGetIMEHotkey(HWND hUnknown1)
621 FIXME("hUnknown1 %p: stub!\n", hUnknown1);
622 return 0; /* unknown */
625 /**********************************************************************
626 * WINNLSEnableIME [USER32.@]
629 BOOL WINAPI WINNLSEnableIME(HWND hUnknown1, BOOL bUnknown2)
631 FIXME("hUnknown1 %p bUnknown2 %d: stub!\n", hUnknown1, bUnknown2);
632 return TRUE; /* success (?) */
635 /**********************************************************************
636 * WINNLSGetEnableStatus [USER32.@]
639 BOOL WINAPI WINNLSGetEnableStatus(HWND hUnknown1)
641 FIXME("hUnknown1 %p: stub!\n", hUnknown1);
642 return TRUE; /* success (?) */
645 /**********************************************************************
646 * SendIMEMessageExA [USER32.@]
649 LRESULT WINAPI SendIMEMessageExA(HWND p1, LPARAM p2)
651 FIXME("(%p,%lx): stub\n", p1, p2);
652 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
653 return 0;
656 /**********************************************************************
657 * SendIMEMessageExW [USER32.@]
660 LRESULT WINAPI SendIMEMessageExW(HWND p1, LPARAM p2)
662 FIXME("(%p,%lx): stub\n", p1, p2);
663 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
664 return 0;