# Help with Script Dialog icon

**URL:** https://resource.dopus.com/t/help-with-script-dialog-icon/30656
**Category:** Help & Support
**Created:** [December 4, 2018, 5:25am UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656 "2018-12-04T05:25:31Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![Jon](https://resource.dopus.com/user_avatar/resource.dopus.com/jon/32/12713_2.png) [@Jon](https://resource.dopus.com/u/Jon)
#### Post date: [December 5, 2018, 9:55pm UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/6 "2018-12-05T21:55:52Z")

</div>

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](https://resource.dopus.com/uploads/default/original/3X/6/0/6039e82134e12ba6ee83504c053533720e7de68a.osp) (30.2 KB)

```vbscript
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>

```

---

_[View the full topic](https://resource.dopus.com/t/help-with-script-dialog-icon/30656)._
