1 const char w32taskbar_rcs[] = "$Id: w32taskbar.c,v 1.1.1.1 2001/05/15 13:59:08 oes Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/w32taskbar.c,v $
6 * Purpose : Functions for creating, setting and destroying the
9 * Copyright : Written by and Copyright (C) 2001 the SourceForge
10 * IJBSWA team. http://ijbswa.sourceforge.net
12 * Written by and Copyright (C) 1999 Adam Lock
15 * This program is free software; you can redistribute it
16 * and/or modify it under the terms of the GNU General
17 * Public License as published by the Free Software
18 * Foundation; either version 2 of the License, or (at
19 * your option) any later version.
21 * This program is distributed in the hope that it will
22 * be useful, but WITHOUT ANY WARRANTY; without even the
23 * implied warranty of MERCHANTABILITY or FITNESS FOR A
24 * PARTICULAR PURPOSE. See the GNU General Public
25 * License for more details.
27 * The GNU General Public License should be included with
28 * this file. If not, you can view it at
29 * http://www.gnu.org/copyleft/gpl.html
30 * or write to the Free Software Foundation, Inc., 59
31 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 * $Log: w32taskbar.c,v $
35 * Revision 1.1.1.1 2001/05/15 13:59:08 oes
36 * Initial import of version 2.9.3 source tree
39 *********************************************************************/
48 #include "w32taskbar.h"
52 const char w32taskbar_h_rcs[] = W32TASKBAR_H_VERSION;
54 #ifndef _WIN_CONSOLE /* entire file */
\r
56 #define WM_TRAYMSG WM_USER+1
58 static HMENU g_hmenuTray;
59 static HWND g_hwndTrayX;
61 static LRESULT CALLBACK TrayProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
64 /*********************************************************************
66 * Function : CreateTrayWindow
68 * Description : Creates and returns the invisible window responsible for processing tray messages.
71 * 1 : hInstance = instance handle of this application
73 * Returns : Handle of the systray window.
75 *********************************************************************/
76 HWND CreateTrayWindow(HINSTANCE hInstance)
79 static const char *szWndName = "JunkbusterTrayWindow";
82 wc.lpfnWndProc = TrayProc;
85 wc.hInstance = hInstance;
90 wc.lpszClassName = szWndName;
94 g_hwndTrayX = CreateWindow(szWndName, szWndName,
95 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
96 CW_USEDEFAULT, NULL, NULL, hInstance, NULL );
98 ShowWindow(g_hwndTrayX, SW_HIDE);
99 UpdateWindow(g_hwndTrayX);
101 g_hmenuTray = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_TRAYMENU));
108 /*********************************************************************
110 * Function : TraySetIcon
112 * Description : Sets the tray icon to the specified shape.
115 * 1 : hwnd = handle of the systray window
116 * 2 : uID = user message number to notify systray window
117 * 3 : hicon = set the current icon to this handle
119 * Returns : Same value as `Shell_NotifyIcon'.
121 *********************************************************************/
122 BOOL TraySetIcon(HWND hwnd, UINT uID, HICON hicon)
126 memset(&nid, 0, sizeof(nid));
128 nid.cbSize = sizeof(nid);
131 nid.uFlags = NIF_ICON;
132 nid.uCallbackMessage = 0;
135 return( Shell_NotifyIcon(NIM_MODIFY, &nid) );
140 /*********************************************************************
142 * Function : TrayAddIcon
144 * Description : Adds a tray icon.
147 * 1 : hwnd = handle of the systray window
148 * 2 : uID = user message number to notify systray window
149 * 3 : hicon = handle of icon to add to systray window
150 * 4 : pszToolTip = tool tip when mouse hovers over systray window
152 * Returns : Same as `Shell_NotifyIcon'.
154 *********************************************************************/
155 BOOL TrayAddIcon(HWND hwnd, UINT uID, HICON hicon, const char *pszToolTip)
159 memset(&nid, 0, sizeof(nid));
161 nid.cbSize = sizeof(nid);
164 nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
165 nid.uCallbackMessage = WM_TRAYMSG;
170 strcpy(nid.szTip, pszToolTip);
173 return( Shell_NotifyIcon(NIM_ADD, &nid) );
178 /*********************************************************************
180 * Function : TrayDeleteIcon
182 * Description : Deletes a tray icon.
185 * 1 : hwnd = handle of the systray window
186 * 2 : uID = user message number to notify systray window
188 * Returns : Same as `Shell_NotifyIcon'.
190 *********************************************************************/
191 BOOL TrayDeleteIcon(HWND hwnd, UINT uID)
195 memset(&nid, 0, sizeof(nid));
197 nid.cbSize = sizeof(nid);
201 return( Shell_NotifyIcon(NIM_DELETE, &nid) );
206 /*********************************************************************
208 * Function : TrayProc
210 * Description : Call back procedure processes tray messages.
213 * 1 : hwnd = handle of the systray window
214 * 2 : msg = message number
215 * 3 : wParam = first param for this message
216 * 4 : lParam = next param for this message
218 * Returns : Appropriate M$ window message handler codes.
220 *********************************************************************/
221 LRESULT CALLBACK TrayProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
234 UINT uID = (UINT) wParam;
235 UINT uMouseMsg = (UINT) lParam;
237 if (uMouseMsg == WM_RBUTTONDOWN)
240 HMENU hmenu = GetSubMenu(g_hmenuTray,0);
242 SetForegroundWindow(g_hwndLogFrame);
243 TrackPopupMenu(hmenu, TPM_LEFTALIGN | TPM_TOPALIGN, pt.x, pt.y, 0, g_hwndLogFrame, NULL);
244 PostMessage(g_hwndLogFrame, WM_NULL, 0, 0 ) ;
246 else if (uMouseMsg == WM_LBUTTONDBLCLK)
258 return DefWindowProc(hwnd, msg, wParam, lParam);
263 #endif /* ndef _WIN_CONSOLE - entire file */
\r