In VB, I have done a simliar thing..
Firstly override the WndProc as you stated.. handle message &HF (WM_PAINT)
and &H85 (WM_NCPAINT i think ) .. code below..
However you will find that the graphics that you can get from CreateGraphics
for the textbox or richtextbox does not include the border region..
You will need to define two external functions to get the correct graphics
region.. also shown below...
I have typed the stuff below from memory, but I think that's about right, it
should get you started in the right direction anyway..
HTH
Rigga
<CODE>
Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc(m)
Select Case m.Msg
Case &H85
DrawTextBoxBorder()
Case &HF
DrawTextBoxBorder()
End Select
End Sub
Private Sub DrawTextBoxBorder()
Dim hdc As IntPtr
hdc = GetWindowDC(Handle)
Dim drawRect As Rectangle = New Rectangle(0, 0, Width, Height)
Dim g As Graphics = Graphics.FromHdc(hdc)
g.DrawRectangle(New Pen(Color.black, 3), drawRect.Left,
drawRect.Top, drawRect.Width - 2, drawRect.Height - 2)
ReleaseDC(Handle, hdc)
End Sub
Public Declare Ansi Function GetWindowDC Lib "User32.dll" (ByVal hwnd As
IntPtr) As IntPtr
Public Declare Ansi Function ReleaseDC Lib "User32.dll" (ByVal hWnd As
IntPtr, ByVal hDC As IntPtr) As Integer
<END CODE>