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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...