Delphi VCL styles tutorial - how to change the style at runtime -


is there vcl styles tutorial see how dynamically (in run time) load/change style ?

this should work delphi xe2 , up, since xe2 first version vcl styles.

i'm adding answer because local information preferred links.

here's key facts need know before start:

  1. many vcl controls have color properties, properties going ignored when styles on, , default "common controls" button going drawn delphi itself, instead of using xp or windows 2000 style "comes windows".

  2. somehow, deep within application, vcl styles puts hooks in take on painting controls. can handle, drawn using "skin" on top of regular controls. many people call "skinning vcl", , prior vcl styles, might have found third party skin system. it's built in.

  3. anything not hooked, still regular style. third party controls, , bits of vcl not themed. don't expect perfect instant results. also, might see momentary flicker or glitches result of skinning, that's expected. add loading of styles @ runtime, , end-quality of result anybody's guess. can't guarantee style loaded @ runtime, contain might want contain. nor can guarantee 1 statically include in app, @ least ones statically include verified qa team (which might you).

and here's simplest steps started: step #2 through #4 essential.

  1. click file -> new -> vcl forms project.

  2. right click on project options in project manager pane, , click properties. navigate application -> appearance

  3. click on custom style turn on. (amakrits first in list, i'll click that).

  4. click on default style combobox , change other default.

  5. put on form it's not empty. (a button, listbox, etc).

  6. run app.

enter image description here

now, advanced stuff: change style @ runtime:

i use button click , formcreate that:

add fdefaultstylename:string; private section of form.

make sure vcl.themes in uses clause.

procedure tform1.button1click(sender: tobject); begin  if assigned(tstylemanager.activestyle) , (tstylemanager.activestyle.name<>'windows') begin    tstylemanager.trysetstyle('windows');  end else begin    tstylemanager.trysetstyle(fdefaultstylename); // whatever in project settings.  end;  end;  procedure tform1.formcreate(sender: tobject); begin if assigned(tstylemanager.activestyle)   fdefaultstylename := tstylemanager.activestyle.name;  end; 

Comments

Popular posts from this blog

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -

c# - error executing child request for server.transfer with Handler -

How to read input from STDIN in x86_64 assembly? -