Welcome

User: Pass:   register


As i don't speak (write?) English that good. You'll find typo's :)

This tutorial is meant for people who have at least some experience in dialogs and custom windows. It explains more about the way a scripter can create bmp's for use in icons (dialogs). You'll need mirc 5.9 to use this tutorial, since i use the "scroll" object wich was recently introduced in mIRC.

This "knowledge" (scripting trick) can be used for the following things:

  • Creating background bmp's for channels, @'s, ...
  • Creating colours for (dialog) icons
  • Displaying a text with correct font and control codes in a dialog (once again using an icon)

I put in three small scripts, wich are of no use at all, except for showing you what you can do with these things. You might have noticed that each line is a comment (starting with a ; altough you should already know that), therefor, this tutorial can be loaded as a remote, do that N0W.

1. Basics.
We create a bmpfile using a window and one simple command, /drawsave, therefor, the window should be a picture window. After that, we use /drawfill, /drawtext, /drawline .... to make the picture, then we /drawsave the picture. Then we do whatever we want with the picture (did -g, /background, drawpic ... ) and finally we remove the file.

Short alias that will create a background for the status - window.

alias status {
  window -hp @status 1 1 380 90
  ; i use -h to hide the window so it doesn't "flash" (try to remove to h and see what i mean)
  drawtext -opb @status $colour(info) $colour(background) arial 60 5 3 Status Window
  ; i use the $colour() so that it will look good on most colour schemes.
  drawsave @status temp.bmp
  window -c @status
  ;We save and close the window.
  background -sp temp.bmp
  ;The p is used because, text is aligned left, -p makes the pic on the right, 
  ; so it won't bother you when reading text.
  .remove temp.bmp
  ;...
}


2. A little further. A /B(mp)C(reator)
Now, we're gonna create a thing that makes a bmp of the specified text. /bc <background colour> <text> ( $1 = colour and $2- = text ) To make sure that the bmp has the right size, and the text fills the window correctly, we have to calculate the needed width and heigth of the window. This alias makes use of the arial font, therefor, the needed with becomes: $calc( $width( $2- , arial , 60 , 1 , 1 ) + 25 ). If you don't get this, i suggest you use /help $width. Same for heigth:

$calc( $height( $2- , arial , 60 ) + 30 )

Since we now know the specified x and y for the window, the alias is easy.

alias bc {
  window -hp @bc 1 1 $calc($width($2-,arial,60,1,1) + 25) $calc($height($2-,arial,60) + 30)
  drawtext -opb @bc 1 $1 arial 60 5 3 $2-
  drawsave @bc temp.bmp
  window -c @bc
}

!!!!! Note that you can use colours, underlines, bolds, etc...



3. Using bmp's in dialogs.
I created a dialog to explain this part, it is a dialog that allows a person to select a colour. I would want the colours to be displayed in "real-time" but I found out the $rgb ident is kinda slow (like $server, $readini, $read etc.. )

alias co dialog -m colours colours

dialog colours {
  Title Colours
  size -1 -1 150 175
  option dbu
  button "Ok", 1 , 10 155 30 15, ok
  box "Preview ",2,5 1 140 90
  text "Red",3,10 106 20 10
  edit "0",4,25 105 15 10, read
  scroll "Blue",5,45 108 90 5, horizontal range 255
  box "RGB - values ",6,5 95 140 55
  text "Green",7,10 121 20 10
  edit "0",8,25 120 15 10, read
  scroll "Blue",9,45 123 90 5, horizontal range 255
  text "Blue",10,10 136 20 10
  edit "0",11,25 135 15 10, read
  scroll "Blue",12,45 138 90 5, horizontal range 255
  button "Generate",13, 50 155 30 15
  icon 14, 10 8 130 80
}

on *:dialog:colours:*:*: {
  if ( $devent == scroll ) did -ra $dname $calc($did - 1) $did($dname,$did).sel
  ; this line fills the editboxes with the rgb values, not needed, but looks kewl
  if ( $did == 13 ) do-colour
}

alias -l do-colour {
  ;This alias creates a bmp that has a rgb colour value, then it did-g's it.
  window -hp @colour 1 1 269 174
  clear @colour
  ; clears the previous colour.
  drawfill -r @colour $rgb($did(colours,4),$did(colours,8),$did(colours,11)) 1 1 1
  ; the three $did's hold the rgb values on the scroll-bar. (well edit-box actually, but they
  ; correspond.
  drawsave @colour temp.bmp
  did -g colours 14 temp.bmp
  ; fills the icon of the dialog.
  .remove temp.bmp
}

Written by Spola_Crite on Dalnet.






© 1996-2010 hdesk.org and dalnethelpdesk.com