VB 设置控件边框颜色
(2012-11-23 17:14:14)
标签:
杂谈 |
分类: VB |
VB
设置控件边框颜色,比如:ListBox、TextBox、PictureBox、ComboBox等等….
调用方法:
-
'setBorderColor (控件句柄,颜色值)
setBorderColor Text1.hWnd, vbRed
Option Explicit
Private Type
RECTW
End Type
Private Type
RECT
End Type
Private Declare
Function SetWindowLong Lib "user32" Alias "SetWindowLongA"
(ByVal hWnd As
Long, ByVal nIndex
As Long, ByVal dwNewLong As Long) As Long
Private Declare
Function CallWindowProc Lib "user32" Alias "CallWindowProcA"
(ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare
Function DefWindowProc Lib "user32" Alias "DefWindowProcA"
(ByVal hWnd As
Long, ByVal wMsg
As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare
Function GetProp Lib
"user32" Alias
"GetPropA" (ByVal
hWnd As Long,
ByVal lpString As
String) As
Long
Private Declare
Function RemoveProp Lib "user32" Alias "RemovePropA" (ByVal hWnd As Long, ByVal lpString As String) As Long
Private Declare
Function SetProp Lib
"user32" Alias
"SetPropA" (ByVal
hWnd As Long,
ByVal lpString As
String, ByVal hData
As Long) As Long
Private Declare
Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare
Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare
Function FrameRect Lib "user32" (ByVal hDC As Long, lpRect As RECT,
ByVal hBrush As
Long) As Long
Private Declare
Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare
Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT)
As Long
Private Declare
Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long
Private Const
WM_DESTROY
Private Const
WM_PAINT
Private Const
WM_NCPAINT
Private Const
GWL_WNDPROC = (-4)
Private Color As
Long
Public Sub
setBorderColor(hWnd As Long, Color_ As Long)
End Sub
Public Sub
UnHook(hWnd As Long)
End Sub
Private Function
OnPaint(OrigProc As Long, hWnd As Long, uMsg As Long, wParam As Long, lParam As Long) As Long
End Function
Private Function
WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long