newsanti Posted August 8, 2021 Share Posted August 8, 2021 Example: SourcePath:= D:\share files\wallpaper\desktop\image1.jpg SourcePathURL:= ConvertToURL(SourcePath)? How to convert SourcePath to SourcePathURL to use with css .. URL(SourcePathURL)? Quote Link to comment Share on other sites More sharing options...
mhmda Posted August 8, 2021 Share Posted August 8, 2021 You can't do it 🙂 the end user is exposed to 'root' folder only, you can create a temp file from your original file. 1 Quote Link to comment Share on other sites More sharing options...
mhmda Posted August 8, 2021 Share Posted August 8, 2021 You can use the helper function NewCacheFileUrl: targetFile:= ServerModule.NewCacheFileUrl(False, 'jpg'{file extension}, '', '', AUrl, True); CopyFile(PChar(SrcFileName),PChar(targetFile),false); Then use the AUrl for your end user. 1 Quote Link to comment Share on other sites More sharing options...
newsanti Posted August 9, 2021 Author Share Posted August 9, 2021 5 hours ago, mhmda said: You can use the helper function NewCacheFileUrl: targetFile:= ServerModule.NewCacheFileUrl(False, 'jpg'{file extension}, '', '', AUrl, True); CopyFile(PChar(SrcFileName),PChar(targetFile),false); Then use the AUrl for your end user. Why MainModule.Background.Url:= AURL; Not Show Background Image. Quote Link to comment Share on other sites More sharing options...
mhmda Posted August 9, 2021 Share Posted August 9, 2021 Are you trying to change mainmodule background image @ runtime? Quote Link to comment Share on other sites More sharing options...
newsanti Posted August 9, 2021 Author Share Posted August 9, 2021 1 hour ago, mhmda said: Are you trying to change mainmodule background image @ runtime? Yes.. but no effect... ............................................. ChangeAppWallPaper procedure work OK. if run localhost only. if Apply to Production Server ...don't work.. with Access Violation Error. ............................................. procedure TisteeuniGUICustomFormLink.ChangeAppWallPaper( const AFileName: String; const ADefault: Boolean); var oMainForm: TUniForm; oPanel: TUniPanel; S: String; begin if Not System.IOUtils.TFile.Exists(AFileName) then Exit; S:= AFileName; if Not ADefault then begin S:= ExtractFileName(AFileName); S:= isteePlatform.Context.DesktopWallpaperPath+S; end; oMainForm:= UniApplication.UniMainModule.MainForm as TuniForm; oPanel:= TuniPanel(oMainForm.FindComponent('Panel_BACKGROUND')); if Assigned(oPanel) then begin oPanel.Background.Picture.LoadFromFile(S); << Access Violation *** Picture object *** S:= oPanel.Background.ImageUrl; UniSession.AddJS(oPanel.JSName+'.setStyle("background-image", ''url("'+S+'")'');'); UniSession.AddJS(oPanel.JSName+'.setStyle("background-size", ''cover'');'); end; end; Quote Link to comment Share on other sites More sharing options...
mhmda Posted August 9, 2021 Share Posted August 9, 2021 It will NOT change !!! You have to do it with the help of the client-side, this will help you, replace MainForm.form with your target object: UniSession.AddJS('MainForm.form.bodyCls="desktopwallpaper1"'); and in servermodule add your css for bg images: .desktopwallpaper1 { background-image: ......... } .desktopwallpaper2 { background-image: ......... } .desktopwallpaper3 { background-image: ......... } 1 Quote Link to comment Share on other sites More sharing options...
newsanti Posted August 10, 2021 Author Share Posted August 10, 2021 14 hours ago, mhmda said: It will NOT change !!! You have to do it with the help of the client-side, this will help you, replace MainForm.form with your target object: UniSession.AddJS('MainForm.form.bodyCls="desktopwallpaper1"'); and in servermodule add your css for bg images: .desktopwallpaper1 { background-image: ......... } .desktopwallpaper2 { background-image: ......... } .desktopwallpaper3 { background-image: ......... } Good Idea 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.