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"
26 #include "stackframe.h"
27 #include "debugtools.h"
29 DEFAULT_DEBUG_CHANNEL(win);
30 DECLARE_DEBUG_CHANNEL(msg);
32 /**********************************************************************/
34 WND_DRIVER *WND_Driver = NULL;
37 static WND *pWndDesktop = NULL;
39 static HWND hwndSysModal = 0;
41 static WORD wDragWidth = 4;
42 static WORD wDragHeight= 3;
45 static SYSLEVEL WIN_SysLevel = { CRITICAL_SECTION_INIT, 2 };
47 /***********************************************************************
50 * Locks access to all WND structures for thread safeness
52 void WIN_LockWnds( void )
54 _EnterSysLevel( &WIN_SysLevel );
57 /***********************************************************************
60 * Unlocks access to all WND structures
62 void WIN_UnlockWnds( void )
64 _LeaveSysLevel( &WIN_SysLevel );
67 /***********************************************************************
70 * Suspend the lock on WND structures.
71 * Returns the number of locks suspended
73 int WIN_SuspendWndsLock( void )
75 int isuspendedLocks = _ConfirmSysLevel( &WIN_SysLevel );
76 int count = isuspendedLocks;
79 _LeaveSysLevel( &WIN_SysLevel );
81 return isuspendedLocks;
84 /***********************************************************************
87 * Restore the suspended locks on WND structures
89 void WIN_RestoreWndsLock( int ipreviousLocks )
91 while ( ipreviousLocks-- > 0 )
92 _EnterSysLevel( &WIN_SysLevel );
95 /***********************************************************************
98 * Return a pointer to the WND structure corresponding to a HWND.
100 WND * WIN_FindWndPtr( HWND hwnd )
104 if (!hwnd || HIWORD(hwnd)) goto error2;
105 ptr = (WND *) USER_HEAP_LIN_ADDR( hwnd );
106 /* Lock all WND structures for thread safeness*/
108 /*and increment destruction monitoring*/
111 if (ptr->dwMagic != WND_MAGIC) goto error;
112 if (ptr->hwndSelf != hwnd)
114 ERR("Can't happen: hwnd %04x self pointer is %04x\n",hwnd, ptr->hwndSelf );
117 /* returns a locked pointer */
120 /* Unlock all WND structures for thread safeness*/
122 /* and decrement destruction monitoring value */
127 SetLastError( ERROR_INVALID_WINDOW_HANDLE );
131 /***********************************************************************
134 * Use in case the wnd ptr is not initialized with WIN_FindWndPtr
136 * Returns the locked initialisation pointer
138 WND *WIN_LockWndPtr(WND *initWndPtr)
140 if(!initWndPtr) return 0;
142 /* Lock all WND structures for thread safeness*/
144 /*and increment destruction monitoring*/
145 initWndPtr->irefCount++;
151 /***********************************************************************
154 * Release the pointer to the WND structure.
156 void WIN_ReleaseWndPtr(WND *wndPtr)
160 /*Decrement destruction monitoring value*/
162 /* Check if it's time to release the memory*/
163 if(wndPtr->irefCount == 0 && !wndPtr->dwMagic)
166 USER_HEAP_FREE( wndPtr->hwndSelf);
167 wndPtr->hwndSelf = 0;
169 else if(wndPtr->irefCount < 0)
171 /* This else if is useful to monitor the WIN_ReleaseWndPtr function */
172 ERR("forgot a Lock on %p somewhere\n",wndPtr);
174 /*unlock all WND structures for thread safeness*/
178 /***********************************************************************
181 * Updates the value of oldPtr to newPtr.
183 void WIN_UpdateWndPtr(WND **oldPtr, WND *newPtr)
187 tmpWnd = WIN_LockWndPtr(newPtr);
188 WIN_ReleaseWndPtr(*oldPtr);
193 /***********************************************************************
196 * Dump the content of a window structure to stderr.
198 void WIN_DumpWindow( HWND hwnd )
204 if (!(ptr = WIN_FindWndPtr( hwnd )))
206 WARN("%04x is not a window handle\n", hwnd );
210 if (!GetClassNameA( hwnd, className, sizeof(className ) ))
211 strcpy( className, "#NULL#" );
213 TRACE("Window %04x (%p):\n", hwnd, ptr );
214 DPRINTF( "next=%p child=%p parent=%p owner=%p class=%p '%s'\n"
215 "inst=%04x taskQ=%04x updRgn=%04x active=%04x dce=%p idmenu=%08x\n"
216 "style=%08lx exstyle=%08lx wndproc=%08x text='%s'\n"
217 "client=%d,%d-%d,%d window=%d,%d-%d,%d"
218 "sysmenu=%04x flags=%04x props=%p vscroll=%p hscroll=%p\n",
219 ptr->next, ptr->child, ptr->parent, ptr->owner,
220 ptr->class, className, ptr->hInstance, ptr->hmemTaskQ,
221 ptr->hrgnUpdate, ptr->hwndLastActive, ptr->dce, ptr->wIDmenu,
222 ptr->dwStyle, ptr->dwExStyle, (UINT)ptr->winproc,
223 ptr->text ? debugstr_w(ptr->text) : "",
224 ptr->rectClient.left, ptr->rectClient.top, ptr->rectClient.right,
225 ptr->rectClient.bottom, ptr->rectWindow.left, ptr->rectWindow.top,
226 ptr->rectWindow.right, ptr->rectWindow.bottom, ptr->hSysMenu,
227 ptr->flags, ptr->pProp, ptr->pVScroll, ptr->pHScroll );
231 DPRINTF( "extra bytes:" );
232 for (i = 0; i < ptr->cbWndExtra; i++)
233 DPRINTF( " %02x", *((BYTE*)ptr->wExtra+i) );
237 WIN_ReleaseWndPtr(ptr);
241 /***********************************************************************
244 * Walk the windows tree and print each window on stderr.
246 void WIN_WalkWindows( HWND hwnd, int indent )
251 ptr = hwnd ? WIN_FindWndPtr( hwnd ) : WIN_GetDesktop();
255 WARN("Invalid window handle %04x\n", hwnd );
259 if (!indent) /* first time around */
260 DPRINTF( "%-16.16s %-8.8s %-6.6s %-17.17s %-8.8s %s\n",
261 "hwnd", " wndPtr", "queue", "Class Name", " Style", " WndProc"
266 DPRINTF( "%*s%04x%*s", indent, "", ptr->hwndSelf, 13-indent,"");
268 GetClassNameA( hwnd, className, sizeof(className) );
269 DPRINTF( "%08lx %-6.4x %-17.17s %08x %08x %.14s\n",
270 (DWORD)ptr, ptr->hmemTaskQ, className,
271 (UINT)ptr->dwStyle, (UINT)ptr->winproc,
272 ptr->text ? debugstr_w(ptr->text) : "<null>");
274 if (ptr->child) WIN_WalkWindows( ptr->child->hwndSelf, indent+1 );
275 WIN_UpdateWndPtr(&ptr,ptr->next);
281 /***********************************************************************
284 * Remove a window from the siblings linked list.
286 BOOL WIN_UnlinkWindow( HWND hwnd )
288 WND *wndPtr, **ppWnd;
291 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
292 else if(!wndPtr->parent)
294 WIN_ReleaseWndPtr(wndPtr);
298 ppWnd = &wndPtr->parent->child;
299 while (*ppWnd && *ppWnd != wndPtr) ppWnd = &(*ppWnd)->next;
302 *ppWnd = wndPtr->next;
305 WIN_ReleaseWndPtr(wndPtr);
310 /***********************************************************************
313 * Insert a window into the siblings linked list.
314 * The window is inserted after the specified window, which can also
315 * be specified as HWND_TOP or HWND_BOTTOM.
317 BOOL WIN_LinkWindow( HWND hwnd, HWND hwndInsertAfter )
319 WND *wndPtr, **ppWnd;
321 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
322 else if(!wndPtr->parent)
324 WIN_ReleaseWndPtr(wndPtr);
327 if ((hwndInsertAfter == HWND_TOP) || (hwndInsertAfter == HWND_BOTTOM))
329 ppWnd = &wndPtr->parent->child; /* Point to first sibling hwnd */
330 if (hwndInsertAfter == HWND_BOTTOM) /* Find last sibling hwnd */
331 while (*ppWnd) ppWnd = &(*ppWnd)->next;
333 else /* Normal case */
335 WND * afterPtr = WIN_FindWndPtr( hwndInsertAfter );
338 WIN_ReleaseWndPtr(wndPtr);
341 ppWnd = &afterPtr->next;
342 WIN_ReleaseWndPtr(afterPtr);
344 wndPtr->next = *ppWnd;
346 WIN_ReleaseWndPtr(wndPtr);
351 /***********************************************************************
352 * WIN_FindWinToRepaint
354 * Find a window that needs repaint.
356 HWND WIN_FindWinToRepaint( HWND hwnd, HQUEUE16 hQueue )
361 /* Note: the desktop window never gets WM_PAINT messages
362 * The real reason why is because Windows DesktopWndProc
363 * does ValidateRgn inside WM_ERASEBKGND handler.
366 pWnd = hwnd ? WIN_FindWndPtr(hwnd) : WIN_LockWndPtr(pWndDesktop->child);
368 for ( ; pWnd ; WIN_UpdateWndPtr(&pWnd,pWnd->next))
370 if (!(pWnd->dwStyle & WS_VISIBLE))
372 TRACE("skipping window %04x\n",
375 else if ((pWnd->hmemTaskQ == hQueue) &&
376 (pWnd->hrgnUpdate || (pWnd->flags & WIN_INTERNAL_PAINT)))
379 else if (pWnd->child )
380 if ((hwndRet = WIN_FindWinToRepaint( pWnd->child->hwndSelf, hQueue )) )
382 WIN_ReleaseWndPtr(pWnd);
393 hwndRet = pWnd->hwndSelf;
395 /* look among siblings if we got a transparent window */
396 while (pWnd && ((pWnd->dwExStyle & WS_EX_TRANSPARENT) ||
397 !(pWnd->hrgnUpdate || (pWnd->flags & WIN_INTERNAL_PAINT))))
399 WIN_UpdateWndPtr(&pWnd,pWnd->next);
403 hwndRet = pWnd->hwndSelf;
404 WIN_ReleaseWndPtr(pWnd);
406 TRACE("found %04x\n",hwndRet);
411 /***********************************************************************
414 * Destroy storage associated to a window. "Internals" p.358
415 * returns a locked wndPtr->next
417 static WND* WIN_DestroyWindow( WND* wndPtr )
419 HWND hwnd = wndPtr->hwndSelf;
422 TRACE("%04x\n", wndPtr->hwndSelf );
424 /* free child windows */
425 WIN_LockWndPtr(wndPtr->child);
426 while ((pWnd = wndPtr->child))
428 wndPtr->child = WIN_DestroyWindow( pWnd );
429 WIN_ReleaseWndPtr(pWnd);
433 * Clear the update region to make sure no WM_PAINT messages will be
434 * generated for this window while processing the WM_NCDESTROY.
436 if ((wndPtr->hrgnUpdate) || (wndPtr->flags & WIN_INTERNAL_PAINT))
438 if (wndPtr->hrgnUpdate > 1)
439 DeleteObject( wndPtr->hrgnUpdate );
441 QUEUE_DecPaintCount( wndPtr->hmemTaskQ );
443 wndPtr->hrgnUpdate = 0;
447 * Send the WM_NCDESTROY to the window being destroyed.
449 SendMessageA( wndPtr->hwndSelf, WM_NCDESTROY, 0, 0);
451 /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
453 WINPOS_CheckInternalPos( wndPtr );
454 if( hwnd == GetCapture()) ReleaseCapture();
456 /* free resources associated with the window */
458 TIMER_RemoveWindowTimers( wndPtr->hwndSelf );
459 PROPERTY_RemoveWindowProps( wndPtr );
461 wndPtr->dwMagic = 0; /* Mark it as invalid */
463 /* toss stale messages from the queue */
465 if( wndPtr->hmemTaskQ )
467 BOOL bPostQuit = FALSE;
468 WPARAM wQuitParam = 0;
469 MESSAGEQUEUE* msgQ = (MESSAGEQUEUE*) QUEUE_Lock(wndPtr->hmemTaskQ);
472 while( (qmsg = QUEUE_FindMsg(msgQ, hwnd, 0, 0)) != 0 )
474 if( qmsg->msg.message == WM_QUIT )
477 wQuitParam = qmsg->msg.wParam;
479 QUEUE_RemoveMsg(msgQ, qmsg);
484 /* repost WM_QUIT to make sure this app exits its message loop */
485 if( bPostQuit ) PostQuitMessage(wQuitParam);
486 wndPtr->hmemTaskQ = 0;
489 if (!(wndPtr->dwStyle & WS_CHILD))
492 DestroyMenu( wndPtr->wIDmenu );
495 if (wndPtr->hSysMenu)
497 DestroyMenu( wndPtr->hSysMenu );
498 wndPtr->hSysMenu = 0;
500 wndPtr->pDriver->pDestroyWindow( wndPtr );
501 DCE_FreeWindowDCE( wndPtr ); /* Always do this to catch orphaned DCs */
502 WINPROC_FreeProc( wndPtr->winproc, WIN_PROC_WINDOW );
503 CLASS_RemoveWindow( wndPtr->class );
504 wndPtr->class = NULL;
506 WIN_UpdateWndPtr(&pWnd,wndPtr->next);
508 wndPtr->pDriver->pFinalize(wndPtr);
513 /***********************************************************************
514 * WIN_ResetQueueWindows
516 * Reset the queue of all the children of a given window.
517 * Return TRUE if something was done.
519 BOOL WIN_ResetQueueWindows( WND* wnd, HQUEUE16 hQueue, HQUEUE16 hNew )
523 if (hNew) /* Set a new queue */
525 for (wnd = WIN_LockWndPtr(wnd->child); (wnd);WIN_UpdateWndPtr(&wnd,wnd->next))
527 if (wnd->hmemTaskQ == hQueue)
529 wnd->hmemTaskQ = hNew;
534 ret |= WIN_ResetQueueWindows( wnd, hQueue, hNew );
538 else /* Queue is being destroyed */
542 WND *tmp = WIN_LockWndPtr(wnd->child);
547 if (tmp->hmemTaskQ == hQueue)
549 DestroyWindow( tmp->hwndSelf );
553 tmp2 = WIN_LockWndPtr(tmp->child);
554 if (tmp2 && WIN_ResetQueueWindows(tmp2,hQueue,0))
558 WIN_UpdateWndPtr(&tmp,tmp->next);
560 WIN_ReleaseWndPtr(tmp2);
562 WIN_ReleaseWndPtr(tmp);
569 /***********************************************************************
570 * WIN_CreateDesktopWindow
572 * Create the desktop window.
574 BOOL WIN_CreateDesktopWindow(void)
576 struct tagCLASS *class;
583 TRACE("Creating desktop window\n");
586 if (!WINPOS_CreateInternalPosAtom() ||
587 !(class = CLASS_AddWindow( (ATOM)LOWORD(DESKTOP_CLASS_ATOM), 0, WIN_PROC_32W,
588 &wndExtra, &winproc, &clsStyle, &dce )))
591 hwndDesktop = USER_HEAP_ALLOC( sizeof(WND) + wndExtra );
592 if (!hwndDesktop) return FALSE;
593 pWndDesktop = (WND *) USER_HEAP_LIN_ADDR( hwndDesktop );
595 pWndDesktop->pDriver = WND_Driver;
596 pWndDesktop->pDriver->pInitialize(pWndDesktop);
598 pWndDesktop->next = NULL;
599 pWndDesktop->child = NULL;
600 pWndDesktop->parent = NULL;
601 pWndDesktop->owner = NULL;
602 pWndDesktop->class = class;
603 pWndDesktop->dwMagic = WND_MAGIC;
604 pWndDesktop->hwndSelf = hwndDesktop;
605 pWndDesktop->hInstance = 0;
606 pWndDesktop->rectWindow.left = 0;
607 pWndDesktop->rectWindow.top = 0;
608 pWndDesktop->rectWindow.right = GetSystemMetrics(SM_CXSCREEN);
609 pWndDesktop->rectWindow.bottom = GetSystemMetrics(SM_CYSCREEN);
610 pWndDesktop->rectClient = pWndDesktop->rectWindow;
611 pWndDesktop->text = NULL;
612 pWndDesktop->hmemTaskQ = GetFastQueue16();
613 pWndDesktop->hrgnUpdate = 0;
614 pWndDesktop->hwndLastActive = hwndDesktop;
615 pWndDesktop->dwStyle = WS_VISIBLE | WS_CLIPCHILDREN |
617 pWndDesktop->dwExStyle = 0;
618 pWndDesktop->clsStyle = clsStyle;
619 pWndDesktop->dce = NULL;
620 pWndDesktop->pVScroll = NULL;
621 pWndDesktop->pHScroll = NULL;
622 pWndDesktop->pProp = NULL;
623 pWndDesktop->wIDmenu = 0;
624 pWndDesktop->helpContext = 0;
625 pWndDesktop->flags = Options.desktopGeometry ? WIN_NATIVE : 0;
626 pWndDesktop->hSysMenu = 0;
627 pWndDesktop->userdata = 0;
628 pWndDesktop->winproc = winproc;
629 pWndDesktop->cbWndExtra = wndExtra;
630 pWndDesktop->irefCount = 0;
632 if(!pWndDesktop->pDriver->pCreateDesktopWindow(pWndDesktop)) return FALSE;
634 SendMessageW( hwndDesktop, WM_NCCREATE, 0, 0 );
635 pWndDesktop->flags |= WIN_NEEDS_ERASEBKGND;
640 /***********************************************************************
643 * Fix the coordinates - Helper for WIN_CreateWindowEx.
644 * returns default show mode in sw.
645 * Note: the feature presented as undocumented *is* in the MSDN since 1993.
647 static void WIN_FixCoordinates( CREATESTRUCTA *cs, INT *sw)
649 if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16 ||
650 cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16)
652 if (cs->style & (WS_CHILD | WS_POPUP))
654 if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16) cs->x = cs->y = 0;
655 if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16) cs->cx = cs->cy = 0;
657 else /* overlapped window */
661 GetStartupInfoA( &info );
663 if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16)
665 /* Never believe Microsoft's documentation... CreateWindowEx doc says
666 * that if an overlapped window is created with WS_VISIBLE style bit
667 * set and the x parameter is set to CW_USEDEFAULT, the system ignores
668 * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
671 * 1) not only it checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
672 * 2) it does not ignore the y parameter as the docs claim; instead, it
673 * uses it as second parameter to ShowWindow() unless y is either
674 * CW_USEDEFAULT or CW_USEDEFAULT16.
676 * The fact that we didn't do 2) caused bogus windows pop up when wine
677 * was running apps that were using this obscure feature. Example -
678 * calc.exe that comes with Win98 (only Win98, it's different from
679 * the one that comes with Win95 and NT)
681 if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) *sw = cs->y;
682 cs->x = (info.dwFlags & STARTF_USEPOSITION) ? info.dwX : 0;
683 cs->y = (info.dwFlags & STARTF_USEPOSITION) ? info.dwY : 0;
686 if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16)
688 if (info.dwFlags & STARTF_USESIZE)
690 cs->cx = info.dwXSize;
691 cs->cy = info.dwYSize;
693 else /* if no other hint from the app, pick 3/4 of the screen real estate */
696 SystemParametersInfoA( SPI_GETWORKAREA, 0, &r, 0);
697 cs->cx = (((r.right - r.left) * 3) / 4) - cs->x;
698 cs->cy = (((r.bottom - r.top) * 3) / 4) - cs->y;
705 /***********************************************************************
708 * Implementation of CreateWindowEx().
710 static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom,
711 WINDOWPROCTYPE type )
714 struct tagCLASS *classPtr;
717 HWND16 hwnd, hwndLinkAfter;
718 POINT maxSize, maxPos, minTrack, maxTrack;
723 LRESULT CALLBACK (*localSend32)(HWND, UINT, WPARAM, LPARAM);
725 TRACE("%s %s %08lx %08lx %d,%d %dx%d %04x %04x %08x %p\n",
726 (type == WIN_PROC_32W) ? debugres_w((LPWSTR)cs->lpszName) : debugres_a(cs->lpszName),
727 (type == WIN_PROC_32W) ? debugres_w((LPWSTR)cs->lpszClass) : debugres_a(cs->lpszClass),
728 cs->dwExStyle, cs->style, cs->x, cs->y, cs->cx, cs->cy,
729 cs->hwndParent, cs->hMenu, cs->hInstance, cs->lpCreateParams );
731 TRACE("winproc type is %d (%s)\n", type, (type == WIN_PROC_16) ? "WIN_PROC_16" :
732 ((type == WIN_PROC_32A) ? "WIN_PROC_32A" : "WIN_PROC_32W") );
734 /* Find the parent window */
738 /* Make sure parent is valid */
739 if (!IsWindow( cs->hwndParent ))
741 WARN("Bad parent %04x\n", cs->hwndParent );
744 } else if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
745 WARN("No parent for child window\n" );
746 return 0; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
749 /* Find the window class */
750 if (!(classPtr = CLASS_AddWindow( classAtom, cs->hInstance, type,
751 &wndExtra, &winproc, &clsStyle, &dce )))
753 WARN("Bad class '%s'\n", cs->lpszClass );
757 WIN_FixCoordinates(cs, &sw); /* fix default coordinates */
759 /* Create the window structure */
761 if (!(hwnd = USER_HEAP_ALLOC( sizeof(*wndPtr) + wndExtra - sizeof(wndPtr->wExtra) )))
763 TRACE("out of memory\n" );
767 /* Fill the window structure */
769 wndPtr = WIN_LockWndPtr((WND *) USER_HEAP_LIN_ADDR( hwnd ));
771 wndPtr->child = NULL;
773 if ((cs->style & WS_CHILD) && cs->hwndParent)
775 wndPtr->parent = WIN_FindWndPtr( cs->hwndParent );
776 wndPtr->owner = NULL;
777 WIN_ReleaseWndPtr(wndPtr->parent);
781 wndPtr->parent = pWndDesktop;
782 if (!cs->hwndParent || (cs->hwndParent == pWndDesktop->hwndSelf))
783 wndPtr->owner = NULL;
786 WND *tmpWnd = WIN_FindWndPtr(cs->hwndParent);
787 wndPtr->owner = WIN_GetTopParentPtr(tmpWnd);
788 WIN_ReleaseWndPtr(wndPtr->owner);
789 WIN_ReleaseWndPtr(tmpWnd);
794 wndPtr->pDriver = wndPtr->parent->pDriver;
795 wndPtr->pDriver->pInitialize(wndPtr);
797 wndPtr->class = classPtr;
798 wndPtr->winproc = winproc;
799 wndPtr->dwMagic = WND_MAGIC;
800 wndPtr->hwndSelf = hwnd;
801 wndPtr->hInstance = cs->hInstance;
803 wndPtr->hmemTaskQ = GetFastQueue16();
804 wndPtr->hrgnUpdate = 0;
806 wndPtr->hwndLastActive = hwnd;
807 wndPtr->dwStyle = cs->style & ~WS_VISIBLE;
808 wndPtr->dwExStyle = cs->dwExStyle;
809 wndPtr->clsStyle = clsStyle;
811 wndPtr->helpContext = 0;
812 wndPtr->flags = (type == WIN_PROC_16) ? 0 : WIN_ISWIN32;
813 wndPtr->pVScroll = NULL;
814 wndPtr->pHScroll = NULL;
815 wndPtr->pProp = NULL;
816 wndPtr->userdata = 0;
817 wndPtr->hSysMenu = (wndPtr->dwStyle & WS_SYSMENU)
818 ? MENU_GetSysMenu( hwnd, 0 ) : 0;
819 wndPtr->cbWndExtra = wndExtra;
820 wndPtr->irefCount = 1;
822 if (wndExtra) memset( wndPtr->wExtra, 0, wndExtra);
824 /* Call the WH_CBT hook */
826 hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
827 ? HWND_BOTTOM : HWND_TOP;
829 if (HOOK_IsHooked( WH_CBT ))
835 cbtc.hwndInsertAfter = hwndLinkAfter;
836 ret = (type == WIN_PROC_32W) ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, hwnd, (LPARAM)&cbtc)
837 : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, hwnd, (LPARAM)&cbtc);
840 TRACE("CBT-hook returned 0\n");
841 wndPtr->pDriver->pFinalize(wndPtr);
842 USER_HEAP_FREE( hwnd );
843 CLASS_RemoveWindow( classPtr );
849 /* Correct the window style */
851 if (!(cs->style & WS_CHILD))
853 wndPtr->dwStyle |= WS_CLIPSIBLINGS;
854 if (!(cs->style & WS_POPUP))
856 wndPtr->dwStyle |= WS_CAPTION;
857 wndPtr->flags |= WIN_NEED_SIZE;
861 /* Get class or window DC if needed */
863 if (clsStyle & CS_OWNDC) wndPtr->dce = DCE_AllocDCE(hwnd,DCE_WINDOW_DC);
864 else if (clsStyle & CS_CLASSDC) wndPtr->dce = dce;
865 else wndPtr->dce = NULL;
867 /* Initialize the dimensions before sending WM_GETMINMAXINFO */
869 wndPtr->rectWindow.left = cs->x;
870 wndPtr->rectWindow.top = cs->y;
871 wndPtr->rectWindow.right = cs->x + cs->cx;
872 wndPtr->rectWindow.bottom = cs->y + cs->cy;
873 wndPtr->rectClient = wndPtr->rectWindow;
875 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
877 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
879 WINPOS_GetMinMaxInfo( wndPtr, &maxSize, &maxPos, &minTrack, &maxTrack);
880 if (maxSize.x < cs->cx) cs->cx = maxSize.x;
881 if (maxSize.y < cs->cy) cs->cy = maxSize.y;
882 if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
883 if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
886 if (cs->cx < 0) cs->cx = 0;
887 if (cs->cy < 0) cs->cy = 0;
889 wndPtr->rectWindow.left = cs->x;
890 wndPtr->rectWindow.top = cs->y;
891 wndPtr->rectWindow.right = cs->x + cs->cx;
892 wndPtr->rectWindow.bottom = cs->y + cs->cy;
893 wndPtr->rectClient = wndPtr->rectWindow;
895 if(!wndPtr->pDriver->pCreateWindow(wndPtr, cs, type == WIN_PROC_32W))
901 /* Set the window menu */
903 if ((wndPtr->dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
905 if (cs->hMenu) SetMenu(hwnd, cs->hMenu);
908 LPCSTR menuName = (LPCSTR)GetClassLongA( hwnd, GCL_MENUNAME );
911 if (HIWORD(cs->hInstance))
912 cs->hMenu = LoadMenuA(cs->hInstance,menuName);
914 cs->hMenu = LoadMenu16(cs->hInstance,menuName);
916 if (cs->hMenu) SetMenu( hwnd, cs->hMenu );
920 else wndPtr->wIDmenu = (UINT)cs->hMenu;
922 /* Send the WM_CREATE message
923 * Perhaps we shouldn't allow width/height changes as well.
924 * See p327 in "Internals".
927 maxPos.x = wndPtr->rectWindow.left; maxPos.y = wndPtr->rectWindow.top;
929 localSend32 = (type == WIN_PROC_32W) ? SendMessageW : SendMessageA;
930 if( (*localSend32)( hwnd, WM_NCCREATE, 0, (LPARAM)cs) )
932 /* Insert the window in the linked list */
934 WIN_LinkWindow( hwnd, hwndLinkAfter );
936 WINPOS_SendNCCalcSize( hwnd, FALSE, &wndPtr->rectWindow,
937 NULL, NULL, 0, &wndPtr->rectClient );
938 OffsetRect(&wndPtr->rectWindow, maxPos.x - wndPtr->rectWindow.left,
939 maxPos.y - wndPtr->rectWindow.top);
940 if( ((*localSend32)( hwnd, WM_CREATE, 0, (LPARAM)cs )) != -1 )
942 /* Send the size messages */
944 if (!(wndPtr->flags & WIN_NEED_SIZE))
947 if (((wndPtr->rectClient.right-wndPtr->rectClient.left) <0)
948 ||((wndPtr->rectClient.bottom-wndPtr->rectClient.top)<0))
949 WARN("sending bogus WM_SIZE message 0x%08lx\n",
950 MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
951 wndPtr->rectClient.bottom-wndPtr->rectClient.top));
952 (*localSend32)( hwnd, WM_SIZE, SIZE_RESTORED,
953 MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
954 wndPtr->rectClient.bottom-wndPtr->rectClient.top));
955 (*localSend32)( hwnd, WM_MOVE, 0,
956 MAKELONG( wndPtr->rectClient.left,
957 wndPtr->rectClient.top ) );
960 /* Show the window, maximizing or minimizing if needed */
962 if (wndPtr->dwStyle & (WS_MINIMIZE | WS_MAXIMIZE))
965 UINT16 swFlag = (wndPtr->dwStyle & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
966 wndPtr->dwStyle &= ~(WS_MAXIMIZE | WS_MINIMIZE);
967 WINPOS_MinMaximize( wndPtr, swFlag, &newPos );
968 swFlag = ((wndPtr->dwStyle & WS_CHILD) || GetActiveWindow())
969 ? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED
970 : SWP_NOZORDER | SWP_FRAMECHANGED;
971 SetWindowPos( hwnd, 0, newPos.left, newPos.top,
972 newPos.right, newPos.bottom, swFlag );
975 if( (wndPtr->dwStyle & WS_CHILD) && !(wndPtr->dwExStyle & WS_EX_NOPARENTNOTIFY) )
977 /* Notify the parent window only */
979 SendMessageA( wndPtr->parent->hwndSelf, WM_PARENTNOTIFY,
980 MAKEWPARAM(WM_CREATE, wndPtr->wIDmenu), (LPARAM)hwnd );
981 if( !IsWindow(hwnd) )
988 if (cs->style & WS_VISIBLE) ShowWindow( hwnd, sw );
990 /* Call WH_SHELL hook */
992 if (!(wndPtr->dwStyle & WS_CHILD) && !wndPtr->owner)
993 HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
995 TRACE("created window %04x\n", hwnd);
999 WIN_UnlinkWindow( hwnd );
1002 /* Abort window creation */
1004 WARN("aborted by WM_xxCREATE!\n");
1005 WIN_ReleaseWndPtr(WIN_DestroyWindow( wndPtr ));
1006 CLASS_RemoveWindow( classPtr );
1009 WIN_ReleaseWndPtr(wndPtr);
1015 /***********************************************************************
1016 * CreateWindow (USER.41)
1018 HWND16 WINAPI CreateWindow16( LPCSTR className, LPCSTR windowName,
1019 DWORD style, INT16 x, INT16 y, INT16 width,
1020 INT16 height, HWND16 parent, HMENU16 menu,
1021 HINSTANCE16 instance, LPVOID data )
1023 return CreateWindowEx16( 0, className, windowName, style,
1024 x, y, width, height, parent, menu, instance, data );
1028 /***********************************************************************
1029 * CreateWindowEx (USER.452)
1031 HWND16 WINAPI CreateWindowEx16( DWORD exStyle, LPCSTR className,
1032 LPCSTR windowName, DWORD style, INT16 x,
1033 INT16 y, INT16 width, INT16 height,
1034 HWND16 parent, HMENU16 menu,
1035 HINSTANCE16 instance, LPVOID data )
1041 /* Find the class atom */
1043 if (HIWORD(className))
1045 if (!(classAtom = GlobalFindAtomA( className )))
1047 ERR( "bad class name %s\n", debugres_a(className) );
1053 classAtom = LOWORD(className);
1054 if (!GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) ))
1056 ERR( "bad atom %x\n", classAtom);
1062 /* Fix the coordinates */
1064 cs.x = (x == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)x;
1065 cs.y = (y == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)y;
1066 cs.cx = (width == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)width;
1067 cs.cy = (height == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)height;
1069 /* Create the window */
1071 cs.lpCreateParams = data;
1072 cs.hInstance = (HINSTANCE)instance;
1073 cs.hMenu = (HMENU)menu;
1074 cs.hwndParent = (HWND)parent;
1076 cs.lpszName = windowName;
1077 cs.lpszClass = className;
1078 cs.dwExStyle = exStyle;
1080 return WIN_CreateWindowEx( &cs, classAtom, WIN_PROC_16 );
1084 /***********************************************************************
1085 * CreateWindowExA (USER32.@)
1087 HWND WINAPI CreateWindowExA( DWORD exStyle, LPCSTR className,
1088 LPCSTR windowName, DWORD style, INT x,
1089 INT y, INT width, INT height,
1090 HWND parent, HMENU menu,
1091 HINSTANCE instance, LPVOID data )
1098 instance=GetModuleHandleA(NULL);
1100 if(exStyle & WS_EX_MDICHILD)
1101 return CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
1103 /* Find the class atom */
1105 if (HIWORD(className))
1107 if (!(classAtom = GlobalFindAtomA( className )))
1109 ERR( "bad class name %s\n", debugres_a(className) );
1115 classAtom = LOWORD(className);
1116 if (!GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) ))
1118 ERR( "bad atom %x\n", classAtom);
1124 /* Create the window */
1126 cs.lpCreateParams = data;
1127 cs.hInstance = instance;
1129 cs.hwndParent = parent;
1135 cs.lpszName = windowName;
1136 cs.lpszClass = className;
1137 cs.dwExStyle = exStyle;
1139 return WIN_CreateWindowEx( &cs, classAtom, WIN_PROC_32A );
1143 /***********************************************************************
1144 * CreateWindowExW (USER32.@)
1146 HWND WINAPI CreateWindowExW( DWORD exStyle, LPCWSTR className,
1147 LPCWSTR windowName, DWORD style, INT x,
1148 INT y, INT width, INT height,
1149 HWND parent, HMENU menu,
1150 HINSTANCE instance, LPVOID data )
1157 instance=GetModuleHandleA(NULL);
1159 if(exStyle & WS_EX_MDICHILD)
1160 return CreateMDIWindowW(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
1162 /* Find the class atom */
1164 if (HIWORD(className))
1166 if (!(classAtom = GlobalFindAtomW( className )))
1168 ERR( "bad class name %s\n", debugres_w(className) );
1174 classAtom = LOWORD(className);
1175 if (!GlobalGetAtomNameW( classAtom, buffer, sizeof(buffer)/sizeof(WCHAR) ))
1177 ERR( "bad atom %x\n", classAtom);
1183 /* Create the window */
1185 cs.lpCreateParams = data;
1186 cs.hInstance = instance;
1188 cs.hwndParent = parent;
1194 cs.lpszName = windowName;
1195 cs.lpszClass = className;
1196 cs.dwExStyle = exStyle;
1198 /* Note: we rely on the fact that CREATESTRUCTA and */
1199 /* CREATESTRUCTW have the same layout. */
1200 return WIN_CreateWindowEx( (CREATESTRUCTA *)&cs, classAtom, WIN_PROC_32W );
1203 /***********************************************************************
1204 * WIN_SendDestroyMsg
1206 static void WIN_SendDestroyMsg( WND* pWnd )
1208 if( CARET_GetHwnd() == pWnd->hwndSelf ) DestroyCaret();
1209 USER_Driver.pResetSelectionOwner( pWnd, TRUE );
1212 * Send the WM_DESTROY to the window.
1214 SendMessageA( pWnd->hwndSelf, WM_DESTROY, 0, 0);
1217 * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
1218 * make sure that the window still exists when we come back.
1220 if (IsWindow(pWnd->hwndSelf))
1222 HWND* pWndArray = NULL;
1227 * Now, if the window has kids, we have to send WM_DESTROY messages
1228 * recursively to it's kids. It seems that those calls can also
1229 * trigger re-entrant calls to DestroyWindow for the kids so we must
1230 * protect against corruption of the list of siblings. We first build
1231 * a list of HWNDs representing all the kids.
1233 pChild = WIN_LockWndPtr(pWnd->child);
1237 WIN_UpdateWndPtr(&pChild,pChild->next);
1241 * If there are no kids, we're done.
1246 pWndArray = HeapAlloc(GetProcessHeap(), 0, nKidCount*sizeof(HWND));
1251 if (pWndArray==NULL)
1255 * Now, enumerate all the kids in a list, since we wait to make the SendMessage
1256 * call, our linked list of siblings should be safe.
1259 pChild = WIN_LockWndPtr(pWnd->child);
1262 pWndArray[nKidCount] = pChild->hwndSelf;
1264 WIN_UpdateWndPtr(&pChild,pChild->next);
1268 * Now that we have a list, go through that list again and send the destroy
1269 * message to those windows. We are using the HWND to retrieve the
1270 * WND pointer so we are effectively checking that all the kid windows are
1271 * still valid before sending the message.
1275 pChild = WIN_FindWndPtr(pWndArray[--nKidCount]);
1279 WIN_SendDestroyMsg( pChild );
1280 WIN_ReleaseWndPtr(pChild);
1287 HeapFree(GetProcessHeap(), 0, pWndArray);
1290 WARN("\tdestroyed itself while in WM_DESTROY!\n");
1294 /***********************************************************************
1295 * DestroyWindow (USER.53)
1297 BOOL16 WINAPI DestroyWindow16( HWND16 hwnd )
1299 return DestroyWindow(hwnd);
1303 /***********************************************************************
1304 * DestroyWindow (USER32.@)
1306 BOOL WINAPI DestroyWindow( HWND hwnd )
1311 BOOL bFocusSet = FALSE;
1313 TRACE("(%04x)\n", hwnd);
1315 /* Initialization */
1317 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
1318 if (wndPtr == pWndDesktop)
1320 retvalue = FALSE; /* Can't destroy desktop */
1324 /* Look whether the focus is within the tree of windows we will
1328 while (h && (GetWindowLongA(h,GWL_STYLE) & WS_CHILD))
1332 SetFocus(GetParent(h));
1338 /* If the focus is on the window we will destroy and it has no parent,
1339 * set the focus to 0.
1341 if (! bFocusSet && (h == hwnd))
1343 if (!(GetWindowLongA(h,GWL_STYLE) & WS_CHILD))
1349 if( HOOK_CallHooks16( WH_CBT, HCBT_DESTROYWND, hwnd, 0L) )
1355 if (!(wndPtr->dwStyle & WS_CHILD) && !wndPtr->owner)
1357 HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWDESTROYED, hwnd, 0L );
1358 /* FIXME: clean up palette - see "Internals" p.352 */
1361 if( !QUEUE_IsExitingQueue(wndPtr->hmemTaskQ) )
1362 if( wndPtr->dwStyle & WS_CHILD && !(wndPtr->dwExStyle & WS_EX_NOPARENTNOTIFY) )
1364 /* Notify the parent window only */
1365 SendMessageA( wndPtr->parent->hwndSelf, WM_PARENTNOTIFY,
1366 MAKEWPARAM(WM_DESTROY, wndPtr->wIDmenu), (LPARAM)hwnd );
1367 if( !IsWindow(hwnd) )
1374 USER_Driver.pResetSelectionOwner( wndPtr, FALSE ); /* before the window is unmapped */
1376 /* Hide the window */
1378 if (wndPtr->dwStyle & WS_VISIBLE)
1380 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW |
1381 SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|
1382 ((QUEUE_IsExitingQueue(wndPtr->hmemTaskQ))?SWP_DEFERERASE:0) );
1383 if (!IsWindow(hwnd))
1390 /* Recursively destroy owned windows */
1392 if( !(wndPtr->dwStyle & WS_CHILD) )
1394 /* make sure top menu popup doesn't get destroyed */
1395 MENU_PatchResidentPopup( (HQUEUE16)0xFFFF, wndPtr );
1399 WND *siblingPtr = WIN_LockWndPtr(wndPtr->parent->child); /* First sibling */
1402 if (siblingPtr->owner == wndPtr)
1404 if (siblingPtr->hmemTaskQ == wndPtr->hmemTaskQ)
1407 siblingPtr->owner = NULL;
1409 WIN_UpdateWndPtr(&siblingPtr,siblingPtr->next);
1413 DestroyWindow( siblingPtr->hwndSelf );
1414 WIN_ReleaseWndPtr(siblingPtr);
1419 if( !Options.managed || EVENT_CheckFocus() )
1420 WINPOS_ActivateOtherWindow(wndPtr);
1422 if( wndPtr->owner &&
1423 wndPtr->owner->hwndLastActive == wndPtr->hwndSelf )
1424 wndPtr->owner->hwndLastActive = wndPtr->owner->hwndSelf;
1427 /* Send destroy messages */
1429 WIN_SendDestroyMsg( wndPtr );
1430 if (!IsWindow(hwnd))
1436 /* Unlink now so we won't bother with the children later on */
1438 if( wndPtr->parent ) WIN_UnlinkWindow(hwnd);
1440 /* Destroy the window storage */
1442 WIN_ReleaseWndPtr(WIN_DestroyWindow( wndPtr ));
1445 WIN_ReleaseWndPtr(wndPtr);
1450 /***********************************************************************
1451 * CloseWindow (USER.43)
1453 BOOL16 WINAPI CloseWindow16( HWND16 hwnd )
1455 return CloseWindow( hwnd );
1459 /***********************************************************************
1460 * CloseWindow (USER32.@)
1462 BOOL WINAPI CloseWindow( HWND hwnd )
1464 WND * wndPtr = WIN_FindWndPtr( hwnd );
1467 if (!wndPtr || (wndPtr->dwStyle & WS_CHILD))
1472 ShowWindow( hwnd, SW_MINIMIZE );
1475 WIN_ReleaseWndPtr(wndPtr);
1481 /***********************************************************************
1482 * OpenIcon (USER.44)
1484 BOOL16 WINAPI OpenIcon16( HWND16 hwnd )
1486 return OpenIcon( hwnd );
1490 /***********************************************************************
1491 * OpenIcon (USER32.@)
1493 BOOL WINAPI OpenIcon( HWND hwnd )
1495 if (!IsIconic( hwnd )) return FALSE;
1496 ShowWindow( hwnd, SW_SHOWNORMAL );
1501 /***********************************************************************
1504 * Implementation of FindWindow() and FindWindowEx().
1506 static HWND WIN_FindWindow( HWND parent, HWND child, ATOM className,
1514 if (!(pWnd = WIN_FindWndPtr( child ))) return 0;
1517 if (!pWnd->parent || (pWnd->parent->hwndSelf != parent))
1523 else if (pWnd->parent != pWndDesktop)
1528 WIN_UpdateWndPtr(&pWnd,pWnd->next);
1532 if (!(pWnd = parent ? WIN_FindWndPtr(parent) : WIN_LockWndPtr(pWndDesktop)))
1537 WIN_UpdateWndPtr(&pWnd,pWnd->child);
1545 for ( ; pWnd ; WIN_UpdateWndPtr(&pWnd,pWnd->next))
1547 if (className && (GetClassWord(pWnd->hwndSelf, GCW_ATOM) != className))
1548 continue; /* Not the right class */
1550 /* Now check the title */
1554 retvalue = pWnd->hwndSelf;
1557 if (pWnd->text && !strcmpW( pWnd->text, title ))
1559 retvalue = pWnd->hwndSelf;
1564 /* In this case we need to check whether other processes
1565 own a window with the given paramters on the Desktop,
1566 but we don't, so let's at least warn about it */
1567 FIXME("Returning 0 without checking other processes\n");
1569 WIN_ReleaseWndPtr(pWnd);
1575 /***********************************************************************
1576 * FindWindow (USER.50)
1578 HWND16 WINAPI FindWindow16( LPCSTR className, LPCSTR title )
1580 return FindWindowA( className, title );
1584 /***********************************************************************
1585 * FindWindowEx (USER.427)
1587 HWND16 WINAPI FindWindowEx16( HWND16 parent, HWND16 child, LPCSTR className, LPCSTR title )
1589 return FindWindowExA( parent, child, className, title );
1593 /***********************************************************************
1594 * FindWindowA (USER32.@)
1596 HWND WINAPI FindWindowA( LPCSTR className, LPCSTR title )
1598 HWND ret = FindWindowExA( 0, 0, className, title );
1599 if (!ret) SetLastError (ERROR_CANNOT_FIND_WND_CLASS);
1604 /***********************************************************************
1605 * FindWindowExA (USER32.@)
1607 HWND WINAPI FindWindowExA( HWND parent, HWND child,
1608 LPCSTR className, LPCSTR title )
1616 /* If the atom doesn't exist, then no class */
1617 /* with this name exists either. */
1618 if (!(atom = GlobalFindAtomA( className )))
1620 SetLastError (ERROR_CANNOT_FIND_WND_CLASS);
1625 buffer = HEAP_strdupAtoW( GetProcessHeap(), 0, title );
1626 hwnd = WIN_FindWindow( parent, child, atom, buffer );
1627 HeapFree( GetProcessHeap(), 0, buffer );
1632 /***********************************************************************
1633 * FindWindowExW (USER32.@)
1635 HWND WINAPI FindWindowExW( HWND parent, HWND child,
1636 LPCWSTR className, LPCWSTR title )
1642 /* If the atom doesn't exist, then no class */
1643 /* with this name exists either. */
1644 if (!(atom = GlobalFindAtomW( className )))
1646 SetLastError (ERROR_CANNOT_FIND_WND_CLASS);
1650 return WIN_FindWindow( parent, child, atom, title );
1654 /***********************************************************************
1655 * FindWindowW (USER32.@)
1657 HWND WINAPI FindWindowW( LPCWSTR className, LPCWSTR title )
1659 return FindWindowExW( 0, 0, className, title );
1663 /**********************************************************************
1665 * returns a locked pointer
1667 WND *WIN_GetDesktop(void)
1669 return WIN_LockWndPtr(pWndDesktop);
1671 /**********************************************************************
1672 * WIN_ReleaseDesktop
1673 * unlock the desktop pointer
1675 void WIN_ReleaseDesktop(void)
1677 WIN_ReleaseWndPtr(pWndDesktop);
1681 /**********************************************************************
1682 * GetDesktopWindow (USER.286)
1684 HWND16 WINAPI GetDesktopWindow16(void)
1686 return (HWND16)pWndDesktop->hwndSelf;
1690 /**********************************************************************
1691 * GetDesktopWindow (USER32.@)
1693 HWND WINAPI GetDesktopWindow(void)
1695 if (pWndDesktop) return pWndDesktop->hwndSelf;
1696 ERR( "You need the -desktop option when running with native USER\n" );
1702 /**********************************************************************
1703 * GetDesktopHwnd (USER.278)
1705 * Exactly the same thing as GetDesktopWindow(), but not documented.
1706 * Don't ask me why...
1708 HWND16 WINAPI GetDesktopHwnd16(void)
1710 return (HWND16)pWndDesktop->hwndSelf;
1714 /*******************************************************************
1715 * EnableWindow (USER.34)
1717 BOOL16 WINAPI EnableWindow16( HWND16 hwnd, BOOL16 enable )
1719 return EnableWindow( hwnd, enable );
1723 /*******************************************************************
1724 * EnableWindow (USER32.@)
1726 BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable )
1731 TRACE("EnableWindow32: ( %x, %d )\n", hwnd, enable);
1733 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
1734 if (enable && (wndPtr->dwStyle & WS_DISABLED))
1737 wndPtr->dwStyle &= ~WS_DISABLED;
1739 if( wndPtr->flags & WIN_NATIVE )
1740 wndPtr->pDriver->pSetHostAttr( wndPtr, HAK_ACCEPTFOCUS, TRUE );
1742 SendMessageA( hwnd, WM_ENABLE, TRUE, 0 );
1746 else if (!enable && !(wndPtr->dwStyle & WS_DISABLED))
1748 SendMessageA( wndPtr->hwndSelf, WM_CANCELMODE, 0, 0);
1750 /* Disable window */
1751 wndPtr->dwStyle |= WS_DISABLED;
1753 if( wndPtr->flags & WIN_NATIVE )
1754 wndPtr->pDriver->pSetHostAttr( wndPtr, HAK_ACCEPTFOCUS, FALSE );
1756 if (hwnd == GetFocus())
1758 SetFocus( 0 ); /* A disabled window can't have the focus */
1760 if (hwnd == GetCapture())
1762 ReleaseCapture(); /* A disabled window can't capture the mouse */
1764 SendMessageA( hwnd, WM_ENABLE, FALSE, 0 );
1768 retvalue = ((wndPtr->dwStyle & WS_DISABLED) != 0);
1770 WIN_ReleaseWndPtr(wndPtr);
1775 /***********************************************************************
1776 * IsWindowEnabled (USER.35)
1778 BOOL16 WINAPI IsWindowEnabled16(HWND16 hWnd)
1780 return IsWindowEnabled(hWnd);
1784 /***********************************************************************
1785 * IsWindowEnabled (USER32.@)
1787 BOOL WINAPI IsWindowEnabled(HWND hWnd)
1792 if (!(wndPtr = WIN_FindWndPtr(hWnd))) return FALSE;
1793 retvalue = !(wndPtr->dwStyle & WS_DISABLED);
1794 WIN_ReleaseWndPtr(wndPtr);
1800 /***********************************************************************
1801 * IsWindowUnicode (USER32.@)
1803 BOOL WINAPI IsWindowUnicode( HWND hwnd )
1808 if (!(wndPtr = WIN_FindWndPtr(hwnd))) return FALSE;
1809 retvalue = (WINPROC_GetProcType( wndPtr->winproc ) == WIN_PROC_32W);
1810 WIN_ReleaseWndPtr(wndPtr);
1815 /**********************************************************************
1816 * GetWindowWord (USER.133)
1818 WORD WINAPI GetWindowWord16( HWND16 hwnd, INT16 offset )
1820 return GetWindowWord( hwnd, offset );
1824 /**********************************************************************
1825 * GetWindowWord (USER32.@)
1827 WORD WINAPI GetWindowWord( HWND hwnd, INT offset )
1830 WND * wndPtr = WIN_FindWndPtr( hwnd );
1831 if (!wndPtr) return 0;
1834 if (offset + sizeof(WORD) > wndPtr->cbWndExtra)
1836 WARN("Invalid offset %d\n", offset );
1840 retvalue = *(WORD *)(((char *)wndPtr->wExtra) + offset);
1846 if (HIWORD(wndPtr->wIDmenu))
1847 WARN("GWW_ID: discards high bits of 0x%08x!\n",
1849 retvalue = (WORD)wndPtr->wIDmenu;
1851 case GWW_HWNDPARENT:
1852 retvalue = GetParent(hwnd);
1855 if (HIWORD(wndPtr->hInstance))
1856 WARN("GWW_HINSTANCE: discards high bits of 0x%08x!\n",
1858 retvalue = (WORD)wndPtr->hInstance;
1861 WARN("Invalid offset %d\n", offset );
1866 WIN_ReleaseWndPtr(wndPtr);
1870 /**********************************************************************
1871 * SetWindowWord (USER.134)
1873 WORD WINAPI SetWindowWord16( HWND16 hwnd, INT16 offset, WORD newval )
1875 return SetWindowWord( hwnd, offset, newval );
1879 /**********************************************************************
1880 * SetWindowWord (USER32.@)
1882 WORD WINAPI SetWindowWord( HWND hwnd, INT offset, WORD newval )
1885 WND * wndPtr = WIN_FindWndPtr( hwnd );
1886 if (!wndPtr) return 0;
1889 if (offset + sizeof(WORD) > wndPtr->cbWndExtra)
1891 WARN("Invalid offset %d\n", offset );
1895 ptr = (WORD *)(((char *)wndPtr->wExtra) + offset);
1899 case GWW_ID: ptr = (WORD *)&wndPtr->wIDmenu; break;
1900 case GWW_HINSTANCE: ptr = (WORD *)&wndPtr->hInstance; break;
1901 case GWW_HWNDPARENT: retval = SetParent( hwnd, newval );
1904 WARN("Invalid offset %d\n", offset );
1911 WIN_ReleaseWndPtr(wndPtr);
1916 /**********************************************************************
1919 * Helper function for GetWindowLong().
1921 static LONG WIN_GetWindowLong( HWND hwnd, INT offset, WINDOWPROCTYPE type )
1924 WND * wndPtr = WIN_FindWndPtr( hwnd );
1925 if (!wndPtr) return 0;
1928 if (offset + sizeof(LONG) > wndPtr->cbWndExtra)
1930 WARN("Invalid offset %d\n", offset );
1934 retvalue = *(LONG *)(((char *)wndPtr->wExtra) + offset);
1935 /* Special case for dialog window procedure */
1936 if ((offset == DWL_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG))
1938 retvalue = (LONG)WINPROC_GetProc( (HWINDOWPROC)retvalue, type );
1945 case GWL_USERDATA: retvalue = wndPtr->userdata;
1947 case GWL_STYLE: retvalue = wndPtr->dwStyle;
1949 case GWL_EXSTYLE: retvalue = wndPtr->dwExStyle;
1951 case GWL_ID: retvalue = (LONG)wndPtr->wIDmenu;
1953 case GWL_WNDPROC: retvalue = (LONG)WINPROC_GetProc( wndPtr->winproc,
1956 case GWL_HWNDPARENT: retvalue = GetParent(hwnd);
1958 case GWL_HINSTANCE: retvalue = wndPtr->hInstance;
1961 WARN("Unknown offset %d\n", offset );
1965 WIN_ReleaseWndPtr(wndPtr);
1970 /**********************************************************************
1973 * Helper function for SetWindowLong().
1975 * 0 is the failure code. However, in the case of failure SetLastError
1976 * must be set to distinguish between a 0 return value and a failure.
1978 * FIXME: The error values for SetLastError may not be right. Can
1979 * someone check with the real thing?
1981 static LONG WIN_SetWindowLong( HWND hwnd, INT offset, LONG newval,
1982 WINDOWPROCTYPE type )
1985 WND * wndPtr = WIN_FindWndPtr( hwnd );
1988 TRACE("%x=%p %x %lx %x\n",hwnd, wndPtr, offset, newval, type);
1992 /* Is this the right error? */
1993 SetLastError( ERROR_INVALID_WINDOW_HANDLE );
1999 if (offset + sizeof(LONG) > wndPtr->cbWndExtra)
2001 WARN("Invalid offset %d\n", offset );
2003 /* Is this the right error? */
2004 SetLastError( ERROR_OUTOFMEMORY );
2009 ptr = (LONG *)(((char *)wndPtr->wExtra) + offset);
2010 /* Special case for dialog window procedure */
2011 if ((offset == DWL_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG))
2013 retval = (LONG)WINPROC_GetProc( (HWINDOWPROC)*ptr, type );
2014 WINPROC_SetProc( (HWINDOWPROC *)ptr, (WNDPROC16)newval,
2015 type, WIN_PROC_WINDOW );
2022 ptr = (DWORD*)&wndPtr->wIDmenu;
2025 retval = SetWindowWord( hwnd, offset, newval );
2028 retval = (LONG)WINPROC_GetProc( wndPtr->winproc, type );
2029 WINPROC_SetProc( &wndPtr->winproc, (WNDPROC16)newval,
2030 type, WIN_PROC_WINDOW );
2033 style.styleOld = wndPtr->dwStyle;
2034 style.styleNew = newval;
2035 if (wndPtr->flags & WIN_ISWIN32)
2036 SendMessageA(hwnd,WM_STYLECHANGING,GWL_STYLE,(LPARAM)&style);
2037 wndPtr->dwStyle = style.styleNew;
2038 if (wndPtr->flags & WIN_ISWIN32)
2039 SendMessageA(hwnd,WM_STYLECHANGED,GWL_STYLE,(LPARAM)&style);
2040 retval = style.styleOld;
2044 ptr = &wndPtr->userdata;
2047 style.styleOld = wndPtr->dwExStyle;
2048 style.styleNew = newval;
2049 if (wndPtr->flags & WIN_ISWIN32)
2050 SendMessageA(hwnd,WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&style);
2051 wndPtr->dwExStyle = newval;
2052 if (wndPtr->flags & WIN_ISWIN32)
2053 SendMessageA(hwnd,WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&style);
2054 retval = style.styleOld;
2058 WARN("Invalid offset %d\n", offset );
2060 /* Don't think this is right error but it should do */
2061 SetLastError( ERROR_OUTOFMEMORY );
2069 WIN_ReleaseWndPtr(wndPtr);
2074 /**********************************************************************
2075 * GetWindowLong (USER.135)
2077 LONG WINAPI GetWindowLong16( HWND16 hwnd, INT16 offset )
2079 return WIN_GetWindowLong( (HWND)hwnd, offset, WIN_PROC_16 );
2083 /**********************************************************************
2084 * GetWindowLongA (USER32.@)
2086 LONG WINAPI GetWindowLongA( HWND hwnd, INT offset )
2088 return WIN_GetWindowLong( hwnd, offset, WIN_PROC_32A );
2092 /**********************************************************************
2093 * GetWindowLongW (USER32.@)
2095 LONG WINAPI GetWindowLongW( HWND hwnd, INT offset )
2097 return WIN_GetWindowLong( hwnd, offset, WIN_PROC_32W );
2101 /**********************************************************************
2102 * SetWindowLong (USER.136)
2104 LONG WINAPI SetWindowLong16( HWND16 hwnd, INT16 offset, LONG newval )
2106 return WIN_SetWindowLong( hwnd, offset, newval, WIN_PROC_16 );
2110 /**********************************************************************
2111 * SetWindowLongA (USER32.@)
2113 LONG WINAPI SetWindowLongA( HWND hwnd, INT offset, LONG newval )
2115 return WIN_SetWindowLong( hwnd, offset, newval, WIN_PROC_32A );
2119 /**********************************************************************
2120 * SetWindowLongW (USER32.@) Set window attribute
2122 * SetWindowLong() alters one of a window's attributes or sets a 32-bit (long)
2123 * value in a window's extra memory.
2125 * The _hwnd_ parameter specifies the window. is the handle to a
2126 * window that has extra memory. The _newval_ parameter contains the
2127 * new attribute or extra memory value. If positive, the _offset_
2128 * parameter is the byte-addressed location in the window's extra
2129 * memory to set. If negative, _offset_ specifies the window
2130 * attribute to set, and should be one of the following values:
2132 * GWL_EXSTYLE The window's extended window style
2134 * GWL_STYLE The window's window style.
2136 * GWL_WNDPROC Pointer to the window's window procedure.
2138 * GWL_HINSTANCE The window's pplication instance handle.
2140 * GWL_ID The window's identifier.
2142 * GWL_USERDATA The window's user-specified data.
2144 * If the window is a dialog box, the _offset_ parameter can be one of
2145 * the following values:
2147 * DWL_DLGPROC The address of the window's dialog box procedure.
2149 * DWL_MSGRESULT The return value of a message
2150 * that the dialog box procedure processed.
2152 * DWL_USER Application specific information.
2156 * If successful, returns the previous value located at _offset_. Otherwise,
2161 * Extra memory for a window class is specified by a nonzero cbWndExtra
2162 * parameter of the WNDCLASS structure passed to RegisterClass() at the
2163 * time of class creation.
2165 * Using GWL_WNDPROC to set a new window procedure effectively creates
2166 * a window subclass. Use CallWindowProc() in the new windows procedure
2167 * to pass messages to the superclass's window procedure.
2169 * The user data is reserved for use by the application which created
2172 * Do not use GWL_STYLE to change the window's WS_DISABLE style;
2173 * instead, call the EnableWindow() function to change the window's
2176 * Do not use GWL_HWNDPARENT to reset the window's parent, use
2177 * SetParent() instead.
2180 * When offset is GWL_STYLE and the calling app's ver is 4.0,
2181 * it sends WM_STYLECHANGING before changing the settings
2182 * and WM_STYLECHANGED afterwards.
2183 * App ver 4.0 can't use SetWindowLong to change WS_EX_TOPMOST.
2187 * GWL_STYLE does not dispatch WM_STYLE... messages.
2194 LONG WINAPI SetWindowLongW(
2195 HWND hwnd, /* [in] window to alter */
2196 INT offset, /* [in] offset, in bytes, of location to alter */
2197 LONG newval /* [in] new value of location */
2199 return WIN_SetWindowLong( hwnd, offset, newval, WIN_PROC_32W );
2203 /*******************************************************************
2204 * GetWindowText (USER.36)
2206 INT16 WINAPI GetWindowText16( HWND16 hwnd, SEGPTR lpString, INT16 nMaxCount )
2208 return (INT16)SendMessage16(hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString);
2212 /*******************************************************************
2213 * GetWindowTextA (USER32.@)
2215 INT WINAPI GetWindowTextA( HWND hwnd, LPSTR lpString, INT nMaxCount )
2217 return (INT)SendMessageA( hwnd, WM_GETTEXT, nMaxCount,
2221 /*******************************************************************
2222 * InternalGetWindowText (USER32.@)
2224 INT WINAPI InternalGetWindowText(HWND hwnd,LPWSTR lpString,INT nMaxCount )
2226 FIXME("(0x%08x,%p,0x%x),stub!\n",hwnd,lpString,nMaxCount);
2227 return GetWindowTextW(hwnd,lpString,nMaxCount);
2231 /*******************************************************************
2232 * GetWindowTextW (USER32.@)
2234 INT WINAPI GetWindowTextW( HWND hwnd, LPWSTR lpString, INT nMaxCount )
2236 return (INT)SendMessageW( hwnd, WM_GETTEXT, nMaxCount,
2241 /*******************************************************************
2242 * SetWindowText (USER.37)
2244 BOOL16 WINAPI SetWindowText16( HWND16 hwnd, SEGPTR lpString )
2246 return (BOOL16)SendMessage16( hwnd, WM_SETTEXT, 0, (LPARAM)lpString );
2250 /*******************************************************************
2251 * SetWindowText (USER32.@)
2253 BOOL WINAPI SetWindowTextA( HWND hwnd, LPCSTR lpString )
2255 return (BOOL)SendMessageA( hwnd, WM_SETTEXT, 0, (LPARAM)lpString );
2259 /*******************************************************************
2260 * SetWindowTextW (USER32.@)
2262 BOOL WINAPI SetWindowTextW( HWND hwnd, LPCWSTR lpString )
2264 return (BOOL)SendMessageW( hwnd, WM_SETTEXT, 0, (LPARAM)lpString );
2268 /*******************************************************************
2269 * GetWindowTextLength (USER.38)
2271 INT16 WINAPI GetWindowTextLength16( HWND16 hwnd )
2273 return (INT16)SendMessage16( hwnd, WM_GETTEXTLENGTH, 0, 0 );
2277 /*******************************************************************
2278 * GetWindowTextLengthA (USER32.@)
2280 INT WINAPI GetWindowTextLengthA( HWND hwnd )
2282 return SendMessageA( hwnd, WM_GETTEXTLENGTH, 0, 0 );
2285 /*******************************************************************
2286 * GetWindowTextLengthW (USER32.@)
2288 INT WINAPI GetWindowTextLengthW( HWND hwnd )
2290 return SendMessageW( hwnd, WM_GETTEXTLENGTH, 0, 0 );
2294 /*******************************************************************
2295 * IsWindow (USER.47)
2297 BOOL16 WINAPI IsWindow16( HWND16 hwnd )
2299 CURRENT_STACK16->es = USER_HeapSel;
2300 return IsWindow( hwnd );
2304 /*******************************************************************
2305 * IsWindow (USER32.@)
2307 BOOL WINAPI IsWindow( HWND hwnd )
2312 if(!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
2313 retvalue = (wndPtr->dwMagic == WND_MAGIC);
2314 WIN_ReleaseWndPtr(wndPtr);
2320 /*****************************************************************
2321 * GetParent (USER.46)
2323 HWND16 WINAPI GetParent16( HWND16 hwnd )
2325 return (HWND16)GetParent( hwnd );
2329 /*****************************************************************
2330 * GetParent (USER32.@)
2332 HWND WINAPI GetParent( HWND hwnd )
2337 if(!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
2338 if ((!(wndPtr->dwStyle & (WS_POPUP|WS_CHILD))))
2341 WIN_UpdateWndPtr(&wndPtr,((wndPtr->dwStyle & WS_CHILD) ? wndPtr->parent : wndPtr->owner));
2343 retvalue = wndPtr->hwndSelf;
2346 WIN_ReleaseWndPtr(wndPtr);
2351 /*****************************************************************
2354 * Get the top-level parent for a child window.
2355 * returns a locked pointer
2357 WND* WIN_GetTopParentPtr( WND* pWnd )
2359 WND *tmpWnd = WIN_LockWndPtr(pWnd);
2361 while( tmpWnd && (tmpWnd->dwStyle & WS_CHILD))
2363 WIN_UpdateWndPtr(&tmpWnd,tmpWnd->parent);
2368 /*****************************************************************
2371 * Get the top-level parent for a child window.
2373 HWND WIN_GetTopParent( HWND hwnd )
2376 WND *tmpPtr = WIN_FindWndPtr(hwnd);
2377 WND *wndPtr = WIN_GetTopParentPtr (tmpPtr );
2379 retvalue = wndPtr ? wndPtr->hwndSelf : 0;
2380 WIN_ReleaseWndPtr(tmpPtr);
2381 WIN_ReleaseWndPtr(wndPtr);
2386 /*****************************************************************
2387 * SetParent (USER.233)
2389 HWND16 WINAPI SetParent16( HWND16 hwndChild, HWND16 hwndNewParent )
2391 return SetParent( hwndChild, hwndNewParent );
2395 /*****************************************************************
2396 * SetParent (USER32.@)
2398 HWND WINAPI SetParent( HWND hwndChild, HWND hwndNewParent )
2407 if(!(wndPtr = WIN_FindWndPtr(hwndChild))) return 0;
2409 dwStyle = wndPtr->dwStyle;
2411 pWndNewParent = hwndNewParent ? WIN_FindWndPtr(hwndNewParent)
2412 : WIN_LockWndPtr(pWndDesktop);
2414 /* Windows hides the window first, then shows it again
2415 * including the WM_SHOWWINDOW messages and all */
2416 if (dwStyle & WS_VISIBLE)
2417 ShowWindow( hwndChild, SW_HIDE );
2419 pWndOldParent = WIN_LockWndPtr((*wndPtr->pDriver->pSetParent)(wndPtr, pWndNewParent));
2421 /* SetParent additionally needs to make hwndChild the topmost window
2422 in the x-order and send the expected WM_WINDOWPOSCHANGING and
2423 WM_WINDOWPOSCHANGED notification messages.
2425 SetWindowPos( hwndChild, HWND_TOPMOST, 0, 0, 0, 0,
2426 SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|((dwStyle & WS_VISIBLE)?SWP_SHOWWINDOW:0));
2427 /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
2428 * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */
2430 retvalue = pWndOldParent?pWndOldParent->hwndSelf:0;
2432 WIN_ReleaseWndPtr(pWndOldParent);
2433 WIN_ReleaseWndPtr(pWndNewParent);
2434 WIN_ReleaseWndPtr(wndPtr);
2440 /*******************************************************************
2443 BOOL16 WINAPI IsChild16( HWND16 parent, HWND16 child )
2445 return IsChild(parent,child);
2449 /*******************************************************************
2450 * IsChild (USER32.@)
2452 BOOL WINAPI IsChild( HWND parent, HWND child )
2454 WND * wndPtr = WIN_FindWndPtr( child );
2455 while (wndPtr && wndPtr->parent)
2457 WIN_UpdateWndPtr(&wndPtr,wndPtr->parent);
2458 if (wndPtr->hwndSelf == GetDesktopWindow()) break;
2459 if (wndPtr->hwndSelf == parent)
2461 WIN_ReleaseWndPtr(wndPtr);
2465 WIN_ReleaseWndPtr(wndPtr);
2470 /***********************************************************************
2471 * IsWindowVisible (USER.49)
2473 BOOL16 WINAPI IsWindowVisible16( HWND16 hwnd )
2475 return IsWindowVisible(hwnd);
2479 /***********************************************************************
2480 * IsWindowVisible (USER32.@)
2482 BOOL WINAPI IsWindowVisible( HWND hwnd )
2485 WND *wndPtr = WIN_FindWndPtr( hwnd );
2486 while (wndPtr && wndPtr->parent)
2488 if (!(wndPtr->dwStyle & WS_VISIBLE))
2490 WIN_ReleaseWndPtr(wndPtr);
2493 WIN_UpdateWndPtr(&wndPtr,wndPtr->parent);
2495 retval = (wndPtr && (wndPtr->dwStyle & WS_VISIBLE));
2496 WIN_ReleaseWndPtr(wndPtr);
2501 /***********************************************************************
2502 * WIN_IsWindowDrawable
2504 * hwnd is drawable when it is visible, all parents are not
2505 * minimized, and it is itself not minimized unless we are
2506 * trying to draw its default class icon.
2508 BOOL WIN_IsWindowDrawable( WND* wnd, BOOL icon )
2510 if (!(wnd->dwStyle & WS_VISIBLE)) return FALSE;
2511 if ((wnd->dwStyle & WS_MINIMIZE) &&
2512 icon && GetClassLongA( wnd->hwndSelf, GCL_HICON )) return FALSE;
2513 for(wnd = wnd->parent; wnd; wnd = wnd->parent)
2514 if( wnd->dwStyle & WS_MINIMIZE ||
2515 !(wnd->dwStyle & WS_VISIBLE) ) break;
2516 return (wnd == NULL);
2520 /*******************************************************************
2521 * GetTopWindow (USER.229)
2523 HWND16 WINAPI GetTopWindow16( HWND16 hwnd )
2525 return GetTopWindow(hwnd);
2529 /*******************************************************************
2530 * GetTopWindow (USER32.@)
2532 HWND WINAPI GetTopWindow( HWND hwnd )
2535 WND * wndPtr = (hwnd) ?
2536 WIN_FindWndPtr( hwnd ) : WIN_GetDesktop();
2538 if (wndPtr && wndPtr->child)
2539 retval = wndPtr->child->hwndSelf;
2541 WIN_ReleaseWndPtr(wndPtr);
2546 /*******************************************************************
2547 * GetWindow (USER.262)
2549 HWND16 WINAPI GetWindow16( HWND16 hwnd, WORD rel )
2551 return GetWindow( hwnd,rel );
2555 /*******************************************************************
2556 * GetWindow (USER32.@)
2558 HWND WINAPI GetWindow( HWND hwnd, WORD rel )
2562 WND * wndPtr = WIN_FindWndPtr( hwnd );
2563 if (!wndPtr) return 0;
2567 retval = wndPtr->parent ? wndPtr->parent->child->hwndSelf : 0;
2571 if (!wndPtr->parent)
2573 retval = 0; /* Desktop window */
2576 while (wndPtr->next)
2578 WIN_UpdateWndPtr(&wndPtr,wndPtr->next);
2580 retval = wndPtr->hwndSelf;
2584 retval = wndPtr->next ? wndPtr->next->hwndSelf : 0;
2588 if (!wndPtr->parent)
2590 retval = 0; /* Desktop window */
2593 WIN_UpdateWndPtr(&wndPtr,wndPtr->parent->child); /* First sibling */
2594 if (wndPtr->hwndSelf == hwnd)
2596 retval = 0; /* First in list */
2599 while (wndPtr->next)
2601 if (wndPtr->next->hwndSelf == hwnd)
2603 retval = wndPtr->hwndSelf;
2606 WIN_UpdateWndPtr(&wndPtr,wndPtr->next);
2612 retval = wndPtr->owner ? wndPtr->owner->hwndSelf : 0;
2616 retval = wndPtr->child ? wndPtr->child->hwndSelf : 0;
2621 WIN_ReleaseWndPtr(wndPtr);
2626 /*******************************************************************
2627 * GetNextWindow (USER.230)
2629 HWND16 WINAPI GetNextWindow16( HWND16 hwnd, WORD flag )
2631 if ((flag != GW_HWNDNEXT) && (flag != GW_HWNDPREV)) return 0;
2632 return GetWindow16( hwnd, flag );
2635 /***********************************************************************
2636 * WIN_InternalShowOwnedPopups
2638 * Internal version of ShowOwnedPopups; Wine functions should use this
2639 * to avoid interfering with application calls to ShowOwnedPopups
2640 * and to make sure the application can't prevent showing/hiding.
2642 * Set unmanagedOnly to TRUE to show/hide unmanaged windows only.
2646 BOOL WIN_InternalShowOwnedPopups( HWND owner, BOOL fShow, BOOL unmanagedOnly )
2648 INT totalChild=0, count=0;
2650 WND **pWnd = WIN_BuildWinArray(WIN_GetDesktop(), 0, &totalChild);
2652 if (!pWnd) return TRUE;
2655 * Show windows Lowest first, Highest last to preserve Z-Order
2657 for (count = totalChild-1 ; count >=0; count--)
2659 if (pWnd[count]->owner && (pWnd[count]->owner->hwndSelf == owner) && (pWnd[count]->dwStyle & WS_POPUP))
2663 /* check in window was flagged for showing in previous WIN_InternalShowOwnedPopups call */
2664 if (pWnd[count]->flags & WIN_NEEDS_INTERNALSOP)
2667 * Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages
2669 ShowWindow(pWnd[count]->hwndSelf,SW_SHOW);
2670 pWnd[count]->flags &= ~WIN_NEEDS_INTERNALSOP; /* remove the flag */
2675 if ( IsWindowVisible(pWnd[count]->hwndSelf) && /* hide only if window is visible */
2676 !( pWnd[count]->flags & WIN_NEEDS_INTERNALSOP ) && /* don't hide if previous call already did it */
2677 !( unmanagedOnly && (pWnd[count]->dwExStyle & WS_EX_MANAGED) ) ) /* don't hide managed windows if unmanagedOnly is TRUE */
2680 * Call ShowWindow directly because an application can intercept WM_SHOWWINDOW messages
2682 ShowWindow(pWnd[count]->hwndSelf,SW_HIDE);
2683 /* flag the window for showing on next WIN_InternalShowOwnedPopups call */
2684 pWnd[count]->flags |= WIN_NEEDS_INTERNALSOP;
2689 WIN_ReleaseDesktop();
2690 WIN_ReleaseWinArray(pWnd);
2695 /*******************************************************************
2696 * ShowOwnedPopups (USER.265)
2698 void WINAPI ShowOwnedPopups16( HWND16 owner, BOOL16 fShow )
2700 ShowOwnedPopups( owner, fShow );
2704 /*******************************************************************
2705 * ShowOwnedPopups (USER32.@)
2707 BOOL WINAPI ShowOwnedPopups( HWND owner, BOOL fShow )
2709 UINT totalChild=0, count=0;
2711 WND **pWnd = WIN_BuildWinArray(WIN_GetDesktop(), 0, &totalChild);
2713 if (!pWnd) return TRUE;
2715 for (; count < totalChild; count++)
2717 if (pWnd[count]->owner && (pWnd[count]->owner->hwndSelf == owner) && (pWnd[count]->dwStyle & WS_POPUP))
2721 if (pWnd[count]->flags & WIN_NEEDS_SHOW_OWNEDPOPUP)
2724 * In Windows, ShowOwnedPopups(TRUE) generates WM_SHOWWINDOW messages with SW_PARENTOPENING,
2725 * regardless of the state of the owner
2727 SendMessageA(pWnd[count]->hwndSelf, WM_SHOWWINDOW, SW_SHOW, SW_PARENTOPENING);
2728 pWnd[count]->flags &= ~WIN_NEEDS_SHOW_OWNEDPOPUP;
2733 if (IsWindowVisible(pWnd[count]->hwndSelf))
2736 * In Windows, ShowOwnedPopups(FALSE) generates WM_SHOWWINDOW messages with SW_PARENTCLOSING,
2737 * regardless of the state of the owner
2739 SendMessageA(pWnd[count]->hwndSelf, WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
2740 pWnd[count]->flags |= WIN_NEEDS_SHOW_OWNEDPOPUP;
2746 WIN_ReleaseDesktop();
2747 WIN_ReleaseWinArray(pWnd);
2752 /*******************************************************************
2753 * GetLastActivePopup (USER.287)
2755 HWND16 WINAPI GetLastActivePopup16( HWND16 hwnd )
2757 return GetLastActivePopup( hwnd );
2760 /*******************************************************************
2761 * GetLastActivePopup (USER32.@)
2763 HWND WINAPI GetLastActivePopup( HWND hwnd )
2766 WND *wndPtr =WIN_FindWndPtr(hwnd);
2767 if (!wndPtr) return hwnd;
2768 retval = wndPtr->hwndLastActive;
2769 WIN_ReleaseWndPtr(wndPtr);
2770 if ((retval != hwnd) && (!IsWindow(retval)))
2776 /*******************************************************************
2779 * Build an array of pointers to the children of a given window.
2780 * The array must be freed with WIN_ReleaseWinArray. Return NULL
2781 * when no windows are found.
2783 WND **WIN_BuildWinArray( WND *wndPtr, UINT bwaFlags, UINT* pTotal )
2785 /* Future: this function will lock all windows associated with this array */
2787 WND **list, **ppWnd;
2789 UINT count = 0, skipOwned, skipHidden;
2792 skipHidden = bwaFlags & BWA_SKIPHIDDEN;
2793 skipOwned = bwaFlags & BWA_SKIPOWNED;
2794 skipFlags = (bwaFlags & BWA_SKIPDISABLED) ? WS_DISABLED : 0;
2795 if( bwaFlags & BWA_SKIPICONIC ) skipFlags |= WS_MINIMIZE;
2797 /* First count the windows */
2800 wndPtr = WIN_GetDesktop();
2802 pWnd = WIN_LockWndPtr(wndPtr->child);
2805 if( !(pWnd->dwStyle & skipFlags) && !(skipOwned && pWnd->owner) &&
2806 (!skipHidden || (pWnd->dwStyle & WS_VISIBLE)) )
2808 WIN_UpdateWndPtr(&pWnd,pWnd->next);
2813 /* Now build the list of all windows */
2815 if ((list = (WND **)HeapAlloc( GetProcessHeap(), 0, sizeof(WND *) * (count + 1))))
2817 for (pWnd = WIN_LockWndPtr(wndPtr->child), ppWnd = list, count = 0; pWnd; WIN_UpdateWndPtr(&pWnd,pWnd->next))
2819 if( (pWnd->dwStyle & skipFlags) || (skipOwned && pWnd->owner) );
2820 else if( !skipHidden || pWnd->dwStyle & WS_VISIBLE )
2826 WIN_ReleaseWndPtr(pWnd);
2832 if( pTotal ) *pTotal = count;
2835 /*******************************************************************
2836 * WIN_ReleaseWinArray
2838 void WIN_ReleaseWinArray(WND **wndArray)
2840 /* Future: this function will also unlock all windows associated with wndArray */
2841 HeapFree( GetProcessHeap(), 0, wndArray );
2845 /*******************************************************************
2846 * EnumWindows (USER32.@)
2848 BOOL WINAPI EnumWindows( WNDENUMPROC lpEnumFunc, LPARAM lParam )
2850 WND **list, **ppWnd;
2852 /* We have to build a list of all windows first, to avoid */
2853 /* unpleasant side-effects, for instance if the callback */
2854 /* function changes the Z-order of the windows. */
2856 if (!(list = WIN_BuildWinArray(WIN_GetDesktop(), 0, NULL )))
2858 WIN_ReleaseDesktop();
2862 /* Now call the callback function for every window */
2864 for (ppWnd = list; *ppWnd; ppWnd++)
2866 LRESULT lpEnumFuncRetval;
2868 /* Make sure that the window still exists */
2869 if (!IsWindow((*ppWnd)->hwndSelf)) continue;
2871 /* To avoid any deadlocks, all the locks on the windows
2872 structures must be suspended before the control
2873 is passed to the application */
2874 iWndsLocks = WIN_SuspendWndsLock();
2875 lpEnumFuncRetval = lpEnumFunc( (*ppWnd)->hwndSelf, lParam);
2876 WIN_RestoreWndsLock(iWndsLocks);
2878 if (!lpEnumFuncRetval) break;
2880 WIN_ReleaseWinArray(list);
2881 WIN_ReleaseDesktop();
2886 /**********************************************************************
2887 * EnumTaskWindows (USER.225)
2889 BOOL16 WINAPI EnumTaskWindows16( HTASK16 hTask, WNDENUMPROC16 func,
2892 WND **list, **ppWnd;
2894 /* This function is the same as EnumWindows(), */
2895 /* except for an added check on the window's task. */
2897 if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
2899 WIN_ReleaseDesktop();
2903 /* Now call the callback function for every window */
2905 for (ppWnd = list; *ppWnd; ppWnd++)
2909 /* Make sure that the window still exists */
2910 if (!IsWindow((*ppWnd)->hwndSelf)) continue;
2911 if (QUEUE_GetQueueTask((*ppWnd)->hmemTaskQ) != hTask) continue;
2913 /* To avoid any deadlocks, all the locks on the windows
2914 structures must be suspended before the control
2915 is passed to the application */
2916 iWndsLocks = WIN_SuspendWndsLock();
2917 funcRetval = func( (*ppWnd)->hwndSelf, lParam );
2918 WIN_RestoreWndsLock(iWndsLocks);
2920 if (!funcRetval) break;
2922 WIN_ReleaseWinArray(list);
2923 WIN_ReleaseDesktop();
2928 /**********************************************************************
2929 * EnumThreadWindows (USER32.@)
2931 BOOL WINAPI EnumThreadWindows( DWORD id, WNDENUMPROC func, LPARAM lParam )
2933 TEB *teb = THREAD_IdToTEB(id);
2935 return (BOOL16)EnumTaskWindows16(teb->htask16, (WNDENUMPROC16)func, lParam);
2939 /**********************************************************************
2940 * WIN_EnumChildWindows
2942 * Helper function for EnumChildWindows().
2944 static BOOL16 WIN_EnumChildWindows( WND **ppWnd, WNDENUMPROC func, LPARAM lParam )
2949 for ( ; *ppWnd; ppWnd++)
2953 /* Make sure that the window still exists */
2954 if (!IsWindow((*ppWnd)->hwndSelf)) continue;
2955 /* Build children list first */
2956 childList = WIN_BuildWinArray( *ppWnd, BWA_SKIPOWNED, NULL );
2958 /* To avoid any deadlocks, all the locks on the windows
2959 structures must be suspended before the control
2960 is passed to the application */
2961 iWndsLocks = WIN_SuspendWndsLock();
2962 ret = func( (*ppWnd)->hwndSelf, lParam );
2963 WIN_RestoreWndsLock(iWndsLocks);
2967 if (ret) ret = WIN_EnumChildWindows( childList, func, lParam );
2968 WIN_ReleaseWinArray(childList);
2970 if (!ret) return FALSE;
2976 /**********************************************************************
2977 * EnumChildWindows (USER32.@)
2979 BOOL WINAPI EnumChildWindows( HWND parent, WNDENUMPROC func,
2982 WND **list, *pParent;
2984 if (!(pParent = WIN_FindWndPtr( parent ))) return FALSE;
2985 if (!(list = WIN_BuildWinArray( pParent, BWA_SKIPOWNED, NULL )))
2987 WIN_ReleaseWndPtr(pParent);
2990 WIN_EnumChildWindows( list, func, lParam );
2991 WIN_ReleaseWinArray(list);
2992 WIN_ReleaseWndPtr(pParent);
2997 /*******************************************************************
2998 * AnyPopup (USER.52)
3000 BOOL16 WINAPI AnyPopup16(void)
3006 /*******************************************************************
3007 * AnyPopup (USER32.@)
3009 BOOL WINAPI AnyPopup(void)
3011 WND *wndPtr = WIN_LockWndPtr(pWndDesktop->child);
3016 if (wndPtr->owner && (wndPtr->dwStyle & WS_VISIBLE))
3021 WIN_UpdateWndPtr(&wndPtr,wndPtr->next);
3025 WIN_ReleaseWndPtr(wndPtr);
3030 /*******************************************************************
3031 * FlashWindow (USER.105)
3033 BOOL16 WINAPI FlashWindow16( HWND16 hWnd, BOOL16 bInvert )
3035 return FlashWindow( hWnd, bInvert );
3039 /*******************************************************************
3040 * FlashWindow (USER32.@)
3042 BOOL WINAPI FlashWindow( HWND hWnd, BOOL bInvert )
3044 WND *wndPtr = WIN_FindWndPtr(hWnd);
3046 TRACE("%04x\n", hWnd);
3048 if (!wndPtr) return FALSE;
3050 if (wndPtr->dwStyle & WS_MINIMIZE)
3052 if (bInvert && !(wndPtr->flags & WIN_NCACTIVATED))
3054 HDC hDC = GetDC(hWnd);
3056 if (!SendMessage16( hWnd, WM_ERASEBKGND, (WPARAM16)hDC, 0 ))
3057 wndPtr->flags |= WIN_NEEDS_ERASEBKGND;
3059 ReleaseDC( hWnd, hDC );
3060 wndPtr->flags |= WIN_NCACTIVATED;
3064 PAINT_RedrawWindow( hWnd, 0, 0, RDW_INVALIDATE | RDW_ERASE |
3065 RDW_UPDATENOW | RDW_FRAME, 0 );
3066 wndPtr->flags &= ~WIN_NCACTIVATED;
3068 WIN_ReleaseWndPtr(wndPtr);
3074 if (bInvert) wparam = !(wndPtr->flags & WIN_NCACTIVATED);
3075 else wparam = (hWnd == GetActiveWindow());
3077 SendMessage16( hWnd, WM_NCACTIVATE, wparam, (LPARAM)0 );
3078 WIN_ReleaseWndPtr(wndPtr);
3084 /*******************************************************************
3085 * SetSysModalWindow (USER.188)
3087 HWND16 WINAPI SetSysModalWindow16( HWND16 hWnd )
3089 HWND hWndOldModal = hwndSysModal;
3090 hwndSysModal = hWnd;
3091 FIXME("EMPTY STUB !! SetSysModalWindow(%04x) !\n", hWnd);
3092 return hWndOldModal;
3096 /*******************************************************************
3097 * GetSysModalWindow (USER.189)
3099 HWND16 WINAPI GetSysModalWindow16(void)
3101 return hwndSysModal;
3105 /*******************************************************************
3106 * GetWindowContextHelpId (USER32.@)
3108 DWORD WINAPI GetWindowContextHelpId( HWND hwnd )
3111 WND *wnd = WIN_FindWndPtr( hwnd );
3113 retval = wnd->helpContext;
3114 WIN_ReleaseWndPtr(wnd);
3119 /*******************************************************************
3120 * SetWindowContextHelpId (USER32.@)
3122 BOOL WINAPI SetWindowContextHelpId( HWND hwnd, DWORD id )
3124 WND *wnd = WIN_FindWndPtr( hwnd );
3125 if (!wnd) return FALSE;
3126 wnd->helpContext = id;
3127 WIN_ReleaseWndPtr(wnd);
3132 /*******************************************************************
3135 * recursively find a child that contains spDragInfo->pt point
3136 * and send WM_QUERYDROPOBJECT
3138 BOOL16 DRAG_QueryUpdate( HWND hQueryWnd, SEGPTR spDragInfo, BOOL bNoSend )
3140 BOOL16 wParam, bResult = 0;
3142 LPDRAGINFO16 ptrDragInfo = MapSL(spDragInfo);
3143 WND *ptrQueryWnd = WIN_FindWndPtr(hQueryWnd),*ptrWnd;
3146 if( !ptrQueryWnd || !ptrDragInfo )
3149 CONV_POINT16TO32( &ptrDragInfo->pt, &pt );
3151 GetWindowRect(hQueryWnd,&tempRect);
3153 if( !PtInRect(&tempRect,pt) ||
3154 (ptrQueryWnd->dwStyle & WS_DISABLED) )
3157 if( !(ptrQueryWnd->dwStyle & WS_MINIMIZE) )
3159 tempRect = ptrQueryWnd->rectClient;
3160 if(ptrQueryWnd->parent)
3161 MapWindowPoints( ptrQueryWnd->parent->hwndSelf, 0,
3162 (LPPOINT)&tempRect, 2 );
3164 if (PtInRect( &tempRect, pt))
3168 for (ptrWnd = WIN_LockWndPtr(ptrQueryWnd->child); ptrWnd ;WIN_UpdateWndPtr(&ptrWnd,ptrWnd->next))
3170 if( ptrWnd->dwStyle & WS_VISIBLE )
3172 GetWindowRect( ptrWnd->hwndSelf, &tempRect );
3173 if (PtInRect( &tempRect, pt )) break;
3179 TRACE_(msg)("hwnd = %04x, %d %d - %d %d\n",
3180 ptrWnd->hwndSelf, ptrWnd->rectWindow.left, ptrWnd->rectWindow.top,
3181 ptrWnd->rectWindow.right, ptrWnd->rectWindow.bottom );
3182 if( !(ptrWnd->dwStyle & WS_DISABLED) )
3183 bResult = DRAG_QueryUpdate(ptrWnd->hwndSelf, spDragInfo, bNoSend);
3185 WIN_ReleaseWndPtr(ptrWnd);
3195 ScreenToClient16(hQueryWnd,&ptrDragInfo->pt);
3197 ptrDragInfo->hScope = hQueryWnd;
3199 bResult = ( bNoSend )
3200 ? ptrQueryWnd->dwExStyle & WS_EX_ACCEPTFILES
3201 : SendMessage16( hQueryWnd ,WM_QUERYDROPOBJECT ,
3202 (WPARAM16)wParam ,(LPARAM) spDragInfo );
3204 CONV_POINT32TO16( &pt, &ptrDragInfo->pt );
3207 WIN_ReleaseWndPtr(ptrQueryWnd);
3212 /*******************************************************************
3213 * DragDetect (USER.465)
3215 BOOL16 WINAPI DragDetect16( HWND16 hWnd, POINT16 pt )
3218 CONV_POINT16TO32( &pt, &pt32 );
3219 return DragDetect( hWnd, pt32 );
3222 /*******************************************************************
3223 * DragDetect (USER32.@)
3225 BOOL WINAPI DragDetect( HWND hWnd, POINT pt )
3230 rect.left = pt.x - wDragWidth;
3231 rect.right = pt.x + wDragWidth;
3233 rect.top = pt.y - wDragHeight;
3234 rect.bottom = pt.y + wDragHeight;
3240 while(PeekMessageA(&msg ,0 ,WM_MOUSEFIRST ,WM_MOUSELAST ,PM_REMOVE))
3242 if( msg.message == WM_LBUTTONUP )
3247 if( msg.message == WM_MOUSEMOVE )
3250 tmp.x = LOWORD(msg.lParam);
3251 tmp.y = HIWORD(msg.lParam);
3252 if( !PtInRect( &rect, tmp ))
3264 /******************************************************************************
3265 * DragObject (USER.464)
3267 DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj,
3268 HANDLE16 hOfStruct, WORD szList, HCURSOR16 hCursor )
3271 LPDRAGINFO16 lpDragInfo;
3273 HCURSOR16 hDragCursor=0, hOldCursor=0, hBummer=0;
3274 HGLOBAL16 hDragInfo = GlobalAlloc16( GMEM_SHARE | GMEM_ZEROINIT, 2*sizeof(DRAGINFO16));
3275 WND *wndPtr = WIN_FindWndPtr(hWnd);
3276 HCURSOR16 hCurrentCursor = 0;
3277 HWND16 hCurrentWnd = 0;
3279 lpDragInfo = (LPDRAGINFO16) GlobalLock16(hDragInfo);
3280 spDragInfo = K32WOWGlobalLock16(hDragInfo);
3282 if( !lpDragInfo || !spDragInfo )
3284 WIN_ReleaseWndPtr(wndPtr);
3288 hBummer = LoadCursorA(0, MAKEINTRESOURCEA(OCR_NO));
3290 if( !hBummer || !wndPtr )
3292 GlobalFree16(hDragInfo);
3293 WIN_ReleaseWndPtr(wndPtr);
3299 if( !(hDragCursor = CURSORICON_IconToCursor(hCursor, FALSE)) )
3301 GlobalFree16(hDragInfo);
3302 WIN_ReleaseWndPtr(wndPtr);
3306 if( hDragCursor == hCursor ) hDragCursor = 0;
3307 else hCursor = hDragCursor;
3309 hOldCursor = SetCursor(hDragCursor);
3312 lpDragInfo->hWnd = hWnd;
3313 lpDragInfo->hScope = 0;
3314 lpDragInfo->wFlags = wObj;
3315 lpDragInfo->hList = szList; /* near pointer! */
3316 lpDragInfo->hOfStruct = hOfStruct;
3324 do{ WaitMessage(); }
3325 while( !PeekMessageA(&msg,0,WM_MOUSEFIRST,WM_MOUSELAST,PM_REMOVE) );
3327 *(lpDragInfo+1) = *lpDragInfo;
3329 lpDragInfo->pt.x = msg.pt.x;
3330 lpDragInfo->pt.y = msg.pt.y;
3332 /* update DRAGINFO struct */
3333 TRACE_(msg)("lpDI->hScope = %04x\n",lpDragInfo->hScope);
3335 if( DRAG_QueryUpdate(hwndScope, spDragInfo, FALSE) > 0 )
3336 hCurrentCursor = hCursor;
3339 hCurrentCursor = hBummer;
3340 lpDragInfo->hScope = 0;
3342 if( hCurrentCursor )
3343 SetCursor(hCurrentCursor);
3345 /* send WM_DRAGLOOP */
3346 SendMessage16( hWnd, WM_DRAGLOOP, (WPARAM16)(hCurrentCursor != hBummer),
3347 (LPARAM) spDragInfo );
3348 /* send WM_DRAGSELECT or WM_DRAGMOVE */
3349 if( hCurrentWnd != lpDragInfo->hScope )
3352 SendMessage16( hCurrentWnd, WM_DRAGSELECT, 0,
3353 (LPARAM)MAKELONG(LOWORD(spDragInfo)+sizeof(DRAGINFO16),
3354 HIWORD(spDragInfo)) );
3355 hCurrentWnd = lpDragInfo->hScope;
3357 SendMessage16( hCurrentWnd, WM_DRAGSELECT, 1, (LPARAM)spDragInfo);
3361 SendMessage16( hCurrentWnd, WM_DRAGMOVE, 0, (LPARAM)spDragInfo);
3363 } while( msg.message != WM_LBUTTONUP && msg.message != WM_NCLBUTTONUP );
3366 ShowCursor( FALSE );
3370 SetCursor( hOldCursor );
3371 if (hDragCursor) DestroyCursor( hDragCursor );
3374 if( hCurrentCursor != hBummer )
3375 msg.lParam = SendMessage16( lpDragInfo->hScope, WM_DROPOBJECT,
3376 (WPARAM16)hWnd, (LPARAM)spDragInfo );
3379 GlobalFree16(hDragInfo);
3380 WIN_ReleaseWndPtr(wndPtr);
3382 return (DWORD)(msg.lParam);
3386 /******************************************************************************
3387 * GetWindowModuleFileNameA (USER32.@)
3389 UINT WINAPI GetWindowModuleFileNameA( HWND hwnd, LPSTR lpszFileName, UINT cchFileNameMax)
3391 FIXME("GetWindowModuleFileNameA(hwnd 0x%x, lpszFileName %p, cchFileNameMax %u) stub!\n",
3392 hwnd, lpszFileName, cchFileNameMax);
3396 /******************************************************************************
3397 * GetWindowModuleFileNameW (USER32.@)
3399 UINT WINAPI GetWindowModuleFileNameW( HWND hwnd, LPSTR lpszFileName, UINT cchFileNameMax)
3401 FIXME("GetWindowModuleFileNameW(hwnd 0x%x, lpszFileName %p, cchFileNameMax %u) stub!\n",
3402 hwnd, lpszFileName, cchFileNameMax);