CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Location
    SA
    Posts
    147

    TextBox ForeColor does not work, when disabled ...

    When a TextBox is disabled, i would like to change the ForeColor, to something else than system default.....

    Going about it as follows ... does not work ....

    Text1.ForeColor = RGB(x, x, x) (or even using a &H...., value)

    now this does not work, so i thought I could use the API called SetTextColor .... which allows you to pass the HDC Object of the control, and then the long value of the color

    SetTextColor GetDC(Text1.hWnd), RGB(x, x, x)

    this does not work either ...........



    Any solutions to work around about setting the ForeColor, to anything else rather than system default if the TextBox/Control is disabled .... ????

    THX, in advance ......

  2. #2
    Join Date
    Feb 2001
    Location
    PA
    Posts
    163
    I do not believe you can change that property when the textbox is disabled. A simple solution is to use the locked property. This will allow you to change the forecolor but not change the contents of the textbox. You will be able to copy and paste and the cursor will be able to placed in the text box but you can't change anything. If you don't like that you can write code so the textbox can't accept the focus. Not sure of that code but I'm sure you could do it.

  3. #3
    Join Date
    Mar 2003
    Location
    SA
    Posts
    147

    THX

    No, I know about the locked property, but I would not want the user to get the impression that the control is enabled, some users might think the control, is enabled even though i locked the textbox, they will think that this is a program error, so i will have to live with the ForeColor is the control is disabled, one thing though is that the BackColor, intristingly enough does work when the control is disabled, and you wanna set it to something else rather than system default ....

    thanx anyways, i will post this to windows, hopefully they fix it .... LOL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured