|
-
Apr 17th, 2013, 04:15 AM
#1
Thread Starter
Frenzied Member
[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?
-
Apr 17th, 2013, 07:01 AM
#2
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
-
Apr 17th, 2013, 02:12 PM
#3
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....
Last edited by SamOscarBrown; Apr 17th, 2013 at 03:48 PM.
-
Apr 17th, 2013, 03:32 PM
#4
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
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Apr 17th, 2013, 04:37 PM
#5
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
-
Apr 17th, 2013, 07:51 PM
#6
Thread Starter
Frenzied Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|