Change DROP/COMBO Background Color When Disabled

I sometimes prefer to change the background color of controls when disabled. Something like:

?TEXT{PROP:Disable} = CHOOSE(MyVar=False)
?TEXT{PROP:Background} = CHOOSE(?TEXT{PROP:Disable}=True,COLOR:BtnFace,COLOR:None)

If this same code is used for a DROP or COMBO control, the background color does not change.
Any suggestions?

I think DISABLE forces the colors.

IIRC the way I did something like that was to not Disable instead set PROP:ReadOnly=True, plus set PROP:Skip=True. Then I set my colors to my preferred Disabled look which was more readable. This also allowed to Copy the value which Disable does not allow copy.

But only for list, drop, combo controls?

Every control has its own handling. A Combo is special being an ENTRY with a LIST and BUTTON. Same for a DROP LIST just the ENTRY is ReadOnly.

Wondering if it possible (easily) to reference the entry part of a combo or drop? The background of disabled entry controls can be changed.

I wonder if it’s possible to use code from this example @MarkGoldberg wrote to change the icon to do what you need with the internal controls.

Mark

Douglas,
What isn’t working for you?
This code works fine for me. Maybe, I’m not understanding what you are after.


  PROGRAM

OMIT('***')
 * Created with Clarion 11.0
 * User: Rick
 * Date: 8/8/2023
 * Time: 9:32 AM
 ***

  MAP
TestWindowProc  procedure()
  END

  CODE
  TestWindowProc()
  
TestWindowProc                procedure()
COMBO1:Queue                    QUEUE
Field1                            STRING(20)
                                END
LIST1:Queue                    QUEUE
Field1                            STRING(20)
                                END

TestWindow                      WINDOW('Test Window'),AT(245,20,235,118),GRAY,SYSTEM,DOUBLE
                                  PROMPT('Combo'),AT(16,32),USE(?PROMPT1)
                                  COMBO(@s20),AT(80,27,104,14),USE(?COMBO1),DROP(15),FROM(COMBO1:Queue)
                                  PROMPT('Drop List'),AT(16,50),USE(?PROMPT1:2)
                                  LIST,AT(80,45,104,14),USE(?LIST1),DROP(15),FROM(LIST1:Queue)
                                  BUTTON('Toggle Disable'),AT(26,86),USE(?btnToggle)
                                END

  code
  open(TestWindow)
  ACCEPT
    case EVENT()
    of EVENT:Accepted
      case FIELD()
      of ?btnToggle
        if ?COMBO1{PROP:Disable} = ''
          ?COMBO1{PROP:Background} = COLOR:Red
          ?COMBO1{PROP:Disable} = true
        ELSE
          ?COMBO1{PROP:Background} = COLOR:NONE
          ?COMBO1{PROP:Disable} = ''
        END
        if ?LIST1{PROP:Disable} = ''
          ?LIST1{PROP:Background} = COLOR:Teal
          ?LIST1{PROP:Disable} = true
        ELSE
          ?LIST1{PROP:Background} = COLOR:NONE
          ?LIST1{PROP:Disable} = ''
        END
        DISPLAY()
      END
    END
  END
  close(TestWindow)
  

Rick,
Thanks. This is a more basic and better test than what I was using. Long forgotten in my list control class is some code setting PROPLIST:BarFrame colors. My guess is that this class code could be overriding procedure code colors since both a disabled drop or combo would be displaying the value of the selected record. Using your code, looks like I will have to test by also setting the BarFrame properties.

I did a quick test and ENTRY and COMBO colored fine. The LIST,DROP would Not Color.

A possible workaround would be to sort of clone the LIST size/position as a ENTRY or COMBO then color that while hiding the LIST. You can’t use CLONE()

I tried coloring the PROP:ListFEQ but it didn’t work, which makes sense it colors the drop list.

I tried every Color Property my Window Preview Tool allows and none stuck. I also added a FORMAT with default color but nope.

image

After a bit more testing, it seems to me the background of the read only display of a LIST,DROP simply does not change using PROP:Background. It is either set on open(window) or another unknown property is involved. Does that agree with what you are seeing?

1 Like

Did any of you guys try a style in the listbox? Just curious enough to ask someone else. :slight_smile:

I tried FORMAT() colors and they had no effect. When not dropped there is an ENTRY showing the value so makes sense Format does nothing.

IIRC in Windows proper the COMBO,DROP and LIST,DROP List are the same control, but the LIST is a Read Only Entry.

1 Like