Focus rectangle in a command button

Is there a simple way to eliminate the focus rectangle from appearing when you select a command button?

I do realize that I can move focus from the command button, but the rectangle will still show when you press down on the button, and it messes up what I am trying to do.
LVL 2
taplinAsked:
Who is Participating?
 
VBGuruConnect With a Mentor Commented:
It works
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

Private Sub Command1_Click()
SendMessage Command1.hwnd, 7, 0&, 0&
End Sub
0
 
AnswerTheManCommented:
use another control.
0
 
vbWayneCommented:
..a click is a click...
by any other name...
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Erick37Commented:
Add the MS Forms 2.0 Object Library control ToggleButton to the form.  Warning: the DLL is pretty large.

Private Sub ToggleButton1_Click()
    If ToggleButton1.Value Then
        ToggleButton1.Value = False
        'Click event code here
        Debug.Print "Click"
    End If
End Sub
0
 
Erick37Commented:
Actually, the ToggleButton does not solve the problem...
There is no focus rect until you add a Caption, then it appears... duh.
0
 
Erick37Commented:
Ok, another try.
You can use the DrawEdge API to create your own command button from a picture box.

" HOWTO: Perform 3-D Line Drawing in Win32 with DrawEdge"

http://support.microsoft.com/support/kb/articles/q142/1/72.asp
0
 
adityauCommented:
You can even use SSPanel control of Sheridian 3D controls
0
 
VBGuruCommented:
check out
Option Explicit
Private Declare Function DrawFocusRect Lib "user32" (ByVal hdc As Long, lpRect As RECT) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type
Private a As RECT

Private Sub Command1_Click()
With a
    .Top = 4
    .Left = 4
    .Bottom = Command1.Height - 4
    .Right = Command1.Width - 4
End With
DrawFocusRect GetDC(Command1.hwnd), a
End Sub
0
 
taplinAuthor Commented:
VBGuru, I do thank you for your answer, but unfortunately, it does not seem to do what I was aiming for.  When I click the button, the focus rectangle is redrawn on top of the other, but it is not completely XORed (or whatever method they use).  It leaves a light gray line around the outside now.

I've played around for a few minutes, but can't seem to get it to work.

Thank you, though.
Jay
0
 
taplinAuthor Commented:
THANK YOU THANK YOU THANK YOU!!!!
I knew I had seen an API call before that did this, yet I couldn't find it, or even a constant that looked like it would do it.

I really appreciate it.

Jay
0
 
VBGuruCommented:
welcome. Happy to see your comment.
0
All Courses

From novice to tech pro — start learning today.