Dialog basics

From Scriptwiki
Revision as of 12:21, 24 August 2006 by Cail (talk | contribs)

Jump to: navigation, search

Basic dialog commands and switches

/dialog -mdtsonkcvie name [table] [x y w h] [text]
Where name is the name by which you'll refer to the dialog, and table is the dialog table name used to create dialog

 -m	create a modeless dialog using 'table' /dialog -m name table
 -a	used with -m, uses currently  active window as the parent
 -x	close a dialog without triggering any events
 -d	open dialog on the desktop, used with -m
 -h	make dialog work with active server connection
 -t	set dialog title /dialog -t name text
 -s	set dialog size/pos /dialog -s name x y w h
 -r	centers dialog
 -bp	interprets size as dbu or pixels
 -o	set dialog ontop of all windows
 -n	unset ontop setting
 -k	click ok button
 -c	click cancel button
 -v	makes the dialog the active window
 -ie	minimize/restore the dialog if created on the desktop

The dialog table You can use the dialog prefix to create a dialog table called name in a script using this format:

dialog [-l] name {
 title	"text"
 icon	filename, index
 size	x y w h
 option	type (dbu, pixels, notheme)
 
 text	"text", id, x y w h, style  (right, center, nowrap)
 edit	"text", id, x y w h, style  (right, center, multi, pass, read, return, hsbar, vsbar, autohs, autovs, limit N)
 button	"text", id, x y w h, style  (default, ok, cancel, flat, multi)
 check	"text", id, x y w h, style  (left, push, 3state)
 radio	"text", id, x y w h, style  (left, push)
 box	"text", id, x y w h, style
 scroll	"text", id, x y w h, style (top left bottom right horizontal range N N)
 
 list	id, x y w h, style          (sort, extsel, multsel, size, vsbar, hsbar, check, radio)
 combo	id, x y w h, style          (sort, edit, drop, size, vsbar, hsbar)
 
 icon	id, x y w h, filename, index, style    (noborder top left bottom right small large actual)
 
 link	"text", id, x y w h
 
 tab 	"text", id, x y w h
 tab	"text", id
 
 menu	"text", menuid [, menuid]
 item	"text", id [, menuid]
 item	break, id [, menuid]
}

The -l switch makes a dialog table local, so that it can only be accessed by other scripts in the same file.

Dbu vs. Pixels The dbu option makes mIRC use dialog base units when creating the dialog, this ensures that the dialog will look the same for all users under any size display, etc. Pixels is the default however to maintain compatibility with previous scripts.

The identifiers $dbuw and $dbuh return the dbu per pixel width and height values for the current display. This may or may not be an integer value.

Ok and Cancel buttons You can specify an ok and/or cancel button, and when a user clicks the ok or cancel buttons, the dialog is closed. You can prevent the dialog from closing if a user clicks the ok button by using /halt.

Default position and size If you specify -1 for any of the x y w h values in the size setting for the dialog, a default setting is used. To make mIRC center the dialog in a window, specify x y as -1 -1. The size setting can be over-ridden in the init event (see below) by using /dialog -s name x y w h.


Example

;create a dialog table with name 'dialogtest'
dialog dialogtest {
 
 ;set the titlebar text of the dialog to "testing dialog"
 title "testing dialog"
 
 ;define the position and size of the dialog, x and y set to -1 so the dialog is created to the middle of mirc window, width set to 150 and height to 200 
 size -1 -1 150 200
 
 ;dpu, dialog basic units, so the dialog will be the same size in every resolution
 option dbu
 
 ;a text item that says "Random text", assigning id 1 for the item, x=5, y=10, w=100, h=10, no style
 text "Random text", 1, 5 10 100 10, 
}

;now you can call this dialog by writing: /dialog -m dialogtest dialogtest