← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcpp-plugin-sdk-cpp/SpellPlugin] Rev 24: there can only be 1 active box

 

------------------------------------------------------------
revno: 24
committer: poy <poy@xxxxxxxxxx>
branch nick: SpellPlugin
timestamp: Sat 2013-05-11 17:34:09 +0200
message:
  there can only be 1 active box
modified:
  src/Plugin.cpp
  src/Plugin.h


--
lp:~dcplusplus-team/dcpp-plugin-sdk-cpp/SpellPlugin
https://code.launchpad.net/~dcplusplus-team/dcpp-plugin-sdk-cpp/SpellPlugin

Your team Dcplusplus-team is subscribed to branch lp:~dcplusplus-team/dcpp-plugin-sdk-cpp/SpellPlugin.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcpp-plugin-sdk-cpp/SpellPlugin/+edit-subscription
=== modified file 'src/Plugin.cpp'
--- src/Plugin.cpp	2013-05-05 14:13:11 +0000
+++ src/Plugin.cpp	2013-05-11 15:34:09 +0000
@@ -134,6 +134,8 @@
 }
 
 LRESULT CALLBACK Plugin::CallWndProc(int code, WPARAM wParam, LPARAM lParam) {
+	static HWND currentBox = nullptr;
+
 	if(code >= 0) {
 		auto& msg = *reinterpret_cast<CWPSTRUCT*>(lParam);
 		if(msg.message == WM_COMMAND && HIWORD(msg.wParam) == EN_UPDATE) {
@@ -158,20 +160,16 @@
 							message += *sug;
 						}
 					}
+
+					currentBox = hwnd;
+
 					auto message16 = Util::toT(message);
 					EDITBALLOONTIP tip { sizeof(EDITBALLOONTIP), _T("Spellcheck"), message16.c_str(), TTI_WARNING };
 					Edit_ShowBalloonTip(hwnd, &tip);
 
-					instance->boxes.push_back(hwnd);
-
-				} else {
-					instance->boxes.erase(std::remove_if(instance->boxes.begin(), instance->boxes.end(), [hwnd](HWND other) {
-						if(other == hwnd) {
-							Edit_HideBalloonTip(hwnd);
-							return true;
-						}
-						return false;
-					}), instance->boxes.end());
+				} else if(hwnd == currentBox) {
+					currentBox = nullptr;
+					Edit_HideBalloonTip(hwnd);
 				}
 			}
 		}

=== modified file 'src/Plugin.h'
--- src/Plugin.h	2013-05-05 14:13:11 +0000
+++ src/Plugin.h	2013-05-11 15:34:09 +0000
@@ -51,9 +51,7 @@
 
 	unique_ptr<Hunspell> spell;
 	vector<pair<string, vector<string>>> cache;
-
 	HHOOK hook;
-	vector<HWND> boxes;
 
 	GUI gui;
 };