[RESOLVED] Cmd button fore colour
Been reading a bit about this and it looks like the best option
is to use a Check box or radio button with Style=1.
After clicking though, it leaves a marquee dotted line on the control until you click on something else.
Can this be removed automatically anyhow?
Re: Cmd button fore colour
Alex
I think what you are referring to is a standard Cmd button feature ..
it is to let you know that said button has Focus.
If this is in fact the issue, then maybe if you set Focus to the Form,
the dashed lines will go away.
Perhaps you could post a screenshot.
Spoo
Re: Cmd button fore colour
Command Button Fore Colour (Color)....? Are you simply wanting to change the FORECOLOR (what is written on a cmd button)...here is a great example of doing jsut that...
EDIT...sorry-- attachment had my exe...will resend without if you want it...Bonnie has solution....
Re: Cmd button fore colour
Try sending your buttons the WM_KILLFOCUS message:
Code:
Private Const WM_KILLFOCUS As Long = &H8
Private Declare Function SendMessageW Lib "user32.dll" (ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Sub Check1_Click()
SendMessageW Check1.hWnd, WM_KILLFOCUS, 0&, 0&
End Sub
Private Sub Command1_Click()
SendMessageW Command1.hWnd, WM_KILLFOCUS, 0&, 0&
End Sub
Private Sub Option1_Click()
SendMessageW Option1.hWnd, WM_KILLFOCUS, 0&, 0&
End Sub
Re: Cmd button fore colour
Alex
You did not ask for this, but you can very easily change the BackColor
of a CmdButton ,,
1. Manually set the button's Style Property to 1 - Graphical. It is read-only, can't be done by code
2. To set the color, you can do it manually (BackColor Property) or by code.
Spoo
Re: [RESOLVED] Cmd button fore colour
Thanks very much everyone. Nice example too Sam but here it fires "Visual Basic has encountered a problem...." when you close it after 8 or so random clicks.
Bonnie's solution was brilliant as it also depresses the button and adding Me.Option1.Value = False makes it behave exactly like a normal button. Wonderful!
Spoo, never knew that - always assumed BackColor would work - guess I never tried it. Thanks :)