newsanti Posted September 23 Share Posted September 23 procedure TMainmForm.UnimFormCreate(Sender: TObject); begin var oPanel:= UnimContainerPanel1; // TuniLayoutConfig(oPanel.LayoutConfig).Cls:= 'mainbackground'; // work OK. var oJS:= oPanel.JSInterface; oJS.JSAddListener('afterrender', oJS.JSFunction('sender', 'document.body.style.background=''url("/files/mainlogo2.jpg");repeat scroll 0% 0%''')); //Mainlogo2.jpg not shown. end; FormBackground.zip Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 23 Share Posted September 23 Hello, I don't know where you got it from: 43 minutes ago, newsanti said: oJS.JSAddListener('afterrender', oJS.JSFunction('sender', 'document.body.style.background=''url("/files/mainlogo2.jpg");repeat scroll 0% 0%''')); //Mainlogo2.jpg not shown. In your case this will be correct: procedure TMainmForm.UnimFormCreate(Sender: TObject); begin var oPanel:= UnimContainerPanel1; // TuniLayoutConfig(oPanel.LayoutConfig).Cls:= 'mainbackground'; var oJS:= oPanel.JSInterface; oJS.JSAddListener('painted', oJS.JSFunction('sender', 'sender.bodyElement.setStyle(''background'', ''url(/files/mainlogo2.jpg) repeat scroll 0% 0%'')')); end; 1 Quote Link to comment Share on other sites More sharing options...
newsanti Posted September 23 Author Share Posted September 23 19 minutes ago, Sherzod said: Hello, I don't know where you got it from: In your case this will be correct: procedure TMainmForm.UnimFormCreate(Sender: TObject); begin var oPanel:= UnimContainerPanel1; // TuniLayoutConfig(oPanel.LayoutConfig).Cls:= 'mainbackground'; var oJS:= oPanel.JSInterface; oJS.JSAddListener('painted', oJS.JSFunction('sender', 'sender.bodyElement.setStyle(''background'', ''url(/files/mainlogo2.jpg) repeat scroll 0% 0%'')')); end; how to set cover of image with setstyle? var oPanel:= UnimContainerPanel1; // TuniLayoutConfig(oPanel.LayoutConfig).Cls:= 'mainbackground'; var oJS:= oPanel.JSInterface; oJS.JSAddListener('painted', oJS.JSFunction('sender', 'sender.bodyElement.setStyle(''background'', ''url(/files/mainlogo2.jpg)'')')); oJS.JSAddListener('painted', oJS.JSFunction('sender', 'sender.bodyElement.setStyle(''background-size'', ''cover'')')); Can coding in single command? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 23 Share Posted September 23 1 hour ago, newsanti said: how to set cover of image with setstyle? Sorry, what do you mean? Quote Link to comment Share on other sites More sharing options...
newsanti Posted September 23 Author Share Posted September 23 11 minutes ago, Sherzod said: Sorry, what do you mean? 'sender.bodyElement.setStyle(''background'', ''url(/files/mainlogo2.jpg) no-repeat 100% 100%'')')); Can do like this? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 23 Share Posted September 23 3 minutes ago, newsanti said: Can do like this? What exactly? Quote Link to comment Share on other sites More sharing options...
newsanti Posted September 23 Author Share Posted September 23 1 minute ago, Sherzod said: What exactly? if oPanelX is TUniCustomContainerPanel then begin var oPanel:= TUniCustomContainerPanel(oPanelX); if Assigned(oPanel) then begin var oJS:= oPanel.JSInterface; oJS.JSAddListener('painted', oJS.JSFunction('sender', 'sender.bodyElement.setStyle(''background'', ''url('+S+')'')')); oJS.JSAddListener('painted', oJS.JSFunction('sender', 'sender.bodyElement.setStyle(''background-repeat'', ''no-repeat'')')); oJS.JSAddListener('painted', oJS.JSFunction('sender', 'sender.bodyElement.setStyle(''background-size'', ''100% 100%'')')); end; end; I try setting in one command. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 23 Share Posted September 23 13 minutes ago, newsanti said: I try setting in one command. Well, 2 hours ago, Sherzod said: oJS.JSAddListener('painted', oJS.JSFunction('sender', 'sender.bodyElement.setStyle(''background'', ''url(/files/mainlogo2.jpg) repeat scroll 0% 0%'')')); This is it in one line of code! 1 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.