I have converted my Script Dialog to a Script Package. I am trying to understand how to change the icon it displays to one that represents what my Script Dialog does. I am thinking that the icons that are included in the *.osp package can be used for this. The picture points to and describes which icon I want to change. If anybody has an example of a script that does change it could you please share. Thanks
I don't think the window icon for a script dialog can be changed at the moment.
Thanks so much!
We've added a way for you to do this in the 12.10.4 Beta.
Opus 12.10.4 (beta)
Added DOpus.LoadImage and Script.LoadImage methods which allow external image files and icons to be loaded by a script. Script.LoadImage can also load an image from a script package when it's placed inside a sub-directory called images . These methods both return an Image object, which can be displayed by a static control in a script dialog by assigning it to the label property of the Control object. An Image object loaded from a .ico file can also be used as the icon for a script dialog by assigning it to the icon property of the Dialog object.
Can we have an example to add icon to icon property please
Here you go. This example adds a command called CatDialog
. The .osp file has the images in it as well as the script file.
catdlg.osp (30.2 KB)
Option Explicit
' catdlg
' (c) 2018 jpotter
' This is a script for Directory Opus.
' See https://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.
' Called by Directory Opus to initialize the script
Function OnInit(initData)
initData.name = "catdlg"
initData.version = "1.0"
initData.copyright = "(c) 2018 jpotter"
' initData.url = "https://resource.dopus.com/viewforum.php?f=35"
initData.desc = ""
initData.default_enable = true
initData.min_version = "12.0"
Dim cmd
Set cmd = initData.AddCommand
cmd.name = "CatDialog"
cmd.method = "OnCatDialog"
cmd.desc = ""
cmd.label = "CatDialog"
cmd.template = ""
cmd.hide = false
cmd.icon = "script"
End Function
' Implement the CatDialog command
Function OnCatDialog(scriptCmdData)
' Choose an appropriate window icon based on the system DPI
Dim icon
if Dopus.DPI.Factor >= 150 then
Set icon = Script.LoadImage("cat32.ico")
else
Set icon = Script.LoadImage("cat16.ico")
end if
' Create the dialog
Dim Dlg
Set Dlg = DOpus.Dlg
Dlg.window = scriptCmdData.func.sourcetab
Dlg.template = "catdlg"
Dlg.icon = icon
Dlg.detach = True
Dlg.Create
' Initialise the cat image
Dlg.control("cat").label = Script.LoadImage("cat.png")
' Display and run the dialog
Dlg.Show
Dlg.RunDlg
End Function
==SCRIPT RESOURCES
<resources>
<resource name="catdlg" type="dialog">
<dialog fontsize="8" height="125" lang="english" title="Meow!" width="182">
<control halign="left" height="101" image="yes" name="cat" title="Static" type="static" width="148" x="15" y="10" />
</dialog>
</resource>
</resources>
This is a super cool feature of this super cool program. I am not surprised, because Directory Opus, its staff, and it's a community just give give give. You guys are so great!
And it's not possible to add icon/image in a button script (OnClick function)?
The filepath to the icon can be a file anywhere on the machine so I don't see why you couldn't, as long as you put the icon file somewhere.
I think this should nail it for you. Make a directory called "C:\temp", place the icon folder there. Note the path in the script. If you need any help getting it to work just shout.
onClkDaIcon.zip (188.8 KB)
Thanks but it failed for me.
I want to do this...
With this script, no icon is display.
Function OnClick(ByRef clickData)
icon = DOpus.LoadImage("C:\\temp\\icon\\flstudo16.ico")
Set dlg = DOpus.Dlg
dlg.window = clickData.func.sourcetab
dlg.message = "<- customize this icon"
dlg.title = "Test"
dlg.buttons = "Possible ?"
dlg.icon = icon
dlg.Show
End Function
You need to use Set
in VBScript to store the icon object which LoadImage
loads,
i.e. Set icon = DOpus.LoadImage(...
Also, just use one \
in path strings in VBScript. You only need \\
in JScript. (Although it might not matter, it could confuse things as well.)
I am not positive, but I don't think that type of dialog can take advantage of the update. The description states that it can be used in a script package and a script dialog. I tried to add to your code with no luck either. I think you need an answer as to can that standard dialog use this feature.
Don't work
Sorry but what's wrong ?
Function OnClick(ByRef clickData)
Set icon = DOpus.LoadImage("C:\DO.ico")
Set dlg = DOpus.Dlg
dlg.window = clickData.func.sourcetab
dlg.message = "<- customize this icon"
dlg.title = "Test"
dlg.buttons = "Possible ?"
dlg.icon = icon
dlg.Show
End Function