Added tray functionality
This commit is contained in:
Binary file not shown.
@@ -266,7 +266,6 @@
|
||||
<td id="ID_BlockHeight">...</td>
|
||||
<td style="text-align: right; vertical-align: bottom">
|
||||
<button style="width: 100px" id="ButtonOK">OK</button>
|
||||
<button style="width: 100px" id="ButtonCancel">Exit</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
Binary file not shown.
@@ -193,6 +193,7 @@
|
||||
<Text Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ntray.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="SiaDriveApp.h" />
|
||||
<ClInclude Include="SiaDriveDlg.h" />
|
||||
@@ -200,6 +201,7 @@
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ntray.cpp" />
|
||||
<ClCompile Include="SiaDriveApp.cpp" />
|
||||
<ClCompile Include="SiaDriveDlg.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
@@ -233,4 +235,9 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties RESOURCE_FILE="SiaDrive.rc" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
@@ -33,6 +33,9 @@
|
||||
<ClInclude Include="SiaDriveApp.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ntray.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="SiaDriveDlg.cpp">
|
||||
@@ -44,6 +47,9 @@
|
||||
<ClCompile Include="SiaDriveApp.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ntray.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="SiaDrive.htm" />
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
#define WM_TRAYNOTIFY WM_USER + 100
|
||||
|
||||
/*
|
||||
* Home Test
|
||||
wept saxophone dialect depth update jaunt loincloth asleep lush gnome laptop upper olive itches essential neither feel fewest siblings brunt tasked upwards coal niece faked dating hedgehog magically abort
|
||||
@@ -90,7 +92,6 @@ END_MESSAGE_MAP()
|
||||
BEGIN_DHTML_EVENT_MAP(CSiaDriveDlg)
|
||||
DHTML_EVENT_ONCLICK(_T("ID_Renter_Edit"), OnButtonRenterEdit)
|
||||
DHTML_EVENT_ONCLICK(_T("ButtonOK"), OnButtonOK)
|
||||
DHTML_EVENT_ONCLICK(_T("ButtonCancel"), OnButtonCancel)
|
||||
DHTML_EVENT_ONCLICK(_T("CreateWalletButton"), OnButtonCreateWallet)
|
||||
DHTML_EVENT_ONCLICK(_T("ConfirmSeedButton"), OnButtonConfirmSeed)
|
||||
DHTML_EVENT_ONCLICK(_T("UnlockWalletButton"), OnButtonUnlockWallet)
|
||||
@@ -127,15 +128,12 @@ BOOL CSiaDriveDlg::PreTranslateMessage(MSG* pMsg)
|
||||
BEGIN_MESSAGE_MAP(CSiaDriveDlg, CDHtmlDialog)
|
||||
ON_WM_SYSCOMMAND()
|
||||
ON_WM_TIMER()
|
||||
ON_MESSAGE(WM_TRAYNOTIFY, &CSiaDriveDlg::OnTrayNotification)
|
||||
ON_COMMAND(ID_MNU_ITEM_TOGGLE, &CSiaDriveDlg::OnMnuItemToggle)
|
||||
ON_COMMAND(ID_MNU_ITEM_EXIT, &CSiaDriveDlg::OnMnuItemExit)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
HRESULT CSiaDriveDlg::OnButtonCancel(IHTMLElement* /*pElement*/)
|
||||
{
|
||||
OnCancel();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CSiaDriveDlg::OnButtonConfirmSeed(IHTMLElement* /*pElement*/)
|
||||
{
|
||||
_seedCreation = false;
|
||||
@@ -170,7 +168,7 @@ HRESULT CSiaDriveDlg::OnButtonMount(IHTMLElement* /*pElement*/)
|
||||
|
||||
HRESULT CSiaDriveDlg::OnButtonOK(IHTMLElement* /*pElement*/)
|
||||
{
|
||||
OnOK();
|
||||
ShowWindow(SW_HIDE);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -231,7 +229,10 @@ void CSiaDriveDlg::OnDocumentComplete(LPDISPATCH, LPCTSTR)
|
||||
BOOL CSiaDriveDlg::OnInitDialog()
|
||||
{
|
||||
CDHtmlDialog::OnInitDialog();
|
||||
|
||||
|
||||
_tray.Create(this, IDR_TRAY_MENU, L"Sia Drive", m_hIcon, WM_TRAYNOTIFY);
|
||||
_tray.SetDefaultMenuItem(ID_MNU_ITEM_TOGGLE, FALSE);
|
||||
|
||||
// Add "About..." menu item to system menu.
|
||||
|
||||
// IDM_ABOUTBOX must be in the system command range.
|
||||
@@ -260,6 +261,16 @@ BOOL CSiaDriveDlg::OnInitDialog()
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
}
|
||||
|
||||
void CSiaDriveDlg::OnMnuItemExit()
|
||||
{
|
||||
OnCancel();
|
||||
}
|
||||
|
||||
void CSiaDriveDlg::OnMnuItemToggle()
|
||||
{
|
||||
ShowWindow(IsWindowVisible() ? SW_HIDE : SW_SHOW);
|
||||
}
|
||||
|
||||
void CSiaDriveDlg::OnPaint()
|
||||
{
|
||||
if (IsIconic())
|
||||
@@ -324,6 +335,12 @@ void CSiaDriveDlg::OnTimer(UINT_PTR nIDEvent)
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CSiaDriveDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
_tray.OnTrayNotification(wParam, lParam);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void CSiaDriveDlg::SetBodyEnabled(const bool& enabled)
|
||||
{
|
||||
@@ -800,4 +817,5 @@ bool CSiaDriveDlg::UpdateUi(const bool& refresh)
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
#include <SiaApi.h>
|
||||
#include "SiaDriveConfig.h"
|
||||
#include "ntray.h"
|
||||
|
||||
using namespace Sia::Api;
|
||||
|
||||
@@ -30,6 +31,7 @@ public:
|
||||
HRESULT OnButtonUnlockWallet(IHTMLElement* pElement);
|
||||
HRESULT OnButtonMount(IHTMLElement* pElement);
|
||||
HRESULT OnButtonRenterEdit(IHTMLElement* pElement);
|
||||
LRESULT OnTrayNotification(WPARAM wParam, LPARAM lParam);
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
@@ -92,6 +94,7 @@ private:
|
||||
private:
|
||||
const DWORD _uiThreadId;
|
||||
CSiaDriveConfig _siaConfig;
|
||||
CTrayNotifyIcon _tray;
|
||||
std::unique_ptr<CSiaApi> _siaApi;
|
||||
CString _walletCreatedSeed;
|
||||
String _receiveAddress;
|
||||
@@ -102,4 +105,7 @@ private:
|
||||
static const UINT IDT_UPDATE = 1;
|
||||
static const UINT IDT_UI_ACTION_QUEUE = 2;
|
||||
static const std::uint8_t RENTER_TAB = 0;
|
||||
public:
|
||||
afx_msg void OnMnuItemToggle();
|
||||
afx_msg void OnMnuItemExit();
|
||||
};
|
||||
|
1398
SiaDrive/ntray.cpp
Normal file
1398
SiaDrive/ntray.cpp
Normal file
File diff suppressed because it is too large
Load Diff
295
SiaDrive/ntray.h
Normal file
295
SiaDrive/ntray.h
Normal file
@@ -0,0 +1,295 @@
|
||||
/*
|
||||
Module : NTray.h
|
||||
Purpose: Interface for a MFC class to encapsulate Shell_NotifyIcon
|
||||
Created: PJN / 14-05-1997
|
||||
|
||||
Copyright (c) 1997 - 2016 by PJ Naughter (Web: www.naughter.com, Email: pjna@naughter.com)
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Copyright / Usage Details:
|
||||
|
||||
You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise)
|
||||
when your product is released in binary form. You are allowed to modify the source code in any way you want
|
||||
except you cannot modify the copyright details at the top of each module. If you want to distribute source
|
||||
code with your application, then you are only allowed to distribute versions released by the author. This is
|
||||
to maintain a single distribution point for the source code.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/////////////////////////// Macros / Defines ///////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _NTRAY_H__
|
||||
#define _NTRAY_H__
|
||||
|
||||
#ifndef CTRAYNOTIFYICON_EXT_CLASS
|
||||
#define CTRAYNOTIFYICON_EXT_CLASS
|
||||
#endif //#ifndef CTRAYNOTIFYICON_EXT_CLASS
|
||||
|
||||
#ifndef _In_
|
||||
#define _In_
|
||||
#endif //#ifndef _In_
|
||||
|
||||
#ifndef _In_opt_
|
||||
#define _In_opt_
|
||||
#endif //#ifndef _In_opt_
|
||||
|
||||
#ifndef _Out_
|
||||
#define _Out_
|
||||
#endif //#ifndef _Out_
|
||||
|
||||
#ifndef _Inout_
|
||||
#define _Inout_
|
||||
#endif //#ifndef _Inout_
|
||||
|
||||
#ifndef __ATLWIN_H__
|
||||
#pragma message("CTrayNotifyIcon as of v1.51 requires ATL support to implement its functionality. If your project is MFC only, then you need to update it to include ATL support")
|
||||
#endif //#ifndef __ATLWIN_H__
|
||||
|
||||
#ifndef _AFX
|
||||
#ifndef __ATLMISC_H__
|
||||
#pragma message("To avoid this message, please put atlmisc.h (part of WTL) in your pre compiled header (normally stdafx.h)")
|
||||
#include <atlmisc.h> //If you do want to use CTrayNotifyIcon independent of MFC, then you need to download and install WTL from http://sourceforge.net/projects/wtl
|
||||
#endif //#ifndef __ATLMISC_H__
|
||||
#endif //#ifndef _AFX
|
||||
|
||||
|
||||
/////////////////////////// Classes ///////////////////////////////////////////
|
||||
|
||||
//the actual tray notification class wrapper
|
||||
class CTRAYNOTIFYICON_EXT_CLASS CTrayNotifyIcon : public CWindowImpl<CTrayNotifyIcon>
|
||||
{
|
||||
public:
|
||||
//Enums / Typedefs
|
||||
#ifndef _AFX
|
||||
typedef _CSTRING_NS::CString String;
|
||||
#else
|
||||
typedef CString String;
|
||||
#endif //#ifndef _AFX
|
||||
|
||||
enum BalloonStyle
|
||||
{
|
||||
Warning,
|
||||
Error,
|
||||
Info,
|
||||
None,
|
||||
User
|
||||
};
|
||||
|
||||
//We use our own definitions of the NOTIFYICONDATA structs so that
|
||||
//we can use all the functionality without requiring client code to
|
||||
//define _WIN32_IE >= 0x500
|
||||
typedef struct _NOTIFYICONDATA_1 //The version of the structure supported by Shell v4
|
||||
{
|
||||
DWORD cbSize;
|
||||
HWND hWnd;
|
||||
UINT uID;
|
||||
UINT uFlags;
|
||||
UINT uCallbackMessage;
|
||||
HICON hIcon;
|
||||
TCHAR szTip[64];
|
||||
} NOTIFYICONDATA_1;
|
||||
|
||||
typedef struct _NOTIFYICONDATA_2 //The version of the structure supported by Shell v5
|
||||
{
|
||||
DWORD cbSize;
|
||||
HWND hWnd;
|
||||
UINT uID;
|
||||
UINT uFlags;
|
||||
UINT uCallbackMessage;
|
||||
HICON hIcon;
|
||||
TCHAR szTip[128];
|
||||
DWORD dwState;
|
||||
DWORD dwStateMask;
|
||||
TCHAR szInfo[256];
|
||||
union
|
||||
{
|
||||
UINT uTimeout;
|
||||
UINT uVersion;
|
||||
} DUMMYUNIONNAME;
|
||||
TCHAR szInfoTitle[64];
|
||||
DWORD dwInfoFlags;
|
||||
} NOTIFYICONDATA_2;
|
||||
|
||||
typedef struct _NOTIFYICONDATA_3 //The version of the structure supported by Shell v6
|
||||
{
|
||||
DWORD cbSize;
|
||||
HWND hWnd;
|
||||
UINT uID;
|
||||
UINT uFlags;
|
||||
UINT uCallbackMessage;
|
||||
HICON hIcon;
|
||||
TCHAR szTip[128];
|
||||
DWORD dwState;
|
||||
DWORD dwStateMask;
|
||||
TCHAR szInfo[256];
|
||||
union
|
||||
{
|
||||
UINT uTimeout;
|
||||
UINT uVersion;
|
||||
} DUMMYUNIONNAME;
|
||||
TCHAR szInfoTitle[64];
|
||||
DWORD dwInfoFlags;
|
||||
GUID guidItem;
|
||||
} NOTIFYICONDATA_3;
|
||||
|
||||
typedef struct _NOTIFYICONDATA_4 //The version of the structure supported by Shell v7
|
||||
{
|
||||
DWORD cbSize;
|
||||
HWND hWnd;
|
||||
UINT uID;
|
||||
UINT uFlags;
|
||||
UINT uCallbackMessage;
|
||||
HICON hIcon;
|
||||
TCHAR szTip[128];
|
||||
DWORD dwState;
|
||||
DWORD dwStateMask;
|
||||
TCHAR szInfo[256];
|
||||
union
|
||||
{
|
||||
UINT uTimeout;
|
||||
UINT uVersion;
|
||||
} DUMMYUNIONNAME;
|
||||
TCHAR szInfoTitle[64];
|
||||
DWORD dwInfoFlags;
|
||||
GUID guidItem;
|
||||
HICON hBalloonIcon;
|
||||
} NOTIFYICONDATA_4;
|
||||
|
||||
DECLARE_WND_CLASS(_T("TrayNotifyIconClass"))
|
||||
|
||||
|
||||
//Constructors / Destructors
|
||||
CTrayNotifyIcon();
|
||||
virtual ~CTrayNotifyIcon();
|
||||
|
||||
//Create the tray icon
|
||||
#ifdef _AFX
|
||||
BOOL Create(_In_ CWnd* pNotifyWnd, _In_ UINT uID, _In_ LPCTSTR pszTooltipText, _In_ HICON hIcon, _In_ UINT nNotifyMessage, _In_ UINT uMenuID = 0, _In_ BOOL bShow = TRUE);
|
||||
BOOL Create(_In_ CWnd* pNotifyWnd, _In_ UINT uID, _In_ LPCTSTR pszTooltipText, _In_ CBitmap* pBitmap, _In_ UINT nNotifyMessage, _In_ UINT uMenuID = 0, _In_ BOOL bShow = TRUE);
|
||||
BOOL Create(_In_ CWnd* pNotifyWnd, _In_ UINT uID, _In_ LPCTSTR pszTooltipText, _In_ HICON* phIcons, _In_ int nNumIcons, _In_ DWORD dwDelay, _In_ UINT nNotifyMessage, _In_ UINT uMenuID = 0, _In_ BOOL bShow = TRUE);
|
||||
BOOL Create(_In_ CWnd* pNotifyWnd, _In_ UINT uID, _In_ LPCTSTR pszTooltipText, _In_ LPCTSTR pszBalloonText, _In_ LPCTSTR pszBalloonCaption, _In_ UINT nTimeout, _In_ BalloonStyle style, _In_ HICON hIcon, _In_ UINT nNotifyMessage, _In_ UINT uMenuID = 0, _In_ BOOL bNoSound = FALSE, _In_ BOOL bLargeIcon = FALSE, _In_ BOOL bRealtime = FALSE, _In_opt_ HICON hBalloonIcon = NULL, _In_ BOOL bQuietTime = FALSE, _In_ BOOL bShow = TRUE);
|
||||
BOOL Create(_In_ CWnd* pNotifyWnd, _In_ UINT uID, _In_ LPCTSTR pszTooltipText, _In_ LPCTSTR pszBalloonText, _In_ LPCTSTR pszBalloonCaption, _In_ UINT nTimeout, _In_ BalloonStyle style, _In_ CBitmap* pBitmap, _In_ UINT nNotifyMessage, _In_ UINT uMenuID = 0, _In_ BOOL bNoSound = FALSE, _In_ BOOL bLargeIcon = FALSE, _In_ BOOL bRealtime = FALSE, _In_opt_ HICON hBalloonIcon = NULL, _In_ BOOL bQuietTime = FALSE, _In_ BOOL bShow = TRUE);
|
||||
BOOL Create(_In_ CWnd* pNotifyWnd, _In_ UINT uID, _In_ LPCTSTR pszTooltipText, _In_ LPCTSTR pszBalloonText, _In_ LPCTSTR pszBalloonCaption, _In_ UINT nTimeout, _In_ BalloonStyle style, _In_ HICON* phIcons, _In_ int nNumIcons, _In_ DWORD dwDelay, _In_ UINT nNotifyMessage, _In_ UINT uMenuID = 0, _In_ BOOL bNoSound = FALSE, _In_ BOOL bLargeIcon = FALSE, _In_ BOOL bRealtime = FALSE, _In_opt_ HICON hBalloonIcon = NULL, _In_ BOOL bQuietTime = FALSE, _In_ BOOL bShow = TRUE);
|
||||
#else
|
||||
BOOL Create(_In_ CWindow* pNotifyWnd, _In_ UINT uID, _In_ LPCTSTR pszTooltipText, _In_ HICON hIcon, _In_ UINT nNotifyMessage, _In_ UINT uMenuID = 0, _In_ BOOL bShow = TRUE);
|
||||
BOOL Create(_In_ CWindow* pNotifyWnd, _In_ UINT uID, _In_ LPCTSTR pszTooltipText, _In_ CBitmap* pBitmap, _In_ UINT nNotifyMessage, _In_ UINT uMenuID = 0, _In_ BOOL bShow = TRUE);
|
||||
BOOL Create(_In_ CWindow* pNotifyWnd, _In_ UINT uID, _In_ LPCTSTR pszTooltipText, _In_ HICON* phIcons, _In_ int nNumIcons, _In_ DWORD dwDelay, _In_ UINT nNotifyMessage, _In_ UINT uMenuID = 0, _In_ BOOL bShow = TRUE);
|
||||
BOOL Create(_In_ CWindow* pNotifyWnd, _In_ UINT uID, _In_ LPCTSTR pszTooltipText, _In_ LPCTSTR pszBalloonText, _In_ LPCTSTR pszBalloonCaption, _In_ UINT nTimeout, _In_ BalloonStyle style, _In_ HICON hIcon, _In_ UINT nNotifyMessage, _In_ UINT uMenuID = 0, _In_ BOOL bNoSound = FALSE, _In_ BOOL bLargeIcon = FALSE, _In_ BOOL bRealtime = FALSE, _In_opt_ HICON hBalloonIcon = NULL, _In_ BOOL bQuietTime = FALSE, _In_ BOOL bShow = TRUE);
|
||||
BOOL Create(_In_ CWindow* pNotifyWnd, _In_ UINT uID, _In_ LPCTSTR pszTooltipText, _In_ LPCTSTR pszBalloonText, _In_ LPCTSTR pszBalloonCaption, _In_ UINT nTimeout, _In_ BalloonStyle style, _In_ CBitmap* pBitmap, _In_ UINT nNotifyMessage, _In_ UINT uMenuID = 0, _In_ BOOL bNoSound = FALSE, _In_ BOOL bLargeIcon = FALSE, _In_ BOOL bRealtime = FALSE, _In_opt_ HICON hBalloonIcon = NULL, _In_ BOOL bQuietTime = FALSE, _In_ BOOL bShow = TRUE);
|
||||
BOOL Create(_In_ CWindow* pNotifyWnd, _In_ UINT uID, _In_ LPCTSTR pszTooltipText, _In_ LPCTSTR pszBalloonText, _In_ LPCTSTR pszBalloonCaption, _In_ UINT nTimeout, _In_ BalloonStyle style, _In_ HICON* phIcons, _In_ int nNumIcons, _In_ DWORD dwDelay, _In_ UINT nNotifyMessage, _In_ UINT uMenuID = 0, _In_ BOOL bNoSound = FALSE, _In_ BOOL bLargeIcon = FALSE, _In_ BOOL bRealtime = FALSE, _In_opt_ HICON hBalloonIcon = NULL, _In_ BOOL bQuietTime = FALSE, _In_ BOOL bShow = TRUE);
|
||||
#endif //#ifdef _AFX
|
||||
|
||||
//Sets or gets the Tooltip text
|
||||
BOOL SetTooltipText(_In_ LPCTSTR pszTooltipText);
|
||||
BOOL SetTooltipText(_In_ UINT nID);
|
||||
String GetTooltipText() const;
|
||||
int GetTooltipMaxSize();
|
||||
|
||||
//Sets or gets the icon displayed
|
||||
BOOL SetIcon(_In_ HICON hIcon);
|
||||
BOOL SetIcon(_In_ CBitmap* pBitmap);
|
||||
BOOL SetIcon(_In_ LPCTSTR lpIconName);
|
||||
BOOL SetIcon(_In_ UINT nIDResource);
|
||||
BOOL SetIcon(_In_ HICON* phIcons, _In_ int nNumIcons, _In_ DWORD dwDelay);
|
||||
BOOL SetStandardIcon(_In_ LPCTSTR lpIconName);
|
||||
BOOL SetStandardIcon(_In_ UINT nIDResource);
|
||||
HICON GetIcon() const;
|
||||
BOOL UsingAnimatedIcon() const;
|
||||
|
||||
//Sets or gets the window to send notification messages to
|
||||
#ifdef _AFX
|
||||
BOOL SetNotificationWnd(_In_ CWnd* pNotifyWnd);
|
||||
CWnd* GetNotificationWnd() const;
|
||||
#else
|
||||
BOOL SetNotificationWnd(_In_ CWindow* pNotifyWnd);
|
||||
CWindow* GetNotificationWnd() const;
|
||||
#endif //#ifdef _AFX
|
||||
|
||||
//Modification of the tray icons
|
||||
BOOL Delete(_In_ BOOL bCloseHelperWindow = TRUE);
|
||||
BOOL Create(_In_ BOOL bShow = TRUE);
|
||||
BOOL Hide();
|
||||
BOOL Show();
|
||||
|
||||
//Dynamic tray icon support
|
||||
HICON BitmapToIcon(_In_ CBitmap* pBitmap);
|
||||
static BOOL GetDynamicDCAndBitmap(_In_ CDC* pDC, _In_ CBitmap* pBitmap);
|
||||
|
||||
//Modification of the menu to use as the context menu
|
||||
void SetMenu(_In_ HMENU hMenu);
|
||||
CMenu& GetMenu();
|
||||
void SetDefaultMenuItem(_In_ UINT uItem, _In_ BOOL fByPos);
|
||||
void GetDefaultMenuItem(_Out_ UINT& uItem, _Out_ BOOL& fByPos) { uItem = m_nDefaultMenuItem; fByPos = m_bDefaultMenuItemByPos; };
|
||||
|
||||
//Default handler for tray notification message
|
||||
virtual LRESULT OnTrayNotification(WPARAM uID, LPARAM lEvent);
|
||||
|
||||
//Status information
|
||||
BOOL IsShowing() const { return !IsHidden(); };
|
||||
BOOL IsHidden() const { return m_bHidden; };
|
||||
|
||||
//Sets or gets the Balloon style tooltip settings
|
||||
BOOL SetBalloonDetails(_In_ LPCTSTR pszBalloonText, _In_ LPCTSTR pszBalloonCaption, _In_ BalloonStyle style, _In_ UINT nTimeout, _In_ HICON hUserIcon = NULL, _In_ BOOL bNoSound = FALSE, _In_ BOOL bLargeIcon = FALSE, _In_ BOOL bRealtime = FALSE, _In_ HICON hBalloonIcon = NULL);
|
||||
String GetBalloonText() const;
|
||||
String GetBalloonCaption() const;
|
||||
BalloonStyle GetBalloonStyle() const;
|
||||
UINT GetBalloonTimeout() const;
|
||||
|
||||
//Other functionality
|
||||
BOOL SetVersion(_In_ UINT uVersion);
|
||||
BOOL SetFocus();
|
||||
|
||||
//Helper functions to load tray icon from resources
|
||||
static HICON LoadIcon(_In_ LPCTSTR lpIconName, _In_ BOOL bLargeIcon = FALSE);
|
||||
static HICON LoadIcon(_In_ UINT nIDResource, _In_ BOOL bLargeIcon = FALSE);
|
||||
static HICON LoadIcon(_In_ HINSTANCE hInstance, _In_ LPCTSTR lpIconName, _In_ BOOL bLargeIcon = FALSE);
|
||||
static HICON LoadIcon(_In_ HINSTANCE hInstance, _In_ UINT nIDResource, _In_ BOOL bLargeIcon = FALSE);
|
||||
|
||||
protected:
|
||||
//Methods
|
||||
BOOL CreateHelperWindow();
|
||||
BOOL StartAnimation(_In_ HICON* phIcons, _In_ int nNumIcons, _In_ DWORD dwDelay);
|
||||
void StopAnimation();
|
||||
HICON GetCurrentAnimationIcon() const;
|
||||
virtual BOOL ProcessWindowMessage(_In_ HWND hWnd, _In_ UINT nMsg, _In_ WPARAM wParam, _In_ LPARAM lParam, _Inout_ LRESULT& lResult, _In_ DWORD dwMsgMapID);
|
||||
LRESULT OnTaskbarCreated(WPARAM wParam, LPARAM lParam);
|
||||
void OnTimer(UINT_PTR nIDEvent);
|
||||
void OnDestroy();
|
||||
DWORD GetNOTIFYICONDATASizeForOS();
|
||||
|
||||
//Enums
|
||||
enum ShellVersion
|
||||
{
|
||||
Version4 = 0, //PreWin2k
|
||||
Version5 = 1, //Win2k
|
||||
Version6 = 2, //XP
|
||||
VersionVista = 3, //Vista
|
||||
Version7 = 4, //Windows7
|
||||
};
|
||||
|
||||
//Member variables
|
||||
NOTIFYICONDATA_4 m_NotifyIconData;
|
||||
BOOL m_bCreated;
|
||||
BOOL m_bHidden;
|
||||
#ifdef _AFX
|
||||
CWnd* m_pNotificationWnd;
|
||||
#else
|
||||
CWindow* m_pNotificationWnd;
|
||||
#endif //#ifdef _AFX
|
||||
CMenu m_Menu;
|
||||
UINT m_nDefaultMenuItem;
|
||||
BOOL m_bDefaultMenuItemByPos;
|
||||
ShellVersion m_ShellVersion;
|
||||
HICON m_hDynamicIcon; //Our cached copy of the last icon created with BitmapToIcon
|
||||
ATL::CHeapPtr<HICON> m_Icons;
|
||||
int m_nNumIcons;
|
||||
UINT_PTR m_nTimerID;
|
||||
int m_nCurrentIconIndex;
|
||||
int m_nTooltipMaxSize;
|
||||
};
|
||||
|
||||
#endif //#ifndef _NTRAY_H__
|
@@ -41,6 +41,9 @@
|
||||
|
||||
|
||||
#include <afxdhtml.h> // HTML Dialogs
|
||||
#include <atlbase.h> // ATL support
|
||||
extern CComModule _Module;
|
||||
#include <atlwin.h>
|
||||
|
||||
|
||||
#ifdef _UNICODE
|
||||
|
Reference in New Issue
Block a user