Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get rid of form by clicking outside the form
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00710203
Message ID:
00710388
Views:
20
Peter,

Just off the top of my head could you determine if the MouseDown is outside the form by using the Form Top, Left, Height, Width and the current mouse position in the screen. If you can then you could alter the forms Top, Left, Height, Width to give an invisible margin around the form.

Just a thought not sure if it can be done or not :)

>Caroline,
>
>The Resize Method is called AFTERWARDS. When you resize, a rectangle will appear and you can resize it. The Resize Method is called as soon (as late) as you RELEASE the mouse button. Too late! IMHO, the object model is hampering here:
>1) There's no BeforeResize Method.
>2) There's no way to detect whether the mouse is on the border.
>
>>Peter,
>>
>>Could you set a flag at the start of the Resize method and then ignore the hide if the flag is set?
>>
>>>Hi Vlad,
>>>
>>>I've tried your idea and also used sys(1270), which I used in some other code successfully.
>>>Now the form will hide if the user clicks outside the form. I can also successfully move the form using the caption, without the risk of a hide. However, resizing the form still gives problems. If I position the mouse very near a border, but INside the form, and then resize, all is okay. But if I position the mouse very near outside the border, resizing will succeed, but nevertheless the HideForm method will be called because sys(1270) will give an object reference to the underlying object, for example to the _screen.
>>>
>>>Who has another idea?
>>>
>>>Peter
>>>
>>>
>>>*method TIMER
>>>local loUnderPointer
>>>with thisform
>>>   do case
>>>   case mdown()
>>>      *	
>>>      if not .lMouseOnForm    && userdefined property
>>>         *
>>>         if mrow() < 0 or mcol() < 0
>>>            *
>>>            loUnderPointer = sys( 1270 )
>>>            *
>>>            .lMouseOnForm = type( 'loUnderPointer' ) = 'O' and loUnderPointer.name = .name
>>>            *
>>>            if not .lMouseOnForm
>>>               .HideForm()    && userdefined method that will hide the form
>>>            endif
>>>         endif
>>>      endif
>>>	
>>>   case .lMouseOnForm
>>>      *
>>>      this.interval = 0    && these lines are a try-out only
>>>      inkey(.5)
>>>      this.interval = 10
>>>      .lMouseOnForm = .f.
>>>      .ShowForm()         && userdefined method showing the form
>>>   endcase
>>>endwith
>>>
>>>
>>>>Hi!
>>>>
>>>>Make a timer with 1 to 10 miliseconds interval. Check in it MDOWN() and MROW()/MCOL() - if mouse button is pressed and is outside of the window. You can also try to use Windows API functions for this for better reliability.
>>>>
>>>>HTH.
>>>>
>>>>>How can I release (thisform.release) a form when the user clicks outside the form? Currently, I have the release code in the Deactivate. Also, the form is invoked with an ON KEY LABEL statement.
>>>>>
>>>>>- I've succeeded when it's a non-modal form and I click outside on a non-modal form.
>>>>>- I've failed when it's a non-modal form and I click outside on a modal form.
>>>>>- I've failed when it's a non-modal form and I click outside on an 'empty' section.
>>>>>- I've failed when it's a modal form and I click outside on a non-modal form.
>>>>>- I've failed when it's a modal form and I click outside on a modal form.
>>>>>- I've failed when it's a modal form and I click outside on an 'empty' section.
>>>>>
>>>>>Suggestions welcome.
Caroline
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform