Frederick Posted November 22, 2019 Share Posted November 22, 2019 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) Quote Link to comment Share on other sites More sharing options...
Ronbral Posted November 22, 2019 Share Posted November 22, 2019 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 Quote Link to comment Share on other sites More sharing options...
Frederick Posted November 22, 2019 Author Share Posted November 22, 2019 Thanks. This works as expected. Quote Link to comment Share on other sites More sharing options...
andyhill Posted December 3, 2019 Share Posted December 3, 2019 Ronbral, How do we add the new background font to the Font DropBox (any text typed on new bodyarea assigned font does not locate Font Name in the Font Dropdown) ? Quote Link to comment Share on other sites More sharing options...
55143681 Posted December 4, 2019 Share Posted December 4, 2019 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\"; }"); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.