PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Martin Francom on January 30, 2010, 04:14:46 AM

Title: TextBox Disable Color
Post by: Martin Francom on January 30, 2010, 04:14:46 AM
I would like to see the ability to set the Foreground and Background colors of a Disabled TextBox in the Control's "Properties"...  It would make it so much more convenient.

I assume the only way to do it now is at RUN time after the TextBox has been "Disable"d.   I have a lot of textboxes that I am working with and  it would be so much more convenient to be able to set the "Disabled"  foreground/background colors at design time.

Paul, is it possible to add the disabled foreground and background color setting to the "properties" of the TextBox control. 
Title: Re: TextBox Disable Color
Post by: Roger Garstang on January 30, 2010, 02:32:15 PM
I imagine that could be done since FF stores the colors it would just be a matter of capturing if disabled, which it probably already does, and painting with the selected colors.  Only issue I'd see is confusing to the user of the application since it would go away from standard colors showing them it is disabled.  You can make the Text Box read only too and it will be able to be colored. I do this a lot to make a textbox without borders and colored like a label as Windows itself does in file properties dialogs and such to look like a label but enable people to select and copy content.
Title: Re: TextBox Disable Color
Post by: Nathan Durland on January 31, 2010, 06:49:34 PM
I think windows takes a bit more control over the appearance of a control that has been disabled; setting the "disabled" color scheme may or may not be possible.  I'll wait until the experts (Paul) chime in.

In the mean time, you might try a two step process -- set the control's color, then set it read-only.
Title: Re: TextBox Disable Color
Post by: Paul Squires on January 31, 2010, 07:15:15 PM

Global ghBrushDisabled As Dword


'--------------------------------------------------------------------------------
Function FORM1_WM_CREATE ( _
                         hWndForm As Dword, _      ' handle of Form
                         ByVal UserData As Long _  ' optional user defined Long value
                         ) As Long
   
   ghBrushDisabled = CreateSolidBrush( %Yellow )
   
End Function


'--------------------------------------------------------------------------------
Function FORM1_WM_DESTROY ( _
                          hWndForm      As Dword _  ' handle of Form
                          ) As Long
                         
   DeleteObject ghBrushDisabled
                         
End Function



'--------------------------------------------------------------------------------
Function FORM1_CUSTOM ( _
                      hWndForm      As Dword, _  ' handle of Form
                      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_CTLCOLOREDIT, _
           %WM_CTLCOLORLISTBOX, _
           %WM_CTLCOLORSTATIC, _
           %WM_CTLCOLORBTN
           
         If IsWindowEnabled( HWND_FORM1_TEXT1 ) = %FALSE Then
            Function = ghBrushDisabled
            Exit Function
         End If   

   End Select
   
End Function


Title: Re: TextBox Disable Color
Post by: Martin Francom on January 31, 2010, 09:47:14 PM
Paul thanks...

Let me see if I understand correctly...

I will need to use one of these  IF statements for every TextBox on the form for which I want to control the disabled color ???

         If IsWindowEnabled( HWND_FORM1_TEXT1 ) = %FALSE then 
                 Function = ghBrushDisabled      :      Exit Function         
         End If   
Title: Re: TextBox Disable Color
Post by: Paul Squires on January 31, 2010, 10:42:49 PM
Try this.....


Function FORM1_CUSTOM ( _
                      hWndForm      As Dword, _  ' handle of Form
                      wMsg          As Long,  _  ' type of message
                      wParam        As Dword, _  ' first message parameter
                      lParam        As Long   _  ' second message parameter
                      ) As Long

   Static zClassName As Asciiz * 20
   
   Select Case wMsg
     
      Case %WM_CTLCOLOREDIT, _
           %WM_CTLCOLORLISTBOX, _
           %WM_CTLCOLORSTATIC, _
           %WM_CTLCOLORBTN
           
         GetClassName lParam, zClassName, SizeOf(zClassName)
         If UCase$(zClassName) = "EDIT" Then
            If IsWindowEnabled( lParam ) = %FALSE Then
               Function = ghBrushDisabled
               Exit Function
            End If   
         End If   

   End Select
   
End Function

Title: Re: TextBox Disable Color
Post by: Martin Francom on February 14, 2010, 07:01:04 PM
Quote from: TechSupport on January 31, 2010, 10:42:49 PM
Try this.....


Function FORM1_CUSTOM ( _
                      hWndForm      As Dword, _  ' handle of Form
                      wMsg          As Long,  _  ' type of message
                      wParam        As Dword, _  ' first message parameter
                      lParam        As Long   _  ' second message parameter
                      ) As Long

   Static zClassName As Asciiz * 20
   
   Select Case wMsg
     
      Case %WM_CTLCOLOREDIT, _
           %WM_CTLCOLORLISTBOX, _
           %WM_CTLCOLORSTATIC, _
           %WM_CTLCOLORBTN
           
         GetClassName lParam, zClassName, SizeOf(zClassName)
         If UCase$(zClassName) = "EDIT" Then
            If IsWindowEnabled( lParam ) = %FALSE Then
               Function = ghBrushDisabled
               Exit Function
            End If   
         End If   

   End Select
   
End Function


Quote from: TechSupport on January 31, 2010, 10:42:49 PM
Try this.....


Function FORM1_CUSTOM ( _
                      hWndForm      As Dword, _  ' handle of Form
                      wMsg          As Long,  _  ' type of message
                      wParam        As Dword, _  ' first message parameter
                      lParam        As Long   _  ' second message parameter
                      ) As Long

   Static zClassName As Asciiz * 20
   
   Select Case wMsg
     
      Case %WM_CTLCOLOREDIT, _
           %WM_CTLCOLORLISTBOX, _
           %WM_CTLCOLORSTATIC, _
           %WM_CTLCOLORBTN
           
         GetClassName lParam, zClassName, SizeOf(zClassName)
         If UCase$(zClassName) = "EDIT" Then
            If IsWindowEnabled( lParam ) = %FALSE Then
               Function = ghBrushDisabled
               Exit Function
            End If   
         End If   

   End Select
   
End Function




Paul,

    This works well to reset all the background colors of all disabled TextBoxes on a particular form.  Thank you.
    Is it also possible to set the foreground colors of all disabled TextBoxes  on a form in a similar manor?