Jump to content

How To Change Background Colour Of TUniHTMLMemo?


Frederick

Recommended Posts

In design mode, I can change the colour of TUniHTMLMemo from say, clWindow to clLime using the Color property. However, when the project is run, the background remains at clWindow.

Using the HTML codes of <body style="background-color:lime;"> ... </body> or <body bgcolor="lime"> ... </body> in the Lines property of the control does not seem to have an effect.

How do I change the background colour of TUniHTMLMemo at runtime?

--
Frederick
(UniGUI Complete - Professional Edition 1.90.0.1514)
 

Link to comment
Share on other sites

It can be done like this:

Quote

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  ...
  // Custom bg and font from the text editor
  with uHTMLMemo do 
    JSInterface.JSAddListener('initialize', 'function(edhtm){ '+
                              'const bodyArea = edhtm.getEditorBody(); '+
                              'bodyArea.style["background-color"] = "#B3FFD9"; '+
                              'bodyArea.style["font-family"] = "Helvetica, Arial, sans-serif"; '+
                              'bodyArea.style["font-size"] = "14px"; }');
end;

Enjoy

Link to comment
Share on other sites

  • 2 weeks later...
On 11/22/2019 at 12:18 PM, Ronbral said:

It can be done like this:

Enjoy

Thanks,cbuilder version:

void __fastcall TMainForm::UniFormCreate(TObject *Sender)
{
UniHTMLMemo1->JSInterface->JSAddListener("initialize", "function(edhtm){ const bodyArea = edhtm.getEditorBody();bodyArea.style[\"background-color\"] = \"#B3FFD9\";bodyArea.style[\"font-family\"] = \"Helvetica, Arial, sans-serif\"; bodyArea.style[\"font-size\"] = \"34px\"; }");
}

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...