DOCUMENT:Q146423 05-FEB-2000 [foxpro] TITLE :How to Change the .BMP Picture On a Command Button at Run Time PRODUCT :Microsoft FoxPro PROD/VER:WINDOWS:3.0,3.0b OPER/SYS: KEYWORDS:kbcode ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b ------------------------------------------------------------------------------- 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. MORE INFORMATION ================ Step-by-Step Example -------------------- The following example demonstrates how to change the Picture property of a command button at run time. 1. Create a new form. 2. 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. 3. 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. 4. Place the following code in the command button's Init event code: THIS.Picture = 'C:\VFP\SAMPLES\CONTROLS\GRAPHICS\Arw08dn.bmp' 5. 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 6. 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. 7. Save and run the form. 8. Press the command button to toggle the Height of the list box and toggle the bitmap that displays on the command button. Additional query words: VFoxWin ====================================================================== Keywords : kbcode Technology : kbVFPsearch kbAudDeveloper kbVFP300 kbVFP300b Version : WINDOWS:3.0,3.0b ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2000.