MSGBOX_DlgProc: break out of WM_COMMAND.
[wine] / windows / dce.c
1 /*
2  * USER DCE functions
3  *
4  * Copyright 1993 Alexandre Julliard
5  *           1996,1997 Alex Korobka
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  *
22  * Note: Visible regions of CS_OWNDC/CS_CLASSDC window DCs
23  * have to be updated dynamically.
24  *
25  * Internal DCX flags:
26  *
27  * DCX_DCEEMPTY    - dce is uninitialized
28  * DCX_DCEBUSY     - dce is in use
29  * DCX_DCEDIRTY    - ReleaseDC() should wipe instead of caching
30  * DCX_KEEPCLIPRGN - ReleaseDC() should not delete the clipping region
31  * DCX_WINDOWPAINT - BeginPaint() is in effect
32  */
33
34 #include <assert.h>
35 #include "dce.h"
36 #include "win.h"
37 #include "gdi.h"
38 #include "user.h"
39 #include "wine/debug.h"
40 #include "windef.h"
41 #include "wingdi.h"
42 #include "wine/winbase16.h"
43 #include "wine/winuser16.h"
44
45 WINE_DEFAULT_DEBUG_CHANNEL(dc);
46
47 static DCE *firstDCE;
48 static HDC defaultDCstate;
49
50 static void DCE_DeleteClipRgn( DCE* );
51 static INT DCE_ReleaseDC( DCE* );
52
53
54 /***********************************************************************
55  *           DCE_DumpCache
56  */
57 static void DCE_DumpCache(void)
58 {
59     DCE *dce;
60
61     USER_Lock();
62     dce = firstDCE;
63
64     DPRINTF("DCE:\n");
65     while( dce )
66     {
67         DPRINTF("\t[0x%08x] hWnd 0x%04x, dcx %08x, %s %s\n",
68              (unsigned)dce, dce->hwndCurrent, (unsigned)dce->DCXflags,
69              (dce->DCXflags & DCX_CACHE) ? "Cache" : "Owned",
70              (dce->DCXflags & DCX_DCEBUSY) ? "InUse" : "" );
71         dce = dce->next;
72     }
73
74     USER_Unlock();
75 }
76
77 /***********************************************************************
78  *           DCE_AllocDCE
79  *
80  * Allocate a new DCE.
81  */
82 DCE *DCE_AllocDCE( HWND hWnd, DCE_TYPE type )
83 {
84     DCE * dce;
85
86     if (!(dce = HeapAlloc( GetProcessHeap(), 0, sizeof(DCE) ))) return NULL;
87     if (!(dce->hDC = CreateDCA( "DISPLAY", NULL, NULL, NULL )))
88     {
89         HeapFree( GetProcessHeap(), 0, dce );
90         return 0;
91     }
92     if (!defaultDCstate) defaultDCstate = GetDCState16( dce->hDC );
93
94     /* store DCE handle in DC hook data field */
95
96     SetDCHook( dce->hDC, DCHook16, (DWORD)dce );
97
98     dce->hwndCurrent = WIN_GetFullHandle( hWnd );
99     dce->hClipRgn    = 0;
100
101     if( type != DCE_CACHE_DC ) /* owned or class DC */
102     {
103         dce->DCXflags = DCX_DCEBUSY;
104         if( hWnd )
105         {
106             LONG style = GetWindowLongW( hWnd, GWL_STYLE );
107             if (style & WS_CLIPCHILDREN) dce->DCXflags |= DCX_CLIPCHILDREN;
108             if (style & WS_CLIPSIBLINGS) dce->DCXflags |= DCX_CLIPSIBLINGS;
109         }
110         SetHookFlags16(dce->hDC,DCHF_INVALIDATEVISRGN);
111     }
112     else dce->DCXflags = DCX_CACHE | DCX_DCEEMPTY;
113
114     USER_Lock();
115     dce->next = firstDCE;
116     firstDCE = dce;
117     USER_Unlock();
118     return dce;
119 }
120
121
122 /***********************************************************************
123  *           DCE_FreeDCE
124  */
125 DCE* DCE_FreeDCE( DCE *dce )
126 {
127     DCE **ppDCE, *ret;
128
129     if (!dce) return NULL;
130
131     USER_Lock();
132
133     ppDCE = &firstDCE;
134
135     while (*ppDCE && (*ppDCE != dce)) ppDCE = &(*ppDCE)->next;
136     if (*ppDCE == dce) *ppDCE = dce->next;
137     ret = *ppDCE;
138     USER_Unlock();
139
140     SetDCHook(dce->hDC, NULL, 0L);
141
142     DeleteDC( dce->hDC );
143     if( dce->hClipRgn && !(dce->DCXflags & DCX_KEEPCLIPRGN) )
144         DeleteObject(dce->hClipRgn);
145     HeapFree( GetProcessHeap(), 0, dce );
146
147     return ret;
148 }
149
150 /***********************************************************************
151  *           DCE_FreeWindowDCE
152  *
153  * Remove owned DCE and reset unreleased cache DCEs.
154  */
155 void DCE_FreeWindowDCE( HWND hwnd )
156 {
157     DCE *pDCE;
158     WND *pWnd = WIN_GetPtr( hwnd );
159
160     pDCE = firstDCE;
161     while( pDCE )
162     {
163         if( pDCE->hwndCurrent == hwnd )
164         {
165             if( pDCE == pWnd->dce ) /* owned or Class DCE*/
166             {
167                 if (pWnd->clsStyle & CS_OWNDC)  /* owned DCE*/
168                 {
169                     pDCE = DCE_FreeDCE( pDCE );
170                     pWnd->dce = NULL;
171                     continue;
172                 }
173                 else if( pDCE->DCXflags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN) ) /* Class DCE*/
174                 {
175                     DCE_DeleteClipRgn( pDCE );
176                     pDCE->hwndCurrent = 0;
177                 }
178             }
179             else
180             {
181                 if( pDCE->DCXflags & DCX_DCEBUSY ) /* shared cache DCE */
182                 {
183                     /* FIXME: AFAICS we are doing the right thing here so
184                      * this should be a WARN. But this is best left as an ERR
185                      * because the 'application error' is likely to come from
186                      * another part of Wine (i.e. it's our fault after all).
187                      * We should change this to WARN when Wine is more stable
188                      * (for 1.0?).
189                      */
190                     ERR("[%08x] GetDC() without ReleaseDC()!\n",hwnd);
191                     DCE_ReleaseDC( pDCE );
192                 }
193
194                 pDCE->DCXflags &= DCX_CACHE;
195                 pDCE->DCXflags |= DCX_DCEEMPTY;
196                 pDCE->hwndCurrent = 0;
197             }
198         }
199         pDCE = pDCE->next;
200     }
201     WIN_ReleasePtr( pWnd );
202 }
203
204
205 /***********************************************************************
206  *   DCE_DeleteClipRgn
207  */
208 static void DCE_DeleteClipRgn( DCE* dce )
209 {
210     dce->DCXflags &= ~(DCX_EXCLUDERGN | DCX_INTERSECTRGN | DCX_WINDOWPAINT);
211
212     if( dce->DCXflags & DCX_KEEPCLIPRGN )
213         dce->DCXflags &= ~DCX_KEEPCLIPRGN;
214     else
215         if( dce->hClipRgn > 1 )
216             DeleteObject( dce->hClipRgn );
217
218     dce->hClipRgn = 0;
219
220     /* make it dirty so that the vis rgn gets recomputed next time */
221     dce->DCXflags |= DCX_DCEDIRTY;
222     SetHookFlags16( dce->hDC, DCHF_INVALIDATEVISRGN );
223 }
224
225
226 /***********************************************************************
227  *   DCE_ReleaseDC
228  */
229 static INT DCE_ReleaseDC( DCE* dce )
230 {
231     if ((dce->DCXflags & (DCX_DCEEMPTY | DCX_DCEBUSY)) != DCX_DCEBUSY) return 0;
232
233     /* restore previous visible region */
234
235     if ((dce->DCXflags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN)) &&
236         (dce->DCXflags & (DCX_CACHE | DCX_WINDOWPAINT)) )
237         DCE_DeleteClipRgn( dce );
238
239     if (dce->DCXflags & DCX_CACHE)
240     {
241         /* make the DC clean so that SetDCState doesn't try to update the vis rgn */
242         SetHookFlags16( dce->hDC, DCHF_VALIDATEVISRGN );
243         SetDCState16( dce->hDC, defaultDCstate );
244         dce->DCXflags &= ~DCX_DCEBUSY;
245         if (dce->DCXflags & DCX_DCEDIRTY)
246         {
247             /* don't keep around invalidated entries
248              * because SetDCState() disables hVisRgn updates
249              * by removing dirty bit. */
250
251             dce->hwndCurrent = 0;
252             dce->DCXflags &= DCX_CACHE;
253             dce->DCXflags |= DCX_DCEEMPTY;
254         }
255     }
256     return 1;
257 }
258
259
260 /***********************************************************************
261  *   DCE_InvalidateDCE
262  *
263  * It is called from SetWindowPos() and EVENT_MapNotify - we have to
264  * mark as dirty all busy DCEs for windows that have pWnd->parent as
265  * an ancestor and whose client rect intersects with specified update
266  * rectangle. In addition, pWnd->parent DCEs may need to be updated if
267  * DCX_CLIPCHILDREN flag is set.  */
268 BOOL DCE_InvalidateDCE(HWND hwnd, const RECT* pRectUpdate)
269 {
270     HWND hwndScope = GetAncestor( hwnd, GA_PARENT );
271     BOOL bRet = FALSE;
272
273     if( hwndScope )
274     {
275         DCE *dce;
276
277         TRACE("scope hwnd = %04x, (%i,%i - %i,%i)\n",
278                      hwndScope, pRectUpdate->left,pRectUpdate->top,
279                      pRectUpdate->right,pRectUpdate->bottom);
280         if(TRACE_ON(dc))
281           DCE_DumpCache();
282
283         /* walk all DCEs and fixup non-empty entries */
284
285         for (dce = firstDCE; (dce); dce = dce->next)
286         {
287             if (dce->DCXflags & DCX_DCEEMPTY) continue;
288             if ((dce->hwndCurrent == hwndScope) && !(dce->DCXflags & DCX_CLIPCHILDREN))
289                 continue;  /* child window positions don't bother us */
290
291             /* check if DCE window is within the z-order scope */
292
293             if (hwndScope == dce->hwndCurrent || IsChild( hwndScope, dce->hwndCurrent ))
294             {
295                 if (hwnd != dce->hwndCurrent)
296                 {
297                     /* check if the window rectangle intersects this DCE window */
298                     RECT rect;
299                     GetWindowRect( dce->hwndCurrent, &rect );
300                     MapWindowPoints( 0, hwndScope, (POINT *)&rect, 2 );
301                     if (!IntersectRect( &rect, &rect, pRectUpdate )) continue;
302
303                 }
304                 if( !(dce->DCXflags & DCX_DCEBUSY) )
305                 {
306                     /* Don't bother with visible regions of unused DCEs */
307
308                     TRACE("\tpurged %p dce [%04x]\n", dce, dce->hwndCurrent);
309                     dce->hwndCurrent = 0;
310                     dce->DCXflags &= DCX_CACHE;
311                     dce->DCXflags |= DCX_DCEEMPTY;
312                 }
313                 else
314                 {
315                     /* Set dirty bits in the hDC and DCE structs */
316
317                     TRACE("\tfixed up %p dce [%04x]\n", dce, dce->hwndCurrent);
318                     dce->DCXflags |= DCX_DCEDIRTY;
319                     SetHookFlags16(dce->hDC, DCHF_INVALIDATEVISRGN);
320                     bRet = TRUE;
321                 }
322             }
323         } /* dce list */
324     }
325     return bRet;
326 }
327
328
329 /***********************************************************************
330  *           DCE_ExcludeRgn
331  *
332  *  Translate given region from the wnd client to the DC coordinates
333  *  and add it to the clipping region.
334  */
335 INT DCE_ExcludeRgn( HDC hDC, HWND hwnd, HRGN hRgn )
336 {
337   POINT  pt = {0, 0};
338   DCE     *dce = firstDCE;
339
340   while (dce && (dce->hDC != hDC)) dce = dce->next;
341   if (!dce) return ERROR;
342
343   MapWindowPoints( hwnd, dce->hwndCurrent, &pt, 1);
344   if( dce->DCXflags & DCX_WINDOW )
345   {
346       WND *wnd = WIN_FindWndPtr(dce->hwndCurrent);
347       pt.x += wnd->rectClient.left - wnd->rectWindow.left;
348       pt.y += wnd->rectClient.top - wnd->rectWindow.top;
349       WIN_ReleaseWndPtr(wnd);
350   }
351   OffsetRgn(hRgn, pt.x, pt.y);
352
353   return ExtSelectClipRgn( hDC, hRgn, RGN_DIFF );
354 }
355
356
357 /***********************************************************************
358  *              GetDCEx (USER32.@)
359  *
360  * Unimplemented flags: DCX_LOCKWINDOWUPDATE
361  *
362  * FIXME: Full support for hrgnClip == 1 (alias for entire window).
363  */
364 HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
365 {
366     HDC         hdc = 0;
367     DCE *       dce;
368     WND *       wndPtr;
369     DWORD       dcxFlags = 0;
370     BOOL        bUpdateVisRgn = TRUE;
371     BOOL        bUpdateClipOrigin = FALSE;
372     HWND parent, full;
373
374     TRACE("hwnd %04x, hrgnClip %04x, flags %08x\n",
375           hwnd, hrgnClip, (unsigned)flags);
376
377     if (!hwnd) hwnd = GetDesktopWindow();
378     if (!(full = WIN_IsCurrentProcess( hwnd )))
379     {
380         FIXME( "not supported yet on other process window %x\n", hwnd );
381         return 0;
382     }
383     hwnd = full;
384     if (!(wndPtr = WIN_GetPtr( hwnd ))) return 0;
385
386     /* fixup flags */
387
388     if (flags & (DCX_WINDOW | DCX_PARENTCLIP)) flags |= DCX_CACHE;
389
390     if (flags & DCX_USESTYLE)
391     {
392         flags &= ~( DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS | DCX_PARENTCLIP);
393
394         if( wndPtr->dwStyle & WS_CLIPSIBLINGS )
395             flags |= DCX_CLIPSIBLINGS;
396
397         if ( !(flags & DCX_WINDOW) )
398         {
399             if (wndPtr->clsStyle & CS_PARENTDC) flags |= DCX_PARENTCLIP;
400
401             if (wndPtr->dwStyle & WS_CLIPCHILDREN &&
402                      !(wndPtr->dwStyle & WS_MINIMIZE) ) flags |= DCX_CLIPCHILDREN;
403             if (!wndPtr->dce) flags |= DCX_CACHE;
404         }
405     }
406
407     if (flags & DCX_WINDOW) flags &= ~DCX_CLIPCHILDREN;
408
409     parent = GetAncestor( hwnd, GA_PARENT );
410     if (!parent || (parent == GetDesktopWindow()))
411         flags = (flags & ~DCX_PARENTCLIP) | DCX_CLIPSIBLINGS;
412
413     /* it seems parent clip is ignored when clipping siblings or children */
414     if (flags & (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN)) flags &= ~DCX_PARENTCLIP;
415
416     if( flags & DCX_PARENTCLIP )
417     {
418         LONG parent_style = GetWindowLongW( parent, GWL_STYLE );
419         if( (wndPtr->dwStyle & WS_VISIBLE) && (parent_style & WS_VISIBLE) )
420         {
421             flags &= ~DCX_CLIPCHILDREN;
422             if (parent_style & WS_CLIPSIBLINGS) flags |= DCX_CLIPSIBLINGS;
423         }
424     }
425
426     /* find a suitable DCE */
427
428     dcxFlags = flags & (DCX_PARENTCLIP | DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN |
429                         DCX_CACHE | DCX_WINDOW);
430
431     if (flags & DCX_CACHE)
432     {
433         DCE*    dceEmpty;
434         DCE*    dceUnused;
435
436         dceEmpty = dceUnused = NULL;
437
438         /* Strategy: First, we attempt to find a non-empty but unused DCE with
439          * compatible flags. Next, we look for an empty entry. If the cache is
440          * full we have to purge one of the unused entries.
441          */
442
443         for (dce = firstDCE; (dce); dce = dce->next)
444         {
445             if ((dce->DCXflags & (DCX_CACHE | DCX_DCEBUSY)) == DCX_CACHE )
446             {
447                 dceUnused = dce;
448
449                 if (dce->DCXflags & DCX_DCEEMPTY)
450                     dceEmpty = dce;
451                 else
452                 if ((dce->hwndCurrent == hwnd) &&
453                    ((dce->DCXflags & (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN |
454                                       DCX_CACHE | DCX_WINDOW | DCX_PARENTCLIP)) == dcxFlags))
455                 {
456                     TRACE("\tfound valid %08x dce [%04x], flags %08x\n",
457                                         (unsigned)dce, hwnd, (unsigned)dcxFlags );
458                     bUpdateVisRgn = FALSE;
459                     bUpdateClipOrigin = TRUE;
460                     break;
461                 }
462             }
463         }
464
465         if (!dce) dce = (dceEmpty) ? dceEmpty : dceUnused;
466
467         /* if there's no dce empty or unused, allocate a new one */
468         if (!dce)
469         {
470             dce = DCE_AllocDCE( 0, DCE_CACHE_DC );
471         }
472     }
473     else
474     {
475         dce = wndPtr->dce;
476         if (dce && dce->hwndCurrent == hwnd)
477         {
478             TRACE("\tskipping hVisRgn update\n");
479             bUpdateVisRgn = FALSE; /* updated automatically, via DCHook() */
480         }
481     }
482     if (!dce)
483     {
484         hdc = 0;
485         goto END;
486     }
487
488     if (!(flags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN))) hrgnClip = 0;
489
490     if (((flags ^ dce->DCXflags) & (DCX_INTERSECTRGN | DCX_EXCLUDERGN)) &&
491         (dce->hClipRgn != hrgnClip))
492     {
493         /* if the extra clip region has changed, get rid of the old one */
494         DCE_DeleteClipRgn( dce );
495     }
496
497     dce->hwndCurrent = hwnd;
498     dce->hClipRgn = hrgnClip;
499     dce->DCXflags = flags & (DCX_PARENTCLIP | DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN |
500                              DCX_CACHE | DCX_WINDOW | DCX_WINDOWPAINT |
501                              DCX_KEEPCLIPRGN | DCX_INTERSECTRGN | DCX_EXCLUDERGN);
502     dce->DCXflags |= DCX_DCEBUSY;
503     dce->DCXflags &= ~DCX_DCEDIRTY;
504     hdc = dce->hDC;
505
506     if (bUpdateVisRgn) SetHookFlags16( hdc, DCHF_INVALIDATEVISRGN ); /* force update */
507
508     if (!USER_Driver.pGetDC( hwnd, hdc, hrgnClip, flags )) hdc = 0;
509
510     TRACE("(%04x,%04x,0x%lx): returning %04x\n", hwnd, hrgnClip, flags, hdc);
511 END:
512     WIN_ReleasePtr(wndPtr);
513     return hdc;
514 }
515
516
517 /***********************************************************************
518  *              GetDC (USER32.@)
519  * RETURNS
520  *      :Handle to DC
521  *      NULL: Failure
522  */
523 HDC WINAPI GetDC(
524              HWND hwnd /* [in] handle of window */
525 ) {
526     if (!hwnd)
527         return GetDCEx( 0, 0, DCX_CACHE | DCX_WINDOW );
528     return GetDCEx( hwnd, 0, DCX_USESTYLE );
529 }
530
531
532 /***********************************************************************
533  *              GetWindowDC (USER32.@)
534  */
535 HDC WINAPI GetWindowDC( HWND hwnd )
536 {
537     return GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW );
538 }
539
540
541 /***********************************************************************
542  *              ReleaseDC (USER32.@)
543  *
544  * RETURNS
545  *      1: Success
546  *      0: Failure
547  */
548 INT WINAPI ReleaseDC(
549              HWND hwnd /* [in] Handle of window - ignored */,
550              HDC hdc   /* [in] Handle of device context */
551 ) {
552     DCE * dce;
553     INT nRet = 0;
554
555     USER_Lock();
556     dce = firstDCE;
557
558     TRACE("%04x %04x\n", hwnd, hdc );
559
560     while (dce && (dce->hDC != hdc)) dce = dce->next;
561
562     if ( dce )
563         if ( dce->DCXflags & DCX_DCEBUSY )
564             nRet = DCE_ReleaseDC( dce );
565
566     USER_Unlock();
567
568     return nRet;
569 }
570
571 /***********************************************************************
572  *              DCHook (USER.362)
573  *
574  * See "Undoc. Windows" for hints (DC, SetDCHook, SetHookFlags)..
575  */
576 BOOL16 WINAPI DCHook16( HDC16 hDC, WORD code, DWORD data, LPARAM lParam )
577 {
578     BOOL retv = TRUE;
579     DCE *dce = (DCE *)data;
580
581     TRACE("hDC = %04x, %i\n", hDC, code);
582
583     if (!dce) return 0;
584     assert(dce->hDC == hDC);
585
586     /* Grab the windows lock before doing anything else  */
587     USER_Lock();
588
589     switch( code )
590     {
591       case DCHC_INVALIDVISRGN:
592            /* GDI code calls this when it detects that the
593             * DC is dirty (usually after SetHookFlags()). This
594             * means that we have to recompute the visible region.
595             */
596            if( dce->DCXflags & DCX_DCEBUSY )
597            {
598                /* Dirty bit has been cleared by caller, set it again so that
599                 * pGetDC recomputes the visible region. */
600                SetHookFlags16( dce->hDC, DCHF_INVALIDATEVISRGN );
601                USER_Driver.pGetDC( dce->hwndCurrent, dce->hDC, dce->hClipRgn, dce->DCXflags );
602            }
603            else /* non-fatal but shouldn't happen */
604              WARN("DC is not in use!\n");
605            break;
606
607       case DCHC_DELETEDC:
608            /*
609             * Windows will not let you delete a DC that is busy
610             * (between GetDC and ReleaseDC)
611             */
612
613            if ( dce->DCXflags & DCX_DCEBUSY )
614            {
615                WARN("Application trying to delete a busy DC\n");
616                retv = FALSE;
617            }
618            else DCE_FreeDCE( dce );
619            break;
620
621       default:
622            FIXME("unknown code\n");
623     }
624
625   USER_Unlock();  /* Release the wnd lock */
626   return retv;
627 }
628
629
630 /**********************************************************************
631  *              WindowFromDC (USER32.@)
632  */
633 HWND WINAPI WindowFromDC( HDC hDC )
634 {
635     DCE *dce;
636     HWND hwnd;
637
638     USER_Lock();
639     dce = firstDCE;
640
641     while (dce && (dce->hDC != hDC)) dce = dce->next;
642
643     hwnd = dce ? dce->hwndCurrent : 0;
644     USER_Unlock();
645
646     return hwnd;
647 }
648
649
650 /***********************************************************************
651  *              LockWindowUpdate (USER32.@)
652  */
653 BOOL WINAPI LockWindowUpdate( HWND hwnd )
654 {
655     static HWND lockedWnd;
656
657     FIXME("(%x), partial stub!\n",hwnd);
658
659     USER_Lock();
660     if (lockedWnd)
661     {
662         if (!hwnd)
663         {
664             /* Unlock lockedWnd */
665             /* FIXME: Do something */
666         }
667         else
668         {
669             /* Attempted to lock a second window */
670             /* Return FALSE and do nothing */
671             USER_Unlock();
672             return FALSE;
673         }
674     }
675     lockedWnd = hwnd;
676     USER_Unlock();
677     return TRUE;
678 }