Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/NotificationMessage.cpp

Issue 11557015: Tooltip notification. Check for update fixes. (Closed)
Patch Set: More comments addressed Created Sept. 25, 2013, 9:57 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/plugin/NotificationMessage.h ('k') | src/plugin/PluginClass.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/plugin/NotificationMessage.cpp
===================================================================
--- a/src/plugin/NotificationMessage.cpp
+++ b/src/plugin/NotificationMessage.cpp
@@ -1,5 +1,5 @@
-#include <Windows.h>
-#include <CommCtrl.h>
+#include <Windows.h>
+#include <CommCtrl.h>
#include "NotificationMessage.h"
@@ -8,21 +8,21 @@
CommonControlsInitialize();
}
-NotificationMessage::NotificationMessage(HWND parent)
-{
- parentWindow = parent;
+NotificationMessage::NotificationMessage(HWND parent)
+{
+ parentWindow = parent;
CommonControlsInitialize();
-};
-
-bool NotificationMessage::commonControlsInitialized(false);
+};
-void NotificationMessage::CommonControlsInitialize()
-{
- if (!commonControlsInitialized)
- {
- INITCOMMONCONTROLSEX commControls;
- commControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
- commControls.dwICC = ICC_BAR_CLASSES;
+bool NotificationMessage::commonControlsInitialized(false);
+
+void NotificationMessage::InitializeCommonControls()
+{
+ if (!commonControlsInitialized)
+ {
+ INITCOMMONCONTROLSEX commControls;
+ commControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ commControls.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&commControls);
commonControlsInitialized = true;
}
@@ -39,52 +39,59 @@
SetWindowPos(toolTipWindow, HWND_TOPMOST,0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- TOOLINFO ti;
- ti.cbSize = sizeof(TOOLINFO);
+ TOOLINFOW ti;
+ ti.cbSize = sizeof(TOOLINFOW);
ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_TRANSPARENT;
- ti.hwnd = toolTipWindow;
- ti.hinst = NULL;
- ti.uId = (UINT_PTR)parentWindow;
- ti.lpszText = (LPWSTR)message.c_str();
+ ti.hwnd = toolTipWindow;
+ ti.hinst = NULL;
+ ti.uId = (UINT_PTR)parentWindow;
+ ti.lpszText = const_cast<LPWSTR>(message.c_str());
GetClientRect(parentWindow, &ti.rect);
- LRESULT res = ::SendMessage(toolTipWindow, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
-
- RECT rect;
- GetWindowRect(parentWindow, &rect);
- Move(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2);
+ LRESULT res = ::SendMessage(toolTipWindow, TTM_ADDTOOL, 0, (LPARAM)&ti);
- res = ::SendMessage(toolTipWindow, TTM_SETTITLE, icon, (LPARAM)title.c_str());
- res = ::SendMessage(toolTipWindow, TTM_TRACKACTIVATE, TRUE, (LPARAM)(LPTOOLINFO) &ti);
+ RECT rect;
+ GetWindowRect(parentWindow, &rect);
+ Move(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2);
+
+ res = ::SendMessage(toolTipWindow, TTM_SETTITLE, icon, (LPARAM)title.c_str());
+ res = ::SendMessage(toolTipWindow, TTM_TRACKACTIVATE, TRUE, (LPARAM)&ti);
return true;
}
bool NotificationMessage::Hide()
{
- DestroyWindow(toolTipWindow);
- toolTipWindow = 0;
- return true;
+ if (IsVisible())
+ {
+ DestroyWindow(toolTipWindow);
+ toolTipWindow = 0;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
void NotificationMessage::Move(short x, short y)
{
- ::SendMessage(toolTipWindow, TTM_TRACKPOSITION, 0, (LPARAM)(LPTOOLINFO)MAKELONG(x, y));
+ ::SendMessage(toolTipWindow, TTM_TRACKPOSITION, 0, MAKELONG(x, y));
return;
}
bool NotificationMessage::SetTextAndIcon(std::wstring text, std::wstring title, int icon)
{
- TOOLINFO ti;
- ti.cbSize = sizeof(TOOLINFO);
+ TOOLINFOW ti;
+ ti.cbSize = sizeof(TOOLINFOW);
ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_TRANSPARENT;
- ti.hwnd = toolTipWindow;
- ti.hinst = NULL;
- ti.uId = (UINT_PTR)parentWindow;
- ti.lpszText = (LPWSTR)text.c_str();
+ ti.hwnd = toolTipWindow;
+ ti.hinst = NULL;
+ ti.uId = (UINT_PTR)parentWindow;
+ ti.lpszText = const_cast<LPWSTR>(text.c_str());
GetClientRect(parentWindow, &ti.rect);
- LRESULT res = ::SendMessage(toolTipWindow, TTM_SETTITLE, icon, (LPARAM)title.c_str());
- res = ::SendMessage(toolTipWindow, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
+ LRESULT res = ::SendMessage(toolTipWindow, TTM_SETTITLE, icon, (LPARAM)title.c_str());
+ res = ::SendMessage(toolTipWindow, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
return res == TRUE;
}
@@ -92,6 +99,7 @@
{
parentWindow = parent;
}
+
bool NotificationMessage::IsVisible()
{
if (toolTipWindow == 0)
« no previous file with comments | « src/plugin/NotificationMessage.h ('k') | src/plugin/PluginClass.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld