K
Ken Tucker [MVP]
Hi,
Here is a class that uses nativewindows to change the border to white.
Create an instance for each label you want to have a white border.
Public Class WhiteBorderChanger
Inherits NativeWindow
Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC"
(ByVal hwnd As IntPtr) _
As IntPtr
Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal
hwnd As IntPtr, _
ByVal hdc As IntPtr) As Integer
Private ctrl As Control
Public Sub New(ByVal ctrl As Control)
AssignHandle(ctrl.Handle)
Me.ctrl = ctrl
End Sub
Protected Overrides Sub WndProc(ByRef m As Message)
' Listen for operating system messages
Const WM_NCPAINT As Integer = &H85
If m.Msg = WM_NCPAINT Then
Dim hdc As IntPtr = GetWindowDC(m.HWnd)
Dim g As Graphics = Graphics.FromHdc(hdc)
Dim pXp As Pen = New Pen(Color.White, 3)
g.DrawRectangle(pXp, 0, 0, ctrl.Width - 1, ctrl.Height -
1)
ReleaseDC(Me.Handle, hdc)
Else
MyBase.WndProc(m)
End If
End Sub
Protected Overrides Sub Finalize()
ReleaseHandle()
MyBase.Finalize()
End Sub
End Class
Ken
-------------------
Here is a class that uses nativewindows to change the border to white.
Create an instance for each label you want to have a white border.
Public Class WhiteBorderChanger
Inherits NativeWindow
Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC"
(ByVal hwnd As IntPtr) _
As IntPtr
Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal
hwnd As IntPtr, _
ByVal hdc As IntPtr) As Integer
Private ctrl As Control
Public Sub New(ByVal ctrl As Control)
AssignHandle(ctrl.Handle)
Me.ctrl = ctrl
End Sub
Protected Overrides Sub WndProc(ByRef m As Message)
' Listen for operating system messages
Const WM_NCPAINT As Integer = &H85
If m.Msg = WM_NCPAINT Then
Dim hdc As IntPtr = GetWindowDC(m.HWnd)
Dim g As Graphics = Graphics.FromHdc(hdc)
Dim pXp As Pen = New Pen(Color.White, 3)
g.DrawRectangle(pXp, 0, 0, ctrl.Width - 1, ctrl.Height -
1)
ReleaseDC(Me.Handle, hdc)
Else
MyBase.WndProc(m)
End If
End Sub
Protected Overrides Sub Finalize()
ReleaseHandle()
MyBase.Finalize()
End Sub
End Class
Ken
-------------------