mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2012
Posts: 299
Epic Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2012
Posts: 299
My client: "mIRC v7.63". For some reason I cannot use the path to the Icon file when I use a variable "%iconpath = $mircexe,21" or hash table value "$hget(icon,path) = C:\Folder\File.ico,2".

I must definitely write a direct path to the "C:\Windows\System32\shell32.dll,0" icon, or so "$mircexe,0". This hinders the creation of a separate custom database like CSS to HTML, only for control the dialog.

Not a working option:

Code
dialog -l MyDialog {
  title "MyDialog"
  size 300 300 300 300
  option pixels
  icon %iconpath
}

Code
dialog -l MyDialog {
  title "MyDialog"
  size 300 300 300 300
  option pixels
  icon $hget(icon,path)
}

And this is how it works:

Code
dialog -l MyDialog {
  title "MyDialog"
  size 300 300 300 300
  option pixels
  icon C:\Windows\System32\shell32.dll,0
}

Code
dialog -l MyDialog {
  title "MyDialog"
  size 300 300 300 300
  option pixels
  icon $mircexe,0
}

Can I solve this somehow on my own, in order to use variables and hash tables for the path to the icon, or is it a bug that needs fixing?

Second question. Is it possible to add a command to the dialog to change the window icon when the dialog is already created? For example: "/dialog -z <name> [table] [size 16,24,32] <icon path,index>"

And the third question. Can you solve the problem so that when creating a dialog in the script code, you can fold multiple lines into one for a more compact look? For example:

Code
dialog -l MyDialog { title "MyDialog" | size 10 10 10 10 | option pixels | icon $mircexe,0 }



🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
You must make mIRC sees the comma, a bit like inside identifier: var %a a.b,2,46 | echo -ag > $gettok(%a) doesn't work.
Inside identifier there's actually a way to force the evaluation of %a inside the identifier with [ ] so that the parsers sees correct stuff, but that's not possible inside dialog definition it seems.
The dialog definition isn't just commands you can chain with |, the parser doesn't understand /option as a command, however it could be made a feature still.
These are suggestions, not bugs.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
It looks like the dialog table has simplistic parsing of identifiers passed to it. It's easier to see what's going on by using shell32.dll, because that way the default icon or index is different than the one you're trying to load. I'm also using aliases without the -l because I'm running the /dialog command from the command line.

I can use method A:
alias return C:\Windows\System32\shell32.dll
with table item:
icon $iconfilename , 21

but not method B
alias iconfilename return C:\Windows\System32\shell32.dll , 21
with table item:
icon $iconfilename

and not method C
alias iconfilename return C:\Windows\System32\shell32.dll
alias iconfilenameindex { echo -s $scriptline | return 21 }
with table item:
icon $iconfilename , $iconfilenameindex

because with method B, it tries to see the comma and 21 as part of the filename. Since this doesn't exist, it's loading the default icon/index. It apparently doesn't like method C either. I can tell that it doesn't even evaluate the 2nd identifier because the debug echo in alias iconfilenameindex doesn't show, indicating that it's evaluating that $identifier no differently than any other non-numeric text. So, method C does load from shell32.dll, but it's evaluating the $iconfilenameindex as a text string with value zero, so it shows index zero from whatever filename is pointed at by $iconfilename

There's a similar problem you have with doing this same thing with an icon control. However, In that case, it actually does like method C. With method C, I can load an image into the icon 'control' using method C like:

icon 53, 0 0 222 222 , $iconfilename , $iconfilenameindex

but if I try to load both the index and the filename like with method B, it displays an error as if it thinks the filename contains a comma and ends with 21.

==

As for your question 2, there is a /did -g for changing the image in an icon *control*, but i don't see a /dialog -switch for changing the icon in the titlebar without doing a fast close/reopen. There probably would be a way to make /did -g backwards compatible based on the fact that it's invalid to create an icon control with index zero, in which case /did -g dialogname 0 [index] filename could be seen as changing the titlebar icon instead of changing a 'real' control.

==

As for question 3, I'm guessing that you have the same problem here for the same problem it has parsing certain types of identifier return strings. If I paste your condensed table above the other multi-line equivalent, then change its title, I can see that the dialog command is actually ignoring the condensed table and loading the multi-line one instead. But if i rename the multiline table too, it's pretending there's no table at all.

This kind of thing also happens with the menu command. This next condensed menu structure doesn't do anything. It doesn't appear in the status window's rightclick menu, and doesn't show the debug echo. However if you edit it to be a normal 3-line menu item, then it does both.

menu status { $iconfilenameindex foobar:noop }

Joined: Jan 2012
Posts: 299
Epic Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2012
Posts: 299
I need the value of a variable or hash table to work when building a dialog box. Because for all other parameters it this works except for the icon.

Let's say I create such a variable database for the convenience of quickly changing data:
Code
/set %dtitle = MyDialog
/set %dsize = 300 300 300 300
/set %doption = pixels
/set %diconpath = $mircexe,21

Or I'm create this using a hash table:
Code
/hash -m icon path $mircexe,21

Then later it is convenient for me to put all these values when creating a dialog:
Code
dialog MyDialog {
  title %dtitle
  size %dsize
  option %doption
  icon %diconpath
}

But I tried 100500 ways with the icon and none of them work...
If this is not a mistake, and not a not flaw oversight in the program, then there must be a 100% solution.
Do you have a concrete working example for solving this problem?



🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
You must use two variables


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
As I mentioned in my post, the icon as a dialog control accepts the index and filename being identifiers, but only separately. The icon definition for the titlebar doesn't even do that. It allows $iconfilename but doesn't allow %comma or $iconindexnumber. I tried $+($iconindex) or even $calc(21) or [ 21 ] to no success. It doesn't work to have an if () statement to change between literal definitions, nor does it work to have some grouped lines that get controlled by /enable or /disable.

The only thing I think can remain is to have the unwieldy methods of either having multiple tables defined by /enable or by modifying the script itself with the /write command.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
This looks like the resurrection of this topic
https://forums.mirc.com/ubbthreads.php/topics/209623/dialog-question

As I mentioned earlier in this thread, while it is true that using 2 variables for filename vs index works for the icon dialog-control that's controlled later by /did -g, the icon command in a table for controlling the dialog window's titlebar icon does not seem to support using anything to define the index except using literal text numbers. But the method C earlier doesn't recognize using an identifier or variable to define the titlebar icon's index. I tried using things including

[ 21 ]
$calc(21)
$eval(21,0)
$+(21)
placing 21 inside %iconindex
having $iconindex return 21
etc

and none of them worked. The old thread said that getting this to work is a feature request, and that appears to never been added, and the OP from 11 years ago ended up creating 2 dialog tables in order to call 1 of 2 alternatives. That's not an easy universal situation, if the table is large, or if there are a lot more than 2 icons to be used. I don't find an old reference where someone wanted to be able to use a /did command to change the titlebar icon, but it appears that's not possible either, barring my earlier suggestion to have /did -g refer to the titlebar icon by index 0 - which could also be a substitute for fixing the parsing of the dialog table.

I haven't checked to see which other contexts of the dialog table doesn't support $identifier/%variable either. Depending on this OP's use case, I don't know if there's a simple way to extract icons out of icon libraries like shell32.dll, then saving the icon to a separate filename by itself. But trying that might only be available on a few of the icon formats. I know of ICL, DLL, EXE, but i suspect there's others, even .ICO files containing multiple sizes of the same thing.

Joined: Jan 2012
Posts: 299
Epic Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2012
Posts: 299
Thanks for the extended answer. I read a similar topic from the link and this is almost the same idea what I want to implement in my script. Of course, it would be easier to use a separate icon file for each window without an index, but I also need to change the icon in the upper left corner on the fly, depending on the purpose of the dialog box. The only thing that I want to create a script using the available icons that everyone has by default, without using additional files, in order to have clean and manageable code. Accordingly, the option of using additional DLLs and files that the user does not have on his system by default is not suitable here. Otherwise, will have to archive the created script for transferring to other users with all the files additional to the code.

It would be much better if "K" would corrected fix this and provide such a simple opportunity to use the value of variables, where there will be a icon path and index separated by commas, because it seems to me that otherwise it won't work with any workaround available. And of course still need a command to quickly change the icon in the upper left corner after the dialog has already been created.

Need such a working variant, for example: "/set %iconpath = $mircexe,21" and then: "icon %iconpath" or "/set %iconpath = $mircexe | /set %iconindex = 21" and then: "icon %iconpath,%iconindex"

And to so that change icon: "/did -g MyDialog 0 [index] <icon path>"




🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples

Link Copied to Clipboard