Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread On Styles for Buttons
Mon, Nov 20 2017 6:37 PMPermanent Link

erickengelke

Avatar

So many people have asked about coloring buttons.  In my EWB book I gave an example of one solution.

I had a case where several different clients wanted colored buttons following a scheme other than the default EWB scheme.

The recommended way is to edit the interface file.  But there were a couple of reasons why that wasn't working on these projects.  What I wanted was some sort of Style manager capability, so in source code I could define the color attributes that are normally inaccessible, and so I could save the color choices of the user.

I made a little unit you can call from the Program Source file (the main section of an EWB program).  Actually, you
can call it anywhere in your program, but it only changes buttons drawn after you set them.  So the startup code is
probably a good place, or after the login if you wish.

contains test, style;  // NOTE: style must be linked

uses WebForms, WebCtrls,  webui;  // NOTE, need webui for the color constants

begin
 // colorful button scheme style
 StyleBackFill( 'TButton', 'Normal', clBlack );
 StyleBackFill( 'TButton', 'Hot', clOrange );
 StyleBackFill( 'TButton', 'Focused', clGreen );
 StyleBackFill( 'TButton', 'Pushed', clOrange );
 StyleBackFill( 'TButton', 'Disabled', clGray );


 // alternate style, black when focused, dark gray most times,
 // red when pressed, gray when disabled
 StyleBackFill( 'TButton', 'Disabled', clGray );
 StyleBackFill( 'TButton', 'Pushed', clRed );
 StyleBackFill( 'TButton', 'Focused', clBlack );
 StyleBackFill( 'TButton', 'Normal,Hot', clDimGray );


  Application.Title := '';
  Application.LoadProgress := False;
  Application.CreateForm(TForm1);
  Application.Run('Form1');
end;

Note, I let you use * or comma separated states.  You should not be tempted to set all the colors to, say, black,
because then people cannot see the focused mouse... and focused mice are required for TAB-capabilities, and
TAB-capabiltieis are required for some users including those with some mobility issues.

Erick
http://www.erickengelke.com



Attachments: ewbext.zip
Tue, Nov 21 2017 1:56 PMPermanent Link

Richard Harding

Wise Nutrition Coaching

Thank you Erick.

Very neat and useful.

Richard
Fri, Nov 24 2017 1:56 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Erick,

<< So many people have asked about coloring buttons.  In my EWB book I gave an example of one solution.

I had a case where several different clients wanted colored buttons following a scheme other than the default EWB scheme.

The recommended way is to edit the interface file.  But there were a couple of reasons why that wasn't working on these projects.  What I wanted was some sort of Style manager capability, so in source code I could define the color attributes that are normally inaccessible, and so I could save the color choices of the user.

I made a little unit you can call from the Program Source file (the main section of an EWB program).  Actually, you
can call it anywhere in your program, but it only changes buttons drawn after you set them.  So the startup code is probably a good place, or after the login if you wish. >>

Well done.  I've been wanting to document this functionality a little more for some time now, but yes, you can manipulate *anything* about any of the control interfaces at run-time in order to change the way that they look.

Also, if you want to reset the control interface for any control, you can use this method:

https://www.elevatesoft.com/manual?action=viewmethod&id=ewb2&comp=TInterfaceController&method=ResetInterface

Tim Young
Elevate Software
www.elevatesoft.com
Image