Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Icons
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Re: Icons
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01059033
Message ID:
01060374
Views:
18
><snip>
>>b) keep the sets in folders underneath a master folder, and use an entry in a configuration DBF to point the app to the desired folder/set of graphics. Your app would have to look at this DBF entry at runtime to assign the correct location and file name of the desired icon/bitmap (this is not difficult, and is the way most of my apps currently behave).
>>
>
>Hi Evan. Where do you set the path for the bmp's and icons using the above? Do you set the icon/bmp for each control in the init for the control or form? what about the menu items?
>
>I have tried playing around with SET PATH in VFP to tell it the search path to use for locating bmps/icons but my menu, which has bmp's, fails and it does not appear to find the image files.
>
>Thanks,

Jos,

My approach is as follows:
All my CommandButton controls have a custom property called icPictureFileName, which holds the name of the BMP/ICO file I want for that button. You could define the same property for any control you desired that needed an associated graphic.

I have a base container called ctrCommandBar, with a custom method called PopulateCommandButtonPictures() and a custom property called icPictureFilePath. You could also do this as a method and property of your primary Form class if you wanted.

The Init() of that container looks like this:
LOCAL llAppExists, ;
      llReturnValue

*-- Define local variables
llAppExists   = ( TYPE( "oApp" ) = "O" AND !ISNULL( oApp ) )

*-- Perform the default behavior
llReturnValue = DODEFAULT()

*-- If the default behavior was successful,
*-- assign the desired properties
IF llReturnValue
	*-- If we have an app object, read the value from the configuration DBF
	THIS.icPictureFilePath = IIF( EMPTY( THIS.icPictureFilePath ) AND llAppExists, ;
					oApp.GetAppInfo( "CommandButtonPictureFilePath" ), ;
					THIS.icPictureFilePath ;
				     )

	*-- If the picture file path is null,
	*-- store an empty string so we don't get errors
	IF ISNULL( THIS.icPictureFilePath )
		THIS.icPictureFilePath = SPACE( 0 )

	ENDIF && ISNULL( THIS.icPictureFilePath )

	*-- Populate the CommandButton controls
	*-- with the desired pictures
	THIS.PopulateCommandButtonPictures()

ENDIF && llReturnValue

*-- Clean up and return
RETURN ( llReturnValue )
The PopulateCommandButtonPictures() code looks like this:
LOCAL lcPictureFilePath, ;
	loControl

*-- Define local variables
lcPictureFilePath = THIS.icPictureFilePath
loControl         = .NULL.

*-- If we have a file path,
*-- add a backslash to the end
lcPictureFilePath = IIF( !EMPTY( lcPictureFilePath ), ;
                          ADDBS( lcPictureFilePath ), ;
                          lcPictureFilePath ;
			)

*-- Loop through the contained controls
FOR EACH loControl IN THIS.Controls
	*-- If the control has the icPictureFileName property,
	*-- assign the Picture property of the control
	IF PEMSTATUS( loControl, "icPictureFileName", 5 )	
		loControl.Picture = lcPictureFilePath + loControl.icPictureFileName

	ENDIF && PEMSTATUS( loControl, "icPictureFileName", 5 )
ENDFOR && EACH loControl IN THIS.Controls
You could apply this same concept to menus by placing this code in a separate logic class and firing the necessary methods in the Skip For prompt option of each menu bar.
Evan Pauley, MCP
Positronic Technology Systems LLC
Knoxville, TN

If a vegetarian eats vegetables, what does a humanitarian eat?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform