Sign in to follow this  
Followers 0
jkollss

Change tray icon if the new chat message appears [patch solution]

4 posts in this topic

Note to this patch: You have to create some NewChatMessage.ico file in the res\ directory. I did this just painted the standard Apex icon to the red. You can create that icon as you wish.

Also, this patch is quick and can be optimized to prevent copy-paste of the code. Take this just as an idea. And setup settings also maybe has to be implemented about that feature.

I used this on my own not so active hub, and found it very usable.

diff --git a/StrongDC.rc b/StrongDC.rc

index 2f7574e..ed7bbcb 100644

 IDD_LINE DIALOGEX 0, 0, 239, 46

@@ -1449,6 +1449,7 @@ IDR_NET_STATS		   ICON					"res\\netstats.ico"

 IDR_UPLOAD_QUEUE		ICON					"res\\uqueue.ico"

 IDR_PRIVATE_OFF		 ICON					"res\\UserOff.ico"

 IDR_HUB_OFF			 ICON					"res\\HubOff.ico"

+IDR_NEW_CHAT_MESSAGE	ICON					"res\\NewChatMessage.ico"


 #ifdef APSTUDIO_INVOKED

 /////////////////////////////////////////////////////////////////////////////

diff --git a/res/NewChatMessage.ico b/res/NewChatMessage.ico

new file mode 100644

index 0000000..be60bd0

Binary files /dev/null and b/res/NewChatMessage.ico differ

diff --git a/strongdc.vcproj b/strongdc.vcproj

index 4926588..c607ec3 100644

--- a/strongdc.vcproj

+++ b/strongdc.vcproj

@@ -308,6 +308,10 @@

 				>

 			</File>

 			<File

+				RelativePath=".\res\NewChatMessage.ico"

+				>

+			</File>

+			<File

 				RelativePath=".\res\notepad.ico"

 				>

 			</File>

diff --git a/windows/HubFrame.cpp b/windows/HubFrame.cpp

index f68101d..33d40e7 100644

--- a/windows/HubFrame.cpp

+++ b/windows/HubFrame.cpp

@@ -714,6 +714,10 @@ LRESULT HubFrame::onSpeaker(UINT /*uMsg*/, WPARAM /* wParam */, LPARAM /* lParam

 			  (msg.from.isOp() && !client->isOp())) {

 				  addLine(msg.from, Text::toT(msg.str), WinUtil::m_ChatTextGeneral);

		 	}

+			if((BOOLSETTING(OLD_TRAY_BEHAV) && BOOLSETTING(MINIMIZE_TRAY)) || !BOOLSETTING(OLD_TRAY_BEHAV)) {

+				HWND hMainWnd = MainFrame::getMainFrame()->m_hWnd;//GetTopLevelWindow();

+				::PostMessage(hMainWnd, WM_SPEAKER, MainFrame::SET_NEWCHATMSG_ICON, NULL);

+			}										

 		} else if(i->first == ADD_STATUS_LINE) {

 			addClientLine(Text::toT(static_cast<StringTask*>(i->second)->str), WinUtil::m_ChatTextServer );

 		} else if(i->first == ADD_SILENT_STATUS_LINE) {

diff --git a/windows/MainFrm.cpp b/windows/MainFrm.cpp

index 28025d3..70a044b 100644

--- a/windows/MainFrm.cpp

+++ b/windows/MainFrm.cpp

@@ -79,7 +79,7 @@ bool MainFrame::m_bDisableAutoComplete = false;

 MainFrame::MainFrame() : trayMessage(0), maximized(false), lastUpload(-1), lastUpdate(0), 

 lastUp(0), lastDown(0), oldshutdown(false), stopperThread(NULL), c(new HttpConnection()), au(NULL),

 closing(false), awaybyminimize(false), missedAutoConnect(false), lastTTHdir(Util::emptyStringT), tabsontop(false),

-bTrayIcon(false), bAppMinimized(false), bIsPM(false), UPnP_TCPConnection(NULL), UPnP_UDPConnection(NULL), 

+bTrayIcon(false), bAppMinimized(false), bIsPM(false), bIsNewChatMsg(false), UPnP_TCPConnection(NULL), UPnP_UDPConnection(NULL), 

 QuickSearchBoxContainer(WC_COMBOBOX, this, QUICK_SEARCH_MAP), QuickSearchEditContainer(WC_EDIT ,this, QUICK_SEARCH_MAP) { 

 		memzero(statusSizes, sizeof(statusSizes));

 		anyMF = this;

@@ -409,6 +409,7 @@ LRESULT MainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,


 	normalicon.hIcon = (HICON)::LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);

 	pmicon.hIcon = (HICON)::LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_TRAY_PM), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);

+	newchatmsgicon.hIcon = (HICON)::LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_NEW_CHAT_MESSAGE), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);


 	updateTray((BOOLSETTING(OLD_TRAY_BEHAV) && BOOLSETTING(MINIMIZE_TRAY)) || !BOOLSETTING(OLD_TRAY_BEHAV));


@@ -822,7 +823,18 @@ LRESULT MainFrame::onSpeaker(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL&

 			::Shell_NotifyIcon(NIM_MODIFY, &nid);

 			bIsPM = true;

 		}

-	}

+	} else if (wParam == SET_NEWCHATMSG_ICON) {

+		if (bIsNewChatMsg == false && (!WinUtil::isAppActive || bAppMinimized) && bTrayIcon == true) {

+			NOTIFYICONDATA nid;

+			nid.cbSize = sizeof(NOTIFYICONDATA);

+			nid.hWnd = m_hWnd;

+			nid.uID = 0;

+			nid.uFlags = NIF_ICON;

+			nid.hIcon = newchatmsgicon.hIcon;

+			::Shell_NotifyIcon(NIM_MODIFY, &nid);

+			bIsNewChatMsg = true;

+		}

+	}


 	return 0;

 }

@@ -1214,6 +1226,16 @@ LRESULT MainFrame::onSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL&

 			::Shell_NotifyIcon(NIM_MODIFY, &nid);

 			bIsPM = false;

 		}

+		if (bIsNewChatMsg && bTrayIcon == true) {

+			NOTIFYICONDATA nid;

+			nid.cbSize = sizeof(NOTIFYICONDATA);

+			nid.hWnd = m_hWnd;

+			nid.uID = 0;

+			nid.uFlags = NIF_ICON;

+			nid.hIcon = normalicon.hIcon;

+			::Shell_NotifyIcon(NIM_MODIFY, &nid);

+			bIsNewChatMsg = false;

+		}

 		bAppMinimized = false;

 	}


@@ -1340,6 +1362,7 @@ LRESULT MainFrame::OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,

 		DestroyIcon(hIconStatusDown);

 		DestroyIcon(hIconStatusUp);

 		DestroyIcon(pmicon.hIcon);

+		DestroyIcon(newchatmsgicon.hIcon);

 		bHandled = FALSE;

 	}


@@ -1776,6 +1799,16 @@ LRESULT MainFrame::onActivateApp(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/

 			::Shell_NotifyIcon(NIM_MODIFY, &nid);

 			bIsPM = false;

 		}

+		if(bIsNewChatMsg && bTrayIcon == true) {

+			NOTIFYICONDATA nid;

+			nid.cbSize = sizeof(NOTIFYICONDATA);

+			nid.hWnd = m_hWnd;

+			nid.uID = 0;

+			nid.uFlags = NIF_ICON;

+			nid.hIcon = normalicon.hIcon;

+			::Shell_NotifyIcon(NIM_MODIFY, &nid);

+			bIsNewChatMsg = false;

+		}

 	}

 	return 0;

 }

diff --git a/windows/MainFrm.h b/windows/MainFrm.h

index d2c24db..8c58c77 100644

--- a/windows/MainFrm.h

+++ b/windows/MainFrm.h

@@ -81,7 +81,8 @@ public:

 		STATUS_MESSAGE,

 		SHOW_POPUP,

 		REMOVE_POPUP,

-		SET_PM_TRAY_ICON

+		SET_PM_TRAY_ICON,

+		SET_NEWCHATMSG_ICON

 	};


 	BOOL PreTranslateMessage(MSG* pMsg)

@@ -421,6 +422,7 @@ public:

 private:

 	NOTIFYICONDATA normalicon;

 	NOTIFYICONDATA pmicon;

+	NOTIFYICONDATA newchatmsgicon;


 	class DirectoryListInfo {

 	public:

@@ -488,6 +490,7 @@ private:

 	bool bTrayIcon;

 	bool bAppMinimized;

 	bool bIsPM;

+	bool bIsNewChatMsg;


 	static bool bShutdown;

 	static uint64_t iCurrentShutdownTime;

diff --git a/windows/resource.h b/windows/resource.h

index 37e3662..f477169 100644

--- a/windows/resource.h

+++ b/windows/resource.h

@@ -982,6 +982,7 @@

 #define IDC_CHATDBLCLICKACTION		  10194

 #define IDC_CHAT_DBLCLICK			   10195

 #define IDC_HEADER_MENU				 10196

+#define IDR_NEW_CHAT_MESSAGE		10197

 #define ID_SHELLCONTEXTMENU_MIN		 12000

 #define ID_SHELLCONTEXTMENU_MAX		 14000

 #define IDC_BITZI_LOOKUP				20000

Share this post


Link to post
Share on other sites

can you explane what to with this? where to apply thios patch, how ?

Im asking for few month to someone make this pls help

Share this post


Link to post
Share on other sites

You need to recompile the client in order to use it. See the compiling ApexDc thread.

Share this post


Link to post
Share on other sites

Can anyone compile that, because i dont have VC or anyuthing to compile that. I m not good at programing and i just want to use apexdc on my lan. For few month i m asking for animated tray icon on MC message receive, and i m waiting for someone to make it. Pls can someone compile this, i know that many people would find this useful.

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0