Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What the f... is this now
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01048571
Message ID:
01050005
Views:
25
Frank,

Bellow is the form's code what uses your class. It works quite nicely (a little bit slow) and the grid flickers much. I'm going to show it to my manager and let them decide, if they want to have the pictures or not. I like them.

If you want to run it, you would have to substitute my classes with your classes (form class, grid class, etc.)
**************************************************
*-- Class:        frmfileselector (c:\mmviscollect\libs\aforms.vcx)
*-- ParentClass:  browserform (c:\mmviscollect\libs\aforms.vcx)
*-- BaseClass:    form
*-- Time Stamp:   09/15/05 01:42:06 PM
*-- A list of files in the specific directory
*
DEFINE CLASS frmfileselector AS browserform


	Height = 306
	Width = 673
	DoCreate = .T.
	Caption = "Select File"
	WindowType = 1
	*-- Index of the last sorted column
	nlastsorted = 3
	*-- 0 means the ascending order, 1 means descending order
	nsortorder = 0
	cnavigationalias = "curFiles"
	cnavigationgridname = "thisform.grdFiles"
	Name = "frmfileselector"
	oSessionEnvironment.CLabel1.Name = "CLabel1"
	oSessionEnvironment.Name = "oSessionEnvironment"


	ADD OBJECT cmdcancel AS ccommandbutton WITH ;
		Top = 266, ;
		Left = 301, ;
		Height = 24, ;
		Width = 71, ;
		Caption = "\<Cancel", ;
		TabIndex = 32, ;
		Name = "cmdCancel"


	ADD OBJECT cmdok AS ccommandbutton WITH ;
		Top = 266, ;
		Left = 224, ;
		Height = 24, ;
		Width = 71, ;
		Caption = "\<Select", ;
		TabIndex = 30, ;
		ZOrderSet = 7, ;
		Name = "cmdOK"


	ADD OBJECT cmdclose AS ccommandbutton WITH ;
		Top = 265, ;
		Left = 378, ;
		Height = 24, ;
		Width = 71, ;
		Caption = "C\<lose", ;
		TabIndex = 32, ;
		Name = "cmdClose"


	ADD OBJECT grdfiles AS grdsorting WITH ;
		ColumnCount = 5, ;
		Height = 230, ;
		Left = 12, ;
		ReadOnly = .T., ;
		RecordSource = "curFiles", ;
		Top = 24, ;
		Width = 646, ;
		ZOrderSet = 4, ;
		lresizable = .T., ;
		Name = "grdFiles", ;
		Column1.FontSize = 8, ;
		Column1.ControlSource = "", ;
		Column1.Width = 17, ;
		Column1.ReadOnly = .T., ;
		Column1.Sparse = .F., ;
		Column1.Name = "colImage", ;
		Column2.FontSize = 8, ;
		Column2.ControlSource = "curFiles.cFile_Name", ;
		Column2.Width = 154, ;
		Column2.ReadOnly = .T., ;
		Column2.Name = "colName", ;
		Column3.FontSize = 8, ;
		Column3.Alignment = 1, ;
		Column3.ColumnOrder = 4, ;
		Column3.ControlSource = "curFiles.cFIle_Size", ;
		Column3.Width = 108, ;
		Column3.ReadOnly = .T., ;
		Column3.InputMask = "XXXXXXXXXX", ;
		Column3.Name = "colSize", ;
		Column4.FontSize = 8, ;
		Column4.ColumnOrder = 5, ;
		Column4.ControlSource = "curFiles.cFile_Type", ;
		Column4.Width = 189, ;
		Column4.ReadOnly = .T., ;
		Column4.Name = "colType", ;
		Column5.FontSize = 8, ;
		Column5.ColumnOrder = 3, ;
		Column5.ControlSource = "curFiles.tLast_Modified", ;
		Column5.Width = 183, ;
		Column5.ReadOnly = .T., ;
		Column5.Name = "colLastModified"


	ADD OBJECT frmfileselector.grdfiles.colimage.header1 AS header WITH ;
		FontSize = 8, ;
		Caption = "*", ;
		Name = "Header1"


	ADD OBJECT frmfileselector.grdfiles.colimage.fileicon AS cimage WITH ;
		Picture = "..\graphics\jzlogo.bmp", ;
		Height = 104, ;
		Left = 12, ;
		Top = 23, ;
		Width = 300, ;
		Name = "FileIcon"


	ADD OBJECT frmfileselector.grdfiles.colname.header1 AS header WITH ;
		FontSize = 8, ;
		Caption = "Name", ;
		Name = "Header1"


	ADD OBJECT frmfileselector.grdfiles.colname.cgridtextbox1 AS cgridtextbox WITH ;
		FontSize = 8, ;
		ReadOnly = .T., ;
		SelectedBackColor = RGB(0,0,255), ;
		Name = "Cgridtextbox1"


	ADD OBJECT frmfileselector.grdfiles.colsize.header1 AS header WITH ;
		FontSize = 8, ;
		Alignment = 1, ;
		Caption = "Size    ", ;
		Name = "Header1"


	ADD OBJECT frmfileselector.grdfiles.colsize.cgridtextbox1 AS cgridtextbox WITH ;
		FontSize = 8, ;
		Alignment = 1, ;
		ReadOnly = .T., ;
		SelectedBackColor = RGB(0,0,255), ;
		Name = "Cgridtextbox1"


	ADD OBJECT frmfileselector.grdfiles.coltype.header1 AS header WITH ;
		FontSize = 8, ;
		Caption = "Type", ;
		Name = "Header1"


	ADD OBJECT frmfileselector.grdfiles.coltype.cgridtextbox1 AS cgridtextbox WITH ;
		FontSize = 8, ;
		ReadOnly = .T., ;
		SelectedBackColor = RGB(0,0,255), ;
		Name = "Cgridtextbox1"


	ADD OBJECT frmfileselector.grdfiles.collastmodified.header1 AS header WITH ;
		FontSize = 8, ;
		Caption = "Last Modified", ;
		Name = "Header1"


	ADD OBJECT frmfileselector.grdfiles.collastmodified.cgridtextbox1 AS cgridtextbox WITH ;
		FontSize = 8, ;
		ReadOnly = .T., ;
		SelectedBackColor = RGB(0,0,255), ;
		Name = "Cgridtextbox1"


	PROCEDURE selectrecord
		*---------------------- Location Section ------------------------
		*   Library: 	Aforms.vcx
		*   Class: 		Frmfileselector  
		*   Method: 	Selectrecord() 
		*----------------------- Usage Section --------------------------
		*)  Description: 
		*)

		*   Scope:      Public
		*   Parameters: 
		*$  Usage:      
		*$              
		*   Returns:  
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	08/29/2005 - NN 
		*		MODIFIED
		*----------------------------------------------------------------
		thisform.uRetVal = curFiles.cFile_Name

		thisform.Hide()
	ENDPROC


	PROCEDURE Load
		*---------------------- Location Section ------------------------
		*   Library: 	Aforms.vcx
		*   Class: 		Frmfileselector  
		*   Method: 	Load() 
		*----------------------- Usage Section --------------------------
		*)  Description: 
		*)

		*   Scope:      Public
		*   Parameters: 
		*$  Usage:      
		*$              
		*   Returns:  
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	08/29/2005 - NN 
		*		MODIFIED
		*----------------------------------------------------------------
		IF DODEFAULT()
		   create cursor curFiles(cFile_Name c(100), nFile_Size n(10), ;
		                          cFile_Type c(100), tLast_Modified t, ;
		                          cIcon_File C(100), cFile_Size C(15))
		   
		   INDEX on cFile_Name TAG cFile_Name
		   INDEX on cFile_Type TAG cType additive
		   INDEX on cFile_Size TAG cSize additive   
		   INDEX on tLast_Modified TAG tDate additive
		ENDIF
	ENDPROC


	PROCEDURE Init
		*---------------------- Location Section ------------------------
		*   Library: 	Aforms.vcx
		*   Class: 		Frmfileselector
		*   Method: 	Init()
		*----------------------- Usage Section --------------------------
		*)  Description:
		*)

		*   Scope:      Public
		*   Parameters:
		*$  Usage:
		*$
		*   Returns:
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	08/29/2005 - NN (FSO code by the late Ed Rauh)
		*		MODIFIED
		*----------------------------------------------------------------
		LPARAMETERS tcDirectory, tcFileExt

		IF EMPTY(m.tcDirectory)
			tcDirectory = GETDIR()
		ENDIF

		this.Caption = this.Caption + ' from ' + m.tcDirectory

		LOCAL loFSO, loFolder, loFile, lcFileType, lcIconFile
		thisform.NewObject("oIconBuddy","iconbuddy", "iconbuddy.vcx")

		loFSO = CREATEOBJECT('Scripting.FileSystemObject')
		loFolder = m.loFSO.GetFolder(m.tcDirectory)

		FOR EACH loFile IN m.loFolder.FILES
			WITH loFile

				IF (EMPTY(m.tcFileExt) OR JUSTEXT(.PATH)== m.tcFileExt) AND NOT INLIST(LOWER(JUSTEXT(.Path)),"exe","dll","ico")
					lcFile = .PATH

					thisform.oIconBuddy.CreateTmpIcons(m.lcFile,.f.,.t.) && Create bitmaps and not icons

		            ** Get the small picture
					lcIconFile = thisform.oIconBuddy.GetTMPIconFileName(LOWER(JUSTEXT(m.lcFile)),.f.,.t.)
					lcFileType = thisform.oIconBuddy.cFileType

					INSERT INTO curFiles VALUES ;
					(JUSTFNAME(m.lcFile), .SIZE, ;
					m.lcFileType, .DateLastModified, m.lcIconFile, ;
					ALLTRIM(STR(ceiling(.Size/1024))) + " KB" )

				ENDIF
			ENDWITH
		ENDFOR

		loFile = .NULL.
		loFolder = .NULL.
		loFSO = .NULL.

		thisform.uRetVal = ""

		*SET ORDER TO tDate DESCENDING IN curFiles

		thisform.grdFiles.colImage.DynamicFontShadow = "thisform.grdFiles.colImage.Refresh()"
		GO TOP IN curFiles

		IF NOT DODEFAULT()
			RETURN .F.
		ENDIF
	ENDPROC


	PROCEDURE Activate
		*---------------------- Location Section ------------------------
		*   Library: 	Aforms.vcx
		*   Class: 		Frmfileselector
		*   Method: 	Activate()
		*----------------------- Usage Section --------------------------
		*)  Description:
		*)

		*   Scope:      Public
		*   Parameters:
		*$  Usage:
		*$
		*   Returns:
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	09/01/2005 - NN
		*		MODIFIED
		*----------------------------------------------------------------
		dodefault()
		with thisform.grdFiles
			.colLastModified.Header1.click()
			.colLastModified.Header1.click()
			.setfocus()
		endwith
	ENDPROC


	PROCEDURE cmdcancel.Click
		*---------------------- Location Section ------------------------
		*   Library: 	Aforms.vcx
		*   Class: 		Frmfilesselector  
		*   Method: 	Cmdcancel.Click() 
		*----------------------- Usage Section --------------------------
		*)  Description: 
		*)

		*   Scope:      Public
		*   Parameters: 
		*$  Usage:      
		*$              
		*   Returns:  
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	08/29/2005 - NN 
		*		MODIFIED
		*----------------------------------------------------------------
		thisform.Hide()
	ENDPROC


	PROCEDURE cmdok.Click
		*---------------------- Location Section ------------------------
		*---------------------- Location Section ------------------------
		*   Library: 	Aforms.vcx
		*   Class: 		Frmfilesselector  
		*   Method: 	Cmdok.Click() 
		*----------------------- Usage Section --------------------------
		*)  Description: 
		*)

		*   Scope:      Public
		*   Parameters: 
		*$  Usage:      
		*$              
		*   Returns:  
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	08/29/2005 - NN 
		*		MODIFIED
		*----------------------------------------------------------------
		thisform.SelectRecord() 
	ENDPROC


	PROCEDURE cmdclose.Click
		*---------------------- Location Section ------------------------
		*   Library: 	Aforms.vcx
		*   Class: 		Frmfilesselector  
		*   Method: 	CmdClose.Click() 
		*----------------------- Usage Section --------------------------
		*)  Description: 
		*)

		*   Scope:      Public
		*   Parameters: 
		*$  Usage:      
		*$              
		*   Returns:  
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	08/29/2005 - NN 
		*		MODIFIED
		*----------------------------------------------------------------
		thisform.release()
	ENDPROC


	PROCEDURE grdfiles.colImage.Refresh
		*---------------------- Location Section ------------------------
		*   Library: 	Aforms.vcx
		*   Class: 		Frmfileselector  
		*   Method: 	Colimage.Refresh() 
		*----------------------- Usage Section --------------------------
		*)  Description: 
		*)

		*   Scope:      Public
		*   Parameters: 
		*$  Usage:      
		*$              
		*   Returns:  
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	09/01/2005 - NN 
		*		MODIFIED
		*----------------------------------------------------------------
		NODEFAULT
		this.FileIcon.Picture = curFiles.cIcon_File
	ENDPROC


ENDDEFINE
*
*-- EndDefine: frmfileselector
**************************************************
>If You like to try it, here is the new beta.
>
>http://www.personalplanung.com/download/Iconbuddy_1_4b_2.zip
>
>it now has the catalogue-function in it. I modified the methods and hope You don't have too much trouble with that.
>
>There is one HighLevel-Method CreateTMPIcons() that will create temporary Icons and/or BMP's with one line of code and have them in the collection. For filenaming You will find properties like cTMPIconsDir, ..Prefix, ..Suffix, ..Extension etc. The default points to SYS(2023)
>
>So the catalogue (collection) now holds up to four filenames and so GetTMPIconFileName() has an additional Parameter.
>
>You also have GetTMPIconsIndex() (to query the index for an Extension) and GetTMPIconsObject (to get the whole Item) and GetTMPIconFileName() to query a filename for an associated Icon (large/small) or Bitmap (large/small)
>
>By default all TMP-Files get erased when IconBuddy dies. But this can be switched off with lAutoDeleteTMPIcons = .F.
>
>the collection has been renamed to oTMPIcons
>
>Have a look at TEST_SAVE5.PRG
>
>Saving associated Icons as BMP-Files without the Collection can be done with GetAssocIconPair2BMPFile()
>
>I think this should be the most important changes.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform