VB icon

Real C++ Buttons (Fixed)

Email
Submitted on: 1/5/2015 3:43:00 AM
By: Randy Mcdowell (Nebuland Technologies) (from psc cd)  
Level: Advanced
User Rating: By 8 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 1926
 
     Notice: THIS CODE HAS BEEN FIXED! PLEASE READ THE COMMENTS AT THE BOTTOM OF THE PAGE TO SEE WHAT WAS WRONG BEFORE. Create real C++ style command buttons with ONE line of code!!! You can use this code on any of your commands buttons. You will loose any images and the BackColor of the button, but that really doesn't matter because you can 'paint' images onto the button using the API. Make sure you set the style property to 'Graphical' or this will not work!. OK here is how it works. You see, by default Visual Basic's command buttons are drawn with the 'Default Push Button' style, which makes them flat and ugly when pushed. But when you set the style to 'Graphical' its really just a C++ button with a single pixel outline drawn around it. This code basically just stops the button from drawing that line to create a sunken style button. This code is not compatible with Visual Basic 4.0/32 because its buttons don't have the style property. However, in Visual Basic 4.0 you can apply the code to an option button and it will appear as a C++ push button (they both have the same basic events and properties: Click, MouseMove, etc...) which is a 'rigged' kind of way of getting it in to Visual Basic 4.0...hehe. I wrote this code because I got tired of all the people trying to create C++ style buttons with CreateWindowEx and Message Hooks, and all that other difficult stuff.

 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :Real C++ Buttons (Fixed)
'**************************************
Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As 
Long, ByVal wParam As Long, lParam As Any) As Long
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Real C++ Buttons (Fixed)
' Description:Notice: THIS CODE HAS BEEN FIXED! PLEASE READ THE COMMENTS AT THE BOTTOM OF THE PAGE TO SEE WHAT WAS WRONG BEFORE. 
Create real C++ style command buttons with ONE line of code!!! You can use this code on any of your commands buttons. You will loose any images and the BackColor of the button, but that really doesn't matter because you can 'paint' images onto the button using the API. Make sure you set the style property to 'Graphical' or this will not work!. OK here is how it works. You see, by default Visual Basic's command buttons are drawn with the 'Default Push Button' style, which makes them flat and ugly when pushed. But when you set the style to 'Graphical' its really just a C++ button with a single pixel outline drawn around it. This code basically just stops the button from drawing that line to create a sunken style button. This code is not compatible with Visual Basic 4.0/32 because its buttons don't have the style property.
However, in Visual Basic 4.0 you can apply the code to an option button and it will appear as a C++ push button (they both have the same basic events and properties: Click, MouseMove, etc...) which is a 'rigged' kind of way of getting it in to Visual Basic 4.0...hehe. I wrote this code because I got tired of all the people trying to create C++ style buttons with CreateWindowEx and Message Hooks, and all that other difficult stuff.
' By: Randy Mcdowell (Nebuland Technologies) (from psc cd)
'
' Inputs:You will need the hWnd of the command button.
'
' Assumes:Set the buttons style property to 'Graphical' first!!!
'
' Side Effects:You will loose the backcolor and images.
'**************************************

Sub Form_Load()
 ' Command1.Style = 1 ' Graphical
 SendMessage Command1.hWnd, &HF4&, &H0&, 0&
End Sub


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.