J
jcrouse
Is there a quick and easy way to change the color of a label controls border
from the default black to white?
Thank you,
John
from the default black to white?
Thank you,
John
* Ken Tucker said:Dim penBorder As New Pen(Color.White, 3)
Dim hdc As IntPtr = GetWindowDC(m.HWnd)
Dim g As Graphics = Graphics.FromHdc(hdc)
Dim rDraw As Rectangle = New Rectangle(0, 0, Me.Width,
Me.Height)
g.DrawRectangle(penBorder, rDraw)
ReleaseDC(Me.Handle, hdc)
Const WM_NCPAINT As Integer = &H85Const WM_NCPAINT = &H85
Cor Ligthert said:Hi Ken,
Can you change this in your sample?
Const WM_NCPAINT As Integer = &H85
Cor
jcrouse said:Ken,
What do I do with this code or where does it need to go. I created a new
project and added one label to the form. Here is the entire code:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Label1
'
Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Label1.Location = New System.Drawing.Point(48, 56)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(136, 48)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Label1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
I added it on the end but got nothing. Do I need to call something somehow
or mix pieces of the code in with the above code?
Thanks,
John
"Ken Tucker [MVP]" <HYPERLINK
"mailto:[email protected]"(e-mail address removed)> wrote in message
* Ken Tucker said:Sure.
... but in this case not necessary. The value will be treated as
'Int32' automatically.
* "Cor Ligthert said:You can be glad that Armin is not active some days I think.
Why?!
Do you think I saw this, I was just making a sample for John, while I
thought Ken was not active, when I saw that Ken was I had already made it
and found it a pity not to send it.
* "Mick Doherty said:Option Strict On requires all variable declarations to have an 'As' clause.
As Armin would point out, we should all have Option Strict On
Herfried K. Wagner said:Yep. I worked with 'Option Strict Off'. The error message is
misleading because it's a constant, not a variable.
* "Mick Doherty said:I agree. Especially since if you put the Constant in an Enum it is
automatically an Int32 unless you specify differently.
Herfried K. Wagner said:... there is no error message if there is no type specified for a
constant inside an enum.
* "Mick Doherty said:That's what I said.
"if you put the Constant in an Enum it is automatically an Int32 unless you
specify differently"
i.e.
\\\
Enum ByteEnum As Byte
SomeVar = 2
End Enum
Enum Int32Enum
SomeVar = 2
End Enum
///
already have two forms and 52 labels and probably 60 pages of code and don'tWell, I finally got a chance to try it out. Nice control. However, I