PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Seltext & Borders  (Read 1756 times)

Petrus Vorster

  • Senior Member
  • ***
  • Posts: 449
Seltext & Borders
« 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.

Wilko Verweij

  • Junior Member
  • **
  • Posts: 163
  • PB10 - FF3.7 User; Win 10
    • CHEAQS
Re: Seltext & Borders
« Reply #1 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:

Code: [Select]
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
  '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,
« Last Edit: July 01, 2017, 05:00:07 PM by Wilko Verweij »