mIRC Homepage

Another dialog question

Posted By: RusselB

Another dialog question - 24/11/08 11:57 PM

If I have an icon item in a dialog, it looks something like
Code:
  icon Canada.ico, 0 
or
Code:
  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
Code:
 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.
Posted By: Pivo

Re: Another dialog question - 25/11/08 12:20 AM

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...
Posted By: Horstl

Re: Another dialog question - 25/11/08 01:11 AM

Try:

icon $iif($isfile(<myicon>),<myicon>,$mircexe)

...making the default icon a stand-in
Posted By: Wims

Re: Another dialog question - 25/11/08 01:33 AM

I would use something like this :
Code:
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)
Posted By: genius_at_work

Re: Another dialog question - 25/11/08 03:25 AM

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
Posted By: RusselB

Re: Another dialog question - 25/11/08 03:29 AM

Your suggestion gives me an error of "Invalid table in icon"
Posted By: RusselB

Re: Another dialog question - 25/11/08 03:36 AM

Your suggestion works great for any icon item, whether in the titlebar or not.

Thanks
Posted By: Horstl

Re: Another dialog question - 25/11/08 10:34 AM

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) smile
Posted By: DJ_Sol

Re: Another dialog question - 25/11/08 01:34 PM

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.
Posted By: DJ_Sol

Re: Another dialog question - 26/11/08 03:42 AM

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 }
}
Posted By: RusselB

Re: Another dialog question - 26/11/08 04:14 AM

RusselB refers DJ_Sol to Wims post in this same topic laugh
Posted By: DJ_Sol

Re: Another dialog question - 26/11/08 05:01 AM

Oh did he suggest to delete the line as well? I don't really pay too much attention.
Posted By: RusselB

Re: Another dialog question - 26/11/08 05:16 AM

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.
Posted By: DJ_Sol

Re: Another dialog question - 26/11/08 12:47 PM

If you choose no icon I believe it uses mirc's default icon anyways, doesn't it?
© 2022 mIRC Discussion Forums