Skip to content

Commit

Permalink
Fixed crash caused by update tooltips, TOOLINFO.hwnd cannot be the to…
Browse files Browse the repository at this point in the history
…oltip itself (causes a recursive loop)
  • Loading branch information
Wladimir Palant committed Oct 8, 2013
1 parent d4d9f35 commit c333dfa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/plugin/NotificationMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "NotificationMessage.h"

NotificationMessage::NotificationMessage(HWND parent): parentWindow(parent)
{
{
toolTipWindow = 0;
InitializeCommonControls();
};
Expand Down Expand Up @@ -41,7 +41,7 @@ bool NotificationMessage::Show(std::wstring message, std::wstring title, int ico
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());
Expand All @@ -51,7 +51,7 @@ bool NotificationMessage::Show(std::wstring message, std::wstring title, int ico

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);
Expand All @@ -78,10 +78,10 @@ bool NotificationMessage::SetTextAndIcon(std::wstring text, std::wstring title,
{
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;
Expand All @@ -97,4 +97,4 @@ bool NotificationMessage::IsVisible()
if (toolTipWindow == 0)
return false;
return IsWindowVisible(toolTipWindow);
}
}

0 comments on commit c333dfa

Please sign in to comment.