Help with Script Dialog icon

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>
3 Likes