mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#198267 24/04/08 07:20 PM
Joined: Apr 2008
Posts: 51
K
kkoser Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2008
Posts: 51
i have a listbox that is populated by filenames.jpg. and on the right side of my dialog is icons.

How can i associate the filenames from the listbox to the icon?

e.g. listbox selection 1.jpg would change icon 1 to 1.jpg

to make it easier to understand, say there is 4 items on the list and there are 4 icon controls.

it is kind of a thumbnail issue. any help to get me pushed in the right direction would be greatly appreciated. smile

the action right now is set to a button.

did -g AutoList 100 \images\1.jpg as AutoList is the dname and 100 is the icon control

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
What (in detail) do you mean by "associate"? In which cases shall the icons be drawn/redrawn/changed?

If the list contains the filenames, and you did not set the "extsel/multsel" style for the list - to draw an icon for the selected line on, say, sclick in the list:
/did -g $dname <ID of Icon> $did($dname,<ID of List>,$did($dname,<ID of List>).sel).text

Joined: Apr 2008
Posts: 51
K
kkoser Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2008
Posts: 51
i think that is the problem.it can be done that way. but i want it so it loads the images into the icon controls upon the click of the button not on the click on a selection on the listbox.

the listbox is loaded with filenames i want to take all of the filenames and load the images into icons on the right side of my dialog.

thanks for taking interest into my issue. i sure appreciate it.

Last edited by kkoser; 24/04/08 08:37 PM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Ok. So you want to create icons for all files in the list on click at a specific button.
Looping the list is not the issue.

I do see two other issues to solve:
1) How to set the position of all the icons
This could be done with a formula (calculating the position of icon N), or by predefining a set of positions (e.g. returning the position of icon N with a custom identifier)

2) You have to limit the max. allowed number of lines in the list (or at least the max. number of icons to draw), this is related to 1)


Joined: Apr 2008
Posts: 51
K
kkoser Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2008
Posts: 51
well the max is 30. after that i will have an action doing something else. But you are right. list.1 = icon.1 , list.2 = icon.2, etc...

I have the icons set to where i need them. i just don't know how to get the filenames from the list. Its too much to try and get the filenames before they get listed. so i thought maybe it would be possible to have it display the images in "thumbnail" like icons. if i can get it like that then i can set actions on the icons rather than the list. Just looks better.

Last edited by kkoser; 25/04/08 04:31 AM.
Joined: Apr 2008
Posts: 51
K
kkoser Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2008
Posts: 51
ok here is what i have so far. maybe you can push me in the right direction.

if ( $did == 85 ) { ; Listbox
set %file \images\ $+ $did($dname,85).seltext $+ .jpg ; Set path
did -ra AutoList 2 %file ; temp check to see path
did -g AutoList 133 %file | did -v AutoList 133 ; icon
}

i commented on the important parts i hope you understand them.
the issue is all the icons on the dialog are hidden. what i would like it to do is go down the list and load each image into its own icon control. (and make it visible). That is where i am stuck. i don't know how to do that. Yet.

should i use:

if (!$did(AutoList,133).visible) did -v AutoList 134
did -g AutoList 134 %file
if (!$did(AutoList,134).visible) did -v AutoList 135
did -g AutoList 135 %file
if (!$did(AutoList,135).visible) did -v AutoList 136
did -g AutoList 136 %file

etc, etc...

any suggestions would help.
btw the visible check doesn't work right. i don't think i did it the right way. but i hope you understand.

Last edited by kkoser; 25/04/08 07:26 AM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Assuming:
1) the 30 icon controls are already created (visible or hidden)
2) first Icon Control ID is 134
3) the 29 other Icon IDs are in order, thus 163 is the last ID
4) the list (filenames) has ID 100
5) that list contains filenames without extension ".jpg" or path
6) the path to the actual JPGs is static (<some core dir>\images\)
7) the ID for the button (show thumbs on sclick) is 85

Code:
; dialog event definition
on *:dialog:Autolist:*:*: {

  ; ... other dialog event code ...

  ; event is sclick
  if ($devent == sclick) {

    ; ... other dialog sclick events  ...

    ; selecting lines in the list
    if ($did == 100) {

      ; check for max 30 items selected - just a suggestion
      if ($did($dname,$did,0).sel > 30) {
        ; some action as the number of selected items exceeds 30
        ; e.g. unselecting the item just selected via: did -ku $dname $did $v1
        ; or by disabling the "show thumbs" button (re-enable via else { })
      }
    }

    ; sklick on "show thumbs" button
    if ($did == 85) {

      ; loop, starting with the first selected line in the list and the first Icon ID
      var %iconID = 134, %nr = 1

      ; as long as 1) the nr of selected lines in the list is <= 30 (superfluous if 
      ; you prevent a selection of more than 30 lines in the list click definition)
      ; and 2) there is a selected line of that %nr:
      while ((%nr <= 30) && ($did($dname,100,%nr).sel)) {

        ; set the full path for this file 
        var %file = $qt($+(<core dir>,\images\,$did($dname,100,$v1).text,.jpg))

        ; if the file is valid
        if ($isfile(%file)) {

          ; use file N (%nr) as icon for icon control N (%iconID)
          did -g $dname %iconID %file

          ; if the iconID is not visible, set it visible
          if (!$did($dname,%iconID).visible) { did -v $dname %iconID }

          ; and inc the N for %iconID, as this ID is now occupied with an icon/thumb
          inc %iconID
        }

        ; proceed with next selected line 
        inc %nr
      }

      ; hide alle the remaining icon IDs (there might be a list-selection of less 
      ; than 30 files and/or an invalid file)
      while (%iconID < 164) { 
        did -h $dname %iconID
        inc %iconID
      }
    }
    ; ... other dialog sclick events  ...
  }
  ; ... other dialog event code ...
}

Please note that I didn't actually test this with a dialog/jpgs - hope it helps nevertheless

Edit: Apparently erroneously I presumed you wanted a list to pick/select the icons - a list that may hold more than 30 lines. I'm sorry about that.
The main suggestion (a while loop to set all selected files to respective Icon IDs, show "occupied" IDs and hide the remaining Icon IDs) isn't affected by this.

Joined: Apr 2008
Posts: 51
K
kkoser Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2008
Posts: 51
This is how i got it to work, somewhat. Be safe to assume that:
1) the 30 icon controls are already created (hidden)
2) first Icon Control ID is 103
3) the 29 other Icon IDs are in order, thus 132 is the last ID
4) the list (filenames) has ID 85.
5) that list contains filenames without extension ".jpg" or path
6) the path to the actual JPGs is static (C:\mIRC\images\. will change later when this is taken care of.
7) the ID for the button (show thumbs on sclick) is 84
Code:
;sclick event

elseif ($did == 84) {


      var %iconID = 103, %nr = 1
      while ((%nr <= 30) && ($did($dname,85,%nr).sel)) {

;changed your line but will return it to proper just put the entire path in
        var %file =  c:\mIRC\images\ $+ $did($dname,85,$v1).text $+ .jpg

;To check to see visually if the path is right
        did -ra AutoList 2 %file 
        

if ($isfile(%file)) {

          did -g $dname %iconID %file

          if (!$did($dname,%iconID).visible) { did -v $dname %iconID }

          inc %iconID
        }

        inc %nr
      }
; disabled for a moment.
      ;      while (%iconID < 133) { 
      ;        did -h $dname %iconID
      ;        inc %iconID
      ;      }

    }


the issue is that it doesn't loop through the entire listbox. it only grabs the one i select from the listbox then click button 84. what i need it to do is display all of the filenames in the list just by the sclick of button 84.

on a side note: i really appreciate you describing what each line means and does. it has helped me immensely in my attempt to learn as much as i can about mirc scripting. Thank you again.

Last edited by kkoser; 25/04/08 06:18 PM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
yw smile

To loop the entire list (not only selected lines), don't use:
Code:
while ((%nr <= 30) && ($did($dname,85,%nr).sel))) {
  var %file =  c:\mIRC\images\ $+ $did($dname,85,$v1).text $+ .jpg
but:
Code:
while ($did($dname,85,%nr)) {
  var %file =  c:\mIRC\images\ $+ $v1 $+ .jpg


The old code meant:
as long as there is a Nth selected line (returning the line number of that line): set filename using the text (content) of the line of this line number
The new one runs:
as long as there is a Nth line (returning the content directly): set filename using this content

Last edited by Horstl; 25/04/08 07:23 PM.
Joined: Apr 2008
Posts: 51
K
kkoser Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2008
Posts: 51
Absolutely fanatastic!!! thanx a lot! Does more than what i expected it to do. I played around a bit and was able to clean about 150 lines from my project. So thank you very much.

i have a couple questions about it though. Maybe i should ask them in a different question though...

i have been using \images\$+ $value in many parts of project. and it seems to work fine.
Why do i need to use the full path here? and if i don't, how can i make it so it always knows that the image directory is always in the same place as the .mrc file? Should i use a set %path upon load?

the other question involves a bit of backward thinking from here.
you have showed me how to take listbox entries(filenames), and display images on my dialog. i was wondering how you can take on dclick of the image and msg the channel with the filename? My project is complete upon this so i am a bit excited about it.

What would you suggest?

on dclick of 103 msg %channel filename.jpg

Will this be hard to do?

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
1) If you want to ensure that the image directory used is the one off of the directory that the script is located in, use
Code:
$scriptdirimages\ $+ $value
in place of
Code:
\images\$+ $value


1a) If you don't use the full path, or a reference that contains the full path, then mIRC will look to the directory where mirc.ini is located. If you want to see what that directory is use
Code:
//echo -a $mircdir


2) Hard to do.. not at all, in fact, you have the correct idea already.
Code:
on *:dialog:<dialog_name>:dclick:103:{
.msg %channel $nopath(%file)
}

Note that %channel must contain a channel that you can send a message to, and %file contains the name of the .jpg file (which it should, as that's what's being set in the code)

Joined: Apr 2008
Posts: 51
K
kkoser Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2008
Posts: 51
thanks RusselB. i will try it out. i did a bit before and i don't think its so simple. the value of %file changes, no? when it runs its loop?

The trouble is dclicking on that icon, and sending the filename to the channel.

i'm still working on changing $scriptdirimages

you guys sure know your stuff!

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
for 2):
Code:
on *:dialog:Autolist:*:*: {

  ; ... your other dialog events, e.g. sclick definitions...

  ; dclick event
  elseif ($devent = dclick) {

    ; it's dclick on one of your icon IDs
    if ($did isnum 103-132) {

      ; $did($dname,$did) returns (if the ID points to an icon): <index-nr> <filename>. you need only the latter.
      var %iconfile = $gettok($did($dname,$did),2-,32)

      ; the active window (the one you may want to msg the filenames to) may be a chan or query
      if (($me ison $active) || ($query($active)) { var %cmd = msg $active I clicked: }

      ; if it's not, you cannot msg to that window, but e.g. echo. 
      ; To do nothing, the line would be: else return
      else { var %cmd = echo -na You selected: }

      ; filename only: 
      %cmd $nopath(%iconfile)

      ; full path would be:
      ; %cmd $longfn(%iconfile)

    }
  }
}

Joined: Apr 2008
Posts: 51
K
kkoser Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2008
Posts: 51
thanks again Horstl and RusselB for your help.

I think i confused myself along with you guys too.

your dclick events won't quite work for me the way i need it to. but your idea is solid. This is where i mentioned "Backward" thinking. you brought in the images on the icons from the listbox.

What i would like to do is dclick on the images and msg the channel with the selected text from the listbox.

I think it means holding the value from the listbox selection then using it on the dclick event.

Although it is a filename, i want to be able manipulate the text
in other ways. the listbox selections also are used for onNotice events.

Any suggestions in trying to do it this way?

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
ok.. let's make this easy on Horstl and myself, who seem to be the two people that are trying to help the most here.. Would you please post your full dialog code so that we can test different ideas that may or may not work depending on how your dialog is layed out.

Joined: Apr 2008
Posts: 51
K
kkoser Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2008
Posts: 51
ok give me a moment to clean it up a bit

Joined: Apr 2008
Posts: 51
K
kkoser Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2008
Posts: 51
http://www.nomorepasting.com/getpaste.php?pasteid=15050

There it is...i'm not sure if it will help or not..its a mess.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I'm working on the code.. so far, just cleaning it up a bit more than you already had, I've managed to reduce the size by about 10% and I can see spots where more can be saved.

Joined: Apr 2008
Posts: 51
K
kkoser Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2008
Posts: 51
wow.. thanx a lot. you could probably tell i.m pretty new to this. smile

Joined: Apr 2008
Posts: 51
K
kkoser Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Apr 2008
Posts: 51
Just a note to see what you came up with. smile

Page 1 of 2 1 2

Link Copied to Clipboard