#pragma once
/* This class is modified from qDong QDongTaskIcon, and intend
* to port to other GUI system. It run in Windows 2K/XP/2K3 and
* above only currently.
*
* onlyAmigo DevTeam 2005-08-14
* by Palinx Young
*
* Prerequisites :
* Tested with wxWidgets 2.6.1, may work fine in 2.6.0 and above;
*
* Tested with MinGW 3.4.4, may be modifed if you use other compilers;
*
* Define the symbol WINVER=0x0500;
*
* Define the symbol _WIN32_IE=0x0500;
*
* To use NIIF_NOSOUND, define _WIN32_IE=0x0600;
*
* You MUST call wxTaskBarIcon::SetIcon() method
* before call oBallonTaskBar::ShowBalloon() method;
*/
#include <wx/taskbar.h>
#include <shellapi.h>
class wxTaskBarIconWindow: public wxFrame {
public:
wxTaskBarIconWindow(wxTaskBarIcon* icon): wxFrame(NULL, wxID_ANY,
wxEmptyString, wxDefaultPosition, wxDefaultSize, 0), m_icon(icon){}
WXLRESULT MSWWindowProc(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam) {
return 0;
}
private:
wxTaskBarIcon* m_icon;
};
class oBallonTaskBar: public wxTaskBarIcon {
public:
static const int ICON_ERROR = NIIF_ERROR;
static const int ICON_INFO = NIIF_INFO;
static const int ICON_NONE = NIIF_NONE;
static const int ICON_WARNING = NIIF_WARNING;
#if _WIN32_IE>=0x0600
static const int ICON_NOSOUND = NIIF_NOSOUND; // _WIN32_IE=0x0600
#endif
oBallonTaskBar(){}
;
bool ShowBalloon(wxString title, wxString msg, int iconID = ICON_INFO,
unsigned int timeout = 3000);
};
inline bool oBallonTaskBar::ShowBalloon(wxString title, wxString msg, int
iconID, unsigned int timeout) {
if (!IsOk()) {
return false;
}
NOTIFYICONDATA notifyData;
memset(¬ifyData, 0, sizeof(notifyData));
notifyData.cbSize = sizeof(notifyData);
notifyData.hWnd = (HWND)m_win->GetHWND();
notifyData.uCallbackMessage = ::RegisterWindowMessage(wxT(
"wxTaskBarIconMessage"));
notifyData.uFlags = NIF_MESSAGE;
notifyData.uFlags |= NIF_INFO;
lstrcpyn(notifyData.szInfo, msg.c_str(), sizeof(notifyData.szInfo));
lstrcpyn(notifyData.szInfoTitle, title.c_str(), sizeof
(notifyData.szInfoTitle));
notifyData.dwInfoFlags = iconID; // | NIIF_NOSOUND; modified by palinx
notifyData.uTimeout = timeout;
notifyData.uID = 99;
if (m_iconAdded) {
return (Shell_NotifyIcon(NIM_MODIFY, ¬ifyData) != 0);
} else {
return false;
}
}