Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get rid of form by clicking outside the form
Message
From
14/10/2002 11:44:41
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00710203
Message ID:
00710944
Views:
23
>Hi!
>
>Nice solution, indeed! You do not need though to compare HWND property - VFP compares objects very well. So, you can just use "loUnderPointer = thisform" to check if it is the same form :-)

Thanks, Vlad. Your additional tip is an eye-opener! However, while my original code seemed to work fine on one machine yesterday, it fails today on another machine! I claimed that hWnd gives a reference to the whole form including the borders. But that's not replicated here today. So, when I resize, then the form will release if I enlarge the form. Do you (and others) have that same result?
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form
	DoCreate = .T.
	AutoCenter = .T.
	Caption = "Form1"
	Name = "Form1"
	lMouseOnForm = .F.

	ADD OBJECT timer1 AS timer WITH ;
		Interval = 10, ;
		Name = "Timer1"

	PROCEDURE timer1.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.hWnd = .hWnd
		            *
		            if not .lMouseOnForm 
		               .release
		            endif
		         endif
		      endif

		   case .lMouseOnForm
		      *
		      .lMouseOnForm = .f.
		   endcase
		endwith
	ENDPROC

ENDDEFINE
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform