Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid with Images Problem
Message
 
À
30/06/2005 04:15:07
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01021569
Message ID:
01028859
Vues:
14
Hi Walter

Thanks for the example. I will give it a try.

Simon


>Hi Simon,
>
>
>I've got it. Yesterday afternoon I developped one class that could be used as a graphical checkbox. It is just as simple as dropping the control in the grid column and setting its picture.
>
>Essentially what this control does is:
>
>- Add two image controls in the colum. One blank, one with the check.
>- Add one cmd_checkbox control without the picture.
>
>If the column is active, one of the command buttons is displayed. If not, one of the images is displayed.
>
>The class below makes a reference to a blank.bmp, which is only neccesary to give the second cmd_checkbox control the same look as the first one (A VFP GUI bug causes the outlining to be different if there is no picture attached to the command button). If this is not disturbing to you you can safely ignore it.
>
>It seems pretty solid without any disturbing visual complications. It handles mouseclicks, up and downarrows, spacebar, carriage returns etc as expected.
>
>Sadly because of using BindEvent, it only works for VFP8 and VFP9, but if really neccesary in prior versions you can make it work by implementing some things on the grid level.
>
>HTH,
>
>Walter,
>
>
>
>
>**************************************************
>*-- Class:        cmd_checkbox (i:\tax\ids5\source\classes\taxbase2.vcx)
>*-- ParentClass:  commandbutton
>*-- BaseClass:    commandbutton
>*-- Time Stamp:   06/29/05 08:33:03 PM
>*
>DEFINE CLASS cmd_checkbox AS commandbutton
>
>
>	Caption = ""
>	SpecialEffect = 1
>	Themes = .F.
>	Name = "cmd_checkbox"
>
>
>	*-- Occurs when a user moves to another row or column, after the new cell gets the focus.
>	PROCEDURE afterrowcolchange
>		LPARAMETERS nColIndex
>
>		DO CASE
>			CASE THIS.Parent.parent.ActiveColumn # THIS.Parent.Columnorder
>
>			CASE TYPE(THIS.Parent.ControlSource) = "L"
>				THIS.Parent.CurrentControl = IIF(EVALUATE(THIS.Parent.ControlSource) = .T., THIS.Name, "Unchecked")
>
>			CASE TYPE(THIS.Parent.ControlSource) = "N"
>				THIS.Parent.CurrentControl = IIF(EVALUATE(THIS.Parent.ControlSource) = 1, THIS.Name, "Unchecked")
>		ENDCASE
>		THIS.refresh
>		THIS.Parent.UnChecked.refresh
>	ENDPROC
>
>
>	*-- Occurs when an object is resized.
>	PROCEDURE resize
>
>		THIS.Parent.Image1.Image.Left = (THIS.Parent.Width - THIS.Parent.Image1.Image.Width) /2
>	ENDPROC
>
>
>	PROCEDURE Refresh
>		THIs.VisualEffect = 1
>	ENDPROC
>
>
>	PROCEDURE Init
>		LOCAL cField, cAlias
>
>		IF THIS.Parent.BaseClass = "Column"
>			THIS.BackColor = THIS.Parent.BackColor
>
>			IF TYPE("THIS.Parent.Unchecked.Name") # "C"
>
>				IF !UPPER(JUSTFNAME(THIS.ClassLibrary)) $ UPPER(SET("CLASSLIB"))
>					SET CLASSLIB TO (THIS.ClassLibrary) ADDI
>				ENDIF
>
>				THIS.Parent.AddObject("Unchecked","Cmd_checkbox")
>				THIS.Parent.Unchecked.Visible = .T.
>				THIS.Parent.Unchecked.Specialeffect = 1
>				THIS.Parent.Unchecked.Picture = ADDBS(JUSTPATH(THIS.Picture))+"Blank.bmp"
>				THIS.Parent.Sparse = .F.
>
>
>				cAlias = JUSTSTEM(THIS.Parent.ControlSource)
>				cField = JUSTEXT(THIS.Parent.ControlSource)
>				IF !EMPTY(cAlias) AND !EMPTY(cField)
>					THIS.Parent.DynamicCurrentControl = "IIF(RECNO('"+cAlias+"') = THIS.Recno AND "+;
>						"THIS.ActiveColumn = "+ALLTRIM(STR(THIS.Parent.Columnorder))+ ;
>						", IIF("+THIS.Parent.ControlSource+",'"+THIS.Name+"','Unchecked'),"+;
>						"IIF("+THIS.Parent.ControlSource+",'Image1','Image2'))"
>				ENDIF
>
>				THIS.Parent.AddObject("Image1","Container")
>				WITH THIS.Parent.Image1
>					.Backstyle = 0
>					.Borderwidth = 0
>					.Visible = .T.
>					.AddObject("Image","Image")
>					.Image.Visible = .T.
>					.Image.Picture = THIS.Picture
>				ENDWITH
>
>				THIS.Parent.AddObject("Image2","Container")
>				WITH THIS.Parent.Image2
>					.Backstyle = 0
>					.Borderwidth = 0
>					.Visible = .T.
>				ENDWITH
>
>				BINDEVENT(THIS.Parent, "Resize", THIS, "Resize")
>				BINDEVENT(THIS.Parent.Parent, "AfterRowColChange", THIS, "afterrowcolchange")
>
>				THIS.Resize
>			ENDIF
>		ENDIF
>		THIS.SpecialEffect = 1
>	ENDPROC
>
>
>	PROCEDURE Click
>		LOCAL cField, cAlias
>
>		DO CASE
>			CASE TYPE("THIS.Parent.Controlsource") # "C" OR THIS.Parent.Readonly
>				** Do nothing
>
>			CASE TYPE(THIS.Parent.Controlsource) = "L"
>
>				cField = JUSTEXT(THIS.Parent.ControlSource)
>				cAlias = JUSTSTEM(THIS.Parent.ControlSource)
>
>				REPLACE &cField WITH !&cField IN (cAlias)
>				THIS.Parent.Parent.Refresh
>
>			CASE TYPE(THIS.Parent.Controlsource) = "N"
>				cField = JUSTEXT(THIS.Parent.ControlSource)
>				cAlias = JUSTSTEM(THIS.Parent.ControlSource)
>
>				REPLACE &cField WITH BITXOR(&cField,1) IN (cAlias)
>				THIS.Parent.Parent.Refresh
>		ENDCASE
>
>	ENDPROC
>
>
>	PROCEDURE KeyPress
>		LPARAMETERS nKeyCode, nShiftAltCtrl
>
>		IF nkeyCode = 13
>			NODEFAULT
>			KEYBOARD '{TAB}'
>		ENDIF
>	ENDPROC
>
>
>ENDDEFINE
>*
>*-- EndDefine: cmd_checkbox
>**************************************************
>
Simon White
dCipher Computing
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform