PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Petrus Vorster on June 28, 2017, 05:28:07 PM

Title: Seltext & Borders
Post by: Petrus Vorster on June 28, 2017, 05:28:07 PM
Hi All.

If I recall correctly, you cannot change the Seltext highlight colour nor the border colour of a textbox?
In other words, if you want borders that can change you have to make your own control?

Its quite frustrating. I have been working on a tool to create SMS notices to customers, and i have been plying with the flat windows look for a while now, even this pastel colours you have nowadays.
Regrettably the Seltext, buttonfocus colours and so forth had been a real pain in the neck since the colours clashes terribly.

The Firetextbox was the easiest way out, but still those other borders are terrible. (still the seltext is the problem.)
Is it something i am just going to have to love with? I dont know where to start with owner draw on these controls.
Title: Re: Seltext & Borders
Post by: Wilko Verweij on July 01, 2017, 04:26:39 PM
Hi, as far as the border concerns, maybe I can help you with a simple method. Not elegant, but it works. First of all, de-select the WS_EX_Clientedge style which is selected by default by Firefly. That will remove the border around the textbox. Subsequently, in the paint event of the text box, add this:

'--------------------------------------------------------------------------------
Function FORM1_TEXT1_WM_PAINT ( _
                              ControlIndex  As Long,  _  ' index in Control Array
                              hWndForm      As Dword, _  ' handle of Form
                              hWndControl   As Dword  _  ' handle of Control
                              ) As Long
                       
  Local hDC As Dword
  Local hPen As Dword
  Local nLeft As Long
  Local nTop As Long
  Local nWidth As Long
  Local nHeight As Long
  Local OrigPen As Dword
                   
  'get a device context for the for
  hDC = GetDC(hWndControl)
  'create a pen (use your own color)
  hPen = CreatePen(%PS_SOLID, 1, %Green)                   '<== use own color here
  'select the pen into the DC
  OrigPen = SelectObject (hDC, hPen)
  'determine location and size of the text box
  FF_Control_GetLoc(HWND_FORM1_TEXT1, nLeft, nTop)
  FF_Control_GetSize(HWND_FORM1_TEXT1, nWidth, nHeight)
  'draw a rectangle
  Rectangle(hDC, - 1, - 1, nWidth + 1, nHeight + 1)
  'restore original pen
  SelectObject hDC, OrigPen
  'delete ours
  DeleteObject(hPen)
 
  'release the DC
  ReleaseDC(hWndControl, hDC)
  'return zero
  Function = 0

End Function


I am sure others here know more elegant ways, including true subclassing, but it works.

I will think about the other one (selected text color) later...

Good luck,
Wilko