Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems on Grid with MemberClass
Message
From
03/11/2003 16:53:11
 
 
To
03/11/2003 13:08:29
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00845710
Message ID:
00845801
Views:
22
Fabio,

Could this have something to do with your changing the .Name property? I seem to recall there is some sort of problem in doing that with using the MemberClass feature.


>Hi,
>
>i write a repro code for a first set of problem on grid when a MemberClass
>is defined.
>
>
>#DEFINE fLocation SYS(2023)+'\try'
>#DEFINE prgfile	fLocation+'\tryClassPrg.prg'
>#DEFINE vcxfile	fLocation+'\tryClassLib.vcx'
>
>CLEAR ALL
>CLEAR
>
>_SCREEN.FontSize = 8
>
>IF !DIRECTORY(fLocation)
>	MD fLocation
>ENDIF
>
>columnDef = ''
>TEXT TO columnDef NOSHOW
>
>	DEFINE CLASS hd	AS header
>	
>		FontName	= 'Microsoft Sans Serif'
>		FontSize	= 8
>		Alignment= 2
>		Caption	= ''
>		
>	ENDDEFINE
>
>	DEFINE CLASS Cl  AS Column
>		ADD OBJECT hd AS hd
>	ENDDEFINE
>ENDTEXT
>
>STRTOFILE(columnDef,prgfile)
>
>IF FILE(vcxfile)
>  ERASE vcxfile
>ENDIF
>
>PRIVATE sLog
>sLog = ''
>SET TEXTMERGE ON SHOW
>SET TEXTMERGE TO MEMVAR sLog ADDITIVE
>\ 1. Create a baseGrid subclass, with MemberClass column cl
>
>TRY
>	CREATE CLASS baseGrid OF vcxfile AS Grid NOWAIT
>	MOVE WINDOW "Class Designer" TO 2,100
>	IF ASELOBJ( myGrid, 1   )=1
>		WITH myGrid[1]
>			.MemberClassLibrary=prgfile
>			.MemberClass="cl"
>			.ColumnCount = 1
>			showProperties()
>		ENDWITH
>	ENDIF
>	SaveClass()
>CATCH
>	\ <<MESSAGE()>>
>ENDTRY
>
>\
>\ 2. Now reopen the grid, and rename the column
>
>TRY
>	MODIFY CLASS baseGrid OF vcxfile NOWAIT
>	MOVE WINDOW "Class Designer" TO 2,100
>	IF ASELOBJ( myGrid, 1   )=1
>		WITH myGrid[1].columns[1]
>			\ Column Name
>			_SCREEN.ForeColor = 255
>			\\  <<.name>>
>			.Name = 'MyNameColonna'
>			\\  is RENAMED to <<.name>>
>			\ Header Caption is not (none). It have a ASCII <<ASC(.controls[1].Caption)>>
>			_SCREEN.ForeColor = 0
>			\ Header Name is free.
>			_SCREEN.ForeColor = 255
>			.controls[1].Name = 'hdRenamed'
>			\ I rename Header to <<.controls[1].Name>>
>			_SCREEN.ForeColor = 0
>		ENDWITH
>		showProperties()
>	ENDIF
>	SaveClass()
>CATCH
>	\ <<MESSAGE()>>
>ENDTRY
>
>\
>\ 3. Now TRY to reopen the grid with column renamed
>
>* next i aspect a catch, then flush text on variable
>SET TEXTMERGE TO
>
>TRY
>	MODIFY CLASS baseGrid OF vcxfile NOWAIT
>	MOVE WINDOW "Class Designer" TO 2,100
>	IF ASELOBJ( myGrid, 1   )=1
>		WITH myGrid[1].columns[1]
>			\ Column Name is <<.name>>
>		ENDWITH
>		showProperties()
>	ENDIF
>	closeClass()
>CATCH
>_SCREEN.ForeColor = 255
>\ <<MESSAGE()>>
>_SCREEN.ForeColor = 0
>\ Now rollback the problem, writing on VCX Table.
> sLog = m.sLog;
> 	+CHR(10)+MESSAGE() ;
> 	+CHR(10)+' Now rollback the problem, writing on VCX Table.'+CHR(10)+CHR(10)
>
> USE vcxfile
> BROWSE NOWAIT NOMODIFY
> REPLACE Parent WITH STRTRAN(Parent,'MyNameColonna','Cl1') FOR  ObjName='Text1'
> INKEY(0.5)
> USE
>ENDTRY
>
>SET TEXTMERGE TO MEMVAR sLog ADDITIVE
>
>\
>\ 4. Now reopen the grid with column name rollback
>
>TRY
>	MODIFY CLASS baseGrid OF vcxfile NOWAIT
>	MOVE WINDOW "Class Designer" TO 2,100
>	IF ASELOBJ( myGrid, 1   )=1
>		WITH myGrid[1].columns[1]
>			_SCREEN.ForeColor = 255
>			\ Column new Name is lost. It return to <<.name>>
>			_SCREEN.ForeColor = 0
>			\ Now remove text1 column control and rename the column
>			.removeobject(.controls[2].Name)
>			.Name = 'MyNameColonna'
>			_SCREEN.ForeColor = 255
>			\ Column new Name is <<.name>>
>			\ Header Caption is correct to (none).
>			\ Header Name return to correct name.
>			_SCREEN.ForeColor = 0
>		ENDWITH
>		showProperties()
>	ENDIF
>	SaveClass()
>CATCH
>	\ <<MESSAGE()>>
>ENDTRY
>
>\
>\ 5. Now reopen the grid with column renamed
>
>TRY
>	MODIFY CLASS baseGrid OF vcxfile NOWAIT
>	MOVE WINDOW "Class Designer" TO 2,100
>	IF ASELOBJ( myGrid, 1   )=1
>		WITH myGrid[1].columns[1]
>			\ SubClass is reopen because Text1 parent reference is correct with the column standard name <<.name>>
>			\ Columns have <<.ControlCount>> controls
>			\ VFP not use renamed column, but reapply standard column name
>			_SCREEN.ForeColor = 255
>			\ Then class definition is stable :
>			\ - Column name is forced to standard name
>			\ - Header caption is correct
>			\ - Column have only header control.
>			_SCREEN.ForeColor = 0
>		ENDWITH
>		showProperties()
>	ENDIF
>	closeClass()
>CATCH
> \ <<MESSAGE()>>
>ENDTRY
>
>\
>\ 6. Now build a subclass of this subclass, and want put a EditBox as Cell column Control
>
>TRY
>	CREATE CLASS subBaseGrid OF vcxfile AS baseGrid FROM vcxfile NOWAIT
>	MOVE WINDOW "Class Designer" TO 2,100	
>	IF ASELOBJ( myGrid, 1   )=1
>		WITH myGrid[1].columns[1]
>			_SCREEN.ForeColor = 255
>			\ This SubClass of BaseGrid have on Column <<.name>> <<.ControlCount>> controls !
>			\ Class designer have added a new <<.controls[2].Name>>  control
>			\ Header Caption is (none).
>			_SCREEN.ForeColor = 0
>			\ Now remove <<.controls[2].Name>>
>			.removeobject(.controls[2].Name)
>			\\ and add a EditBox
>			.addobject('Edit1','EditBox')
>		ENDWITH
>		showProperties()
>	ENDIF
>	SaveClass()
>CATCH
>	\ <<MESSAGE()>>
>ENDTRY
>
>FOR k=1 TO 2
>  \
>  \ 7.<<k>> Now reopen the subBaseGrid
>	TRY
>		MODIFY CLASS subBaseGrid OF vcxfile NOWAIT
>		MOVE WINDOW "Class Designer" TO 2,100
>		IF ASELOBJ( myGrid, 1   )=1
>			WITH myGrid[1].columns[1]
>				_SCREEN.ForeColor = 255
>				\ Now SubClass subBaseGrid have on Column <<.name>>
>				_SCREEN.ForeColor = 255
>				\\ <<.ControlCount>> controls !
>				\ Class designer have add another <<.controls[2].Name>>  control
>				\ Header Caption is not (none). It have a ASCII <<ASC(.controls[1].Caption)>>
>				_SCREEN.ForeColor = 0
>			ENDWITH
>			showProperties()
>		ENDIF
>		IF k<2
>			SaveClass()
>		ELSE
>			\ .....
>			\ This continue until a overflow occur.
>			\ The error is on MemberClass loader, it see empty column on BaseGrid,
>			\ then add a Text1, ignoring ControlCount on current subBaseClass column
>			closeClass()
>		ENDIF
>	CATCH
>	 \ <<MESSAGE()>>
>	ENDTRY
>NEXT
>
>\
>\ 8. Now reopen baseGrid, and change Header FontName
>
>TRY
>	MODIFY CLASS baseGrid OF vcxfile NOWAIT
>	MOVE WINDOW "Class Designer" TO 2,100
>	IF ASELOBJ( myGrid, 1   )=1
>		WITH myGrid[1]
>			\ LockColumns is set to
>			.LockColumns = 1
>			_SCREEN.ForeColor = 255
>			\\  <<.LockColumns>>
>			_SCREEN.ForeColor = 0
>			WITH .columns[1].controls[1]
>				\ Header FontName
>				_SCREEN.ForeColor = 255
>				\\  <<.FontName>>
>				.FontName = 'Batang'
>				\\  is set to <<.FontName>>
>				_SCREEN.ForeColor = 0
>			ENDWITH
>		ENDWITH
>		showProperties()
>	ENDIF
>	SaveClass()
>CATCH
>	\ <<MESSAGE()>>
>ENDTRY
>
>\
>\ 9. Now reopen the subBaseGrid
>TRY
>	MODIFY CLASS subBaseGrid OF vcxfile NOWAIT
>	MOVE WINDOW "Class Designer" TO 2,100
>	IF ASELOBJ( myGrid, 1   )=1
>		WITH myGrid[1]
>			\ LockColumns is
>			_SCREEN.ForeColor = 255
>			\\  <<.LockColumns>> . Inheritance is not apply
>			_SCREEN.ForeColor = 0
>			WITH .columns[1].controls[1]
>				\ Header FontName is
>				_SCREEN.ForeColor = 255
>				\\  <<.FontName>> . Inheritance is not apply
>				_SCREEN.ForeColor = 0
>				\ Header Caption is not empty. It have a ASCII <<ASC(.Caption)>>
>			ENDWITH
>		ENDWITH
>	ENDIF
>CATCH
> \ <<MESSAGE()>>
>ENDTRY
>	
>SET TEXTMERGE TO
>SET TEXTMERGE OFF
>
>_CLIPTEXT =M.SLOG
>
>WAIT CLEAR
>*!*	ERASE fLocation+'\*.*'
>*!*	RMDIR fLocation
>
>PROCEDURE showProperties
>*	ALINES(aTips,msg)
>	ACTIVATE WINDOW "properties"
>	WAIT WINDOW "Read on screen area the step messages";
>		+CHR(13)+"See on Properties Window class definition";
>		+CHR(13)+"For next step PRESS SPACE" NOWAIT NOCLEAR
>	MOUSE CLICK AT 20,50 PIXELS WINDOW "properties"
>	DOEVENTS FORCE
>	ACTIVATE WINDOW "Class Designer"
>ENDPROC
>
>PROCEDURE saveClass
>	\ Now save this
>	KEYBOARD '{CTRL+W}' CLEAR PLAIN
>	DOEVENTS FORCE
>ENDPROC
>
>PROCEDURE closeClass
>	KEYBOARD '{CTRL+F4}' CLEAR PLAIN
>	DOEVENTS FORCE
>ENDPROC
>
>
>I need uses a MemberClass Column without cell controls for put
>a different cell control on different subclasses.
>
>I work ( on free time ) to other repro codes for other problems.
>
>Fabio
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform