Another dialog question
#206761
24/11/08 11:57 PM
|
Joined: Aug 2004
Posts: 7,252
RusselB
OP
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
If I have an icon item in a dialog, it looks something like or icon 21, 535 60 64 64, RusselB.jpg, 0, noborder Occasionally, especially while getting others to test the script, I will forget to include the picture files, which causes mIRC to generate an error, as the file is missing. I was wondering if there was a way of doing something like if $exists(Canada.ico) {
icon Canada.ico, 0
} NOTE: I have tried this in the dialog, and it is not liked. I realize that I could make multiple dialog layouts depending on if the picture exists or not, but if there's an alternative I haven't thought of, I'd appreciate hearing what it is.
|
|
|
Re: Another dialog question
[Re: RusselB]
#206762
25/11/08 12:20 AM
|
Joined: Jun 2008
Posts: 58
Pivo
Babel fish
|
Babel fish
Joined: Jun 2008
Posts: 58 |
You could try using error handling to check, if the error occurs (or simply check for the files before you open the dialog), and if so, you could try to use /bwrite to create a small sample-image instead of the real one... But thats just an idea, I don't have time to play with /bwrite and create pics now (and I'm too tired anyway) ... I only know that this concept may fail at jpeg files due to their size, but as I said - that's all just guessed :P
Edit: If /bwrite doesn't work for you, you could also use Picture Windows... that should do the job. But is it worth the trouble? ...
good night...
|
|
|
Re: Another dialog question
[Re: RusselB]
#206765
25/11/08 01:11 AM
|
Joined: Nov 2006
Posts: 1,559
Horstl
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
Try:
icon $iif($isfile(<myicon>),<myicon>,$mircexe)
...making the default icon a stand-in
|
|
|
Re: Another dialog question
[Re: RusselB]
#206766
25/11/08 01:33 AM
|
Joined: Jul 2006
Posts: 3,890
Wims
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 3,890 |
I would use something like this : alias tryit {
if (!$exists($1-)) .timertry -m 0 20 if ($dialog(try)) $({,0) did -h try 1 $(|) .timertry off $(},0)
return $iif(!$v1,$1-,$mircexe)
}
dialog try {
title try
size -1 -1 300 300
option dbu
icon 1, 10 10 10 10, $tryit(path/file.ext)
} If the file does not exists, just use the first mirc icon file, and hide the icon as fast as possible (i use -m 0 20, because it's fine, but you can change these value)
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
Re: Another dialog question
[Re: RusselB]
#206769
25/11/08 03:25 AM
|
Joined: Oct 2005
Posts: 1,741
genius_at_work
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
Why not use a default icon (possibly hidden) in your dialog declaration, and then change it in your onDIALOG init event? (It may not be possible to change the titlebar icon after loading.)
See the following command in the help file:
/did -g name id [n] filename
-genius_at_work
|
|
|
Re: Another dialog question
[Re: Horstl]
#206770
25/11/08 03:29 AM
|
Joined: Aug 2004
Posts: 7,252
RusselB
OP
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Your suggestion gives me an error of "Invalid table in icon"
|
|
|
Re: Another dialog question
[Re: Wims]
#206771
25/11/08 03:36 AM
|
Joined: Aug 2004
Posts: 7,252
RusselB
OP
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Your suggestion works great for any icon item, whether in the titlebar or not.
Thanks
|
|
|
Re: Another dialog question
[Re: RusselB]
#206780
25/11/08 10:34 AM
|
Joined: Nov 2006
Posts: 1,559
Horstl
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
I just wanted to put the general idea in the shortest format. Of course you get that error for dialog item definitions using $iif, due to the "," char in $iif statements, and a custom identifier bypasses this issue (Wims exteded it with the "...and hide it via timer" idea) 
|
|
|
Re: Another dialog question
[Re: RusselB]
#206782
25/11/08 01:34 PM
|
Joined: Jan 2007
Posts: 1,156
DJ_Sol
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
I dunno, make a start menu event that checks for the image files. If the image isn't there remove the line from the file. If you reference the id in code later you can double check the file then before executing.
|
|
|
Re: Another dialog question
[Re: DJ_Sol]
#206823
26/11/08 03:42 AM
|
Joined: Jan 2007
Posts: 1,156
DJ_Sol
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
hmm, I was barely awake, maybe I didn't make sense.
What I am saying is to actually remove a line from the file. The line in the dialog { event that sets the icon.
In a start event, check for the needed image, or your image folder whatever ... If it doesn't exist /write -c the line that set's the icon.
Yeah this is pretty drastic. Doesn;t offer the user the chance of downloading the proper image folder/files.
Ok .... here's another idea. Make a custom identifier for the image.
icon 21, 535 60 64 64, $image , 0, noborder
alias image {
if (image not found) { return mirc or windows .ico path (known good .ico path) } else { return your image path } }
|
|
|
Re: Another dialog question
[Re: DJ_Sol]
#206825
26/11/08 04:14 AM
|
Joined: Aug 2004
Posts: 7,252
RusselB
OP
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
RusselB refers DJ_Sol to Wims post in this same topic 
|
|
|
Re: Another dialog question
[Re: RusselB]
#206828
26/11/08 05:01 AM
|
Joined: Jan 2007
Posts: 1,156
DJ_Sol
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
Oh did he suggest to delete the line as well? I don't really pay too much attention.
|
|
|
Re: Another dialog question
[Re: DJ_Sol]
#206830
26/11/08 05:16 AM
|
Joined: Aug 2004
Posts: 7,252
RusselB
OP
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Not the delete line, but the alias.. which is what I'm using as it guarantees some kind of icon, even if the picture I actually wanted is missing.
|
|
|
Re: Another dialog question
[Re: RusselB]
#206838
26/11/08 12:47 PM
|
Joined: Jan 2007
Posts: 1,156
DJ_Sol
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
If you choose no icon I believe it uses mirc's default icon anyways, doesn't it?
|
|
|
|
|