Author Topic: Light/Dark Mode  (Read 55 times)

Frank Kelley

  • Newbie
  • *
  • Posts: 7
    • View Profile
Light/Dark Mode
« on: April 01, 2025, 01:47:47 pm »
Many programs today offer both a "light" and "dark" mode. Is there an easy way such a toggle can be incorporated in an EZGUI-created application?

Chris Boss

  • Administrator
  • Jr. Member
  • *****
  • Posts: 70
    • View Profile
Re: Light/Dark Mode
« Reply #1 on: April 03, 2025, 04:47:33 pm »
EZGUI provides enumeration commands so you can walk through all the controls on a form.

In controls you desire to allow changing their color you can change their color enmass for a form in the forms %EZ_Loaded event before the form is visible.

Once a form is visible and the user changes color mode, you can disable the forms redraw state, enumerate all the controls and change their colors as desired, enable the forms redraw state and then force the form to redraw itself.

Use a Global variable to track the color mode state and store that in the registry so it can be automatically set when the app is run again.

It will require a little effort, but it is quite doable.

There are functions which can tell you want the class (type) of control it is when you enumerate through them.

For ownerdraw stuff it will be a little more complicated, since you have to custom the ownerdraw routine so it can change colors.

Frank Kelley

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Light/Dark Mode
« Reply #2 on: April 03, 2025, 11:45:24 pm »
Thank you for the response, Chris.

Most of my apps don't use OwnerRedraw. What is the method of enumerating all the controls? Is there an example of this in the EZGUI examples folder?

Chris Boss

  • Administrator
  • Jr. Member
  • *****
  • Posts: 70
    • View Profile
Re: Light/Dark Mode
« Reply #3 on: April 05, 2025, 08:12:29 am »
There is a section in Help file:

"Your EZ Guide to EZGUI"
... "Forms"
... ... "Enumerating a Forms Controls"

The available commands are:

EZ_StartCList
EZ_EndCList
EZ_GetCListCount
EZ_GetCListID
EZ_GetCListClass
EZ_GetCListHandle

You start an enumeration task with EZ_StartCList.

Then you can get info about the controls on the form using the other functions and then finish the enumration task with EZ_CList.

Chris Boss

  • Administrator
  • Jr. Member
  • *****
  • Posts: 70
    • View Profile
Re: Light/Dark Mode
« Reply #4 on: April 05, 2025, 08:14:23 am »
An example:

Code: [Select]
     EZ_StartCList "Form1", ""
     Count&=EZ_GetCListCount
     IF Count&>0 THEN
          FOR N&=1 TO Count&
              ID& = EZ_GetCListID(N&)
              Class$ = EZ_GetCListClass(N&,1)
              hWnd& = EZ_GetCListHandle(N&)
          NEXT N&
     END IF
     EZ_EndCList