473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Painting a textbox Border--the Answer

After spending a morning wading through all the the Wrong answers and
responses I have figured out how to change the border on a textbox.

Here is the code:

Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal
hwnd As Integer, ByVal hdc As Integer) As Integer
Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc(m)
Const WM_PAINTBKG As Integer = 15
If m.Msg = WM_PAINTBKG Then
Dim g As Graphics = Me.CreateGraphics
Dim mypen As Pen = New
Pen(System.Drawing.SystemColors.GrayText, 1)
Dim width As Integer = Bounds.Width - 1
Dim height As Integer = Bounds.Height - 1
g.DrawRectangle(mypen, 0, 0, width, height)
mypen.Dispose()
g.Dispose()
End If
End Sub

I hope it saves some of you some trouble

Tal McMahon
Jul 21 '05 #1
1 1243
While your approach probably will work....... accept the fact that your
also relaying on the call to the winAPI to also work... through unmanaged
code.......

Have you looked at inheriting the textbox (to define one of your own)...
and override the paint function ? I'm not even sure this would work on the
border...... but it might be there...... as the border is a property that
is set.... and must be painted .......

"Tal McMahon" <ta**@report-software.com> wrote in message
news:7e*************************@posting.google.co m...
After spending a morning wading through all the the Wrong answers and
responses I have figured out how to change the border on a textbox.

Here is the code:

Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal
hwnd As Integer, ByVal hdc As Integer) As Integer
Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc(m)
Const WM_PAINTBKG As Integer = 15
If m.Msg = WM_PAINTBKG Then
Dim g As Graphics = Me.CreateGraphics
Dim mypen As Pen = New
Pen(System.Drawing.SystemColors.GrayText, 1)
Dim width As Integer = Bounds.Width - 1
Dim height As Integer = Bounds.Height - 1
g.DrawRectangle(mypen, 0, 0, width, height)
mypen.Dispose()
g.Dispose()
End If
End Sub

I hope it saves some of you some trouble

Tal McMahon

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Alien | last post by:
I have a hex editor-type class that extends UserControl and paints its data to a PictureBox. Basically the problem is that repainting it takes usually between 60 and 80ms, which may seem pretty...
2
by: Robert Misiak | last post by:
Hi everyone- I've done a lot of searching around on the web and I'm sure the answer to this question is no, but I'll ask anyway. Is it possible to create an inherited MonthCalendar control and...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
1
by: Tal McMahon | last post by:
After spending a morning wading through all the the Wrong answers and responses I have figured out how to change the border on a textbox. Here is the code: Declare Function ReleaseDC Lib...
3
by: Dave | last post by:
Hey all, Ok, here's another of my fun questions. I want to rewrite the textbox control in VB.NET. I need to implement superscript and subscript within the box. Don't ask why, but I can't use...
8
by: Filipe Marcelino | last post by:
Hi, I'm trying to create a textbox inheriting from the standard textbox. I would like to: 1. repaint the textbox border; 2. define a color for that border; Till now I made this:
13
by: WALDO | last post by:
I have a .Net TextBox (TextBoxBase, really) in which I am appending about 20 lines of text per second. I use the AppendText() method to accomplish this. This is a great substitute for taking the...
4
by: H-S | last post by:
Please help. This is a real puzzler! Originally posted on microsoft.public.dotnet.framework.windowsforms but no answer found! I have a read-only textBox which shows the results of a selection...
1
by: =?Utf-8?B?RmxvcmlhbiBLb3dhbHNreQ==?= | last post by:
I need to paint a rectangle in above the textbox of a combobox. How can i do that. At present the rectangle is always in the background and the textbox is in the foreground!! Thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.