[Home] [Downloads] [Search] [Help/forum]

Miniwindows in MUSHclient - Create / move / resize

Written by Nick Gammon - July 2008. Updated September 2010.

On this page:

See also:


Before starting scripting with miniwindows, let's look at some basic technical details.

Create or resize a miniwindow

WindowCreate function prototype:

This creates (or re-creates) a miniwindow of the given name. It is not initially shown so it will be invisible until you call WindowShow. You can re-create an existing miniwindow by simply calling WindowCreate with the same name (thus letting you change various aspects of it). You can also use WindowResize to resize it, or WindowPosition to move it.

Example of creating a window

You can try this example in the Immediate window (Ctrl+I) and you should see a 200 x 200 pixel white window appear, centered (position 12). Outside a plugin, GetPluginID will return an empty string, which is why you need to put something before the string returned by GetPluginID.

If you want to see the grid lines I used in my examples, the following extra lines will do that:

You should really put the code to draw the lines before the call to the WindowShow function, otherwise the window is not redrawn immediately. Alternatively, put Redraw () after drawing the grid, which forces a window redraw.

When can I draw to a miniwindow?

Once the window has been created by a call to WindowCreate, you can draw to it anytime. You may find it useful to clear the window and start again "on a blank slate". For example:

This clears the entire window to white.

What happens when I re-create an existing miniwindow?

You can do a WindowCreate on an existing miniwindow with no problems. This will have the following effects:

The following items are retained:

Delete a miniwindow

WindowDelete function prototype:

You can delete a miniwindow by calling WindowDelete, supplying the miniwindow name. All resources used by that miniwindow will be freed, and the output window redrawn.

Show a miniwindow

WindowShow function prototype:

This shows or hides the designated window. A window redraw is scheduled.

Creating and showing windows are separate operations. This is because you may want to maintain something like an inventory list, or quest objectives, but not necessarily have space on the screen for them at a particular moment. By creating the window early on, you can draw to it (offscreen), add or remove items, and generally keep it up-to-date as events occur on the game. However when the player actually wants to see the window s/he may hit a hotkey or type an alias, which simply causes the window to be shown (or hidden).

Calling WindowShow forces a window refresh, so the screen will be updated with the new miniwindow (or absence, as the case may be).

If you have changed the miniwindow, you may not want to call WindowShow (in case they currently want it hidden). In this case you can call Redraw () instead, to cause the main output window to be redrawn, without changing the status of any miniwindows.


List all miniwindows

WindowList function prototype:

This returns a list of all miniwindows created for this world. You could use this to find which windows have been created, and then use WindowInfo to find information about each one.


Get information about a miniwindow

WindowInfo function prototype:

This returns information about a particular miniwindow. You might use this to find where the window is on the screen, what its size is, whether it is visible, and so on.

InfoType 10 to 13 are where the auto positioning last placed the window (the last time the main screen was refreshed).

The "show" flag is whether you want the window shown. Infotype 6 is whether it had to be temporarily hidden. This only applies to position codes 5, 7, 9, 11. The window will thus be visible if:

Move a miniwindow

WindowPosition function prototype:

This lets you move a miniwindow. This is only really useful if you are setting the "Absolute location" flag when creating it. In this case, if you notice the output window has been resized, you may want to resposition the window, without having to re-create it, and redraw all its contents.

Resize a miniwindow

WindowResize function prototype:

This lets you resize a miniwindow. This can be used to change the size of a window in response to a click and drag in a "resize" hotspot. The window's width and height are changed to the new values. The existing window contents is retained in the top-left corner (therefore it may be clipped if you are sizing smaller). If you are sizing larger any new area is filled with the colour BackgroundColour.

Other pages about miniwindows


Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]