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:
01051281
Views:
23
>>
>> Thanks, Frank. Your new version works fine for me and I don't have to change my code.
>> Also is it OK to remove version6 from the IconBuddy.vcx? I did so in my version.
>>
>
>Yes. IconBuddy6 is for VFP6-users. Some of the api-calls do not work the same way there. an external dll is needed to make that work. this is what version6 is for. So if You're using 7+ You're fine without it. 6 is inherited from IconBuddy. So nothing can happen.
>
>Good it works now - thanks for the tip
>
>>
>> One more question: if I use thisform.oIconBuddy = newobject(...) I have to
>> do thisform.oIconBuddy = null in form's destroy, right?
>>
>
>I am not using any OLE-Controls in it, so it should be ok to leave it out, it will be destroyed automatically. But I prefer to do a proper cleanup and garbage collection. In IconBuddy's destroy, dll's get released and temporary icons erased from disk. So, I would give it the time it needs to do its cleanup by issuing a deliberate this.oIconBuddy = null.

I found I was using a different syntax (e.g. thisform.NewObject('oIconBuddy',..), so no code is required in this case from me.

Thanks again, my form is now completed and looks quite nice. May be you can convert my classes to VFP base classes and include this form as a test form with your class. Here is my current code again:
**************************************************
*-- Class:        frmfileselector (c:\mmviscollect\libs\aforms.vcx)
*-- ParentClass:  browserform (c:\mmviscollect\libs\aforms.vcx)
*-- BaseClass:    form
*-- Time Stamp:   09/19/05 01:17:04 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
	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), ;
		cseektag = "cFile_Name", ;
		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), ;
		cseektag = "cType", ;
		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 UPPER(cFile_Name) TAG cFile_Name
		   INDEX on UPPER(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, loIconBuddy
		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

		STORE .null. TO loFile, loFolder, loFSO

		IF RECCOUNT('curFiles') = 0
		   =ErrorMsg("The directory " + m.tcDirectory + " does not contain files")   
		   RETURN .f.
		ENDIF

		IF NOT DODEFAULT()
			RETURN .F.
		ENDIF

		thisform.uRetVal = ""
		thisform.grdFiles.colImage.DynamicFontShadow = "thisform.grdFiles.colImage.Refresh()"         
	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.picture = 'downarrow.bmp'
			.oLastSorted = .colLastModified.Header1
			SET ORDER TO tDate descending
			GO TOP IN curFiles
			.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.DblClick
		*---------------------- Location Section ------------------------
		*   Library: 	Aforms.vcx
		*   Class: 		Frmfileselector  
		*   Method: 	Grdfiles.Dblclick() 
		*----------------------- Usage Section --------------------------
		*)  Description: 
		*)

		*   Scope:      Public
		*   Parameters: 
		*$  Usage:      
		*$              
		*   Returns:  
		*--------------------- Maintenance Section ----------------------
		*   Change Log:
		*       CREATED 	09/19/2005 - NN 
		*		MODIFIED
		*----------------------------------------------------------------
		thisform.SelectRecord() 
	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 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