WS_Border Color

Started by Marc van Cauwenberghe, April 17, 2011, 11:28:37 AM

Previous topic - Next topic

Marc van Cauwenberghe

Hello,

is there a way to have an other color (normally black)  for the textbox WS_border color?


Marc van Cauwenberghe

Hi guys,

anyone has a clue?

Paul Squires

I imagine you could handle the painting in the non-client area via processing the WM_NCPAINT message.

Let me try a sample to see if it actually works..... I'll let you know.

Paul Squires
PlanetSquires Software

Paul Squires

Maybe try this. Put it in the CUSTOM handler for the TEXTBOX control you want to change the border color for.


'--------------------------------------------------------------------------------
Function FORM1_TEXT1_CUSTOM ( _
                            ControlIndex  As Long,  _  ' index in Control Array
                            hWndForm      As Dword, _  ' handle of Form
                            hWndControl   As Dword, _  ' handle of Control
                            wMsg          As Long,  _  ' type of message
                            wParam        As Dword, _  ' first message parameter
                            lParam        As Long   _  ' second message parameter
                            ) As Long

   
   Select Case wMsg
   
      Case %WM_NCPAINT

         Local hDC     As Dword
         Local hOldPen As Dword
         Local hPen    As Dword
         Local rc      As Rect

         ' Paint into the Device Context
         hDC = GetDC( hWndControl )
         
         ' Create a new red pen and put it in the device context
         hPen    = CreatePen( %PS_SOLID, 2, %Red )
         hOldPen = SelectObject( hDC, hPen )
         
         GetWindowRect hWndControl, rc
         Rectangle hDC, 0, 0, rc.nRight - rc.nLeft + 1, rc.nBottom - rc.nTop + 1
         
         ' Put the old pen back into the device context before deleting our new pen
         SelectObject hDC, hOldPen
         
         ReleaseDC hWndControl, hDC
         
         DeleteObject hPen         

         Function = -1: Exit Function
             
     
   End Select
   
End Function


Paul Squires
PlanetSquires Software