Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetFile analogue with ability to limit directory
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01044804
Message ID:
01045114
Vues:
31
>Hi Naomi,
>
>(huh... big change for me :-) )
>
>API GetOpenFileName() don't support flag OFN_NOCHANGEDIR as GetSaveFileName(). Maybe is possibly create DLL/FLL with hook procedure and test if user change folder - if yes, then change current folder to default folder.
>
>MartinJ
>
I decided to create the interface myself using ListView and IconBuddy to put icons and file type. It works quite nicely except that for some reason I can not re-order by clicking on the columns. That's my first attempt to use ListView, so I'm not familiar with all the properties I have to set to make it work. Here is my current code, may be you can help me out to finish it:
LPARAMETERS tcDirectory, tcFileExt

* Listview Control Constants
#DEFINE lvwIcon 		0
#DEFINE lvwSmallIcon	1
#DEFINE LvwList			2
#DEFINE lvwReport 		3

* ListColumnAlignment Constants
#Define lvwColumnLeft 	0
#Define lvwColumnRight 	1
#Define lvwColumnCenter	2

LOCAL loFSO, loFolder, loFile, lcImgKey, lnIndexSmall, lnIndexLarge, loListItem, loIconBuddy, lcFile

IF NOT DODEFAULT()
	RETURN .F.
ENDIF

IF EMPTY(m.tcDirectory)
	tcDirectory = GETDIR()
*!*	   =System_Parameters_list('c_SP')
*!*	   tcDirectory = c_Sp.cLocation_Client_Imports
*!*	   USE IN c_SP
ENDIF

WITH THISFORM.ListView
	.ColumnHeaderIcons = THISFORM.oleImageList3  && this was set visually using the designer
* to get the width I will specify for each column.  You may specify specific values if you wish.
	liWidth = INT(.WIDTH/4)	
	.VIEW = lvwReport
ENDWITH
	
WITH THISFORM.ListView.ColumnHeaders 

* Add Column Headers to List View

* this adds column headings to the listview control it assigns the next
* index value to the new item (because I did not include the first
* parameter where I could set the index value), then sets the values
* for Key, Text, Width, Column Alignment, and ColumnHeadingIcon imagelist index

	.ADD(,"Name","Name",liWidth,lvwColumnLeft,1)	&& column heading 1
	.ADD(,"Size","Size",liWidth,lvwColumnLeft,0)	&& column heading 2
	.ADD(,"Type"   ,"Type"   ,liWidth,lvwColumnLeft,0)	&& column heading 3
	.ADD(,"LastModified" ,"Last Modified" ,liWidth,lvwColumnLeft,0)	&& column heading 4
*.Add(,"Hidden","Hidden",0,lvwColumnLeft,0)	&& column heading 0
	
ENDWITH

thisform.ListView.ColumnHeaders(thisform.ListView.SortKey+1).ICON = 1

loIconBuddy = NEWOBJECT("iconbuddy", "iconbuddy.vcx")
lnIndexSmall = 0
lnIndexLarge = 0

loFSO = CREATEOBJECT('Scripting.FileSystemObject')
loFolder = m.loFSO.GetFolder(m.tcDirectory)
** Code by Frank Dietrich
FOR EACH loFile IN m.loFolder.FILES
	WITH loFile

		IF EMPTY(m.tcFileExt) OR JUSTEXT(.PATH)== m.tcFileExt
			lcFile = .PATH
			lcImgKey = LOWER(JUSTEXT(m.lcFile))

*========================================*
*  Resource-Files have their own icons.  *
*  so build another key here             *
*========================================*
			IF INLIST(m.lcImgKey, "exe","dll","ico")
				lcImgKey = LOWER( JUSTFNAME(m.lcFile) )
			ENDIF

*-- Extract the large associated Image to the
*-- first ImageList
			lnIndexLarge = loIconBuddy.Extract2ImageList(m.lcFile, m.lcImgKey,;
				THISFORM.ImageListLarge, .F., -1)

*-- and now the small one
			lnIndexSmall =  loIconBuddy.Extract2ImageList(m.lcFile, m.lcImgKey,;
				THISFORM.ImageListSmall, .T., -1)

			THISFORM.ListView.OBJECT.Icons 	 = THISFORM.ImageListLarge.OBJECT
			THISFORM.ListView.OBJECT.SmallIcons = THISFORM.ImageListSmall.OBJECT

			loListItem = thisform.ListView.ListItems.ADD( ,m.lcImgKey+SYS(2015), JUSTFNAME(m.lcFile), m.lnIndexLarge, m.lnIndexSmall)
			m.loListItem.SubItems(1) = .SIZE
			m.loListItem.SubItems(2) = ALLTRIM(m.loIconBuddy.cFileType)
			m.loListItem.SubItems(3) = .DateLastModified
			
			INSERT INTO curFiles VALUES (JUSTFNAME(m.lcFile), .SIZE, loIconBuddy.cFileType, .DateLastModified )
		ENDIF	
	ENDWITH
ENDFOR

loFile = .NULL.
loFolder = .NULL.
loFSO = .NULL.
loIconBuddy = .NULL.
WITH thisform.ListView 
   .Sorted = .t.
   .refresh()
endwith
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform