Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP6 version of PreVFP historic code
Message
From
13/07/2004 14:05:52
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00922398
Message ID:
00923883
Views:
21
Hi Bhavbhuti,

One of the problems with posting bits of code that work independantly is that they need twiddling to integrate them into an application.

It is a bit artificial, but I have tried to reproduce an app (below) that uses the selection object we have been playing with. You will notice that the CLEAR EVENTS has been removed from the selection object and placed in the Destroy event of the main form. Whether it goes here or/and in a menu Exit button is up to you. I have added a little bit of bullet proofing to the select object, so that the correct table is selected and the prior table is restored on entry and exit from the object.

If you are likely to use this sort of object in the future, it would be a good idea to generalise the code and add the class to a class library.

Depending on your preferences, this could all be done visually but for ease of posting I have stuck to coding it out explicitly.

Does this sort out your READ EVENTS problem?

Alan
USE cname
oSel = CREATEOBJECT("MySelect")		&& Create a selection object

oForm = CREATEOBJECT("myForm")
oForm.Visible = .T.

READ EVENTS

* Tidy up code goes here
* ... 

DEFINE CLASS myForm AS Form

	ADD OBJECT oButt1 AS Commandbutton
	
	oButt1.Caption="Select"
	oButt1.Top = 5
	oButt1.Left = 5

	FUNCTION oButt1.Click
	
		oSel.Visible = .T.
		
	ENDFUNC
	
	ADD OBJECT oButt2 AS Commandbutton
	
	oButt2.Caption="Exit"
	oButt2.Top = 35
	oButt2.Left = 5

	FUNCTION oButt2.Click
	
		ThisForm.Release
		
	ENDFUNC
	
	FUNCTION Destroy
	
		CLEAR EVENTS
		
	ENDFUNC

ENDDEFINE

DEFINE CLASS mySelect AS Form

	ShowWindow = 1 && 0=In Screen, 1=In Top-Level Form, 2=As Top-Level Form
	WindowType = 0 && 0=Modeless, 1=Modal
	AlwaysOnTop = .T.
	Height = 60
	Width = 220
	Caption = "Select Data Folder"
	MaxButton = .F.
	MinButton = .F.
	OldSel = ''

	ADD OBJECT myListbox AS Listbox WITH ;
		Left = 0,;
		Top = 0,;
		Height = 60,;
		Width = 220,;
		ColumnCount = 3,;
		ColumnWidths = '70,64,52',;
		FirstElement = 1,;
		NumberOfElements = 0,;
		RowSource = 'cname,cextra,iid',;
		RowSourceType = 6
		
	FUNCTION myListbox.DblClick
	
		ThisForm.Visible=.F.
		
	ENDFUNC
		
	FUNCTION myListbox.KeyPress
	
		LPARAMETERS nKeyCode, nShiftAltCtrl
		IF nKeyCode = 13	&& Allow ENTER to terminate
			ThisForm.Visible=.F.
		ENDIF
		
	ENDFUNC
	
	FUNCTION Activate
	
		This.OldSel = SELECT()
		SELECT cname
		
	ENDFUNC
	
	FUNCTION Deactivate
		
		WAIT WINDOW cname+cextra+STR(iid)
		SELECT (This.OldSel)
		
	ENDFUNC

ENDDEFINE
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform