From WikiChip
Custom Windows - mIRC
< mirc

Prior to mIRC 5.5, Custom Windows was the main method for making a GUI (graphical user interface).

Custom Windows[edit]

A custom window is just another window, like a channel window or a server window but with the added ability to control every aspect of it. The following commands allow you to modify, add, and change things in that custom window of yours.

Window Components[edit]

A custom window has the ability to contain the following 3 components:

Custom Window

Creating a window[edit]

Before you can do anything with a window, you must actually create it. All windows must have a name, their name must also start with the '@' symbol. The name can be anything as long as it doesn't contain spaces. Use the /window command to create a window:

/window @<WindowName> [x y [w h]]

This will create a blank window containing only the chatbox. If you'd like to add the editbox you'd need to use the -e switch. Placing a number after the switch allows you to define what kind of editbox to be used: 0 - single line, 1 - multi-line editbox, 2 - auto editbox, 3 - default. A window can also be made to be detached from the main window using the -d switch.

/window -e[N] @<WindowName> [x y [w h]]

A size-listbox can also be added to the window using the -l switch. Adding a number after the 'l' will define the width (in characters) of the listbox.

/window -l[N] @<WindowName> [x y [w h]]

For example:

alias example {
  ; -d desktop window, -e editbox, (3 = auto), -l = side-editbox (20-char width)
  ; position (200,200) size 500x350
  window -de3l20 @example 200 200 500 350
}

The code above will create a desktop window with an editbox and a side-listbox.

Text Operations[edit]

The following commands can be used to add, modify, delete, insert, or replace the lines in the chatbox or the side-listbox:

  • Add a line - This command will simply add a line of text to the end of the window. The [color] is the color number for the line. The -n switch can be used to prevent from adding duplicates. The -i indents the line.
    /aline [-ni] [color] <@name> <text>
  • Delete a line - This command is used to delete the Nth line from the window. The N2 line can be specified to give a range of line ex: 4-7 will delete line 4, 5, 6, and 7.
    /dline [color] <@name> <N[-N2]>
  • Insert a line - This command allows you to add a line of text after the Nth line. The [color] is the color number for the line. The -n switch can be used to prevent from adding duplicates. The -i indents the line.
    /iline [-ni] [color] <@name> <N> <text>
  • Replace a line - This command is used to replace the Nth line of a window with another line. The [color] is the color number for the line.
    /rline [color] <@name> <N> <text>
  • Change color of a line - This command is used to change the color of the Nth line with the new [color]. The -m switch can be used to associate nickname color in side-listbox with the nickname in the chatbox. The -r switch can be used to reset the color back to default.
    /cline [-rm] [color] <@name> <N>
  • Select a line - This command is used to select the Nth line of window. The -p switch can be used to force the line of text to be wrapped if it's too long to fit on one line. -h highlights the window's icon (only if its minimized). -a can be used to add this line to the current selection and -s can be used to clear the current selection and select just this line.
    /sline [color] <@name> <N>

Customizing the window[edit]

The titlebar command can be used to change the window's title.

/titlebar @window <text>

Please Note: this will not change the actual @window name, only its title. To change the actual window's name, use the rewin command:

/renwin <@oldname> <@newname> [topic]

Custom Window's Menu[edit]

You can also create a customized right click menu for the window, this can be done using one of the two ways:

  1. Plain text file (must be named "POPUP.TXT") which will contain the menu
  2. Coding the menu in the remote section

The first option is using a popup file. This method is very much like the popups tab in the script editor. In the code below we will assume you are going with option 2, writing it in the remote section. If you choose to go with a popup file, you will need to omit the "menu" keyword from your code. The basic syntax is:

menu @windowName  {
  <event>: {
    ;/commands
  }
  ;or
  <event>: /commands
}

There are 8 possible built-in events; however, only 3 of them pertain to regular custom windows (the rest can only be used in a Picture Window.

  • dclick - Triggers when a mouse has double clicked on the window.
  • rclick - Triggers when a mouse right clicked on the window.
  • lbclick - Triggers when an item from the side-listbox was clicked.

In addition to built-in events, you can also add your own custom menu items.

Note: if you have built-in mouse events as well as custom menu items, the built-in events MUST be placed above the custom menu items. The basic syntax for the menu items is:

menu @windowName  {
  item: {
    ;/commands
  }
  ;or
  item: /commands
}

Sub menus and sub items are possible by prefixing the sub menu item with a period. Additional periods will indicate sub-sub menus. For example:

menu @example  {
  menu  
  .sub_item: echo -a sub item clicked!
  .sub_item2
  ..sub__sub_item: echo -a sub sub item clicked!
  .sub: echo -a another item!
  item2: echo -a main item 2.
}

will generate the following menu:

Custom Window Menu

Getting Info[edit]

There are a number of identifiers that can be used to retrieved information from a custom window.

The $window identifier can be used to retrieve window-specific information:

$window(@name | N )

Some of $window's more helpful properties are:

Property Description
x, y, w, h left, top, width, and height
dx, dy, dw, dh left, top, width and height position relative to the desktop
state Returns the window's state (minimized/maximized/hidden/normal)
title Returns the window's title
font Returns the window's font
fontsize Returns the window's font size
ontop Returns $true/$false if the window is set ontop
wid Returns the window's ID
sbtext Returns the switchbar button text
sbcolor Returns the switchbar highlight color
sbstate Returns the switchbar button state
tdbstate Returns the treebar button state

Retrieving Text[edit]

You can retrieve a line of text from a custom window using the $line identifier:

$line(@windowName, N, T)

$lines returns the Nth line of text from a window. If N = 0, $lines returns the total number of lines in the window. If T = 1, the side-listbox will be used instead of the chatbox (default is 0).

You can also search the window for a line wild-matching a specific sequence.

$fline(@windowName, wildtext, N, T)

This will return the Nth line wild-matching a specific wildtext sequence. If T = 1, the side-listbox will be used instead of the chatbox (default is 0).

If a listbox is used, you can use the $sline identifier to retrieve the Nth selected text.

$sline(@windowName, N)[.ln]

If N = 0, the total number of selected lines is returned. If the .ln property is used, the line number will be returned instead of the actual text.