Microsoft KB Archive/146423

= How to Change the .BMP Picture On a Command Button at Run Time =

Article ID: 146423

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition

-



This article was previously published under Q146423



SUMMARY
The Command Button control has a Picture property that can be assigned a bitmap (a graphic file with a .bmp extension), which allows the bitmap to be displayed on the face of the command button. This article shows by example how the Picture property can be changed at run time to change the bitmap displayed on the button.



Step-by-Step Example
The following example demonstrates how to change the Picture property of a command button at run time.

 Create a new form. In the Form Designer, right-click the form, and select Data Environment. Right-click within the Data Environment window, and select Add. Select Other in the "Add Table or View" dialog box, and select the Customer table from the Testdata database located in the \Vfp\Samples\Data directory. Add a command button (Command1) to the form. Remove Command1 from the Caption property by highlighting the Caption property in the Property Sheet and pressing the DELETE key. Set the command button's Height property to 50 and Width property to 50.  Place the following code in the command button's Init event code: THIS.Picture = 'C:\VFP\SAMPLES\CONTROLS\GRAPHICS\Arw08dn.bmp'   Place the following code in the command button's Click event: IF THIS.parent.List1.Height = 23 THIS.parent.List1.Height = 170 THIS.Picture = HOME + 'SAMPLES\CONTROLS\GRAPHICS\Arw08up.bmp' ELSE THIS.parent.List1.Height = 23 THIS.Picture = HOME + 'SAMPLES\CONTROLS\GRAPHICS\Arw08dn.bmp' ENDIF  Place a list box on the form. Set its Height property to 23, its RowSourceType property to 2-Alias, and its RowSource property to Customer.Contact. Save and run the form.</li> Press the command button to toggle the Height of the list box and toggle the bitmap that displays on the command button.</li></ol>

Additional query words: VFoxWin

Keywords: kbcode KB146423

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.