# 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:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![pctechtv](https://resource.dopus.com/user_avatar/resource.dopus.com/pctechtv/32/33246_2.png) [@pctechtv](https://resource.dopus.com/u/pctechtv)\
**Post date:** [December 4, 2018, 5:25am UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/1 "2018-12-04T05:25:31Z")

</div>

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  
 ![chngIco](https://resource.dopus.com/uploads/default/original/3X/2/7/2759c1f97e6d2c7749c90ea0088db78bb7193d5d.png)

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [December 4, 2018, 10:30am UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/2 "2018-12-04T10:30:16Z")

</div>

I don't think the window icon for a script dialog can be changed at the moment.

---

<div class="post-metadata">

**Author:** ![pctechtv](https://resource.dopus.com/user_avatar/resource.dopus.com/pctechtv/32/33246_2.png) [@pctechtv](https://resource.dopus.com/u/pctechtv)\
**Post date:** [December 4, 2018, 4:03pm UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/3 "2018-12-04T16:03:05Z")

</div>

Thanks so much!

---

<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, 3:36am UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/4 "2018-12-05T03:36:18Z")

</div>

We've added a way for you to do this in the [12.10.4 Beta](https://resource.dopus.com/t/directory-opus-12-10-4-beta/30667).

---

<div class="post-metadata">

**Author:** ![AlbatorV](https://resource.dopus.com/user_avatar/resource.dopus.com/albatorv/32/25847_2.png) [@AlbatorV](https://resource.dopus.com/u/AlbatorV)\
**Post date:** [December 5, 2018, 8:34pm UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/5 "2018-12-05T20:34:11Z")

</div>

> 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

---

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

```

---

<div class="post-metadata">

**Author:** ![pctechtv](https://resource.dopus.com/user_avatar/resource.dopus.com/pctechtv/32/33246_2.png) [@pctechtv](https://resource.dopus.com/u/pctechtv)\
**Post date:** [December 6, 2018, 4:09pm UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/7 "2018-12-06T16:09:59Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![AlbatorV](https://resource.dopus.com/user_avatar/resource.dopus.com/albatorv/32/25847_2.png) [@AlbatorV](https://resource.dopus.com/u/AlbatorV)\
**Post date:** [December 6, 2018, 9:51pm UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/8 "2018-12-06T21:51:16Z")

</div>

And it's not possible to add icon/image in a button script (OnClick function)?

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [December 6, 2018, 9:55pm UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/9 "2018-12-06T21:55:00Z")

</div>

> [@AlbatorV](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![pctechtv](https://resource.dopus.com/user_avatar/resource.dopus.com/pctechtv/32/33246_2.png) [@pctechtv](https://resource.dopus.com/u/pctechtv)\
**Post date:** [December 6, 2018, 11:01pm UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/10 "2018-12-06T23:01:06Z")

</div>

> [@AlbatorV](#):
>
> And it's not possible to add icon/image in a button script (OnClick function)?

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](https://resource.dopus.com/uploads/default/original/3X/2/1/212bd97db7291ecb38503de4f5175fbc67f27333.zip) (188.8 KB)

---

<div class="post-metadata">

**Author:** ![AlbatorV](https://resource.dopus.com/user_avatar/resource.dopus.com/albatorv/32/25847_2.png) [@AlbatorV](https://resource.dopus.com/u/AlbatorV)\
**Post date:** [December 7, 2018, 12:13pm UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/11 "2018-12-07T12:13:45Z")

</div>

Thanks but it failed for me.

I want to do this...

![2018-12-07_130907](https://resource.dopus.com/uploads/default/original/3X/3/e/3ed672d8b4ae37ce07be339ba3e64bad0a6ede04.png)

With this script, no icon is display.

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

```

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [December 7, 2018, 5:47pm UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/12 "2018-12-07T17:47:18Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![pctechtv](https://resource.dopus.com/user_avatar/resource.dopus.com/pctechtv/32/33246_2.png) [@pctechtv](https://resource.dopus.com/u/pctechtv)\
**Post date:** [December 7, 2018, 11:14pm UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/13 "2018-12-07T23:14:50Z")

</div>

> [@AlbatorV](#):
>
> With this script, no icon is display.

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.

---

<div class="post-metadata">

**Author:** ![AlbatorV](https://resource.dopus.com/user_avatar/resource.dopus.com/albatorv/32/25847_2.png) [@AlbatorV](https://resource.dopus.com/u/AlbatorV)\
**Post date:** [December 8, 2018, 8:33am UTC](https://resource.dopus.com/t/help-with-script-dialog-icon/30656/14 "2018-12-08T08:33:13Z")

</div>

> [@Leo](#):
>
> 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.)

Don't work 😕  
Sorry but what's wrong ?

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

```
