How to Create Customized Command Button by brzi brzi@devious.tsongkie.com Released Under DEViOUS http://devious.tsongkie.com ---------------------------- The steps to create a customized "command button" are as follows: 1. Start Visual Basic 2. Put a picture control (Picture1) on Form1. 3. Set the properties for Picture1 as given in the chart below: Property Value -------- ----- AutoRedraw True AutoSize True BorderStyle 0-None DrawMode 6-Invert 4. Assign the Picture property of Picture1 to the bitmap of your choice. For example, choose ARW01DN.ICO from the ARROWS subdirectory of the ICONS directory shipped with Visual Basic. This is a good example of a bitmap with a three dimensional appearance. 5. Enter the following code in the Picture1_DblClick event procedure of Picture1: Sub Picture1_DblClick () Picture1.Line (0, 0)-(Picture1.width, Picture1.height), , BF End Sub NOTE: This code is necessary to avoid getting the bitmap stuck in an inverted state because of Mouse messages being processed out of order or from piling up due to fast clicking. 6. Enter the following code in the Picture1_MouseDown event procedure of Picture1: Sub Picture1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single) ' Append to above line Picture1.Line (0, 0)-(Picture1.width, Picture1.height), , BF End Sub 7. Enter the following code in the Picture1_MouseUp event procedure of Picture1: Sub Picture1_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single) ' Append to above line. Picture1.Line (0, 0)-(Picture1.width, Picture1.height), , BF End Sub 8. Add the following code to the Picture1_KeyUp event procedure for Picture1: Sub Picture1_KeyUp (KeyCode As Integer, Shift As Integer) '* Check to see if the ENTER key was pressed. If so, restore '* the picture image. If KeyCode = 13 Then Picture1.Line (0, 0)-(Picture1.width, Picture1.height), , BF End If End Sub 9. Add the following code to the Picture1_KeyDown event procedure for Picture1: Sub Picture1_KeyDown (KeyCode As Integer, Shift As Integer) '* Check to see if the ENTER key was pressed. If so, invert '* the picture image. If KeyCode = 13 Then Picture1.Line (0, 0)-(Picture1.width, Picture1.height), , BF End If End Sub -----------------------------------------------------------------------