Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What the f... is this now
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01048571
Message ID:
01048717
Vues:
23
Hi Frank,

Here is the code I have:
*---------------------- Location Section ------------------------
*   Library: 	Iconbuddy.vcx
*   Class: 		Iconbuddy  
*   Method: 	Createtmppicture() 
*----------------------- Usage Section --------------------------
*)  Description: 
*)

*   Scope:      Public
*   Parameters: 
*$  Usage:      
*$              
*   Returns:  
*--------------------- Maintenance Section ----------------------
*   Change Log:
*       CREATED 	09/02/2005 - NN (Frank Dietrich)
*		MODIFIED
*----------------------------------------------------------------
lparameters tcFile as string

local lcExtension, loItem, lcIconFile, lcOutFile, ;
	lcOutStem, loIconLarge, loIconSmall, lnIconsFound, lcTempPath, ;
	ogpInit, ogpImage

*-- Get the extension of the given file
lcExtension = lower(justext(tcFile))

*-- and see if we already have an icon for it
lcIconFile = this.GetIconFile(lcExtension)

if empty(lcIconFile)
*-- Not in the collection yet

	loItem = createobject("EMPTY")
	addproperty(loItem, "cIconLarge", "")
	addproperty(loItem, "cIconSmall", "")
	addproperty(loItem, "cFileType", "")

*-- now extract the icons for the filetype
	loIconLarge  = null
	loIconSmall  = null
	
	lnIconsFound = this.GetAssocIconPairObjects(tcFile, @loIconLarge, @loIconSmall)
	
	if lnIconsFound = 2
		
		IF VARTYPE(this.ogpInit) <> "O"
		    this.ogpInit = newobject("gpinit", "gpImage.prg")  && <-- needed as a basis for gpImage
    	    this.ogpImage = newobject("gpimage", "gpImage.prg")
    	endif	
		
		lcTempPath = addbs(sys(2023))		
	
*-- Save the IconObject to disk
		lcOutStem = "PCT" + sys(2015)
		lcOutFile = lcTempPath + lcOutStem + "_L.BMP"
		lcTempPath = addbs(sys(2023))	

		*-- load the large Icon into the gpImage-Class
		this.ogpImage.FromPicture(loIconLarge)

*-- And save it as a bitmap
		this.ogpImage.SaveAsBMP(lcOutFile)

*-- and keep for further reference
		loItem.cIconLarge = lcOutFile

*-- and do the same with the small icon
		lcOutFile = lcTempPath + lcOutStem + "_S.BMP"

		*-- load the small Icon into the gpImage-Class
		this.ogpImage.FromPicture(loIconSmall)

*-- And save it as a bitmap
		this.ogpImage.SaveAsBMP(lcOutFile)

*-- and keep for further reference
		loItem.cIconSmall = lcOutFile
		loItem.cFileType = this.cFileType
	endif

*-- ... and add the Item to the Collection
	this.oIcons.add( loItem, lcExtension )

endif

return
>Naomi,
>
>I had the same problem and was able to solve it...
>
>this really *is* completely idiotic. I've spent another couple of hours on it now, just to see what happens where. When I do the same steps from within the class I can not access loIcon.Handle at any point, but in the debugger *always* have it at hand, and also am able to query it. The handle does not get destroyed neither. I have now added added two properties that temporarily hold the handle. with those the method runs through and properly creates the bitmaps (So You're getting close to having Your bitmaps). It must have something to do with VFP's internal memory management. Running the same methods from an external prg works like a charm.
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