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

Unified Diff: src/plugin/NotificationMessage.cpp

Issue 12836004: Fixed crash caused by update tooltips, TOOLINFO.hwnd cannot be thetooltip itself (causes a recursi… (Closed)
Patch Set: Created Oct. 9, 2013, 5:44 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 | « no previous file | no next file » | 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,15 +1,15 @@
#include <Windows.h>
#include <CommCtrl.h>
#include "NotificationMessage.h"
NotificationMessage::NotificationMessage(HWND parent): parentWindow(parent)
-{
+{
toolTipWindow = 0;
InitializeCommonControls();
};
bool NotificationMessage::commonControlsInitialized(false);
void NotificationMessage::InitializeCommonControls()
{
@@ -36,27 +36,27 @@ bool NotificationMessage::Show(std::wstr
parentWindow, NULL, NULL,
NULL);
SetWindowPos(toolTipWindow, HWND_TOPMOST,0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
TOOLINFOW ti = {};
ti.cbSize = sizeof(TOOLINFOW);
ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_TRANSPARENT;
- ti.hwnd = toolTipWindow;
+ ti.hwnd = parentWindow;
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)&ti);
RECT rect;
GetWindowRect(parentWindow, &rect);
- Move(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2);
+ Move(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2);
SetTextAndIcon(message, title, icon);
res = ::SendMessage(toolTipWindow, TTM_TRACKACTIVATE, TRUE, (LPARAM)&ti);
return true;
}
void NotificationMessage::Hide()
@@ -73,28 +73,28 @@ void NotificationMessage::Move(short x,
::SendMessage(toolTipWindow, TTM_TRACKPOSITION, 0, MAKELONG(x, y));
return;
}
bool NotificationMessage::SetTextAndIcon(std::wstring text, std::wstring title, int icon)
{
TOOLINFOW ti = {};
ti.cbSize = sizeof(TOOLINFOW);
- ti.hwnd = toolTipWindow;
+ ti.hwnd = parentWindow;
ti.hinst = NULL;
ti.uId = (UINT_PTR)parentWindow;
- ti.lpszText = const_cast<LPWSTR>(text.c_str());
+ ti.lpszText = const_cast<LPWSTR>(text.c_str());
LRESULT res = ::SendMessage(toolTipWindow, TTM_SETTITLE, icon, (LPARAM)title.c_str());
res = ::SendMessage(toolTipWindow, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
return res == TRUE;
}
void NotificationMessage::SetParent(HWND parent)
{
parentWindow = parent;
}
bool NotificationMessage::IsVisible()
{
if (toolTipWindow == 0)
return false;
return IsWindowVisible(toolTipWindow);
-}
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld