Computer Workshop forums

EZGUI 5.0 Professional => EZGUI 5 support forum => Topic started by: Frank Kelley on April 01, 2025, 01:47:47 pm

Title: Light/Dark Mode
Post by: Frank Kelley 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?
Title: Re: Light/Dark Mode
Post by: Chris Boss 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.
Title: Re: Light/Dark Mode
Post by: Frank Kelley 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?
Title: Re: Light/Dark Mode
Post by: Chris Boss 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.
Title: Re: Light/Dark Mode
Post by: Chris Boss 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