This code, which was not written by me, will prevent a command button from receiving the focus (The box with dashed lines on command button).

VB Code:
  1. 'In a Module
  2. Option Explicit
  3.  
  4. Public Declare Function SetWindowLong Lib "user32" _
  5.                                         Alias "SetWindowLongA" _
  6.                                         (ByVal hwnd As Long, _
  7.                                         ByVal nIndex As Long, _
  8.                                         ByVal dwNewLong As Long) As Long
  9.  
  10. Public Declare Function CallWindowProc Lib "user32" _
  11.                                         Alias "CallWindowProcA" _
  12.                                         (ByVal lpPrevWndFunc As Long, _
  13.                                         ByVal hwnd As Long, _
  14.                                         ByVal uMsg As Long, _
  15.                                         ByVal wParam As Long, _
  16.                                         ByVal lParam As Long) As Long
  17.                                            
  18. Public Const GWL_WNDPROC            As Long = (-4)
  19. Private WndProcOrig                 As Long
  20.  
  21. Public Function BtnWndProc(ByVal hwndBtn As Long, _
  22.                             ByVal wMsg As Long, _
  23.                             ByVal wParam As Long, _
  24.                             ByVal lParam As Long) As Long
  25.    
  26.     If wMsg = 7 Then
  27.         BtnWndProc = 0
  28.         Exit Function
  29.     Else
  30.         BtnWndProc = CallWindowProc(WndProcOrig, hwndBtn, wMsg, wParam, lParam)
  31.     End If
  32. End Function
  33.  
  34. Public Sub SubClassBtn(ByVal hwndBtn As Long)
  35.     WndProcOrig = SetWindowLong(ByVal hwndBtn, GWL_WNDPROC, AddressOf BtnWndProc)
  36. End Sub
  37.  
  38. Public Sub UnSubclassBtn(ByVal hwndBtn As Long)
  39.     Call SetWindowLong(hwndBtn, GWL_WNDPROC, WndProcOrig)
  40.     WndProcOrig = 0
  41. End Sub

and then you call it like this:

VB Code:
  1. 'On the form
  2. Option Explicit
  3.  
  4. Private Sub Form_Load()
  5. Dim a As Long
  6.     With Command1
  7.         For a = .LBound To .UBound
  8.             SubClassBtn .Item(a).hwnd
  9.         Next a
  10.     End With
  11. End Sub
  12.  
  13. Private Sub Form_Unload(Cancel As Integer)
  14. Dim a As Long
  15.     With Command1
  16.         For a = .LBound To .UBound
  17.             UnSubclassBtn .Item(a).hwnd
  18.         Next a
  19.     End With
  20.  
  21. End Sub