Jump to content

chnage color of css at runtime?


erich.wanker

Recommended Posts

hy .. 

At designtime, i give x-mask a random color:

Quote

 

UniHTMLFrame1.HTML.Append ('  .x-mask {');
UniHTMLFrame1.HTML.Append ('  background-image: none;');

zufall1:=inttostr(random(255));
zufall2:=inttostr(random(255));
zufall3:=inttostr(random(255));
UniHTMLFrame1.HTML.Append ('  background-color: rgba('+zufall1+','+zufall2+','+zufall3+', 0.8) !important; ');
UniHTMLFrame1.HTML.Append ('}');

 

.. different UniContainerPanel´s   have the class x-mask .. and if i start the UniGUI App - the UniContainerPanels have a random color...

 

But how can i change the color-value OF THE CSS  at runtime with a UniColorButton? ... I

ThanX

Erich

Link to comment
Share on other sites

ok .. got it :-)

 

but i think - i use a crazy way ;-)  .. but it works 

 

Quote

 

procedure TMainForm.UniColorButton1Select(Sender: TObject; Color: TColor);
var r,g,b:Integer;
    farbe : LongInt;
begin


my_background_color:=Color;

  farbe := ColorToRGB(Color);
       R := GetRValue(farbe);
       G := GetGValue(farbe);
       B := GetBValue(farbe);

my_background_color_string:='rgba('+inttostr(r)+','+inttostr(g)+','+inttostr(b)+',1)';

UniHTMLFrame5.HTML.Clear;
UniHTMLFrame5.HTML.Append ('<style type="text/css"> ');
UniHTMLFrame5.HTML.Append ('  .x-mask {');
UniHTMLFrame5.HTML.Append ('  background-color: rgba('+inttostr(r)+','+inttostr(g)+','+inttostr(b)+',0.6) !important; ');
UniHTMLFrame5.HTML.Append ('}');

... and so on 

 

 

 

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...