PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Marc van Cauwenberghe on April 17, 2011, 11:28:37 AM

Title: WS_Border Color
Post by: Marc van Cauwenberghe on April 17, 2011, 11:28:37 AM
Hello,

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

Title: Re: WS_Border Color
Post by: Marc van Cauwenberghe on April 22, 2011, 12:33:53 PM
Hi guys,

anyone has a clue?
Title: Re: WS_Border Color
Post by: Paul Squires on April 22, 2011, 04:06:41 PM
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.

Title: Re: WS_Border Color
Post by: Paul Squires on April 22, 2011, 06:43:25 PM
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