Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Modal form auto close
Message
 
To
12/02/2002 02:31:50
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00618679
Message ID:
00619122
Views:
20
>>I have a modal form. I want to set it up so that when the user clicks anywhere ouside that from it automatically closes. Can I do this? If so, how? I tried to use the deactivate and lostfocus events of the form, but it didnt work.
>>
>>Any help is appreciated
>>Eric Stephani
>
>Eric,
>This might not be elegant but a working solution :
>
>
* A timer on form with interval 10
>*Form.Load
>Declare short GetCursorPos in win32api string @ lpPoint
>DECLARE RtlMoveMemory IN WIN32API ;
>	INTEGER @DestNumeric, ;
>	STRING @pVoidSource, ;
>	INTEGER nLength
>declare short ScreenToClient in win32API ;
>  integer hWnd,  string @ lpPoint
>set library to home()+'foxtools.fll' additive
>
>*Timer1.interval = 10
>*timer1.timer
>With thisform
>  If mdown()
>    Store 0 to lnPosX,lnPosY
>    lpPoint = space(8)
>    If GetCursorPos(@lpPoint)#0
>      ScreenToClient(_WhToHwnd(_WOnTop()),@lpPoint)
>      RtlMoveMemory(@lnPosX, left(lpPoint,4), 4)
>      RtlMoveMemory(@lnPosY, right(lpPoint,4), 4)
>      If !between(lnPosX, 0-sysmetric(3), .width+sysmetric(3)) ;
>          or !between(lnPosY, 0-sysmetric(4)-sysmetric(19),.height+sysmetric(4))
>        .release
>      Endif
>    Endif
>  Endif
>Endwith
>
Cetin



Thanks for the suggestion Cetin. This is extreamly similar to what I already created. Instead of using api functions to determine the mouse position and window position I used mrow() and mcol() to deterime where the mouse was. mcol and mrow return -1 when the mouse is out of the active window. So I have the timer check if mdown() is true and then checks if mrow or mcol is -1. If either is negitive it hides the form.

Eric
Previous
Reply
Map
View

Click here to load this message in the networking platform