Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
New related comments Number of comments in the last 48 hoursPlay WAV files 1 new comments
|
Buttons in Win95 taskbar
This article has not been rated yet. After reading, feel free to leave comments and rate it.
The ShellAPI provides the function Shell_NotifyIcon to add or remove a button.
You can pass a user defined message (called WM_TBBUTTON in the sample code) which will be sent to your form each time your new button in the task bar gets a mouse event.
Here are the code snippets to do just that!
 | |  | | uses
ShellAPI;
const
WM_TBBUTTON = WM_USER + 100;
procedure TForm1.IconCallBackMessage( var Mess : TMessage );
message WM_TBBUTTON;
procedure TForm1.FormCreate(Sender: TObject);
var
NotifyID : TNotifyIconData;
begin
with NotifyID do
begin
cbSize := SizeOf(TNotifyIconData);
Wnd := Form1.Handle;
uID := 1;
uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
uCallbackMessage := WM_TBBUTTON;
hIcon := Application.Icon.Handle;
szTip := 'This is the hint!';
end;
Shell_NotifyIcon(NIM_ADD, @NotifyID);
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
var
NotifyID : TNotifyIconData;
begin
with NotifyID do
begin
cbSize := SizeOf(TNotifyIconData);
Wnd := Form1.Handle;
uID := 1;
uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
uCallbackMessage := WM_TBBUTTON;
hIcon := Application.Icon.Handle;
szTip := 'This is the hint!';
end;
Shell_NotifyIcon(NIM_DELETE, @NotifyID);
end;
procedure TForm1.IconCallBackMessage(var Mess : TMessage);
begin
case Mess.lParam of
WM_LBUTTONDBLCLK : ShowMessage('Left Double Click');
WM_LBUTTONDOWN : ShowMessage('Left Down');
WM_LBUTTONUP : ShowMessage('Left Up');
WM_MBUTTONDBLCLK : ShowMessage('M Dbl');
WM_MBUTTONDOWN : ShowMessage('M D');
WM_MBUTTONUP : ShowMessage('M U');
WM_MOUSEMOVE : ShowMessage('Mouse movement');
WM_MOUSEWHEEL : ShowMessage('Mouse wheel');
WM_RBUTTONDBLCLK : ShowMessage('r dbl');
WM_RBUTTONDOWN : ShowMessage('r down');
WM_RBUTTONUP : ShowMessage('r up');
end;
end;
| |  | |  |
Comments:
|