我有一个很笨,但很灵的办法。屡用屡爽。在窗体中建一个临时的文本框,隐藏在其他控件的后面。在希望去掉虚框的按钮添加如下代码: Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Txt_Tmp.SetFocus End Sub当然也可以用MouseDown之类。
用下列API就可以去掉按钮上的虚框,但在什么时候使用下当的执行代码我没找到好位置, 因为cammand没有paint事件,所以不能很好的擦除. 你看看吧. 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 LongPrivate Type RECT Left As Long Top As Long Right As Long Bottom As Long End TypeDim hDc As Long Dim hRect As RECT
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Txt_Tmp.SetFocus
End Sub当然也可以用MouseDown之类。
因为cammand没有paint事件,所以不能很好的擦除.
你看看吧.
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 LongPrivate Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End TypeDim hDc As Long
Dim hRect As RECT
hDc = GetDC(Command1.hwnd)
hRect.Left = 4
hRect.Top = 4
hRect.Right = Command1.Width / 15 - 4
hRect.Bottom = Command1.Height / 15 - 4
DrawFocusRect hDc, hRect
用PICTUREBOX代替,再用API将PICTUREBOX的Body设成CommandButton那样的就可以啦.
你使用下面两个属性即可搞定:
MaskColor=你按钮的底色
UseMaskColor=True