diff options
author | George Hazan <george.hazan@gmail.com> | 2013-06-11 14:59:35 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-06-11 14:59:35 +0000 |
commit | 48fc03aa394f4506c6053323386c040fede13a29 (patch) | |
tree | 2cbb748d340ae1bb0fb141486a1033e629cad9ab /plugins/TooltipNotify | |
parent | 11cc72bbdc90d99d2383da11f13031ef31921baa (diff) |
- buggy window position saving code replaced with the standard Miranda service (fixes bug #350);
- version bump;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@4916 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TooltipNotify')
-rw-r--r-- | plugins/TooltipNotify/src/Tooltip.cpp | 41 | ||||
-rw-r--r-- | plugins/TooltipNotify/src/Tooltip.h | 28 | ||||
-rw-r--r-- | plugins/TooltipNotify/src/TooltipNotify.cpp | 234 | ||||
-rw-r--r-- | plugins/TooltipNotify/src/TooltipNotify.h | 37 | ||||
-rw-r--r-- | plugins/TooltipNotify/src/main.cpp | 5 | ||||
-rw-r--r-- | plugins/TooltipNotify/src/stdafx.h | 4 | ||||
-rw-r--r-- | plugins/TooltipNotify/src/version.h | 6 |
7 files changed, 164 insertions, 191 deletions
diff --git a/plugins/TooltipNotify/src/Tooltip.cpp b/plugins/TooltipNotify/src/Tooltip.cpp index e9804ea8b9..9821af1232 100644 --- a/plugins/TooltipNotify/src/Tooltip.cpp +++ b/plugins/TooltipNotify/src/Tooltip.cpp @@ -20,7 +20,7 @@ CTooltip::CTooltip(CTooltipNotify *pTooltipNotify) m_hWnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, s_szTooltipClass, 0,
WS_POPUP|WS_BORDER, 100, 100, 50, 50, 0, 0,
- m_pTooltipNotify->GetDllInstance(), NULL);
+ g_hInstDLL, NULL);
SetWindowLongPtr(m_hWnd, GWLP_USERDATA, reinterpret_cast<LONG>(this));
}
@@ -34,27 +34,20 @@ CTooltip::~CTooltip() if (m_szText) free(m_szText);
}
-/*static*/ void CTooltip::Initialize(HMODULE hInstance)
+/*static*/ void CTooltip::Initialize()
{
- WNDCLASSEX wcexWndClass;
- wcexWndClass.cbSize = sizeof(WNDCLASSEX);
- wcexWndClass.style = CS_SAVEBITS;
- wcexWndClass.lpfnWndProc = (WNDPROC)CTooltip::WindowProcWrapper;
- wcexWndClass.cbClsExtra = 0;
- wcexWndClass.cbWndExtra = 0;
- wcexWndClass.hInstance = hInstance;
- wcexWndClass.hIcon = 0;
- wcexWndClass.hCursor = 0;
- wcexWndClass.hbrBackground = 0;
- wcexWndClass.lpszMenuName = 0;
+ WNDCLASSEX wcexWndClass = { 0 };
+ wcexWndClass.cbSize = sizeof(WNDCLASSEX);
+ wcexWndClass.style = CS_SAVEBITS;
+ wcexWndClass.lpfnWndProc = (WNDPROC)CTooltip::WindowProcWrapper;
+ wcexWndClass.hInstance = g_hInstDLL;
wcexWndClass.lpszClassName = s_szTooltipClass;
- wcexWndClass.hIconSm = 0;
RegisterClassEx(&wcexWndClass);
}
-/*static*/ void CTooltip::Deinitialize(HMODULE hInstance)
+/*static*/ void CTooltip::Deinitialize()
{
- UnregisterClass(s_szTooltipClass, hInstance);
+ UnregisterClass(s_szTooltipClass, g_hInstDLL);
}
LRESULT CALLBACK CTooltip::WindowProcWrapper(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -148,7 +141,7 @@ LRESULT CALLBACK CTooltip::WindowProc(HWND hWnd, UINT message, WPARAM wParam, LP }
-VOID CTooltip::Validate()
+void CTooltip::Validate()
{
m_hFont = CreateFontIndirect(&m_lfFont);
SIZE Size;
@@ -161,20 +154,20 @@ VOID CTooltip::Validate() }
-VOID CTooltip::Show()
+void CTooltip::Show()
{
ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
}
-VOID CTooltip::Hide()
+void CTooltip::Hide()
{
ShowWindow(m_hWnd, SW_HIDE);
}
-VOID CTooltip::set_Translucency(BYTE bAlpha)
+void CTooltip::set_Translucency(BYTE bAlpha)
{
typedef BOOL (WINAPI *pfnSetLayeredWindowAttributes_t)(HWND, COLORREF, BYTE, DWORD);
pfnSetLayeredWindowAttributes_t pfnSetLayeredWindowAttributes;
@@ -189,7 +182,7 @@ VOID CTooltip::set_Translucency(BYTE bAlpha) }
}
-VOID CTooltip::set_TransparentInput(BOOL bOnOff)
+void CTooltip::set_TransparentInput(BOOL bOnOff)
{
if (bOnOff)
SetWindowLongPtr(m_hWnd, GWL_EXSTYLE, GetWindowLongPtr(m_hWnd, GWL_EXSTYLE) | WS_EX_TRANSPARENT);
@@ -198,17 +191,17 @@ VOID CTooltip::set_TransparentInput(BOOL bOnOff) }
-VOID CTooltip::get_Rect(RECT *Rect) const
+void CTooltip::get_Rect(RECT *Rect) const
{
GetWindowRect(m_hWnd, Rect);
}
-VOID CTooltip::set_Position(INT x, INT y)
+void CTooltip::set_Position(INT x, INT y)
{
SetWindowPos(m_hWnd, 0, x, y, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
}
-VOID CTooltip::set_Text(const TCHAR* szText)
+void CTooltip::set_Text(const TCHAR* szText)
{
if (m_szText) free(m_szText);
m_szText = _tcsdup(szText);
diff --git a/plugins/TooltipNotify/src/Tooltip.h b/plugins/TooltipNotify/src/Tooltip.h index ed79eefcd0..2ad5bea397 100644 --- a/plugins/TooltipNotify/src/Tooltip.h +++ b/plugins/TooltipNotify/src/Tooltip.h @@ -12,20 +12,20 @@ public: virtual ~CTooltip();
HWND GetHandle() const { return m_hWnd; }
- VOID Hide();
- VOID Show();
- VOID Validate();
- VOID set_Position(INT x, INT y);
- VOID get_Rect(RECT *Rect) const;
- VOID set_TransparentInput(BOOL bOnOff);
- VOID set_Translucency(BYTE bAlpha);
- VOID set_Text(const TCHAR* szText);
- VOID set_Font(const LOGFONT& Font) { m_lfFont = Font; }
- VOID set_TextColor(DWORD TextColor) { m_dwTextColor = TextColor; }
- VOID set_BgColor(DWORD BgColor) { m_dwBgColor = BgColor; }
-
- static void Initialize(HMODULE hInstance);
- static void Deinitialize(HMODULE hInstance);
+ void Hide();
+ void Show();
+ void Validate();
+ void set_Position(INT x, INT y);
+ void get_Rect(RECT *Rect) const;
+ void set_TransparentInput(BOOL bOnOff);
+ void set_Translucency(BYTE bAlpha);
+ void set_Text(const TCHAR* szText);
+ void set_Font(const LOGFONT& Font) { m_lfFont = Font; }
+ void set_TextColor(DWORD TextColor) { m_dwTextColor = TextColor; }
+ void set_BgColor(DWORD BgColor) { m_dwBgColor = BgColor; }
+
+ static void Initialize();
+ static void Deinitialize();
private:
// prohibit copying
diff --git a/plugins/TooltipNotify/src/TooltipNotify.cpp b/plugins/TooltipNotify/src/TooltipNotify.cpp index 1d71b312c5..34bcedbdbd 100644 --- a/plugins/TooltipNotify/src/TooltipNotify.cpp +++ b/plugins/TooltipNotify/src/TooltipNotify.cpp @@ -4,16 +4,6 @@ #include "stdafx.h"
-#define ReadSettingByte(c, d) db_get_b(NULL, s_szModuleName, c, d)
-#define ReadSettingWord(c, d) db_get_w(NULL, s_szModuleName, c, d)
-#define ReadSettingDword(c, d) db_get_dw(NULL, s_szModuleName, c, d)
-#define ReadSettingString(c, d) db_get_ts(NULL, s_szModuleName, c, d)
-
-#define WriteSettingByte(c, d) db_set_b(NULL, s_szModuleName, c, d)
-#define WriteSettingWord(c, d) db_set_w(NULL, s_szModuleName, c, d)
-#define WriteSettingDword(c, d) db_set_dw(NULL, s_szModuleName, c, d)
-#define WriteSettingString(c, d) db_set_ts(NULL, s_szModuleName, c, d)
-
enum
{
ProtoIntBit = 0x01,
@@ -30,12 +20,12 @@ static const int ID_TTNTF_STATUS_TYPING = ID_STATUS_INVISIBLE+10; static const int ID_TTNTF_STATUS_IDLE = ID_STATUS_INVISIBLE+11;
static const int ID_TTNTF_STATUS_NOT_IDLE = ID_STATUS_INVISIBLE+12;
-#define FONTSERV_GROUP LPGENT("Tooltip Notify")
-#define FONTSERV_ONLINE LPGENT("Online")
-#define FONTSERV_OFFLINE LPGENT("Offline")
-#define FONTSERV_OTHER LPGENT("Other Status")
-#define FONTSERV_TYPING LPGENT("Typing")
-#define FONTSERV_IDLE LPGENT("Idle")
+#define FONTSERV_GROUP LPGENT("Tooltip Notify")
+#define FONTSERV_ONLINE LPGENT("Online")
+#define FONTSERV_OFFLINE LPGENT("Offline")
+#define FONTSERV_OTHER LPGENT("Other Status")
+#define FONTSERV_TYPING LPGENT("Typing")
+#define FONTSERV_IDLE LPGENT("Idle")
struct FontEntry
{
@@ -55,39 +45,36 @@ static FontEntry s_fontTable[] = 0, FONTSERV_OTHER, "OtherFont", "OtherBgColor",
};
-/*static*/ CTooltipNotify *CTooltipNotify::s_pInstance = 0;
-/*static*/ const char *CTooltipNotify::s_szModuleNameOld = "ttntfmod";
-/*static*/ const char *CTooltipNotify::s_szModuleName = "TooltipNotify";
-
+CTooltipNotify *CTooltipNotify::s_pInstance = 0;
+const char *CTooltipNotify::s_szModuleNameOld = "ttntfmod";
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
-CTooltipNotify::CTooltipNotify(HINSTANCE hinstDLL) :
- m_hDllInstance(hinstDLL), m_bNt50(IsNt50())
+CTooltipNotify::CTooltipNotify() :
+ m_bNt50( IsNt50())
{
if (s_pInstance!=0)
throw EAlreadyExists();
s_pInstance = this;
- CTooltip::Initialize(m_hDllInstance);
+ CTooltip::Initialize();
}
CTooltipNotify::~CTooltipNotify()
{
EndNotifyAll();
- CTooltip::Deinitialize(m_hDllInstance);
+ CTooltip::Deinitialize();
s_pInstance=0;
}
void CTooltipNotify::RegisterFonts()
{
- FontIDT fontId = {0};
- fontId.cbSize = sizeof(fontId);
+ FontIDT fontId = { sizeof(fontId) };
_tcscpy(fontId.group, FONTSERV_GROUP);
- strcpy(fontId.dbSettingsGroup, s_szModuleName);
+ strcpy(fontId.dbSettingsGroup, MODULENAME);
fontId.flags = FIDF_DEFAULTVALID;
fontId.deffontsettings.colour = DEF_SETTING_TXTCOLOR;
fontId.deffontsettings.size = -MulDiv(DEF_SETTING_FONT_SIZE, DEF_LOGPIXELSY, 72);
@@ -97,16 +84,14 @@ void CTooltipNotify::RegisterFonts() fontId.order = 0;
_tcscpy(fontId.backgroundGroup, FONTSERV_GROUP);
- ColourIDT colorId = {0};
- colorId.cbSize = sizeof(colorId);
+ ColourIDT colorId = { sizeof(colorId) };
_tcscpy(colorId.group, FONTSERV_GROUP);
- strcpy(colorId.dbSettingsGroup, s_szModuleName);
+ strcpy(colorId.dbSettingsGroup, MODULENAME);
colorId.flags = 0;
colorId.defcolour = DEF_SETTING_BGCOLOR;
colorId.order = 0;
- for (int i=0; i<SIZEOF(s_fontTable); i++)
- {
+ for (int i=0; i<SIZEOF(s_fontTable); i++) {
_tcscpy(fontId.name, s_fontTable[i].name);
strcpy(fontId.prefix, s_fontTable[i].fontPrefix);
_tcscpy(fontId.backgroundName, s_fontTable[i].name);
@@ -154,7 +139,7 @@ int CTooltipNotify::ModulesLoaded(WPARAM wParam, LPARAM lParam) db_set_b(NULL, "SkinSoundsOff", SND_OFFLINE, 1);
db_set_b(NULL, "SkinSoundsOff", SND_OTHER, 1);
db_set_b(NULL, "SkinSoundsOff", SND_TYPING, 1);
- WriteSettingByte("firstrun", 0);
+ db_set_b(NULL, MODULENAME, "firstrun", 0);
}
// register fonts
@@ -206,9 +191,9 @@ int CTooltipNotify::ProtoAck(WPARAM wParam, LPARAM lParam) if (wNewStatus == ID_STATUS_OFFLINE)
{
- BYTE bProtoActive = ReadSettingByte(szProtocol, ProtoUserBit|ProtoIntBit);
+ BYTE bProtoActive = db_get_b(NULL, MODULENAME, szProtocol, ProtoUserBit|ProtoIntBit);
bProtoActive &= ~ProtoIntBit;
- WriteSettingByte(szProtocol, bProtoActive);
+ db_set_b(NULL, MODULENAME, szProtocol, bProtoActive);
}
else
{
@@ -239,7 +224,7 @@ int CTooltipNotify::ContactSettingChanged(WPARAM wParam, LPARAM lParam) if(db_get_b(hContact, "CList", "Hidden", 0)) return 0;
const char *pszProto = cws->szModule;
- if (ReadSettingByte(pszProto, ProtoUserBit|ProtoIntBit) != (ProtoUserBit|ProtoIntBit))
+ if (db_get_b(NULL, MODULENAME, pszProto, ProtoUserBit|ProtoIntBit) != (ProtoUserBit|ProtoIntBit))
{
return 0;
}
@@ -249,7 +234,7 @@ int CTooltipNotify::ContactSettingChanged(WPARAM wParam, LPARAM lParam) return 0;
}
- if (db_get_b(hContact, s_szModuleName, CONTACT_IGNORE_TTNOTIFY, m_sOptions.bIgnoreNew))
+ if (db_get_b(hContact, MODULENAME, CONTACT_IGNORE_TTNOTIFY, m_sOptions.bIgnoreNew))
{
return 0;
}
@@ -292,10 +277,9 @@ int CTooltipNotify::ContactSettingChanged(WPARAM wParam, LPARAM lParam) int CTooltipNotify::InitializeOptions(WPARAM wParam, LPARAM lParam)
{
- OPTIONSDIALOGPAGE odp = { 0 };
- odp.cbSize = sizeof(odp);
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.position = 100000000;
- odp.hInstance = m_hDllInstance;
+ odp.hInstance = g_hInstDLL;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.pszTitle = LPGEN("Tooltip Notify");
odp.pszGroup = LPGEN("Popups");
@@ -331,22 +315,10 @@ CTooltip *CTooltipNotify::BeginNotify(STooltipData *pTooltipData) SystemParametersInfo(SPI_GETWORKAREA, 0, &WorkAreaRect, 0);
pTooltip->get_Rect(&TooltipRect);
- int tt_width = TooltipRect.right-TooltipRect.left;
- int tt_height = TooltipRect.bottom-TooltipRect.top;
-
- if (m_sOptions.bAutoPos ||
- m_sOptions.wXPos > WorkAreaRect.right-tt_width ||
- m_sOptions.wYPos > WorkAreaRect.bottom-tt_height)
- {
+ if (m_sOptions.bAutoPos || Utils_RestoreWindowPositionNoSize(pTooltip->GetHandle(), NULL, MODULENAME, "toolwindow"))
pTooltip->set_Position(
- WorkAreaRect.right - 10 - tt_width,
- WorkAreaRect.bottom - 2 - tt_height);
- }
- else
- {
- pTooltip->set_Position(m_sOptions.wXPos, m_sOptions.wYPos);
- }
-
+ WorkAreaRect.right - 10 - (TooltipRect.right-TooltipRect.left),
+ WorkAreaRect.bottom - 2 - (TooltipRect.bottom-TooltipRect.top));
UINT_PTR idTimer = SetTimer(0, 0, pTooltipData->uiTimeout, TooltipTimerProcWrapper);
pTooltipData->idTimer = idTimer;
@@ -378,7 +350,7 @@ BOOL CTooltipNotify::EndNotify(STooltipData* pTooltipData) return TRUE;
}
-VOID CTooltipNotify::EndNotifyAll()
+void CTooltipNotify::EndNotifyAll()
{
// iterate through active tooltips and
// remove one which do not have its timer suspended
@@ -413,7 +385,7 @@ CTooltipNotify::MapTimerIdProtoIter CTooltipNotify::FindProtoByTimer(UINT idTime return m_mapTimerIdProto.end();
}
-VOID CTooltipNotify::OnConnectionTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+void CTooltipNotify::OnConnectionTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
BOOL bSuccess = KillTimer(0, idEvent);
assert(bSuccess);
@@ -421,16 +393,16 @@ VOID CTooltipNotify::OnConnectionTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, D MapTimerIdProtoIter iter = FindProtoByTimer(idEvent);
assert(iter!=m_mapTimerIdProto.end());
- BYTE bProtoActive = ReadSettingByte(iter->proto, ProtoUserBit|ProtoIntBit);
+ BYTE bProtoActive = db_get_b(NULL, MODULENAME, iter->proto, ProtoUserBit|ProtoIntBit);
bProtoActive |= ProtoIntBit;
- WriteSettingByte(iter->proto, bProtoActive);
+ db_set_b(NULL, MODULENAME, iter->proto, bProtoActive);
free((char*)iter->proto);
m_mapTimerIdProto.erase(iter);
}
-VOID CTooltipNotify::OnTooltipTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+void CTooltipNotify::OnTooltipTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
TooltipsList::iterator iter = FindBy(&STooltipData::idTimer, idEvent);
assert(iter!=m_TooltipsList.end());
@@ -439,63 +411,78 @@ VOID CTooltipNotify::OnTooltipTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWOR EndNotify(pTooltipData);
}
-VOID CTooltipNotify::MigrateSettings()
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct
{
- if (ModuleSettingsExists(NULL, s_szModuleNameOld) && !ModuleSettingsExists(NULL, s_szModuleName))
- {
- RenameModule(NULL, s_szModuleNameOld, s_szModuleName);
+ const char *szOldSetting, *szNewSetting;
+}
+static arSettings[] =
+{
+ { "xpos", "toolwindowx" },
+ { "ypos", "toolwindowy" }
+};
+
+void CTooltipNotify::MigrateSettings()
+{
+ for (int i=0; i < SIZEOF(arSettings); i++) {
+ int val = db_get_w(NULL, MODULENAME, arSettings[i].szOldSetting, -1);
+ if (val != -1) {
+ db_set_w(NULL, MODULENAME, arSettings[i].szNewSetting, val);
+ db_unset(NULL, MODULENAME, arSettings[i].szOldSetting);
+ }
}
}
-VOID CTooltipNotify::LoadSettings()
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void CTooltipNotify::LoadSettings()
{
- m_sOptions.bFirstRun = ReadSettingByte("firstrun", DEF_SETTING_FIRSTRUN);
- m_sOptions.bOffline = ReadSettingByte("offline", DEF_SETTING_OFFLINE);
- m_sOptions.bOnline = ReadSettingByte("online", DEF_SETTING_ONLINE);
- m_sOptions.bOther = ReadSettingByte("other", DEF_SETTING_OTHER);
- m_sOptions.bTyping = ReadSettingByte("typing", DEF_SETTING_TYPING);
- m_sOptions.bIdle = ReadSettingByte("idle", DEF_SETTING_TYPING);
- m_sOptions.bX2 = ReadSettingByte("x2", DEF_SETTING_X2);
- m_sOptions.bConjSOLN = ReadSettingByte("conjsoln", DEF_SETTING_CONJSOLN);
- m_sOptions.bAutoPos = ReadSettingByte("autopos", DEF_SETTING_DEF_POS);
- m_sOptions.bBallonTip = ReadSettingByte("balloontip", DEF_SETTING_BALLONTIP);
- m_sOptions.bTransp = ReadSettingByte("transp", DEF_SETTING_TRANSP);
- m_sOptions.bAlpha = ReadSettingByte("alpha", DEF_SETTING_ALPHA);
- m_sOptions.bTranspInput = ReadSettingByte("transpinput", DEF_SETTING_TRANSP_INPUT);
- m_sOptions.bPrefixProto = ReadSettingByte("prfxproto", DEF_SETTING_PREFIX_PROTO);
- m_sOptions.bLDblClick = ReadSettingByte("ldblclick", DEF_SETTING_LDBLCLICK);
- m_sOptions.wDuration = ReadSettingWord("duration", DEF_SETTING_DURATION);
- m_sOptions.wXPos = ReadSettingWord("xpos", DEF_SETTING_DEF_XPOS);
- m_sOptions.wYPos = ReadSettingWord("ypos", DEF_SETTING_DEF_YPOS);
- m_sOptions.wStartupDelay = ReadSettingWord("suprconndelay", DEF_SETTING_STARTUP_DELAY);
- m_sOptions.bIgnoreUnknown = ReadSettingByte("ignoreunknown", DEF_SETTING_IGNORE_UNKNOWN);
- m_sOptions.bIgnoreNew = ReadSettingByte("ignorenew", DEF_SETTING_IGNORE_NEW);
+ m_sOptions.bFirstRun = db_get_b(NULL, MODULENAME, "firstrun", DEF_SETTING_FIRSTRUN);
+ m_sOptions.bOffline = db_get_b(NULL, MODULENAME, "offline", DEF_SETTING_OFFLINE);
+ m_sOptions.bOnline = db_get_b(NULL, MODULENAME, "online", DEF_SETTING_ONLINE);
+ m_sOptions.bOther = db_get_b(NULL, MODULENAME, "other", DEF_SETTING_OTHER);
+ m_sOptions.bTyping = db_get_b(NULL, MODULENAME, "typing", DEF_SETTING_TYPING);
+ m_sOptions.bIdle = db_get_b(NULL, MODULENAME, "idle", DEF_SETTING_TYPING);
+ m_sOptions.bX2 = db_get_b(NULL, MODULENAME, "x2", DEF_SETTING_X2);
+ m_sOptions.bConjSOLN = db_get_b(NULL, MODULENAME, "conjsoln", DEF_SETTING_CONJSOLN);
+ m_sOptions.bAutoPos = db_get_b(NULL, MODULENAME, "autopos", DEF_SETTING_DEF_POS);
+ m_sOptions.bBallonTip = db_get_b(NULL, MODULENAME, "balloontip", DEF_SETTING_BALLONTIP);
+ m_sOptions.bTransp = db_get_b(NULL, MODULENAME, "transp", DEF_SETTING_TRANSP);
+ m_sOptions.bAlpha = db_get_b(NULL, MODULENAME, "alpha", DEF_SETTING_ALPHA);
+ m_sOptions.bTranspInput = db_get_b(NULL, MODULENAME, "transpinput", DEF_SETTING_TRANSP_INPUT);
+ m_sOptions.bPrefixProto = db_get_b(NULL, MODULENAME, "prfxproto", DEF_SETTING_PREFIX_PROTO);
+ m_sOptions.bLDblClick = db_get_b(NULL, MODULENAME, "ldblclick", DEF_SETTING_LDBLCLICK);
+ m_sOptions.wDuration = db_get_w(NULL, MODULENAME, "duration", DEF_SETTING_DURATION);
+ m_sOptions.wStartupDelay = db_get_w(NULL, MODULENAME, "suprconndelay", DEF_SETTING_STARTUP_DELAY);
+ m_sOptions.bIgnoreUnknown = db_get_b(NULL, MODULENAME, "ignoreunknown", DEF_SETTING_IGNORE_UNKNOWN);
+ m_sOptions.bIgnoreNew = db_get_b(NULL, MODULENAME, "ignorenew", DEF_SETTING_IGNORE_NEW);
}
-VOID CTooltipNotify::SaveSettings()
+void CTooltipNotify::SaveSettings()
{
- WriteSettingWord("duration", m_sOptions.wDuration);
- WriteSettingWord("suprconndelay", m_sOptions.wStartupDelay);
- WriteSettingByte("offline", m_sOptions.bOffline);
- WriteSettingByte("online", m_sOptions.bOnline);
- WriteSettingByte("other", m_sOptions.bOther);
- WriteSettingByte("typing", m_sOptions.bTyping);
- WriteSettingByte("idle", m_sOptions.bIdle);
- WriteSettingByte("prfxproto", m_sOptions.bPrefixProto);
- WriteSettingByte("x2", m_sOptions.bX2);
- WriteSettingByte("conjsoln", m_sOptions.bConjSOLN);
- WriteSettingByte("autopos", m_sOptions.bAutoPos);
- WriteSettingByte("balloontip", m_sOptions.bBallonTip);
- WriteSettingByte("transp", m_sOptions.bTransp);
- WriteSettingByte("alpha", m_sOptions.bAlpha);
- WriteSettingByte("transpinput", m_sOptions.bTranspInput);
- WriteSettingByte("ldblclick", m_sOptions.bLDblClick);
- WriteSettingByte("ignoreunknown", m_sOptions.bIgnoreUnknown);
- WriteSettingByte("ignorenew", m_sOptions.bIgnoreNew);
+ db_set_w(NULL, MODULENAME, "duration", m_sOptions.wDuration);
+ db_set_w(NULL, MODULENAME, "suprconndelay", m_sOptions.wStartupDelay);
+ db_set_b(NULL, MODULENAME, "offline", m_sOptions.bOffline);
+ db_set_b(NULL, MODULENAME, "online", m_sOptions.bOnline);
+ db_set_b(NULL, MODULENAME, "other", m_sOptions.bOther);
+ db_set_b(NULL, MODULENAME, "typing", m_sOptions.bTyping);
+ db_set_b(NULL, MODULENAME, "idle", m_sOptions.bIdle);
+ db_set_b(NULL, MODULENAME, "prfxproto", m_sOptions.bPrefixProto);
+ db_set_b(NULL, MODULENAME, "x2", m_sOptions.bX2);
+ db_set_b(NULL, MODULENAME, "conjsoln", m_sOptions.bConjSOLN);
+ db_set_b(NULL, MODULENAME, "autopos", m_sOptions.bAutoPos);
+ db_set_b(NULL, MODULENAME, "balloontip", m_sOptions.bBallonTip);
+ db_set_b(NULL, MODULENAME, "transp", m_sOptions.bTransp);
+ db_set_b(NULL, MODULENAME, "alpha", m_sOptions.bAlpha);
+ db_set_b(NULL, MODULENAME, "transpinput", m_sOptions.bTranspInput);
+ db_set_b(NULL, MODULENAME, "ldblclick", m_sOptions.bLDblClick);
+ db_set_b(NULL, MODULENAME, "ignoreunknown", m_sOptions.bIgnoreUnknown);
+ db_set_b(NULL, MODULENAME, "ignorenew", m_sOptions.bIgnoreNew);
}
-VOID CTooltipNotify::ReadSettingsFromDlg(HWND hDlg)
+void CTooltipNotify::ReadSettingsFromDlg(HWND hDlg)
{
m_sOptions.bOffline = (BYTE)(IsDlgButtonChecked(hDlg, IDC_OFFLINE) == BST_CHECKED ? 1:0);
m_sOptions.bOnline = (BYTE)(IsDlgButtonChecked(hDlg, IDC_ONLINE) == BST_CHECKED ? 1:0);
@@ -515,7 +502,7 @@ VOID CTooltipNotify::ReadSettingsFromDlg(HWND hDlg) m_sOptions.wStartupDelay = LOWORD(SendDlgItemMessage(hDlg, IDC_DELAYONCONNSPIN, UDM_GETPOS, 0, 0));
}
-VOID CTooltipNotify::WriteSettingsToDlg(HWND hDlg)
+void CTooltipNotify::WriteSettingsToDlg(HWND hDlg)
{
SendDlgItemMessage(hDlg, IDC_DURATIONSPIN, UDM_SETRANGE, 0, MAKELONG(550*36, 550));
SendDlgItemMessage(hDlg, IDC_DURATIONSPIN, UDM_SETPOS, 0, MAKELONG(m_sOptions.wDuration, 0));
@@ -556,7 +543,7 @@ VOID CTooltipNotify::WriteSettingsToDlg(HWND hDlg) }
-VOID CTooltipNotify::ValidateSettings()
+void CTooltipNotify::ValidateSettings()
{
if (m_sOptions.wStartupDelay>30) m_sOptions.wStartupDelay=30;
if (m_sOptions.wDuration>550*36) m_sOptions.wDuration=550*36;
@@ -642,11 +629,11 @@ BOOL CTooltipNotify::OptionsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l }
case IDC_SEL_PROTO:
- DialogBox(m_hDllInstance, MAKEINTRESOURCE(IDD_PROTOS), hDlg, CTooltipNotify::ProtosDlgProcWrapper);
+ DialogBox(g_hInstDLL, MAKEINTRESOURCE(IDD_PROTOS), hDlg, CTooltipNotify::ProtosDlgProcWrapper);
break;
case IDC_IGNORE:
- DialogBox(m_hDllInstance, MAKEINTRESOURCE(IDD_CONTACTS), hDlg, CTooltipNotify::ContactsDlgProcWrapper);
+ DialogBox(g_hInstDLL, MAKEINTRESOURCE(IDD_CONTACTS), hDlg, CTooltipNotify::ContactsDlgProcWrapper);
break;
default:
@@ -725,7 +712,7 @@ BOOL CTooltipNotify::ProtosDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP int new_item = ListView_InsertItem(GetDlgItem(hDlg,IDC_PROTOS),&lvi);
- BYTE bProtoState = ReadSettingByte(ppProtos[i]->szModuleName, ProtoUserBit|ProtoIntBit);
+ BYTE bProtoState = db_get_b(NULL, MODULENAME, ppProtos[i]->szModuleName, ProtoUserBit|ProtoIntBit);
BOOL bProtoEnabled = (bProtoState & ProtoUserBit) != 0;
ListView_SetCheckState(GetDlgItem(hDlg,IDC_PROTOS), i, bProtoEnabled);
}
@@ -751,13 +738,13 @@ BOOL CTooltipNotify::ProtosDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP szMultiByteProto, sizeof(szMultiByteProto), NULL, NULL);
szMultiByteProto[lLen] = '\0';
- BYTE bProtoState = ReadSettingByte(szMultiByteProto, ProtoUserBit|ProtoIntBit);
+ BYTE bProtoState = db_get_b(NULL, MODULENAME, szMultiByteProto, ProtoUserBit|ProtoIntBit);
BOOL bProtoEnabled = ListView_GetCheckState(GetDlgItem(hDlg,IDC_PROTOS), i);
bProtoState = bProtoEnabled ? bProtoState|ProtoUserBit : bProtoState&~ProtoUserBit;
- WriteSettingByte(szMultiByteProto, bProtoState);
+ db_set_b(NULL, MODULENAME, szMultiByteProto, bProtoState);
}
@@ -814,7 +801,7 @@ void CTooltipNotify::LoadList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM) hContact, 0);
- if (hItem && !db_get_b(hContact, s_szModuleName, CONTACT_IGNORE_TTNOTIFY, m_sOptions.bIgnoreNew))
+ if (hItem && !db_get_b(hContact, MODULENAME, CONTACT_IGNORE_TTNOTIFY, m_sOptions.bIgnoreNew))
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM) hItem, 1);
}
}
@@ -831,7 +818,7 @@ void CTooltipNotify::SaveList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM) hContact, 0);
if (hItem) {
BYTE bChecked = (BYTE) (SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM) hItem, 0));
- db_set_b(hContact, s_szModuleName, CONTACT_IGNORE_TTNOTIFY, bChecked ? 0 : 1);
+ db_set_b(hContact, MODULENAME, CONTACT_IGNORE_TTNOTIFY, bChecked ? 0 : 1);
}
}
}
@@ -957,7 +944,7 @@ TCHAR *CTooltipNotify::MakeTooltipString(HANDLE hContact, int iStatus, TCHAR *sz }
-VOID CTooltipNotify::OnTooltipDblClicked(CTooltip *pTooltip)
+void CTooltipNotify::OnTooltipDblClicked(CTooltip *pTooltip)
{
switch(m_sOptions.bLDblClick)
{
@@ -990,21 +977,14 @@ BOOL CTooltipNotify::OnTooltipBeginMove(CTooltip *pTooltip) }
-VOID CTooltipNotify::OnTooltipEndMove(CTooltip *pTooltip)
+void CTooltipNotify::OnTooltipEndMove(CTooltip *pTooltip)
{
- RECT TooltipRect;
-
- pTooltip->get_Rect(&TooltipRect);
- m_sOptions.wXPos = (WORD)TooltipRect.left;
- m_sOptions.wYPos = (WORD)TooltipRect.top;
- WriteSettingWord("xpos", m_sOptions.wXPos);
- WriteSettingWord("ypos", m_sOptions.wYPos);
-
+ Utils_SaveWindowPosition(pTooltip->GetHandle(), NULL, MODULENAME, "toolwindow");
ResumeTimer(pTooltip);
}
-VOID CTooltipNotify::SuspendTimer(CTooltip *pTooltip)
+void CTooltipNotify::SuspendTimer(CTooltip *pTooltip)
{
TooltipsList::iterator iter = FindBy(&STooltipData::pTooltip, pTooltip);
assert(iter!=m_TooltipsList.end());
@@ -1017,7 +997,7 @@ VOID CTooltipNotify::SuspendTimer(CTooltip *pTooltip) }
-VOID CTooltipNotify::ResumeTimer(CTooltip *pTooltip)
+void CTooltipNotify::ResumeTimer(CTooltip *pTooltip)
{
TooltipsList::iterator iter = FindBy(&STooltipData::pTooltip, pTooltip);
assert(iter!=m_TooltipsList.end());
diff --git a/plugins/TooltipNotify/src/TooltipNotify.h b/plugins/TooltipNotify/src/TooltipNotify.h index 8cdb306203..886cacb553 100644 --- a/plugins/TooltipNotify/src/TooltipNotify.h +++ b/plugins/TooltipNotify/src/TooltipNotify.h @@ -10,18 +10,18 @@ private: struct STooltipData;
public:
- CTooltipNotify(HINSTANCE hinstDLL);
+ CTooltipNotify();
virtual ~CTooltipNotify();
// exceptions
class EAlreadyExists {};
BOOL EndNotify(STooltipData* pTooltipData);
- VOID EndNotifyAll();
+ void EndNotifyAll();
CTooltip *BeginNotify(STooltipData *pTooltipData);
- VOID OnTooltipDblClicked(CTooltip *pTooltip);
+ void OnTooltipDblClicked(CTooltip *pTooltip);
BOOL OnTooltipBeginMove(CTooltip *pTooltip);
- VOID OnTooltipEndMove(CTooltip *pTooltip);
+ void OnTooltipEndMove(CTooltip *pTooltip);
int InitializeOptions(WPARAM wParam, LPARAM lParam);
int ContactSettingChanged(WPARAM wParam, LPARAM lParam);
int ProtoAck(WPARAM wParam, LPARAM lParam);
@@ -29,7 +29,6 @@ public: int ProtoContactIsTyping(WPARAM wParam, LPARAM lParam);
static CTooltipNotify *GetObjInstance() { return s_pInstance; }
- HINSTANCE GetDllInstance() const { return m_hDllInstance; }
private:
// prohibit copying
@@ -39,9 +38,7 @@ private: private:
static CTooltipNotify *s_pInstance;
static const char *s_szModuleNameOld;
- static const char *s_szModuleName;
- const HINSTANCE m_hDllInstance;
const BOOL m_bNt50;
struct SOptions {
@@ -61,8 +58,6 @@ private: BYTE bLDblClick;
BYTE bPrefixProto;
WORD wDuration;
- WORD wXPos;
- WORD wYPos;
WORD wStartupDelay;
BYTE bIgnoreNew;
BYTE bIgnoreUnknown;
@@ -94,33 +89,33 @@ private: template<typename T> TooltipsListIter FindBy(T STooltipData::* m, const T& value);
TCHAR *StatusToString(int iStatus, TCHAR *szStatus, int iBufSize);
TCHAR *MakeTooltipString(HANDLE hContact, int iStatus, TCHAR *szString, int iBufSize);
- VOID MigrateSettings();
+ void MigrateSettings();
void RegisterFonts();
void GetFont(int iStatus, LOGFONT* lf, COLORREF* text, COLORREF* bg);
void ResetCList(HWND hwndDlg);
void LoadList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown);
void SaveList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown);
- VOID LoadSettings();
- VOID SaveSettings();
- VOID ValidateSettings();
- VOID ReadSettingsFromDlg(HWND hDlg);
- VOID WriteSettingsToDlg(HWND hDlg);
+ void LoadSettings();
+ void SaveSettings();
+ void ValidateSettings();
+ void ReadSettingsFromDlg(HWND hDlg);
+ void WriteSettingsToDlg(HWND hDlg);
- VOID SuspendTimer(CTooltip *pTooltip);
- VOID ResumeTimer(CTooltip *pTooltip);
- VOID OnConnectionTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
- VOID OnTooltipTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
+ void SuspendTimer(CTooltip *pTooltip);
+ void ResumeTimer(CTooltip *pTooltip);
+ void OnConnectionTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
+ void OnTooltipTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
// Dialog procedures
BOOL OptionsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL ProtosDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL ContactsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
- static VOID CALLBACK ConnectionTimerProcWrapper(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+ static void CALLBACK ConnectionTimerProcWrapper(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
CTooltipNotify::GetObjInstance()->OnConnectionTimer(hwnd, uMsg, idEvent, dwTime);
}
- static VOID CALLBACK TooltipTimerProcWrapper(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+ static void CALLBACK TooltipTimerProcWrapper(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
CTooltipNotify::GetObjInstance()->OnTooltipTimer(hwnd, uMsg, idEvent, dwTime);
}
diff --git a/plugins/TooltipNotify/src/main.cpp b/plugins/TooltipNotify/src/main.cpp index d3112e752e..d53c350fea 100644 --- a/plugins/TooltipNotify/src/main.cpp +++ b/plugins/TooltipNotify/src/main.cpp @@ -15,7 +15,8 @@ static HANDLE g_hOptionsInitialize = 0; static HANDLE g_hModulesLoaded = 0;
static HANDLE g_hProtoAck = 0;
static HANDLE g_hProtoContactIsTyping = 0;
-static HINSTANCE g_hInstDLL = 0;
+
+HINSTANCE g_hInstDLL = 0;
// Main global object
static CTooltipNotify *g_pTooltipNotify = 0;
@@ -56,7 +57,7 @@ extern "C" int __declspec(dllexport) Load(void) {
mir_getLP(&sPluginInfo);
- g_pTooltipNotify = new CTooltipNotify(g_hInstDLL);
+ g_pTooltipNotify = new CTooltipNotify();
assert(g_pTooltipNotify!=0);
g_hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
diff --git a/plugins/TooltipNotify/src/stdafx.h b/plugins/TooltipNotify/src/stdafx.h index 72c8c13416..2f007caefa 100644 --- a/plugins/TooltipNotify/src/stdafx.h +++ b/plugins/TooltipNotify/src/stdafx.h @@ -26,6 +26,8 @@ #include <m_fontservice.h>
#include <win2k.h>
+#define MODULENAME "TooltipNotify"
+
#include "version.h"
#include "TooltipNotify.h"
#include "DbHelpers.h"
@@ -33,3 +35,5 @@ #include "Settings.h"
#include "resource.h"
#include "Utils.h"
+
+extern HINSTANCE g_hInstDLL;
\ No newline at end of file diff --git a/plugins/TooltipNotify/src/version.h b/plugins/TooltipNotify/src/version.h index 6a60505c7c..c5021ca484 100644 --- a/plugins/TooltipNotify/src/version.h +++ b/plugins/TooltipNotify/src/version.h @@ -1,14 +1,14 @@ #define __MAJOR_VERSION 0
-#define __MINOR_VERSION 6
+#define __MINOR_VERSION 7
#define __RELEASE_NUM 0
-#define __BUILD_NUM 47
+#define __BUILD_NUM 1
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __PLUGIN_NAME "Tooltip notify"
#define __FILENAME "TooltipNotify.dll"
#define __DESCRIPTION "Shows a small tooltip above system tray area when a contact status is changed."
-#define __AUTHOR "perf"
+#define __AUTHOR "perf"
#define __AUTHOREMAIL "perf@mail333.com"
#define __AUTHORWEB "http://miranda-ng.org/"
#define __COPYRIGHT "© 2004-2008 Gneedah software"
|