2 * Window related functions
4 * Copyright 1993, 1994 Alexandre Julliard
10 #include "wine/winbase16.h"
11 #include "wine/winuser16.h"
12 #include "wine/unicode.h"
19 #include "cursoricon.h"
25 #include "stackframe.h"
26 #include "debugtools.h"
28 DEFAULT_DEBUG_CHANNEL(win);
29 DECLARE_DEBUG_CHANNEL(msg);
31 /**********************************************************************/
33 WND_DRIVER *WND_Driver = NULL;
36 static WND *pWndDesktop = NULL;
38 static HWND hwndSysModal = 0;
40 static WORD wDragWidth = 4;
41 static WORD wDragHeight= 3;
44 static SYSLEVEL WIN_SysLevel = { CRITICAL_SECTION_INIT, 2 };
46 /***********************************************************************
49 * Locks access to all WND structures for thread safeness
51 void WIN_LockWnds( void )
53 _EnterSysLevel( &WIN_SysLevel );
56 /***********************************************************************
59 * Unlocks access to all WND structures
61 void WIN_UnlockWnds( void )
63 _LeaveSysLevel( &WIN_SysLevel );
66 /***********************************************************************
69 * Suspend the lock on WND structures.
70 * Returns the number of locks suspended
72 int WIN_SuspendWndsLock( void )
74 int isuspendedLocks = _ConfirmSysLevel( &WIN_SysLevel );
75 int count = isuspendedLocks;
78 _LeaveSysLevel( &WIN_SysLevel );
80 return isuspendedLocks;
83 /***********************************************************************
86 * Restore the suspended locks on WND structures
88 void WIN_RestoreWndsLock( int ipreviousLocks )
90 while ( ipreviousLocks-- > 0 )
91 _EnterSysLevel( &WIN_SysLevel );
94 /***********************************************************************
97 * Return a pointer to the WND structure corresponding to a HWND.
99 WND * WIN_FindWndPtr( HWND hwnd )
103 if (!hwnd || HIWORD(hwnd)) goto error2;
104 ptr = (WND *) USER_HEAP_LIN_ADDR( hwnd );
105 /* Lock all WND structures for thread safeness*/
107 /*and increment destruction monitoring*/
110 if (ptr->dwMagic != WND_MAGIC) goto error;
111 if (ptr->hwndSelf != hwnd)
113 ERR("Can't happen: hwnd %04x self pointer is %04x\n",hwnd, ptr->hwndSelf );
116 /* returns a locked pointer */
119 /* Unlock all WND structures for thread safeness*/
121 /* and decrement destruction monitoring value */
126 SetLastError( ERROR_INVALID_WINDOW_HANDLE );
130 /***********************************************************************
133 * Use in case the wnd ptr is not initialized with WIN_FindWndPtr
135 * Returns the locked initialisation pointer
137 WND *WIN_LockWndPtr(WND *initWndPtr)
139 if(!initWndPtr) return 0;
141 /* Lock all WND structures for thread safeness*/
143 /*and increment destruction monitoring*/
144 initWndPtr->irefCount++;
150 /***********************************************************************
153 * Release the pointer to the WND structure.
155 void WIN_ReleaseWndPtr(WND *wndPtr)
159 /*Decrement destruction monitoring value*/
161 /* Check if it's time to release the memory*/
162 if(wndPtr->irefCount == 0 && !wndPtr->dwMagic)
165 USER_HEAP_FREE( wndPtr->hwndSelf);
166 wndPtr->hwndSelf = 0;
168 else if(wndPtr->irefCount < 0)
170 /* This else if is useful to monitor the WIN_ReleaseWndPtr function */
171 ERR("forgot a Lock on %p somewhere\n",wndPtr);
173 /*unlock all WND structures for thread safeness*/
177 /***********************************************************************
180 * Updates the value of oldPtr to newPtr.
182 void WIN_UpdateWndPtr(WND **oldPtr, WND *newPtr)
186 tmpWnd = WIN_LockWndPtr(newPtr);
187 WIN_ReleaseWndPtr(*oldPtr);
192 /***********************************************************************
195 * Dump the content of a window structure to stderr.
197 void WIN_DumpWindow( HWND hwnd )
203 if (!(ptr = WIN_FindWndPtr( hwnd )))
205 WARN("%04x is not a window handle\n", hwnd );
209 if (!GetClassNameA( hwnd, className, sizeof(className ) ))
210 strcpy( className, "#NULL#" );
212 TRACE("Window %04x (%p):\n", hwnd, ptr );
213 DPRINTF( "next=%p child=%p parent=%p owner=%p class=%p '%s'\n"
214 "inst=%04x taskQ=%04x updRgn=%04x active=%04x dce=%p idmenu=%08x\n"
215 "style=%08lx exstyle=%08lx wndproc=%08x text='%s'\n"
216 "client=%d,%d-%d,%d window=%d,%d-%d,%d"
217 "sysmenu=%04x flags=%04x props=%p vscroll=%p hscroll=%p\n",
218 ptr->next, ptr->child, ptr->parent, ptr->owner,
219 ptr->class, className, ptr->hInstance, ptr->hmemTaskQ,
220 ptr->hrgnUpdate, ptr->hwndLastActive, ptr->dce, ptr->wIDmenu,
221 ptr->dwStyle, ptr->dwExStyle, (UINT)ptr->winproc,
222 ptr->text ? debugstr_w(ptr->text) : "",
223 ptr->rectClient.left, ptr->rectClient.top, ptr->rectClient.right,
224 ptr->rectClient.bottom, ptr->rectWindow.left, ptr->rectWindow.top,
225 ptr->rectWindow.right, ptr->rectWindow.bottom, ptr->hSysMenu,
226 ptr->flags, ptr->pProp, ptr->pVScroll, ptr->pHScroll );
230 DPRINTF( "extra bytes:" );
231 for (i = 0; i < ptr->cbWndExtra; i++)
232 DPRINTF( " %02x", *((BYTE*)ptr->wExtra+i) );
236 WIN_ReleaseWndPtr(ptr);
240 /***********************************************************************
243 * Walk the windows tree and print each window on stderr.
245 void WIN_WalkWindows( HWND hwnd, int indent )
250 ptr = hwnd ? WIN_FindWndPtr( hwnd ) : WIN_GetDesktop();
254 WARN("Invalid window handle %04x\n", hwnd );
258 if (!indent) /* first time around */
259 DPRINTF( "%-16.16s %-8.8s %-6.6s %-17.17s %-8.8s %s\n",
260 "hwnd", " wndPtr", "queue", "Class Name", " Style", " WndProc"
265 DPRINTF( "%*s%04x%*s", indent, "", ptr->hwndSelf, 13-indent,"");
267 GetClassNameA( ptr->hwndSelf, className, sizeof(className) );
268 DPRINTF( "%08lx %-6.4x %-17.17s %08x %08x %.14s\n",
269 (DWORD)ptr, ptr->hmemTaskQ, className,
270 (UINT)ptr->dwStyle, (UINT)ptr->winproc,
271 ptr->text ? debugstr_w(ptr->text) : "<null>");
273 if (ptr->child) WIN_WalkWindows( ptr->child->hwndSelf, indent+1 );
274 WIN_UpdateWndPtr(&ptr,ptr->next);
278 /***********************************************************************
281 * Remove a window from the siblings linked list.
283 BOOL WIN_UnlinkWindow( HWND hwnd )
285 WND *wndPtr, **ppWnd;
288 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
289 else if(!wndPtr->parent)
291 WIN_ReleaseWndPtr(wndPtr);
295 ppWnd = &wndPtr->parent->child;
296 while (*ppWnd && *ppWnd != wndPtr) ppWnd = &(*ppWnd)->next;
299 *ppWnd = wndPtr->next;
302 WIN_ReleaseWndPtr(wndPtr);
307 /***********************************************************************
310 * Insert a window into the siblings linked list.
311 * The window is inserted after the specified window, which can also
312 * be specified as HWND_TOP or HWND_BOTTOM.
314 BOOL WIN_LinkWindow( HWND hwnd, HWND hwndInsertAfter )
316 WND *wndPtr, **ppWnd;
318 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
319 else if(!wndPtr->parent)
321 WIN_ReleaseWndPtr(wndPtr);
324 if ((hwndInsertAfter == HWND_TOP) || (hwndInsertAfter == HWND_BOTTOM))
326 ppWnd = &wndPtr->parent->child; /* Point to first sibling hwnd */
327 if (hwndInsertAfter == HWND_BOTTOM) /* Find last sibling hwnd */
328 while (*ppWnd) ppWnd = &(*ppWnd)->next;
330 else /* Normal case */
332 WND * afterPtr = WIN_FindWndPtr( hwndInsertAfter );
335 WIN_ReleaseWndPtr(wndPtr);
338 ppWnd = &afterPtr->next;
339 WIN_ReleaseWndPtr(afterPtr);
341 wndPtr->next = *ppWnd;
343 WIN_ReleaseWndPtr(wndPtr);
348 /***********************************************************************
349 * WIN_FindWinToRepaint
351 * Find a window that needs repaint.
353 HWND WIN_FindWinToRepaint( HWND hwnd, HQUEUE16 hQueue )
358 /* Note: the desktop window never gets WM_PAINT messages
359 * The real reason why is because Windows DesktopWndProc
360 * does ValidateRgn inside WM_ERASEBKGND handler.
363 pWnd = hwnd ? WIN_FindWndPtr(hwnd) : WIN_LockWndPtr(pWndDesktop->child);
365 for ( ; pWnd ; WIN_UpdateWndPtr(&pWnd,pWnd->next))
367 if (!(pWnd->dwStyle & WS_VISIBLE))
369 TRACE("skipping window %04x\n",
372 else if ((pWnd->hmemTaskQ == hQueue) &&
373 (pWnd->hrgnUpdate || (pWnd->flags & WIN_INTERNAL_PAINT)))
376 else if (pWnd->child )
377 if ((hwndRet = WIN_FindWinToRepaint( pWnd->child->hwndSelf, hQueue )) )
379 WIN_ReleaseWndPtr(pWnd);
390 hwndRet = pWnd->hwndSelf;
392 /* look among siblings if we got a transparent window */
393 while (pWnd && ((pWnd->dwExStyle & WS_EX_TRANSPARENT) ||
394 !(pWnd->hrgnUpdate || (pWnd->flags & WIN_INTERNAL_PAINT))))
396 WIN_UpdateWndPtr(&pWnd,pWnd->next);
400 hwndRet = pWnd->hwndSelf;
401 WIN_ReleaseWndPtr(pWnd);
403 TRACE("found %04x\n",hwndRet);
408 /***********************************************************************
411 * Destroy storage associated to a window. "Internals" p.358
412 * returns a locked wndPtr->next
414 static WND* WIN_DestroyWindow( WND* wndPtr )
416 HWND hwnd = wndPtr->hwndSelf;
419 TRACE("%04x\n", wndPtr->hwndSelf );
421 /* free child windows */
422 WIN_LockWndPtr(wndPtr->child);
423 while ((pWnd = wndPtr->child))
425 wndPtr->child = WIN_DestroyWindow( pWnd );
426 WIN_ReleaseWndPtr(pWnd);
430 * Clear the update region to make sure no WM_PAINT messages will be
431 * generated for this window while processing the WM_NCDESTROY.
433 if ((wndPtr->hrgnUpdate) || (wndPtr->flags & WIN_INTERNAL_PAINT))
435 if (wndPtr->hrgnUpdate > 1)
436 DeleteObject( wndPtr->hrgnUpdate );
438 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
440 wndPtr->hrgnUpdate = 0;
444 * Send the WM_NCDESTROY to the window being destroyed.
446 SendMessageA( wndPtr->hwndSelf, WM_NCDESTROY, 0, 0);
448 /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
450 WINPOS_CheckInternalPos( wndPtr );
451 if( hwnd == GetCapture()) ReleaseCapture();
453 /* free resources associated with the window */
455 TIMER_RemoveWindowTimers( wndPtr->hwndSelf );
456 PROPERTY_RemoveWindowProps( wndPtr );
458 /* toss stale messages from the queue */
460 if( wndPtr->hmemTaskQ )
462 BOOL bPostQuit = FALSE;
463 WPARAM wQuitParam = 0;
464 MESSAGEQUEUE* msgQ = (MESSAGEQUEUE*) QUEUE_Lock(wndPtr->hmemTaskQ);
467 while( (qmsg = QUEUE_FindMsg(msgQ, hwnd, 0, 0)) != 0 )
469 if( qmsg->msg.message == WM_QUIT )
472 wQuitParam = qmsg->msg.wParam;
474 QUEUE_RemoveMsg(msgQ, qmsg);
479 /* repost WM_QUIT to make sure this app exits its message loop */
480 if( bPostQuit ) PostQuitMessage(wQuitParam);
481 wndPtr->hmemTaskQ = 0;
484 if (!(wndPtr->dwStyle & WS_CHILD))
487 DestroyMenu( wndPtr->wIDmenu );
490 if (wndPtr->hSysMenu)
492 DestroyMenu( wndPtr->hSysMenu );
493 wndPtr->hSysMenu = 0;
495 USER_Driver.pDestroyWindow( wndPtr->hwndSelf );
496 DCE_FreeWindowDCE( wndPtr ); /* Always do this to catch orphaned DCs */
497 WINPROC_FreeProc( wndPtr->winproc, WIN_PROC_WINDOW );
498 CLASS_RemoveWindow( wndPtr->class );
499 wndPtr->class = NULL;
500 wndPtr->dwMagic = 0; /* Mark it as invalid */
502 WIN_UpdateWndPtr(&pWnd,wndPtr->next);
507 /***********************************************************************
508 * WIN_ResetQueueWindows
510 * Reset the queue of all the children of a given window.
511 * Return TRUE if something was done.
513 BOOL WIN_ResetQueueWindows( WND* wnd, HQUEUE16 hQueue, HQUEUE16 hNew )
517 if (hNew) /* Set a new queue */
519 for (wnd = WIN_LockWndPtr(wnd->child); (wnd);WIN_UpdateWndPtr(&wnd,wnd->next))
521 if (wnd->hmemTaskQ == hQueue)
523 wnd->hmemTaskQ = hNew;
528 ret |= WIN_ResetQueueWindows( wnd, hQueue, hNew );
532 else /* Queue is being destroyed */
536 WND *tmp = WIN_LockWndPtr(wnd->child);
541 if (tmp->hmemTaskQ == hQueue)
543 DestroyWindow( tmp->hwndSelf );
547 tmp2 = WIN_LockWndPtr(tmp->child);
548 if (tmp2 && WIN_ResetQueueWindows(tmp2,hQueue,0))
552 WIN_UpdateWndPtr(&tmp,tmp->next);
554 WIN_ReleaseWndPtr(tmp2);
556 WIN_ReleaseWndPtr(tmp);
563 /***********************************************************************
564 * WIN_CreateDesktopWindow
566 * Create the desktop window.
568 BOOL WIN_CreateDesktopWindow(void)
570 struct tagCLASS *class;
577 TRACE("Creating desktop window\n");
580 if (!WINPOS_CreateInternalPosAtom() ||
581 !(class = CLASS_AddWindow( (ATOM)LOWORD(DESKTOP_CLASS_ATOM), 0, WIN_PROC_32W,
582 &wndExtra, &winproc, &clsStyle, &dce )))
585 hwndDesktop = USER_HEAP_ALLOC( sizeof(WND) + wndExtra );
586 if (!hwndDesktop) return FALSE;
587 pWndDesktop = (WND *) USER_HEAP_LIN_ADDR( hwndDesktop );
589 pWndDesktop->pDriver = WND_Driver;
590 pWndDesktop->next = NULL;
591 pWndDesktop->child = NULL;
592 pWndDesktop->parent = NULL;
593 pWndDesktop->owner = NULL;
594 pWndDesktop->class = class;
595 pWndDesktop->dwMagic = WND_MAGIC;
596 pWndDesktop->hwndSelf = hwndDesktop;
597 pWndDesktop->hInstance = 0;
598 pWndDesktop->rectWindow.left = 0;
599 pWndDesktop->rectWindow.top = 0;
600 pWndDesktop->rectWindow.right = GetSystemMetrics(SM_CXSCREEN);
601 pWndDesktop->rectWindow.bottom = GetSystemMetrics(SM_CYSCREEN);
602 pWndDesktop->rectClient = pWndDesktop->rectWindow;
603 pWndDesktop->text = NULL;
604 pWndDesktop->hmemTaskQ = GetFastQueue16();
605 pWndDesktop->hrgnUpdate = 0;
606 pWndDesktop->hwndLastActive = hwndDesktop;
607 pWndDesktop->dwStyle = WS_VISIBLE | WS_CLIPCHILDREN |
609 pWndDesktop->dwExStyle = 0;
610 pWndDesktop->clsStyle = clsStyle;
611 pWndDesktop->dce = NULL;
612 pWndDesktop->pVScroll = NULL;
613 pWndDesktop->pHScroll = NULL;
614 pWndDesktop->pProp = NULL;
615 pWndDesktop->wIDmenu = 0;
616 pWndDesktop->helpContext = 0;
617 pWndDesktop->flags = 0;
618 pWndDesktop->hSysMenu = 0;
619 pWndDesktop->userdata = 0;
620 pWndDesktop->winproc = winproc;
621 pWndDesktop->cbWndExtra = wndExtra;
622 pWndDesktop->irefCount = 0;
624 if (!USER_Driver.pCreateWindow( hwndDesktop )) return FALSE;
626 SendMessageW( hwndDesktop, WM_NCCREATE, 0, 0 );
627 pWndDesktop->flags |= WIN_NEEDS_ERASEBKGND;
632 /***********************************************************************
635 * Fix the coordinates - Helper for WIN_CreateWindowEx.
636 * returns default show mode in sw.
637 * Note: the feature presented as undocumented *is* in the MSDN since 1993.
639 static void WIN_FixCoordinates( CREATESTRUCTA *cs, INT *sw)
641 if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16 ||
642 cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16)
644 if (cs->style & (WS_CHILD | WS_POPUP))
646 if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16) cs->x = cs->y = 0;
647 if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16) cs->cx = cs->cy = 0;
649 else /* overlapped window */
653 GetStartupInfoA( &info );
655 if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16)
657 /* Never believe Microsoft's documentation... CreateWindowEx doc says
658 * that if an overlapped window is created with WS_VISIBLE style bit
659 * set and the x parameter is set to CW_USEDEFAULT, the system ignores
660 * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
663 * 1) not only it checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
664 * 2) it does not ignore the y parameter as the docs claim; instead, it
665 * uses it as second parameter to ShowWindow() unless y is either
666 * CW_USEDEFAULT or CW_USEDEFAULT16.
668 * The fact that we didn't do 2) caused bogus windows pop up when wine
669 * was running apps that were using this obscure feature. Example -
670 * calc.exe that comes with Win98 (only Win98, it's different from
671 * the one that comes with Win95 and NT)
673 if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) *sw = cs->y;
674 cs->x = (info.dwFlags & STARTF_USEPOSITION) ? info.dwX : 0;
675 cs->y = (info.dwFlags & STARTF_USEPOSITION) ? info.dwY : 0;
678 if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16)
680 if (info.dwFlags & STARTF_USESIZE)
682 cs->cx = info.dwXSize;
683 cs->cy = info.dwYSize;
685 else /* if no other hint from the app, pick 3/4 of the screen real estate */
688 SystemParametersInfoA( SPI_GETWORKAREA, 0, &r, 0);
689 cs->cx = (((r.right - r.left) * 3) / 4) - cs->x;
690 cs->cy = (((r.bottom - r.top) * 3) / 4) - cs->y;
697 /***********************************************************************
700 * Implementation of CreateWindowEx().
702 static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom,
703 WINDOWPROCTYPE type )
706 struct tagCLASS *classPtr;
709 HWND16 hwnd, hwndLinkAfter;
710 POINT maxSize, maxPos, minTrack, maxTrack;
715 LRESULT CALLBACK (*localSend32)(HWND, UINT, WPARAM, LPARAM);
717 TRACE("%s %s %08lx %08lx %d,%d %dx%d %04x %04x %08x %p\n",
718 (type == WIN_PROC_32W) ? debugres_w((LPWSTR)cs->lpszName) : debugres_a(cs->lpszName),
719 (type == WIN_PROC_32W) ? debugres_w((LPWSTR)cs->lpszClass) : debugres_a(cs->lpszClass),
720 cs->dwExStyle, cs->style, cs->x, cs->y, cs->cx, cs->cy,
721 cs->hwndParent, cs->hMenu, cs->hInstance, cs->lpCreateParams );
723 TRACE("winproc type is %d (%s)\n", type, (type == WIN_PROC_16) ? "WIN_PROC_16" :
724 ((type == WIN_PROC_32A) ? "WIN_PROC_32A" : "WIN_PROC_32W") );
726 /* Find the parent window */
730 /* Make sure parent is valid */
731 if (!IsWindow( cs->hwndParent ))
733 WARN("Bad parent %04x\n", cs->hwndParent );
736 } else if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
737 WARN("No parent for child window\n" );
738 return 0; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
741 /* Find the window class */
742 if (!(classPtr = CLASS_AddWindow( classAtom, cs->hInstance, type,
743 &wndExtra, &winproc, &clsStyle, &dce )))
745 WARN("Bad class '%s'\n", cs->lpszClass );
749 WIN_FixCoordinates(cs, &sw); /* fix default coordinates */
751 /* Create the window structure */
753 if (!(hwnd = USER_HEAP_ALLOC( sizeof(*wndPtr) + wndExtra - sizeof(wndPtr->wExtra) )))
755 TRACE("out of memory\n" );
759 /* Fill the window structure */
761 wndPtr = WIN_LockWndPtr((WND *) USER_HEAP_LIN_ADDR( hwnd ));
763 wndPtr->child = NULL;
765 if ((cs->style & WS_CHILD) && cs->hwndParent)
767 wndPtr->parent = WIN_FindWndPtr( cs->hwndParent );
768 wndPtr->owner = NULL;
769 WIN_ReleaseWndPtr(wndPtr->parent);
773 wndPtr->parent = pWndDesktop;
774 if (!cs->hwndParent || (cs->hwndParent == pWndDesktop->hwndSelf))
775 wndPtr->owner = NULL;
778 WND *tmpWnd = WIN_FindWndPtr(cs->hwndParent);
779 wndPtr->owner = WIN_GetTopParentPtr(tmpWnd);
780 WIN_ReleaseWndPtr(wndPtr->owner);
781 WIN_ReleaseWndPtr(tmpWnd);
786 wndPtr->pDriver = wndPtr->parent->pDriver;
788 wndPtr->class = classPtr;
789 wndPtr->winproc = winproc;
790 wndPtr->dwMagic = WND_MAGIC;
791 wndPtr->hwndSelf = hwnd;
792 wndPtr->hInstance = cs->hInstance;
794 wndPtr->hmemTaskQ = GetFastQueue16();
795 wndPtr->hrgnUpdate = 0;
797 wndPtr->hwndLastActive = hwnd;
798 wndPtr->dwStyle = cs->style & ~WS_VISIBLE;
799 wndPtr->dwExStyle = cs->dwExStyle;
800 wndPtr->clsStyle = clsStyle;
802 wndPtr->helpContext = 0;
803 wndPtr->flags = (type == WIN_PROC_16) ? 0 : WIN_ISWIN32;
804 wndPtr->pVScroll = NULL;
805 wndPtr->pHScroll = NULL;
806 wndPtr->pProp = NULL;
807 wndPtr->userdata = 0;
808 wndPtr->hSysMenu = (wndPtr->dwStyle & WS_SYSMENU)
809 ? MENU_GetSysMenu( hwnd, 0 ) : 0;
810 wndPtr->cbWndExtra = wndExtra;
811 wndPtr->irefCount = 1;
813 if (wndExtra) memset( wndPtr->wExtra, 0, wndExtra);
815 /* Call the WH_CBT hook */
817 hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
818 ? HWND_BOTTOM : HWND_TOP;
820 if (HOOK_IsHooked( WH_CBT ))
826 cbtc.hwndInsertAfter = hwndLinkAfter;
827 ret = (type == WIN_PROC_32W) ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, hwnd, (LPARAM)&cbtc)
828 : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, hwnd, (LPARAM)&cbtc);
831 TRACE("CBT-hook returned 0\n");
832 USER_HEAP_FREE( hwnd );
833 CLASS_RemoveWindow( classPtr );
839 /* Correct the window style */
841 if (!(cs->style & WS_CHILD))
843 wndPtr->dwStyle |= WS_CLIPSIBLINGS;
844 if (!(cs->style & WS_POPUP))
846 wndPtr->dwStyle |= WS_CAPTION;
847 wndPtr->flags |= WIN_NEED_SIZE;
851 /* Get class or window DC if needed */
853 if (clsStyle & CS_OWNDC) wndPtr->dce = DCE_AllocDCE(hwnd,DCE_WINDOW_DC);
854 else if (clsStyle & CS_CLASSDC) wndPtr->dce = dce;
855 else wndPtr->dce = NULL;
857 /* Initialize the dimensions before sending WM_GETMINMAXINFO */
859 wndPtr->rectWindow.left = cs->x;
860 wndPtr->rectWindow.top = cs->y;
861 wndPtr->rectWindow.right = cs->x + cs->cx;
862 wndPtr->rectWindow.bottom = cs->y + cs->cy;
863 wndPtr->rectClient = wndPtr->rectWindow;
865 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
867 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
869 WINPOS_GetMinMaxInfo( wndPtr, &maxSize, &maxPos, &minTrack, &maxTrack);
870 if (maxSize.x < cs->cx) cs->cx = maxSize.x;
871 if (maxSize.y < cs->cy) cs->cy = maxSize.y;
872 if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
873 if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
876 if (cs->cx < 0) cs->cx = 0;
877 if (cs->cy < 0) cs->cy = 0;
879 wndPtr->rectWindow.left = cs->x;
880 wndPtr->rectWindow.top = cs->y;
881 wndPtr->rectWindow.right = cs->x + cs->cx;
882 wndPtr->rectWindow.bottom = cs->y + cs->cy;
883 wndPtr->rectClient = wndPtr->rectWindow;
885 if (!USER_Driver.pCreateWindow(wndPtr->hwndSelf))
891 /* Set the window menu */
893 if ((wndPtr->dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
895 if (cs->hMenu) SetMenu(hwnd, cs->hMenu);
898 LPCSTR menuName = (LPCSTR)GetClassLongA( hwnd, GCL_MENUNAME );
901 if (HIWORD(cs->hInstance))
902 cs->hMenu = LoadMenuA(cs->hInstance,menuName);
904 cs->hMenu = LoadMenu16(cs->hInstance,menuName);
906 if (cs->hMenu) SetMenu( hwnd, cs->hMenu );
910 else wndPtr->wIDmenu = (UINT)cs->hMenu;
912 /* Send the WM_CREATE message
913 * Perhaps we shouldn't allow width/height changes as well.
914 * See p327 in "Internals".
917 maxPos.x = wndPtr->rectWindow.left; maxPos.y = wndPtr->rectWindow.top;
919 localSend32 = (type == WIN_PROC_32W) ? SendMessageW : SendMessageA;
920 if( (*localSend32)( hwnd, WM_NCCREATE, 0, (LPARAM)cs) )
922 /* Insert the window in the linked list */
924 WIN_LinkWindow( hwnd, hwndLinkAfter );
926 WINPOS_SendNCCalcSize( hwnd, FALSE, &wndPtr->rectWindow,
927 NULL, NULL, 0, &wndPtr->rectClient );
928 OffsetRect(&wndPtr->rectWindow, maxPos.x - wndPtr->rectWindow.left,
929 maxPos.y - wndPtr->rectWindow.top);
930 if( ((*localSend32)( hwnd, WM_CREATE, 0, (LPARAM)cs )) != -1 )
932 /* Send the size messages */
934 if (!(wndPtr->flags & WIN_NEED_SIZE))
937 if (((wndPtr->rectClient.right-wndPtr->rectClient.left) <0)
938 ||((wndPtr->rectClient.bottom-wndPtr->rectClient.top)<0))
939 WARN("sending bogus WM_SIZE message 0x%08lx\n",
940 MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
941 wndPtr->rectClient.bottom-wndPtr->rectClient.top));
942 (*localSend32)( hwnd, WM_SIZE, SIZE_RESTORED,
943 MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
944 wndPtr->rectClient.bottom-wndPtr->rectClient.top));
945 (*localSend32)( hwnd, WM_MOVE, 0,
946 MAKELONG( wndPtr->rectClient.left,
947 wndPtr->rectClient.top ) );
950 /* Show the window, maximizing or minimizing if needed */
952 if (wndPtr->dwStyle & (WS_MINIMIZE | WS_MAXIMIZE))
955 UINT16 swFlag = (wndPtr->dwStyle & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
956 wndPtr->dwStyle &= ~(WS_MAXIMIZE | WS_MINIMIZE);
957 WINPOS_MinMaximize( wndPtr, swFlag, &newPos );
958 swFlag = ((wndPtr->dwStyle & WS_CHILD) || GetActiveWindow())
959 ? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED
960 : SWP_NOZORDER | SWP_FRAMECHANGED;
961 SetWindowPos( hwnd, 0, newPos.left, newPos.top,
962 newPos.right, newPos.bottom, swFlag );
965 if( (wndPtr->dwStyle & WS_CHILD) && !(wndPtr->dwExStyle & WS_EX_NOPARENTNOTIFY) )
967 /* Notify the parent window only */
969 SendMessageA( wndPtr->parent->hwndSelf, WM_PARENTNOTIFY,
970 MAKEWPARAM(WM_CREATE, wndPtr->wIDmenu), (LPARAM)hwnd );
971 if( !IsWindow(hwnd) )
978 if (cs->style & WS_VISIBLE) ShowWindow( hwnd, sw );
980 /* Call WH_SHELL hook */
982 if (!(wndPtr->dwStyle & WS_CHILD) && !wndPtr->owner)
983 HOOK_CallHooksA( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
985 TRACE("created window %04x\n", hwnd);
989 WIN_UnlinkWindow( hwnd );
992 /* Abort window creation */
994 WARN("aborted by WM_xxCREATE!\n");
995 WIN_ReleaseWndPtr(WIN_DestroyWindow( wndPtr ));
996 CLASS_RemoveWindow( classPtr );
999 WIN_ReleaseWndPtr(wndPtr);
1005 /***********************************************************************
1006 * CreateWindow (USER.41)
1008 HWND16 WINAPI CreateWindow16( LPCSTR className, LPCSTR windowName,
1009 DWORD style, INT16 x, INT16 y, INT16 width,
1010 INT16 height, HWND16 parent, HMENU16 menu,
1011 HINSTANCE16 instance, LPVOID data )
1013 return CreateWindowEx16( 0, className, windowName, style,
1014 x, y, width, height, parent, menu, instance, data );
1018 /***********************************************************************
1019 * CreateWindowEx (USER.452)
1021 HWND16 WINAPI CreateWindowEx16( DWORD exStyle, LPCSTR className,
1022 LPCSTR windowName, DWORD style, INT16 x,
1023 INT16 y, INT16 width, INT16 height,
1024 HWND16 parent, HMENU16 menu,
1025 HINSTANCE16 instance, LPVOID data )
1031 /* Find the class atom */
1033 if (HIWORD(className))
1035 if (!(classAtom = GlobalFindAtomA( className )))
1037 ERR( "bad class name %s\n", debugres_a(className) );
1043 classAtom = LOWORD(className);
1044 if (!GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) ))
1046 ERR( "bad atom %x\n", classAtom);
1052 /* Fix the coordinates */
1054 cs.x = (x == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)x;
1055 cs.y = (y == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)y;
1056 cs.cx = (width == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)width;
1057 cs.cy = (height == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)height;
1059 /* Create the window */
1061 cs.lpCreateParams = data;
1062 cs.hInstance = (HINSTANCE)instance;
1063 cs.hMenu = (HMENU)menu;
1064 cs.hwndParent = (HWND)parent;
1066 cs.lpszName = windowName;
1067 cs.lpszClass = className;
1068 cs.dwExStyle = exStyle;
1070 return WIN_CreateWindowEx( &cs, classAtom, WIN_PROC_16 );
1074 /***********************************************************************
1075 * CreateWindowExA (USER32.@)
1077 HWND WINAPI CreateWindowExA( DWORD exStyle, LPCSTR className,
1078 LPCSTR windowName, DWORD style, INT x,
1079 INT y, INT width, INT height,
1080 HWND parent, HMENU menu,
1081 HINSTANCE instance, LPVOID data )
1088 instance=GetModuleHandleA(NULL);
1090 if(exStyle & WS_EX_MDICHILD)
1091 return CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
1093 /* Find the class atom */
1095 if (HIWORD(className))
1097 if (!(classAtom = GlobalFindAtomA( className )))
1099 ERR( "bad class name %s\n", debugres_a(className) );
1105 classAtom = LOWORD(className);
1106 if (!GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) ))
1108 ERR( "bad atom %x\n", classAtom);
1114 /* Create the window */
1116 cs.lpCreateParams = data;
1117 cs.hInstance = instance;
1119 cs.hwndParent = parent;
1125 cs.lpszName = windowName;
1126 cs.lpszClass = className;
1127 cs.dwExStyle = exStyle;
1129 return WIN_CreateWindowEx( &cs, classAtom, WIN_PROC_32A );
1133 /***********************************************************************
1134 * CreateWindowExW (USER32.@)
1136 HWND WINAPI CreateWindowExW( DWORD exStyle, LPCWSTR className,
1137 LPCWSTR windowName, DWORD style, INT x,
1138 INT y, INT width, INT height,
1139 HWND parent, HMENU menu,
1140 HINSTANCE instance, LPVOID data )
1147 instance=GetModuleHandleA(NULL);
1149 if(exStyle & WS_EX_MDICHILD)
1150 return CreateMDIWindowW(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
1152 /* Find the class atom */
1154 if (HIWORD(className))
1156 if (!(classAtom = GlobalFindAtomW( className )))
1158 ERR( "bad class name %s\n", debugres_w(className) );
1164 classAtom = LOWORD(className);
1165 if (!GlobalGetAtomNameW( classAtom, buffer, sizeof(buffer)/sizeof(WCHAR) ))
1167 ERR( "bad atom %x\n", classAtom);
1173 /* Create the window */
1175 cs.lpCreateParams = data;
1176 cs.hInstance = instance;
1178 cs.hwndParent = parent;
1184 cs.lpszName = windowName;
1185 cs.lpszClass = className;
1186 cs.dwExStyle = exStyle;
1188 /* Note: we rely on the fact that CREATESTRUCTA and */
1189 /* CREATESTRUCTW have the same layout. */
1190 return WIN_CreateWindowEx( (CREATESTRUCTA *)&cs, classAtom, WIN_PROC_32W );
1193 /***********************************************************************
1194 * WIN_SendDestroyMsg
1196 static void WIN_SendDestroyMsg( WND* pWnd )
1198 if( CARET_GetHwnd() == pWnd->hwndSelf ) DestroyCaret();
1199 USER_Driver.pResetSelectionOwner( pWnd, TRUE );
1202 * Send the WM_DESTROY to the window.
1204 SendMessageA( pWnd->hwndSelf, WM_DESTROY, 0, 0);
1207 * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
1208 * make sure that the window still exists when we come back.
1210 if (IsWindow(pWnd->hwndSelf))
1212 HWND* pWndArray = NULL;
1217 * Now, if the window has kids, we have to send WM_DESTROY messages
1218 * recursively to it's kids. It seems that those calls can also
1219 * trigger re-entrant calls to DestroyWindow for the kids so we must
1220 * protect against corruption of the list of siblings. We first build
1221 * a list of HWNDs representing all the kids.
1223 pChild = WIN_LockWndPtr(pWnd->child);
1227 WIN_UpdateWndPtr(&pChild,pChild->next);
1231 * If there are no kids, we're done.
1236 pWndArray = HeapAlloc(GetProcessHeap(), 0, nKidCount*sizeof(HWND));
1241 if (pWndArray==NULL)
1245 * Now, enumerate all the kids in a list, since we wait to make the SendMessage
1246 * call, our linked list of siblings should be safe.
1249 pChild = WIN_LockWndPtr(pWnd->child);
1252 pWndArray[nKidCount] = pChild->hwndSelf;
1254 WIN_UpdateWndPtr(&pChild,pChild->next);
1258 * Now that we have a list, go through that list again and send the destroy
1259 * message to those windows. We are using the HWND to retrieve the
1260 * WND pointer so we are effectively checking that all the kid windows are
1261 * still valid before sending the message.
1265 pChild = WIN_FindWndPtr(pWndArray[--nKidCount]);
1269 WIN_SendDestroyMsg( pChild );
1270 WIN_ReleaseWndPtr(pChild);
1277 HeapFree(GetProcessHeap(), 0, pWndArray);
1280 WARN("\tdestroyed itself while in WM_DESTROY!\n");
1284 /***********************************************************************
1285 * DestroyWindow (USER.53)
1287 BOOL16 WINAPI DestroyWindow16( HWND16 hwnd )
1289 return DestroyWindow(hwnd);
1293 /***********************************************************************
1294 * DestroyWindow (USER32.@)
1296 BOOL WINAPI DestroyWindow( HWND hwnd )
1301 BOOL bFocusSet = FALSE;
1303 TRACE("(%04x)\n", hwnd);
1305 /* Initialization */
1307 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
1308 if (wndPtr == pWndDesktop)
1310 retvalue = FALSE; /* Can't destroy desktop */
1314 /* Look whether the focus is within the tree of windows we will
1318 while (h && (GetWindowLongA(h,GWL_STYLE) & WS_CHILD))
1322 SetFocus(GetParent(h));
1328 /* If the focus is on the window we will destroy and it has no parent,
1329 * set the focus to 0.
1331 if (! bFocusSet && (h == hwnd))
1333 if (!(GetWindowLongA(h,GWL_STYLE) & WS_CHILD))
1339 if( HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, hwnd, 0L) )
1345 if (!(wndPtr->dwStyle & WS_CHILD) && !wndPtr->owner)
1347 HOOK_CallHooksA( WH_SHELL, HSHELL_WINDOWDESTROYED, hwnd, 0L );
1348 /* FIXME: clean up palette - see "Internals" p.352 */
1351 if( !QUEUE_IsExitingQueue(wndPtr->hmemTaskQ) )
1352 if( wndPtr->dwStyle & WS_CHILD && !(wndPtr->dwExStyle & WS_EX_NOPARENTNOTIFY) )
1354 /* Notify the parent window only */
1355 SendMessageA( wndPtr->parent->hwndSelf, WM_PARENTNOTIFY,
1356 MAKEWPARAM(WM_DESTROY, wndPtr->wIDmenu), (LPARAM)hwnd );
1357 if( !IsWindow(hwnd) )
1364 USER_Driver.pResetSelectionOwner( wndPtr, FALSE ); /* before the window is unmapped */
1366 /* Hide the window */
1368 if (wndPtr->dwStyle & WS_VISIBLE)
1370 ShowWindow( hwnd, SW_HIDE );
1371 if (!IsWindow(hwnd))
1378 /* Recursively destroy owned windows */
1380 if( !(wndPtr->dwStyle & WS_CHILD) )
1382 /* make sure top menu popup doesn't get destroyed */
1383 MENU_PatchResidentPopup( (HQUEUE16)0xFFFF, wndPtr );
1387 WND *siblingPtr = WIN_LockWndPtr(wndPtr->parent->child); /* First sibling */
1390 if (siblingPtr->owner == wndPtr)
1392 if (siblingPtr->hmemTaskQ == wndPtr->hmemTaskQ)
1395 siblingPtr->owner = NULL;
1397 WIN_UpdateWndPtr(&siblingPtr,siblingPtr->next);
1401 DestroyWindow( siblingPtr->hwndSelf );
1402 WIN_ReleaseWndPtr(siblingPtr);
1407 WINPOS_ActivateOtherWindow(wndPtr);
1409 if( wndPtr->owner &&
1410 wndPtr->owner->hwndLastActive == wndPtr->hwndSelf )
1411 wndPtr->owner->hwndLastActive = wndPtr->owner->hwndSelf;
1414 /* Send destroy messages */
1416 WIN_SendDestroyMsg( wndPtr );
1417 if (!IsWindow(hwnd))
1423 /* Unlink now so we won't bother with the children later on */
1425 if( wndPtr->parent ) WIN_UnlinkWindow(hwnd);
1427 /* Destroy the window storage */
1429 WIN_ReleaseWndPtr(WIN_DestroyWindow( wndPtr ));
1432 WIN_ReleaseWndPtr(wndPtr);
1437 /***********************************************************************
1438 * CloseWindow (USER.43)
1440 BOOL16 WINAPI CloseWindow16( HWND16 hwnd )
1442 return CloseWindow( hwnd );
1446 /***********************************************************************
1447 * CloseWindow (USER32.@)
1449 BOOL WINAPI CloseWindow( HWND hwnd )
1451 WND * wndPtr = WIN_FindWndPtr( hwnd );
1454 if (!wndPtr || (wndPtr->dwStyle & WS_CHILD))
1459 ShowWindow( hwnd, SW_MINIMIZE );
1462 WIN_ReleaseWndPtr(wndPtr);
1468 /***********************************************************************
1469 * OpenIcon (USER.44)
1471 BOOL16 WINAPI OpenIcon16( HWND16 hwnd )
1473 return OpenIcon( hwnd );
1477 /***********************************************************************
1478 * OpenIcon (USER32.@)
1480 BOOL WINAPI OpenIcon( HWND hwnd )
1482 if (!IsIconic( hwnd )) return FALSE;
1483 ShowWindow( hwnd, SW_SHOWNORMAL );
1488 /***********************************************************************
1491 * Implementation of FindWindow() and FindWindowEx().
1493 static HWND WIN_FindWindow( HWND parent, HWND child, ATOM className,
1501 if (!(pWnd = WIN_FindWndPtr( child ))) return 0;
1504 if (!pWnd->parent || (pWnd->parent->hwndSelf != parent))
1510 else if (pWnd->parent != pWndDesktop)
1515 WIN_UpdateWndPtr(&pWnd,pWnd->next);
1519 if (!(pWnd = parent ? WIN_FindWndPtr(parent) : WIN_LockWndPtr(pWndDesktop)))
1524 WIN_UpdateWndPtr(&pWnd,pWnd->child);
1532 for ( ; pWnd ; WIN_UpdateWndPtr(&pWnd,pWnd->next))
1534 if (className && (GetClassWord(pWnd->hwndSelf, GCW_ATOM) != className))
1535 continue; /* Not the right class */
1537 /* Now check the title */
1541 retvalue = pWnd->hwndSelf;
1544 if (pWnd->text && !strcmpW( pWnd->text, title ))
1546 retvalue = pWnd->hwndSelf;
1551 /* In this case we need to check whether other processes
1552 own a window with the given paramters on the Desktop,
1553 but we don't, so let's at least warn about it */
1554 FIXME("Returning 0 without checking other processes\n");
1556 WIN_ReleaseWndPtr(pWnd);
1562 /***********************************************************************
1563 * FindWindow (USER.50)
1565 HWND16 WINAPI FindWindow16( LPCSTR className, LPCSTR title )
1567 return FindWindowA( className, title );
1571 /***********************************************************************
1572 * FindWindowEx (USER.427)
1574 HWND16 WINAPI FindWindowEx16( HWND16 parent, HWND16 child, LPCSTR className, LPCSTR title )
1576 return FindWindowExA( parent, child, className, title );
1580 /***********************************************************************
1581 * FindWindowA (USER32.@)
1583 HWND WINAPI FindWindowA( LPCSTR className, LPCSTR title )
1585 HWND ret = FindWindowExA( 0, 0, className, title );
1586 if (!ret) SetLastError (ERROR_CANNOT_FIND_WND_CLASS);
1591 /***********************************************************************
1592 * FindWindowExA (USER32.@)
1594 HWND WINAPI FindWindowExA( HWND parent, HWND child,
1595 LPCSTR className, LPCSTR title )
1603 /* If the atom doesn't exist, then no class */
1604 /* with this name exists either. */
1605 if (!(atom = GlobalFindAtomA( className )))
1607 SetLastError (ERROR_CANNOT_FIND_WND_CLASS);
1612 buffer = HEAP_strdupAtoW( GetProcessHeap(), 0, title );
1613 hwnd = WIN_FindWindow( parent, child, atom, buffer );
1614 HeapFree( GetProcessHeap(), 0, buffer );
1619 /***********************************************************************
1620 * FindWindowExW (USER32.@)
1622 HWND WINAPI FindWindowExW( HWND parent, HWND child,
1623 LPCWSTR className, LPCWSTR title )
1629 /* If the atom doesn't exist, then no class */
1630 /* with this name exists either. */
1631 if (!(atom = GlobalFindAtomW( className )))
1633 SetLastError (ERROR_CANNOT_FIND_WND_CLASS);
1637 return WIN_FindWindow( parent, child, atom, title );
1641 /***********************************************************************
1642 * FindWindowW (USER32.@)
1644 HWND WINAPI FindWindowW( LPCWSTR className, LPCWSTR title )
1646 return FindWindowExW( 0, 0, className, title );
1650 /**********************************************************************
1652 * returns a locked pointer
1654 WND *WIN_GetDesktop(void)
1656 return WIN_LockWndPtr(pWndDesktop);
1658 /**********************************************************************
1659 * WIN_ReleaseDesktop
1660 * unlock the desktop pointer
1662 void WIN_ReleaseDesktop(void)
1664 WIN_ReleaseWndPtr(pWndDesktop);
1668 /**********************************************************************
1669 * GetDesktopWindow (USER.286)
1671 HWND16 WINAPI GetDesktopWindow16(void)
1673 return (HWND16)pWndDesktop->hwndSelf;
1677 /**********************************************************************
1678 * GetDesktopWindow (USER32.@)
1680 HWND WINAPI GetDesktopWindow(void)
1682 if (pWndDesktop) return pWndDesktop->hwndSelf;
1683 ERR( "You need the -desktop option when running with native USER\n" );
1689 /**********************************************************************
1690 * GetDesktopHwnd (USER.278)
1692 * Exactly the same thing as GetDesktopWindow(), but not documented.
1693 * Don't ask me why...
1695 HWND16 WINAPI GetDesktopHwnd16(void)
1697 return (HWND16)pWndDesktop->hwndSelf;
1701 /*******************************************************************
1702 * EnableWindow (USER.34)
1704 BOOL16 WINAPI EnableWindow16( HWND16 hwnd, BOOL16 enable )
1706 return EnableWindow( hwnd, enable );
1710 /*******************************************************************
1711 * EnableWindow (USER32.@)
1713 BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable )
1718 TRACE("( %x, %d )\n", hwnd, enable);
1720 if (USER_Driver.pEnableWindow)
1721 return USER_Driver.pEnableWindow( hwnd, enable );
1723 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
1725 retvalue = ((wndPtr->dwStyle & WS_DISABLED) != 0);
1727 if (enable && (wndPtr->dwStyle & WS_DISABLED))
1729 wndPtr->dwStyle &= ~WS_DISABLED; /* Enable window */
1730 SendMessageA( hwnd, WM_ENABLE, TRUE, 0 );
1732 else if (!enable && !(wndPtr->dwStyle & WS_DISABLED))
1734 SendMessageA( wndPtr->hwndSelf, WM_CANCELMODE, 0, 0);
1736 wndPtr->dwStyle |= WS_DISABLED; /* Disable window */
1738 if (hwnd == GetFocus())
1739 SetFocus( 0 ); /* A disabled window can't have the focus */
1741 if (hwnd == GetCapture())
1742 ReleaseCapture(); /* A disabled window can't capture the mouse */
1744 SendMessageA( hwnd, WM_ENABLE, FALSE, 0 );
1746 WIN_ReleaseWndPtr(wndPtr);
1751 /***********************************************************************
1752 * IsWindowEnabled (USER.35)
1754 BOOL16 WINAPI IsWindowEnabled16(HWND16 hWnd)
1756 return IsWindowEnabled(hWnd);
1760 /***********************************************************************
1761 * IsWindowEnabled (USER32.@)
1763 BOOL WINAPI IsWindowEnabled(HWND hWnd)
1768 if (!(wndPtr = WIN_FindWndPtr(hWnd))) return FALSE;
1769 retvalue = !(wndPtr->dwStyle & WS_DISABLED);
1770 WIN_ReleaseWndPtr(wndPtr);
1776 /***********************************************************************
1777 * IsWindowUnicode (USER32.@)
1779 BOOL WINAPI IsWindowUnicode( HWND hwnd )
1784 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return FALSE;
1785 retvalue = (WINPROC_GetProcType( wndPtr->winproc ) == WIN_PROC_32W);
1786 WIN_ReleaseWndPtr(wndPtr);
1791 /**********************************************************************
1792 * GetWindowWord (USER.133)
1794 WORD WINAPI GetWindowWord16( HWND16 hwnd, INT16 offset )
1796 return GetWindowWord( hwnd, offset );
1800 /**********************************************************************
1801 * GetWindowWord (USER32.@)
1803 WORD WINAPI GetWindowWord( HWND hwnd, INT offset )
1806 WND * wndPtr = WIN_FindWndPtr( hwnd );
1807 if (!wndPtr) return 0;
1810 if (offset + sizeof(WORD) > wndPtr->cbWndExtra)
1812 WARN("Invalid offset %d\n", offset );
1816 retvalue = *(WORD *)(((char *)wndPtr->wExtra) + offset);
1822 if (HIWORD(wndPtr->wIDmenu))
1823 WARN("GWW_ID: discards high bits of 0x%08x!\n",
1825 retvalue = (WORD)wndPtr->wIDmenu;
1827 case GWW_HWNDPARENT:
1828 retvalue = GetParent(hwnd);
1831 if (HIWORD(wndPtr->hInstance))
1832 WARN("GWW_HINSTANCE: discards high bits of 0x%08x!\n",
1834 retvalue = (WORD)wndPtr->hInstance;
1837 WARN("Invalid offset %d\n", offset );
1842 WIN_ReleaseWndPtr(wndPtr);
1846 /**********************************************************************
1847 * SetWindowWord (USER.134)
1849 WORD WINAPI SetWindowWord16( HWND16 hwnd, INT16 offset, WORD newval )
1851 return SetWindowWord( hwnd, offset, newval );
1855 /**********************************************************************
1856 * SetWindowWord (USER32.@)
1858 WORD WINAPI SetWindowWord( HWND hwnd, INT offset, WORD newval )
1861 WND * wndPtr = WIN_FindWndPtr( hwnd );
1862 if (!wndPtr) return 0;
1865 if (offset + sizeof(WORD) > wndPtr->cbWndExtra)
1867 WARN("Invalid offset %d\n", offset );
1871 ptr = (WORD *)(((char *)wndPtr->wExtra) + offset);
1875 case GWW_ID: ptr = (WORD *)&wndPtr->wIDmenu; break;
1876 case GWW_HINSTANCE: ptr = (WORD *)&wndPtr->hInstance; break;
1877 case GWW_HWNDPARENT: retval = SetParent( hwnd, newval );
1880 WARN("Invalid offset %d\n", offset );
1887 WIN_ReleaseWndPtr(wndPtr);
1892 /**********************************************************************
1895 * Helper function for GetWindowLong().
1897 static LONG WIN_GetWindowLong( HWND hwnd, INT offset, WINDOWPROCTYPE type )
1900 WND * wndPtr = WIN_FindWndPtr( hwnd );
1901 if (!wndPtr) return 0;
1904 if (offset + sizeof(LONG) > wndPtr->cbWndExtra)
1906 WARN("Invalid offset %d\n", offset );
1910 retvalue = *(LONG *)(((char *)wndPtr->wExtra) + offset);
1911 /* Special case for dialog window procedure */
1912 if ((offset == DWL_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG))
1914 retvalue = (LONG)WINPROC_GetProc( (HWINDOWPROC)retvalue, type );
1921 case GWL_USERDATA: retvalue = wndPtr->userdata;
1923 case GWL_STYLE: retvalue = wndPtr->dwStyle;
1925 case GWL_EXSTYLE: retvalue = wndPtr->dwExStyle;
1927 case GWL_ID: retvalue = (LONG)wndPtr->wIDmenu;
1929 case GWL_WNDPROC: retvalue = (LONG)WINPROC_GetProc( wndPtr->winproc,
1932 case GWL_HWNDPARENT: retvalue = GetParent(hwnd);
1934 case GWL_HINSTANCE: retvalue = wndPtr->hInstance;
1937 WARN("Unknown offset %d\n", offset );
1941 WIN_ReleaseWndPtr(wndPtr);
1946 /**********************************************************************
1949 * Helper function for SetWindowLong().
1951 * 0 is the failure code. However, in the case of failure SetLastError
1952 * must be set to distinguish between a 0 return value and a failure.
1954 * FIXME: The error values for SetLastError may not be right. Can
1955 * someone check with the real thing?
1957 static LONG WIN_SetWindowLong( HWND hwnd, INT offset, LONG newval,
1958 WINDOWPROCTYPE type )
1961 WND * wndPtr = WIN_FindWndPtr( hwnd );
1964 TRACE("%x=%p %x %lx %x\n",hwnd, wndPtr, offset, newval, type);
1968 /* Is this the right error? */
1969 SetLastError( ERROR_INVALID_WINDOW_HANDLE );
1975 if (offset + sizeof(LONG) > wndPtr->cbWndExtra)
1977 WARN("Invalid offset %d\n", offset );
1979 /* Is this the right error? */
1980 SetLastError( ERROR_OUTOFMEMORY );
1985 ptr = (LONG *)(((char *)wndPtr->wExtra) + offset);
1986 /* Special case for dialog window procedure */
1987 if ((offset == DWL_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG))
1989 retval = (LONG)WINPROC_GetProc( (HWINDOWPROC)*ptr, type );
1990 WINPROC_SetProc( (HWINDOWPROC *)ptr, (WNDPROC16)newval,
1991 type, WIN_PROC_WINDOW );
1998 ptr = (DWORD*)&wndPtr->wIDmenu;
2001 retval = SetWindowWord( hwnd, offset, newval );
2004 retval = (LONG)WINPROC_GetProc( wndPtr->winproc, type );
2005 WINPROC_SetProc( &wndPtr->winproc, (WNDPROC16)newval,
2006 type, WIN_PROC_WINDOW );
2009 style.styleOld = wndPtr->dwStyle;
2010 style.styleNew = newval;
2011 if (wndPtr->flags & WIN_ISWIN32)
2012 SendMessageA(hwnd,WM_STYLECHANGING,GWL_STYLE,(LPARAM)&style);
2013 wndPtr->dwStyle = style.styleNew;
2014 if (wndPtr->flags & WIN_ISWIN32)
2015 SendMessageA(hwnd,WM_STYLECHANGED,GWL_STYLE,(LPARAM)&style);
2016 retval = style.styleOld;
2020 ptr = &wndPtr->userdata;
2023 style.styleOld = wndPtr->dwExStyle;
2024 style.styleNew = newval;
2025 if (wndPtr->flags & WIN_ISWIN32)
2026 SendMessageA(hwnd,WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&style);
2027 wndPtr->dwExStyle = newval;
2028 if (wndPtr->flags & WIN_ISWIN32)
2029 SendMessageA(hwnd,WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&style);
2030 retval = style.styleOld;
2034 WARN("Invalid offset %d\n", offset );
2036 /* Don't think this is right error but it should do */
2037 SetLastError( ERROR_OUTOFMEMORY );
2045 WIN_ReleaseWndPtr(wndPtr);
2050 /**********************************************************************
2051 * GetWindowLong (USER.135)
2053 LONG WINAPI GetWindowLong16( HWND16 hwnd, INT16 offset )
2055 return WIN_GetWindowLong( (HWND)hwnd, offset, WIN_PROC_16 );
2059 /**********************************************************************
2060 * GetWindowLongA (USER32.@)
2062 LONG WINAPI GetWindowLongA( HWND hwnd, INT offset )
2064 return WIN_GetWindowLong( hwnd, offset, WIN_PROC_32A );
2068 /**********************************************************************
2069 * GetWindowLongW (USER32.@)
2071 LONG WINAPI GetWindowLongW( HWND hwnd, INT offset )
2073 return WIN_GetWindowLong( hwnd, offset, WIN_PROC_32W );
2077 /**********************************************************************
2078 * SetWindowLong (USER.136)
2080 LONG WINAPI SetWindowLong16( HWND16 hwnd, INT16 offset, LONG newval )
2082 return WIN_SetWindowLong( hwnd, offset, newval, WIN_PROC_16 );
2086 /**********************************************************************
2087 * SetWindowLongA (USER32.@)
2089 LONG WINAPI SetWindowLongA( HWND hwnd, INT offset, LONG newval )
2091 return WIN_SetWindowLong( hwnd, offset, newval, WIN_PROC_32A );
2095 /**********************************************************************
2096 * SetWindowLongW (USER32.@) Set window attribute
2098 * SetWindowLong() alters one of a window's attributes or sets a 32-bit (long)
2099 * value in a window's extra memory.
2101 * The _hwnd_ parameter specifies the window. is the handle to a
2102 * window that has extra memory. The _newval_ parameter contains the
2103 * new attribute or extra memory value. If positive, the _offset_
2104 * parameter is the byte-addressed location in the window's extra
2105 * memory to set. If negative, _offset_ specifies the window
2106 * attribute to set, and should be one of the following values:
2108 * GWL_EXSTYLE The window's extended window style
2110 * GWL_STYLE The window's window style.
2112 * GWL_WNDPROC Pointer to the window's window procedure.
2114 * GWL_HINSTANCE The window's pplication instance handle.
2116 * GWL_ID The window's identifier.
2118 * GWL_USERDATA The window's user-specified data.
2120 * If the window is a dialog box, the _offset_ parameter can be one of
2121 * the following values:
2123 * DWL_DLGPROC The address of the window's dialog box procedure.
2125 * DWL_MSGRESULT The return value of a message
2126 * that the dialog box procedure processed.
2128 * DWL_USER Application specific information.
2132 * If successful, returns the previous value located at _offset_. Otherwise,
2137 * Extra memory for a window class is specified by a nonzero cbWndExtra
2138 * parameter of the WNDCLASS structure passed to RegisterClass() at the
2139 * time of class creation.
2141 * Using GWL_WNDPROC to set a new window procedure effectively creates
2142 * a window subclass. Use CallWindowProc() in the new windows procedure
2143 * to pass messages to the superclass's window procedure.
2145 * The user data is reserved for use by the application which created
2148 * Do not use GWL_STYLE to change the window's WS_DISABLE style;
2149 * instead, call the EnableWindow() function to change the window's
2152 * Do not use GWL_HWNDPARENT to reset the window's parent, use
2153 * SetParent() instead.
2156 * When offset is GWL_STYLE and the calling app's ver is 4.0,
2157 * it sends WM_STYLECHANGING before changing the settings
2158 * and WM_STYLECHANGED afterwards.
2159 * App ver 4.0 can't use SetWindowLong to change WS_EX_TOPMOST.
2163 * GWL_STYLE does not dispatch WM_STYLE... messages.
2170 LONG WINAPI SetWindowLongW(
2171 HWND hwnd, /* [in] window to alter */
2172 INT offset, /* [in] offset, in bytes, of location to alter */
2173 LONG newval /* [in] new value of location */
2175 return WIN_SetWindowLong( hwnd, offset, newval, WIN_PROC_32W );
2179 /*******************************************************************
2180 * GetWindowText (USER.36)
2182 INT16 WINAPI GetWindowText16( HWND16 hwnd, SEGPTR lpString, INT16 nMaxCount )
2184 return (INT16)SendMessage16(hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString);
2188 /*******************************************************************
2189 * GetWindowTextA (USER32.@)
2191 INT WINAPI GetWindowTextA( HWND hwnd, LPSTR lpString, INT nMaxCount )
2193 return (INT)SendMessageA( hwnd, WM_GETTEXT, nMaxCount,
2197 /*******************************************************************
2198 * InternalGetWindowText (USER32.@)
2200 INT WINAPI InternalGetWindowText(HWND hwnd,LPWSTR lpString,INT nMaxCount )
2202 FIXME("(0x%08x,%p,0x%x),stub!\n",hwnd,lpString,nMaxCount);
2203 return GetWindowTextW(hwnd,lpString,nMaxCount);
2207 /*******************************************************************
2208 * GetWindowTextW (USER32.@)
2210 INT WINAPI GetWindowTextW( HWND hwnd, LPWSTR lpString, INT nMaxCount )
2212 return (INT)SendMessageW( hwnd, WM_GETTEXT, nMaxCount,
2217 /*******************************************************************
2218 * SetWindowText (USER.37)
2220 BOOL16 WINAPI SetWindowText16( HWND16 hwnd, SEGPTR lpString )
2222 return (BOOL16)SendMessage16( hwnd, WM_SETTEXT, 0, (LPARAM)lpString );
2226 /*******************************************************************
2227 * SetWindowText (USER32.@)
2229 BOOL WINAPI SetWindowTextA( HWND hwnd, LPCSTR lpString )
2231 return (BOOL)SendMessageA( hwnd, WM_SETTEXT, 0, (LPARAM)lpString );
2235 /*******************************************************************
2236 * SetWindowTextW (USER32.@)
2238 BOOL WINAPI SetWindowTextW( HWND hwnd, LPCWSTR lpString )
2240 return (BOOL)SendMessageW( hwnd, WM_SETTEXT, 0, (LPARAM)lpString );
2244 /*******************************************************************
2245 * GetWindowTextLength (USER.38)
2247 INT16 WINAPI GetWindowTextLength16( HWND16 hwnd )
2249 return (INT16)SendMessage16( hwnd, WM_GETTEXTLENGTH, 0, 0 );
2253 /*******************************************************************
2254 * GetWindowTextLengthA (USER32.@)
2256 INT WINAPI GetWindowTextLengthA( HWND hwnd )
2258 return SendMessageA( hwnd, WM_GETTEXTLENGTH, 0, 0 );
2261 /*******************************************************************
2262 * GetWindowTextLengthW (USER32.@)
2264 INT WINAPI GetWindowTextLengthW( HWND hwnd )
2266 return SendMessageW( hwnd, WM_GETTEXTLENGTH, 0, 0 );
2270 /*******************************************************************
2271 * IsWindow (USER.47)
2273 BOOL16 WINAPI IsWindow16( HWND16 hwnd )
2275 CURRENT_STACK16->es = USER_HeapSel;
2276 return IsWindow( hwnd );
2280 /*******************************************************************
2281 * IsWindow (USER32.@)
2283 BOOL WINAPI IsWindow( HWND hwnd )
2288 if(!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
2289 retvalue = (wndPtr->dwMagic == WND_MAGIC);
2290 WIN_ReleaseWndPtr(wndPtr);
2296 /*****************************************************************
2297 * GetParent (USER.46)
2299 HWND16 WINAPI GetParent16( HWND16 hwnd )
2301 return (HWND16)GetParent( hwnd );
2305 /*****************************************************************
2306 * GetParent (USER32.@)
2308 HWND WINAPI GetParent( HWND hwnd )
2313 if(!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
2314 if ((!(wndPtr->dwStyle & (WS_POPUP|WS_CHILD))))
2317 WIN_UpdateWndPtr(&wndPtr,((wndPtr->dwStyle & WS_CHILD) ? wndPtr->parent : wndPtr->owner));
2319 retvalue = wndPtr->hwndSelf;
2322 WIN_ReleaseWndPtr(wndPtr);
2327 /*****************************************************************
2330 * Get the top-level parent for a child window.
2331 * returns a locked pointer
2333 WND* WIN_GetTopParentPtr( WND* pWnd )
2335 WND *tmpWnd = WIN_LockWndPtr(pWnd);
2337 while( tmpWnd && (tmpWnd->dwStyle & WS_CHILD))
2339 WIN_UpdateWndPtr(&tmpWnd,tmpWnd->parent);
2344 /*****************************************************************
2347 * Get the top-level parent for a child window.
2349 HWND WIN_GetTopParent( HWND hwnd )
2352 WND *tmpPtr = WIN_FindWndPtr(hwnd);
2353 WND *wndPtr = WIN_GetTopParentPtr (tmpPtr );
2355 retvalue = wndPtr ? wndPtr->hwndSelf : 0;
2356 WIN_ReleaseWndPtr(tmpPtr);
2357 WIN_ReleaseWndPtr(wndPtr);
2362 /*****************************************************************
2363 * SetParent (USER.233)
2365 HWND16 WINAPI SetParent16( HWND16 hwndChild, HWND16 hwndNewParent )
2367 return SetParent( hwndChild, hwndNewParent );
2371 /*****************************************************************
2372 * SetParent (USER32.@)
2374 HWND WINAPI SetParent( HWND hwnd, HWND parent )
2381 if (hwnd == GetDesktopWindow()) /* sanity check */
2383 SetLastError( ERROR_INVALID_WINDOW_HANDLE );
2387 if (USER_Driver.pSetParent)
2388 return USER_Driver.pSetParent( hwnd, parent );
2390 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
2392 dwStyle = wndPtr->dwStyle;
2394 if (!parent) parent = GetDesktopWindow();
2396 if (!(pWndParent = WIN_FindWndPtr(parent)))
2398 WIN_ReleaseWndPtr( wndPtr );
2402 /* Windows hides the window first, then shows it again
2403 * including the WM_SHOWWINDOW messages and all */
2404 if (dwStyle & WS_VISIBLE) ShowWindow( hwnd, SW_HIDE );
2406 retvalue = wndPtr->parent->hwndSelf; /* old parent */
2407 if (pWndParent != wndPtr->parent)
2409 WIN_UnlinkWindow(wndPtr->hwndSelf);
2410 wndPtr->parent = pWndParent;
2412 if (parent != GetDesktopWindow()) /* a child window */
2414 if( !( wndPtr->dwStyle & WS_CHILD ) )
2416 if( wndPtr->wIDmenu != 0)
2418 DestroyMenu( (HMENU) wndPtr->wIDmenu );
2419 wndPtr->wIDmenu = 0;
2423 WIN_LinkWindow(wndPtr->hwndSelf, HWND_TOP);
2425 WIN_ReleaseWndPtr( pWndParent );
2426 WIN_ReleaseWndPtr( wndPtr );
2428 /* SetParent additionally needs to make hwnd the topmost window
2429 in the x-order and send the expected WM_WINDOWPOSCHANGING and
2430 WM_WINDOWPOSCHANGED notification messages.
2432 SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0,
2433 SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|
2434 ((dwStyle & WS_VISIBLE)?SWP_SHOWWINDOW:0));
2435 /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
2436 * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */
2441 /*******************************************************************
2444 BOOL16 WINAPI IsChild16( HWND16 parent, HWND16 child )
2446 return IsChild(parent,child);
2450 /*******************************************************************
2451 * IsChild (USER32.@)
2453 BOOL WINAPI IsChild( HWND parent, HWND child )
2455 WND * wndPtr = WIN_FindWndPtr( child );
2456 while (wndPtr && wndPtr->parent)
2458 WIN_UpdateWndPtr(&wndPtr,wndPtr->parent);
2459 if (wndPtr->hwndSelf == GetDesktopWindow()) break;
2460 if (wndPtr->hwndSelf == parent)
2462 WIN_ReleaseWndPtr(wndPtr);
2466 WIN_ReleaseWndPtr(wndPtr);
2471 /***********************************************************************
2472 * IsWindowVisible (USER.49)
2474 BOOL16 WINAPI IsWindowVisible16( HWND16 hwnd )
2476 return IsWindowVisible(hwnd);
2480 /***********************************************************************
2481 * IsWindowVisible (USER32.@)
2483 BOOL WINAPI IsWindowVisible( HWND hwnd )
2486 WND *wndPtr = WIN_FindWndPtr( hwnd );
2487 while (wndPtr && wndPtr->parent)
2489 if (!(wndPtr->dwStyle & WS_VISIBLE))
2491 WIN_ReleaseWndPtr(wndPtr);
2494 WIN_UpdateWndPtr(&wndPtr,wndPtr->parent);
2496 retval = (wndPtr && (wndPtr->dwStyle & WS_VISIBLE));
2497 WIN_ReleaseWndPtr(wndPtr);
2502 /***********************************************************************
2503 * WIN_IsWindowDrawable
2505 * hwnd is drawable when it is visible, all parents are not
2506 * minimized, and it is itself not minimized unless we are
2507 * trying to draw its default class icon.
2509 BOOL WIN_IsWindowDrawable( WND* wnd, BOOL icon )
2511 if (!(wnd->dwStyle & WS_VISIBLE)) return FALSE;
2512 if ((wnd->dwStyle & WS_MINIMIZE) &&
2513 icon && GetClassLongA( wnd->hwndSelf, GCL_HICON )) return FALSE;
2514 for(wnd = wnd->parent; wnd; wnd = wnd->parent)
2515 if( wnd->dwStyle & WS_MINIMIZE ||
2516 !(wnd->dwStyle & WS_VISIBLE) ) break;
2517 return (wnd == NULL);
2521 /*******************************************************************
2522 * GetTopWindow (USER.229)
2524 HWND16 WINAPI GetTopWindow16( HWND16 hwnd )
2526 return GetTopWindow(hwnd);
2530 /*******************************************************************
2531 * GetTopWindow (USER32.@)
2533 HWND WINAPI GetTopWindow( HWND hwnd )
2536 WND * wndPtr = (hwnd) ?
2537 WIN_FindWndPtr( hwnd ) : WIN_GetDesktop();
2539 if (wndPtr && wndPtr->child)
2540 retval = wndPtr->child->hwndSelf;
2542 WIN_ReleaseWndPtr(wndPtr);
2547 /*******************************************************************
2548 * GetWindow (USER.262)
2550 HWND16 WINAPI GetWindow16( HWND16 hwnd, WORD rel )
2552 return GetWindow( hwnd,rel );
2556 /*******************************************************************
2557 * GetWindow (USER32.@)
2559 HWND WINAPI GetWindow( HWND hwnd, WORD rel )
2563 WND * wndPtr = WIN_FindWndPtr( hwnd );
2564 if (!wndPtr) return 0;
2568 retval = wndPtr->parent ? wndPtr->parent->child->hwndSelf : 0;
2572 if (!wndPtr->parent)
2574 retval = 0; /* Desktop window */
2577 while (wndPtr->next)
2579 WIN_UpdateWndPtr(&wndPtr,wndPtr->next);
2581 retval = wndPtr->hwndSelf;
2585 retval = wndPtr->next ? wndPtr->next->hwndSelf : 0;
2589 if (!wndPtr->parent)
2591 retval = 0; /* Desktop window */
2594 WIN_UpdateWndPtr(&wndPtr,wndPtr->parent->child); /* First sibling */
2595 if (wndPtr->hwndSelf == hwnd)
2597 retval = 0; /* First in list */
2600 while (wndPtr->next)
2602 if (wndPtr->next->hwndSelf == hwnd)
2604 retval = wndPtr->hwndSelf;
2607 WIN_UpdateWndPtr(&wndPtr,wndPtr->next);
2613 retval = wndPtr->owner ? wndPtr->owner->hwndSelf : 0;
2617 retval = wndPtr->child ? wndPtr->child->hwndSelf : 0;
2622 WIN_ReleaseWndPtr(wndPtr);
2627 /*******************************************************************
2628 * GetNextWindow (USER.230)
2630 HWND16 WINAPI GetNextWindow16( HWND16 hwnd, WORD flag )
2632 if ((flag != GW_HWNDNEXT) && (flag != GW_HWNDPREV)) return 0;
2633 return GetWindow16( hwnd, flag );
2636 /***********************************************************************
2637 * WIN_InternalShowOwnedPopups
2639 * Internal version of ShowOwnedPopups; Wine functions should use this
2640 * to avoid interfering with application calls to ShowOwnedPopups
2641 * and to make sure the application can't prevent showing/hiding.
2643 * Set unmanagedOnly to TRUE to show/hide unmanaged windows only.
2647 BOOL WIN_InternalShowOwnedPopups( HWND owner, BOOL fShow, BOOL unmanagedOnly )
2649 INT totalChild=0, count=0;
2651 WND **pWnd = WIN_BuildWinArray(WIN_GetDesktop(), 0, &totalChild);
2653 if (!pWnd) return TRUE;
2656 * Show windows Lowest first, Highest last to preserve Z-Order
2658 for (count = totalChild-1 ; count >=0; count--)
2660 if (pWnd[count]->owner && (pWnd[count]->owner->hwndSelf == owner) && (pWnd[count]->dwStyle & WS_POPUP))
2664 /* check in window was flagged for showing in previous WIN_InternalShowOwnedPopups call */
2665 if (pWnd[count]->flags & WIN_NEEDS_INTERNALSOP)
2668 * Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages
2670 ShowWindow(pWnd[count]->hwndSelf,SW_SHOW);
2671 pWnd[count]->flags &= ~WIN_NEEDS_INTERNALSOP; /* remove the flag */
2676 if ( IsWindowVisible(pWnd[count]->hwndSelf) && /* hide only if window is visible */
2677 !( pWnd[count]->flags & WIN_NEEDS_INTERNALSOP ) && /* don't hide if previous call already did it */
2678 !( unmanagedOnly && (pWnd[count]->dwExStyle & WS_EX_MANAGED) ) ) /* don't hide managed windows if unmanagedOnly is TRUE */
2681 * Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages
2683 ShowWindow(pWnd[count]->hwndSelf,SW_HIDE);
2684 /* flag the window for showing on next WIN_InternalShowOwnedPopups call */
2685 pWnd[count]->flags |= WIN_NEEDS_INTERNALSOP;
2690 WIN_ReleaseDesktop();
2691 WIN_ReleaseWinArray(pWnd);
2696 /*******************************************************************
2697 * ShowOwnedPopups (USER.265)
2699 void WINAPI ShowOwnedPopups16( HWND16 owner, BOOL16 fShow )
2701 ShowOwnedPopups( owner, fShow );
2705 /*******************************************************************
2706 * ShowOwnedPopups (USER32.@)
2708 BOOL WINAPI ShowOwnedPopups( HWND owner, BOOL fShow )
2710 UINT totalChild=0, count=0;
2712 WND **pWnd = WIN_BuildWinArray(WIN_GetDesktop(), 0, &totalChild);
2714 if (!pWnd) return TRUE;
2716 for (; count < totalChild; count++)
2718 if (pWnd[count]->owner && (pWnd[count]->owner->hwndSelf == owner) && (pWnd[count]->dwStyle & WS_POPUP))
2722 if (pWnd[count]->flags & WIN_NEEDS_SHOW_OWNEDPOPUP)
2725 * In Windows, ShowOwnedPopups(TRUE) generates WM_SHOWWINDOW messages with SW_PARENTOPENING,
2726 * regardless of the state of the owner
2728 SendMessageA(pWnd[count]->hwndSelf, WM_SHOWWINDOW, SW_SHOW, SW_PARENTOPENING);
2729 pWnd[count]->flags &= ~WIN_NEEDS_SHOW_OWNEDPOPUP;
2734 if (IsWindowVisible(pWnd[count]->hwndSelf))
2737 * In Windows, ShowOwnedPopups(FALSE) generates WM_SHOWWINDOW messages with SW_PARENTCLOSING,
2738 * regardless of the state of the owner
2740 SendMessageA(pWnd[count]->hwndSelf, WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
2741 pWnd[count]->flags |= WIN_NEEDS_SHOW_OWNEDPOPUP;
2747 WIN_ReleaseDesktop();
2748 WIN_ReleaseWinArray(pWnd);
2753 /*******************************************************************
2754 * GetLastActivePopup (USER.287)
2756 HWND16 WINAPI GetLastActivePopup16( HWND16 hwnd )
2758 return GetLastActivePopup( hwnd );
2761 /*******************************************************************
2762 * GetLastActivePopup (USER32.@)
2764 HWND WINAPI GetLastActivePopup( HWND hwnd )
2767 WND *wndPtr =WIN_FindWndPtr(hwnd);
2768 if (!wndPtr) return hwnd;
2769 retval = wndPtr->hwndLastActive;
2770 WIN_ReleaseWndPtr(wndPtr);
2771 if ((retval != hwnd) && (!IsWindow(retval)))
2777 /*******************************************************************
2780 * Build an array of pointers to the children of a given window.
2781 * The array must be freed with WIN_ReleaseWinArray. Return NULL
2782 * when no windows are found.
2784 WND **WIN_BuildWinArray( WND *wndPtr, UINT bwaFlags, UINT* pTotal )
2786 /* Future: this function will lock all windows associated with this array */
2788 WND **list, **ppWnd;
2790 UINT count = 0, skipOwned, skipHidden;
2793 skipHidden = bwaFlags & BWA_SKIPHIDDEN;
2794 skipOwned = bwaFlags & BWA_SKIPOWNED;
2795 skipFlags = (bwaFlags & BWA_SKIPDISABLED) ? WS_DISABLED : 0;
2796 if( bwaFlags & BWA_SKIPICONIC ) skipFlags |= WS_MINIMIZE;
2798 /* First count the windows */
2801 wndPtr = WIN_GetDesktop();
2803 pWnd = WIN_LockWndPtr(wndPtr->child);
2806 if( !(pWnd->dwStyle & skipFlags) && !(skipOwned && pWnd->owner) &&
2807 (!skipHidden || (pWnd->dwStyle & WS_VISIBLE)) )
2809 WIN_UpdateWndPtr(&pWnd,pWnd->next);
2814 /* Now build the list of all windows */
2816 if ((list = (WND **)HeapAlloc( GetProcessHeap(), 0, sizeof(WND *) * (count + 1))))
2818 for (pWnd = WIN_LockWndPtr(wndPtr->child), ppWnd = list, count = 0; pWnd; WIN_UpdateWndPtr(&pWnd,pWnd->next))
2820 if( (pWnd->dwStyle & skipFlags) || (skipOwned && pWnd->owner) );
2821 else if( !skipHidden || pWnd->dwStyle & WS_VISIBLE )
2827 WIN_ReleaseWndPtr(pWnd);
2833 if( pTotal ) *pTotal = count;
2836 /*******************************************************************
2837 * WIN_ReleaseWinArray
2839 void WIN_ReleaseWinArray(WND **wndArray)
2841 /* Future: this function will also unlock all windows associated with wndArray */
2842 HeapFree( GetProcessHeap(), 0, wndArray );
2846 /*******************************************************************
2847 * EnumWindows (USER32.@)
2849 BOOL WINAPI EnumWindows( WNDENUMPROC lpEnumFunc, LPARAM lParam )
2851 WND **list, **ppWnd;
2853 /* We have to build a list of all windows first, to avoid */
2854 /* unpleasant side-effects, for instance if the callback */
2855 /* function changes the Z-order of the windows. */
2857 if (!(list = WIN_BuildWinArray(WIN_GetDesktop(), 0, NULL )))
2859 WIN_ReleaseDesktop();
2863 /* Now call the callback function for every window */
2865 for (ppWnd = list; *ppWnd; ppWnd++)
2867 LRESULT lpEnumFuncRetval;
2869 /* Make sure that the window still exists */
2870 if (!IsWindow((*ppWnd)->hwndSelf)) continue;
2872 /* To avoid any deadlocks, all the locks on the windows
2873 structures must be suspended before the control
2874 is passed to the application */
2875 iWndsLocks = WIN_SuspendWndsLock();
2876 lpEnumFuncRetval = lpEnumFunc( (*ppWnd)->hwndSelf, lParam);
2877 WIN_RestoreWndsLock(iWndsLocks);
2879 if (!lpEnumFuncRetval) break;
2881 WIN_ReleaseWinArray(list);
2882 WIN_ReleaseDesktop();
2887 /**********************************************************************
2888 * WIN_EnumQueueWindows
2890 * Helper for EnumTaskWindows16 and EnumThreadWindows.
2892 static BOOL WIN_EnumQueueWindows( HQUEUE16 queue, WNDENUMPROC func, LPARAM lParam )
2894 WND **list, **ppWnd;
2896 /* This function is the same as EnumWindows(), */
2897 /* except for an added check on the window's task. */
2899 if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
2901 WIN_ReleaseDesktop();
2905 /* Now call the callback function for every window */
2907 for (ppWnd = list; *ppWnd; ppWnd++)
2911 /* Make sure that the window still exists */
2912 if (!IsWindow((*ppWnd)->hwndSelf)) continue;
2913 if ((*ppWnd)->hmemTaskQ != queue) continue;
2915 /* To avoid any deadlocks, all the locks on the windows
2916 structures must be suspended before the control
2917 is passed to the application */
2918 iWndsLocks = WIN_SuspendWndsLock();
2919 funcRetval = func( (*ppWnd)->hwndSelf, lParam );
2920 WIN_RestoreWndsLock(iWndsLocks);
2922 if (!funcRetval) break;
2924 WIN_ReleaseWinArray(list);
2925 WIN_ReleaseDesktop();
2930 /**********************************************************************
2931 * EnumTaskWindows16 (USER.225)
2933 BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func,
2936 HQUEUE16 queue = GetTaskQueue16( hTask );
2937 if (!queue) return FALSE;
2938 return WIN_EnumQueueWindows( queue, (WNDENUMPROC)func, lParam );
2942 /**********************************************************************
2943 * EnumThreadWindows (USER32.@)
2945 BOOL WINAPI EnumThreadWindows( DWORD id, WNDENUMPROC func, LPARAM lParam )
2947 HQUEUE16 queue = GetThreadQueue16( id );
2948 if (!queue) return FALSE;
2949 return WIN_EnumQueueWindows( queue, func, lParam );
2953 /**********************************************************************
2954 * WIN_EnumChildWindows
2956 * Helper function for EnumChildWindows().
2958 static BOOL16 WIN_EnumChildWindows( WND **ppWnd, WNDENUMPROC func, LPARAM lParam )
2963 for ( ; *ppWnd; ppWnd++)
2967 /* Make sure that the window still exists */
2968 if (!IsWindow((*ppWnd)->hwndSelf)) continue;
2969 /* Build children list first */
2970 childList = WIN_BuildWinArray( *ppWnd, BWA_SKIPOWNED, NULL );
2972 /* To avoid any deadlocks, all the locks on the windows
2973 structures must be suspended before the control
2974 is passed to the application */
2975 iWndsLocks = WIN_SuspendWndsLock();
2976 ret = func( (*ppWnd)->hwndSelf, lParam );
2977 WIN_RestoreWndsLock(iWndsLocks);
2981 if (ret) ret = WIN_EnumChildWindows( childList, func, lParam );
2982 WIN_ReleaseWinArray(childList);
2984 if (!ret) return FALSE;
2990 /**********************************************************************
2991 * EnumChildWindows (USER32.@)
2993 BOOL WINAPI EnumChildWindows( HWND parent, WNDENUMPROC func,
2996 WND **list, *pParent;
2998 if (!(pParent = WIN_FindWndPtr( parent ))) return FALSE;
2999 if (!(list = WIN_BuildWinArray( pParent, BWA_SKIPOWNED, NULL )))
3001 WIN_ReleaseWndPtr(pParent);
3004 WIN_EnumChildWindows( list, func, lParam );
3005 WIN_ReleaseWinArray(list);
3006 WIN_ReleaseWndPtr(pParent);
3011 /*******************************************************************
3012 * AnyPopup (USER.52)
3014 BOOL16 WINAPI AnyPopup16(void)
3020 /*******************************************************************
3021 * AnyPopup (USER32.@)
3023 BOOL WINAPI AnyPopup(void)
3025 WND *wndPtr = WIN_LockWndPtr(pWndDesktop->child);
3030 if (wndPtr->owner && (wndPtr->dwStyle & WS_VISIBLE))
3035 WIN_UpdateWndPtr(&wndPtr,wndPtr->next);
3039 WIN_ReleaseWndPtr(wndPtr);
3044 /*******************************************************************
3045 * FlashWindow (USER.105)
3047 BOOL16 WINAPI FlashWindow16( HWND16 hWnd, BOOL16 bInvert )
3049 return FlashWindow( hWnd, bInvert );
3053 /*******************************************************************
3054 * FlashWindow (USER32.@)
3056 BOOL WINAPI FlashWindow( HWND hWnd, BOOL bInvert )
3058 WND *wndPtr = WIN_FindWndPtr(hWnd);
3060 TRACE("%04x\n", hWnd);
3062 if (!wndPtr) return FALSE;
3064 if (wndPtr->dwStyle & WS_MINIMIZE)
3066 if (bInvert && !(wndPtr->flags & WIN_NCACTIVATED))
3068 HDC hDC = GetDC(hWnd);
3070 if (!SendMessage16( hWnd, WM_ERASEBKGND, (WPARAM16)hDC, 0 ))
3071 wndPtr->flags |= WIN_NEEDS_ERASEBKGND;
3073 ReleaseDC( hWnd, hDC );
3074 wndPtr->flags |= WIN_NCACTIVATED;
3078 RedrawWindow( hWnd, 0, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_FRAME );
3079 wndPtr->flags &= ~WIN_NCACTIVATED;
3081 WIN_ReleaseWndPtr(wndPtr);
3087 if (bInvert) wparam = !(wndPtr->flags & WIN_NCACTIVATED);
3088 else wparam = (hWnd == GetActiveWindow());
3090 SendMessage16( hWnd, WM_NCACTIVATE, wparam, (LPARAM)0 );
3091 WIN_ReleaseWndPtr(wndPtr);
3097 /*******************************************************************
3098 * SetSysModalWindow (USER.188)
3100 HWND16 WINAPI SetSysModalWindow16( HWND16 hWnd )
3102 HWND hWndOldModal = hwndSysModal;
3103 hwndSysModal = hWnd;
3104 FIXME("EMPTY STUB !! SetSysModalWindow(%04x) !\n", hWnd);
3105 return hWndOldModal;
3109 /*******************************************************************
3110 * GetSysModalWindow (USER.189)
3112 HWND16 WINAPI GetSysModalWindow16(void)
3114 return hwndSysModal;
3118 /*******************************************************************
3119 * GetWindowContextHelpId (USER32.@)
3121 DWORD WINAPI GetWindowContextHelpId( HWND hwnd )
3124 WND *wnd = WIN_FindWndPtr( hwnd );
3126 retval = wnd->helpContext;
3127 WIN_ReleaseWndPtr(wnd);
3132 /*******************************************************************
3133 * SetWindowContextHelpId (USER32.@)
3135 BOOL WINAPI SetWindowContextHelpId( HWND hwnd, DWORD id )
3137 WND *wnd = WIN_FindWndPtr( hwnd );
3138 if (!wnd) return FALSE;
3139 wnd->helpContext = id;
3140 WIN_ReleaseWndPtr(wnd);
3145 /*******************************************************************
3148 * recursively find a child that contains spDragInfo->pt point
3149 * and send WM_QUERYDROPOBJECT
3151 BOOL16 DRAG_QueryUpdate( HWND hQueryWnd, SEGPTR spDragInfo, BOOL bNoSend )
3153 BOOL16 wParam, bResult = 0;
3155 LPDRAGINFO16 ptrDragInfo = MapSL(spDragInfo);
3156 WND *ptrQueryWnd = WIN_FindWndPtr(hQueryWnd),*ptrWnd;
3159 if( !ptrQueryWnd || !ptrDragInfo )
3162 CONV_POINT16TO32( &ptrDragInfo->pt, &pt );
3164 GetWindowRect(hQueryWnd,&tempRect);
3166 if( !PtInRect(&tempRect,pt) ||
3167 (ptrQueryWnd->dwStyle & WS_DISABLED) )
3170 if( !(ptrQueryWnd->dwStyle & WS_MINIMIZE) )
3172 tempRect = ptrQueryWnd->rectClient;
3173 if(ptrQueryWnd->parent)
3174 MapWindowPoints( ptrQueryWnd->parent->hwndSelf, 0,
3175 (LPPOINT)&tempRect, 2 );
3177 if (PtInRect( &tempRect, pt))
3181 for (ptrWnd = WIN_LockWndPtr(ptrQueryWnd->child); ptrWnd ;WIN_UpdateWndPtr(&ptrWnd,ptrWnd->next))
3183 if( ptrWnd->dwStyle & WS_VISIBLE )
3185 GetWindowRect( ptrWnd->hwndSelf, &tempRect );
3186 if (PtInRect( &tempRect, pt )) break;
3192 TRACE_(msg)("hwnd = %04x, %d %d - %d %d\n",
3193 ptrWnd->hwndSelf, ptrWnd->rectWindow.left, ptrWnd->rectWindow.top,
3194 ptrWnd->rectWindow.right, ptrWnd->rectWindow.bottom );
3195 if( !(ptrWnd->dwStyle & WS_DISABLED) )
3196 bResult = DRAG_QueryUpdate(ptrWnd->hwndSelf, spDragInfo, bNoSend);
3198 WIN_ReleaseWndPtr(ptrWnd);
3208 ScreenToClient16(hQueryWnd,&ptrDragInfo->pt);
3210 ptrDragInfo->hScope = hQueryWnd;
3212 bResult = ( bNoSend )
3213 ? ptrQueryWnd->dwExStyle & WS_EX_ACCEPTFILES
3214 : SendMessage16( hQueryWnd ,WM_QUERYDROPOBJECT ,
3215 (WPARAM16)wParam ,(LPARAM) spDragInfo );
3217 CONV_POINT32TO16( &pt, &ptrDragInfo->pt );
3220 WIN_ReleaseWndPtr(ptrQueryWnd);
3225 /*******************************************************************
3226 * DragDetect (USER.465)
3228 BOOL16 WINAPI DragDetect16( HWND16 hWnd, POINT16 pt )
3231 CONV_POINT16TO32( &pt, &pt32 );
3232 return DragDetect( hWnd, pt32 );
3235 /*******************************************************************
3236 * DragDetect (USER32.@)
3238 BOOL WINAPI DragDetect( HWND hWnd, POINT pt )
3243 rect.left = pt.x - wDragWidth;
3244 rect.right = pt.x + wDragWidth;
3246 rect.top = pt.y - wDragHeight;
3247 rect.bottom = pt.y + wDragHeight;
3253 while(PeekMessageA(&msg ,0 ,WM_MOUSEFIRST ,WM_MOUSELAST ,PM_REMOVE))
3255 if( msg.message == WM_LBUTTONUP )
3260 if( msg.message == WM_MOUSEMOVE )
3263 tmp.x = LOWORD(msg.lParam);
3264 tmp.y = HIWORD(msg.lParam);
3265 if( !PtInRect( &rect, tmp ))
3277 /******************************************************************************
3278 * DragObject (USER.464)
3280 DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj,
3281 HANDLE16 hOfStruct, WORD szList, HCURSOR16 hCursor )
3284 LPDRAGINFO16 lpDragInfo;
3286 HCURSOR16 hDragCursor=0, hOldCursor=0, hBummer=0;
3287 HGLOBAL16 hDragInfo = GlobalAlloc16( GMEM_SHARE | GMEM_ZEROINIT, 2*sizeof(DRAGINFO16));
3288 WND *wndPtr = WIN_FindWndPtr(hWnd);
3289 HCURSOR16 hCurrentCursor = 0;
3290 HWND16 hCurrentWnd = 0;
3292 lpDragInfo = (LPDRAGINFO16) GlobalLock16(hDragInfo);
3293 spDragInfo = K32WOWGlobalLock16(hDragInfo);
3295 if( !lpDragInfo || !spDragInfo )
3297 WIN_ReleaseWndPtr(wndPtr);
3301 hBummer = LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO));
3303 if( !hBummer || !wndPtr )
3305 GlobalFree16(hDragInfo);
3306 WIN_ReleaseWndPtr(wndPtr);
3312 if( !(hDragCursor = CURSORICON_IconToCursor(hCursor, FALSE)) )
3314 GlobalFree16(hDragInfo);
3315 WIN_ReleaseWndPtr(wndPtr);
3319 if( hDragCursor == hCursor ) hDragCursor = 0;
3320 else hCursor = hDragCursor;
3322 hOldCursor = SetCursor(hDragCursor);
3325 lpDragInfo->hWnd = hWnd;
3326 lpDragInfo->hScope = 0;
3327 lpDragInfo->wFlags = wObj;
3328 lpDragInfo->hList = szList; /* near pointer! */
3329 lpDragInfo->hOfStruct = hOfStruct;
3337 do{ WaitMessage(); }
3338 while( !PeekMessageA(&msg,0,WM_MOUSEFIRST,WM_MOUSELAST,PM_REMOVE) );
3340 *(lpDragInfo+1) = *lpDragInfo;
3342 lpDragInfo->pt.x = msg.pt.x;
3343 lpDragInfo->pt.y = msg.pt.y;
3345 /* update DRAGINFO struct */
3346 TRACE_(msg)("lpDI->hScope = %04x\n",lpDragInfo->hScope);
3348 if( DRAG_QueryUpdate(hwndScope, spDragInfo, FALSE) > 0 )
3349 hCurrentCursor = hCursor;
3352 hCurrentCursor = hBummer;
3353 lpDragInfo->hScope = 0;
3355 if( hCurrentCursor )
3356 SetCursor(hCurrentCursor);
3358 /* send WM_DRAGLOOP */
3359 SendMessage16( hWnd, WM_DRAGLOOP, (WPARAM16)(hCurrentCursor != hBummer),
3360 (LPARAM) spDragInfo );
3361 /* send WM_DRAGSELECT or WM_DRAGMOVE */
3362 if( hCurrentWnd != lpDragInfo->hScope )
3365 SendMessage16( hCurrentWnd, WM_DRAGSELECT, 0,
3366 (LPARAM)MAKELONG(LOWORD(spDragInfo)+sizeof(DRAGINFO16),
3367 HIWORD(spDragInfo)) );
3368 hCurrentWnd = lpDragInfo->hScope;
3370 SendMessage16( hCurrentWnd, WM_DRAGSELECT, 1, (LPARAM)spDragInfo);
3374 SendMessage16( hCurrentWnd, WM_DRAGMOVE, 0, (LPARAM)spDragInfo);
3376 } while( msg.message != WM_LBUTTONUP && msg.message != WM_NCLBUTTONUP );
3379 ShowCursor( FALSE );
3383 SetCursor( hOldCursor );
3384 if (hDragCursor) DestroyCursor( hDragCursor );
3387 if( hCurrentCursor != hBummer )
3388 msg.lParam = SendMessage16( lpDragInfo->hScope, WM_DROPOBJECT,
3389 (WPARAM16)hWnd, (LPARAM)spDragInfo );
3392 GlobalFree16(hDragInfo);
3393 WIN_ReleaseWndPtr(wndPtr);
3395 return (DWORD)(msg.lParam);
3399 /******************************************************************************
3400 * GetWindowModuleFileNameA (USER32.@)
3402 UINT WINAPI GetWindowModuleFileNameA( HWND hwnd, LPSTR lpszFileName, UINT cchFileNameMax)
3404 FIXME("GetWindowModuleFileNameA(hwnd 0x%x, lpszFileName %p, cchFileNameMax %u) stub!\n",
3405 hwnd, lpszFileName, cchFileNameMax);
3409 /******************************************************************************
3410 * GetWindowModuleFileNameW (USER32.@)
3412 UINT WINAPI GetWindowModuleFileNameW( HWND hwnd, LPSTR lpszFileName, UINT cchFileNameMax)
3414 FIXME("GetWindowModuleFileNameW(hwnd 0x%x, lpszFileName %p, cchFileNameMax %u) stub!\n",
3415 hwnd, lpszFileName, cchFileNameMax);