winico(n) 0.6 winico "winico"
winico - Windows Icon extension for Tcl/Tk
TABLE OF CONTENTS
SYNOPSIS
DESCRIPTION
COMMANDS
CALLBACK EVENTS
EXAMPLES
AUTHORS
KEYWORDS
COPYRIGHT
package require Tcl 8.4
package require winico ?0.6?
The Winico extension is an extension that provides enhanced
handling of icons for Tk applications under Window. This includes
loading icons from icon files and from executable resources and also
provides Taskbar icon management.
- winico createfrom filename
-
Load icons from a .ico file. If successful this command returns an
identifier that should be used to access this resource with other
winico commands. Icon files often contain several icons for
different color depths of the screen and may contain different sizes
(e.g. 16x16 and 32x32 icons) To obtain information on what has been
loaded, see the info subcommand.
- winico load resourcename ?filename?
-
Load icons from the resource section of an executable file (.exe or .dll).
Only icons for the current colordepth are loaded (unlike the createfrom
subcommand). resourcename may be a string identifier or a number
that identifies the item in the resource file. If no filename is
given then you may load some standard windows icons (defined for the
LoadIcon Win32 API function). The following names are recognised:
"application", "asterisk", "error", "exclamation", "hand", "question",
"information", "warning", and "winlogo".
- winico info ?id?
-
Returns information about icon resources managed by this extension. If
id is ommitted then the command returns a list of all the
current icon ids. If an icon id is specified then the result is
a list option value pairs for each icon in the icon resource For
identifiers created via winico load the values given are not
relevant.
- -pos
-
position inside the iconresource (beginning from 0)
- -width
-
width of the icon in pixels
- -height
-
height of the icon in pixels
- -geometry
-
widthxheight in pixels (for convenience)
- -bpp
-
color depth in bits per pixel (4 means 16 colors)
- -hicon
-
windows icon handle for this icon (in the actual version
all hicons of a resource will be immediately created after
reading from disk, in later versions this may occur on demand ,
to economize system load )
- -ptr
-
C-pointer of the internal struct, only interesting for hackers :-)
- winico setwindow windowid id ?big|small? ?pos?
-
Set the icon for the toplevel window given by windowid which may
be either the Tk pathname for the window, or a valid Windows HWND
value (for use with non-Tk windows).
NOTE: the window MUST BE MAPPED. If not then this may fail or crash.
- big|small
-
If ?big|small? is "big" (default) the taskbar icon AND the caption icon
are set under Win95/WinNT, if it's "small" only the small caption icon
is set (via WM_SETICON).
Under Win32s ?big|small? is ignored (setting done via SetClassLong())
(for setting individual toplevels different Windows-classnames per toplevel
would be required , TkToplevel0, TkToplevel1 and so on)
- pos
-
If pos is set, the icon with that -pos number is used for setting
the toplevel icon, otherwise winico chooses the first 32x32 16color icon
(this could be improved)
This option only has an effect on icons created with the "createfrom"
subcommand (FIX ME: check this)
- winico delete id
-
Free the resource identified by id. This command is
always successful, even in id is invalid.
- winico taskbar add|modify|delete id ?-callback procname? ?-pos num? ?-text tooltiptext?
-
Modify an icon registration with the Windows taskbar. To add and
icon to the system tray you use the add command and provide a
suitable winico id. You should probably also provide a
-text argument otherwise the icon id will be used for the
text too (Windows displays the text as a tooltip).
To modify the text or the icon displayed in the taskbar status area,
use the -pos and -text options to change the current
settings.
The remove an icon from the status area use the delete and
give the id provided to the add command.
The optional -callback is for specifying a Tcl procedure to
be called when events occur on the icon. This includes mouse motion
and button click events.
In the callback there are bind-like abbreviations possible :
- %m
- the windows message specifier (see CALLBACK EVENTS)
- %i
- the icon identifier (ico#1, ico#2 a.s.o)
- %x
- current xposition of the cursor
- %y
- current yposition of the cursor
- %X
- xposition of the cursor when the last windows-message was processed
- %Y
- yposition of the cursor when the last windows-message was processed
(%X,%Y may differ from %x,%y however the difference is marginal )
- %t
- current tickcount of the system
- %w
- wParam of the internal callback message (the integer part of %i)
- %l
- lParam of the internal callback message (integer value of %m)
- %%
- a %-sign
The following Windows events will generate calls to a callback
procedure registered by the winico taskbar command. The
following lists all the possible values of %m in the callback
substitution. Typically WM_RBUTTONUP is bound to a context menu.
- WM_MOUSEMOVE
-
- WM_LBUTTONDOWN
-
- WM_LBUTTONUP
-
- WM_LBUTTONDBLCLK
-
- WM_RBUTTONDOWN
-
- WM_RBUTTONUP
-
- WM_RBUTTONDBLCLK
-
- WM_MBUTTONDOWN
-
- WM_MBUTTONUP
-
- WM_MBUTTONDBLCLK
-
|
% winico createfrom icons/smiley.ico
ico#5
% winico info ico#5
{-pos 0 -width 32 -height 32 -geometry 32x32 -bpp 4 -hicon 0x670081 -ptr 0xf99884} {-pos 1 -width 16 -height 16 -geometry 16x16 -bpp 4 -hicon 0xad01b4 -ptr 0xf99884}
|
|
set contextmenu [menu .popup -tearoff 0]
...
winico taskbar add ico#1 -pos 1 -text "big tcp server" -callback "mytclproc $contextmenu %m %i %X %Y"
...
proc mytclproc {contextmenu msg ico x y } {
if { $msg=="WM_RBUTTONUP" } {
$contextmenu post $x $y
}
}
|
Leo Schubert, Brueckner&Jarosch Ing.-GmbH
Modifications by Pat Thoyts.
icons, system tray, taskbar
Copyright © 1997-1998, Brueckner&Jarosch