summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-03-22 16:06:52 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-03-22 16:06:52 +0300
commitf6129d9855bcd96d6258c2de4a75f764e0455993 (patch)
treeb5d052018357f927866b00b6cb6144e78404242c /plugins
parent79742b2d021b99425d4c9ceac871deb6b8967cee (diff)
Notes & reminders:
- resource id cleaning & reordering; - one more fix related to #1660: stored reminders cannot be edited
Diffstat (limited to 'plugins')
-rw-r--r--plugins/NotesAndReminders/res/resource.rc68
-rw-r--r--plugins/NotesAndReminders/src/notes.cpp81
-rw-r--r--plugins/NotesAndReminders/src/reminders.cpp258
-rw-r--r--plugins/NotesAndReminders/src/resource.h50
-rw-r--r--plugins/NotesAndReminders/src/stdafx.h1
5 files changed, 222 insertions, 236 deletions
diff --git a/plugins/NotesAndReminders/res/resource.rc b/plugins/NotesAndReminders/res/resource.rc
index 39ea977bf9..887cb04e72 100644
--- a/plugins/NotesAndReminders/res/resource.rc
+++ b/plugins/NotesAndReminders/res/resource.rc
@@ -179,77 +179,77 @@ IDI_VIEWNOTES ICON "viewnotes.ico"
MNU_REMINDERPOPUP MENU
BEGIN
- POPUP "Context Menu Reminder ListView"
+ POPUP ""
BEGIN
- MENUITEM "Edi&t Reminder", ID_CONTEXTMENUREMINDERLISTVIEW_EDIT
+ MENUITEM "Edi&t Reminder", ID_CONTEXTMENUREMINDER_EDIT
MENUITEM SEPARATOR
- MENUITEM "New &Reminder", 40001
- MENUITEM "&Delete Reminder", 40002
+ MENUITEM "New &Reminder", ID_CONTEXTMENUREMINDER_NEW
+ MENUITEM "&Delete Reminder", ID_CONTEXTMENUREMINDER_DELETE
MENUITEM SEPARATOR
- MENUITEM "D&elete All Reminders", 40003
+ MENUITEM "D&elete All Reminders", ID_CONTEXTMENUREMINDER_DELETEALL
END
END
MNU_NOTEPOPUP MENU
BEGIN
- POPUP "Context Menu Note Popup"
+ POPUP ""
BEGIN
- MENUITEM "&Hide Note", 40002
- MENUITEM "&Always On Top", 40003
- MENUITEM "&New Note", ID_CONTEXTMENUNOTEPOPUP_NEWNOTE
- MENUITEM "&Delete Note", 40001
+ MENUITEM "&Hide Note", ID_CONTEXTMENUNOTE_HIDENOTE
+ MENUITEM "&Always On Top", ID_CONTEXTMENUNOTE_TOGGLEONTOP
+ MENUITEM "&New Note", ID_CONTEXTMENUNOTE_NEWNOTE
+ MENUITEM "&Delete Note", ID_CONTEXTMENUNOTE_REMOVENOTE
MENUITEM SEPARATOR
POPUP "Appearance"
BEGIN
POPUP "Background Color"
BEGIN
- MENUITEM "Custom...", ID_APPEARANCE_CUSTOMBG
+ MENUITEM "Custom...", ID_BACKGROUNDCOLOR_CUSTOM
MENUITEM SEPARATOR
- MENUITEM "Reset", ID_BACKGROUNDCOLOR_RESET
+ MENUITEM "Reset", ID_BACKGROUNDCOLOR_RESET
END
POPUP "Text Color"
BEGIN
- MENUITEM "Custom...", ID_APPEARANCE_CUSTOMTEXT
+ MENUITEM "Custom...", ID_TEXTCOLOR_CUSTOM
MENUITEM SEPARATOR
- MENUITEM "Reset", ID_TEXTCOLOR_RESET
+ MENUITEM "Reset", ID_TEXTCOLOR_RESET
END
POPUP "Font"
BEGIN
- MENUITEM "Custom...", ID_APPEARANCE_CUSTOMFONT
+ MENUITEM "Custom...", ID_FONT_CUSTOM
MENUITEM SEPARATOR
- MENUITEM "Reset", ID_FONT_RESET
+ MENUITEM "Reset", ID_FONT_RESET
END
END
- MENUITEM "Paste Title", ID_CONTEXTMENUNOTEPOPUP_PASTETITLE
- MENUITEM "Reset Title", ID_CONTEXTMENUNOTEPOPUP_RESETTITLE
+ MENUITEM "Paste Title", ID_CONTEXTMENUNOTE_PASTETITLE
+ MENUITEM "Reset Title", ID_CONTEXTMENUNOTE_RESETTITLE
MENUITEM SEPARATOR
- MENUITEM "Undo", 40004
+ MENUITEM "Undo", ID_CONTEXTMENUNOTE_UNDO
MENUITEM SEPARATOR
- MENUITEM "&Copy", 40005
- MENUITEM "&Paste", 40006
- MENUITEM "C&ut", 40007
- MENUITEM "C&lear", 40008
+ MENUITEM "&Copy", ID_CONTEXTMENUNOTE_COPY
+ MENUITEM "&Paste", ID_CONTEXTMENUNOTE_PASTE
+ MENUITEM "C&ut", ID_CONTEXTMENUNOTE_CUT
+ MENUITEM "C&lear", ID_CONTEXTMENUNOTE_CLEAR
MENUITEM SEPARATOR
- MENUITEM "&View Notes", ID_CONTEXTMENUNOTEPOPUP_VIEWNOTES
- MENUITEM "&Bring All To Front", ID_CONTEXTMENUNOTEPOPUP_BRINGALLTOTOP
+ MENUITEM "&View Notes", ID_CONTEXTMENUNOTE_VIEWNOTES
+ MENUITEM "&Bring All To Front", ID_CONTEXTMENUNOTE_BRINGALLTOTOP
END
END
MNU_NOTELISTPOPUP MENU
BEGIN
- POPUP "Context Menu Note ListView"
+ POPUP ""
BEGIN
- MENUITEM "Edi&t Note", ID_CONTEXTMENUNOTELISTVIEW_EDITNOTE
+ MENUITEM "Edi&t Note", ID_CONTEXTMENUNOTE_EDITNOTE
MENUITEM SEPARATOR
- MENUITEM "&Visible", ID_CONTEXTMENUNOTELISTVIEW_TOGGLEVISIBILITY
- MENUITEM "Always &On Top", 40003
- MENUITEM "&New Note", ID_CONTEXTMENUNOTEPOPUP_NEWNOTE
- MENUITEM "&Delete Note", 40001
+ MENUITEM "&Visible", ID_CONTEXTMENUNOTE_TOGGLEVISIBILITY
+ MENUITEM "Always &On Top", ID_CONTEXTMENUNOTE_TOGGLEONTOP
+ MENUITEM "&New Note", ID_CONTEXTMENUNOTE_NEWNOTE
+ MENUITEM "&Delete Note", ID_CONTEXTMENUNOTE_REMOVENOTE
MENUITEM SEPARATOR
- MENUITEM "Delete &All Notes", ID_CONTEXTMENUNOTELISTVIEW_DELETEALLNOTES
+ MENUITEM "Delete &All Notes", ID_CONTEXTMENUNOTE_DELETEALLNOTES
MENUITEM SEPARATOR
- MENUITEM "&Show / Hide Notes", ID_CONTEXTMENUNOTELISTVIEW_SHOW
- MENUITEM "&Bring All To Front", ID_CONTEXTMENUNOTEPOPUP_BRINGALLTOTOP
+ MENUITEM "&Show / Hide Notes", ID_CONTEXTMENUNOTE_SHOW
+ MENUITEM "&Bring All To Front", ID_CONTEXTMENUNOTE_BRINGALLTOTOP
END
END
diff --git a/plugins/NotesAndReminders/src/notes.cpp b/plugins/NotesAndReminders/src/notes.cpp
index 24e13506a6..8b8dc1ac25 100644
--- a/plugins/NotesAndReminders/src/notes.cpp
+++ b/plugins/NotesAndReminders/src/notes.cpp
@@ -21,14 +21,7 @@
#ifndef WS_EX_NOACTIVATE
#define WS_EX_NOACTIVATE 0x08000000
#endif
-#define IDM_REMOVENOTE 40001
-#define IDM_HIDENOTE 40002
-#define IDM_TOGGLEONTOP 40003
-#define IDM_UNDO 40004
-#define IDM_COPY 40005
-#define IDM_PASTE 40006
-#define IDM_CUT 40007
-#define IDM_CLEAR 40008
+
#define WS_EX_LAYERED 0x00080000
#define LWA_ALPHA 0x00000002
@@ -439,12 +432,12 @@ static BOOL DoContextMenu(HWND AhWnd, WPARAM, LPARAM lParam)
FhMenu = GetSubMenu(hMenuLoad, 0);
if (SN->bOnTop)
- CheckMenuItem(FhMenu, IDM_TOGGLEONTOP, MF_CHECKED | MF_BYCOMMAND);
+ CheckMenuItem(FhMenu, ID_CONTEXTMENUNOTE_TOGGLEONTOP, MF_CHECKED | MF_BYCOMMAND);
- EnableMenuItem(FhMenu, ID_CONTEXTMENUNOTEPOPUP_PASTETITLE, MF_BYCOMMAND | (IsClipboardFormatAvailable(CF_TEXT) ? MF_ENABLED : MF_GRAYED));
+ EnableMenuItem(FhMenu, ID_CONTEXTMENUNOTE_PASTETITLE, MF_BYCOMMAND | (IsClipboardFormatAvailable(CF_TEXT) ? MF_ENABLED : MF_GRAYED));
if (!SN->CustomTitle)
- EnableMenuItem(FhMenu, ID_CONTEXTMENUNOTEPOPUP_RESETTITLE, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(FhMenu, ID_CONTEXTMENUNOTE_RESETTITLE, MF_BYCOMMAND | MF_GRAYED);
// NOTE: names used for FindMenuItem would need to include & chars if such shortcuts are added to the menus
@@ -792,15 +785,15 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARA
Y = HIWORD(lParam) - rect.top;
if (X > Tw - 16) {
- SendMessage(hdlg, WM_COMMAND, IDM_TOGGLEONTOP, 0);
+ SendMessage(hdlg, WM_COMMAND, ID_CONTEXTMENUNOTE_TOGGLEONTOP, 0);
return TRUE;
}
else if (X > Tw - 31 && X < Tw - 16) {
- SendMessage(hdlg, WM_COMMAND, IDM_REMOVENOTE, 0);
+ SendMessage(hdlg, WM_COMMAND, ID_CONTEXTMENUNOTE_REMOVENOTE, 0);
return TRUE;
}
else if (X > Tw - 48 && X < Tw - 32) {
- SendMessage(hdlg, WM_COMMAND, IDM_HIDENOTE, 0);
+ SendMessage(hdlg, WM_COMMAND, ID_CONTEXTMENUNOTE_HIDENOTE, 0);
return TRUE;
}
}
@@ -877,11 +870,11 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARA
}
switch (id) {
- case ID_CONTEXTMENUNOTEPOPUP_NEWNOTE:
+ case ID_CONTEXTMENUNOTE_NEWNOTE:
PluginMenuCommandAddNew(0, 0);
break;
- case ID_APPEARANCE_CUSTOMBG:
+ case ID_BACKGROUNDCOLOR_CUSTOM:
{
COLORREF custclr[16] = {0};
CHOOSECOLOR cc = {0};
@@ -900,7 +893,7 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARA
}
}
break;
- case ID_APPEARANCE_CUSTOMTEXT:
+ case ID_TEXTCOLOR_CUSTOM:
{
COLORREF custclr[16] = {0};
COLORREF orgclr = SN->FgColor ? (COLORREF)(SN->FgColor & 0xffffff) : (COLORREF)(BodyFontColor & 0xffffff);
@@ -927,7 +920,7 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARA
}
break;
- case ID_APPEARANCE_CUSTOMFONT:
+ case ID_FONT_CUSTOM:
{
LOGFONT lf = {};
if (SN->pCustomFont)
@@ -1004,7 +997,7 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARA
}
break;
- case ID_CONTEXTMENUNOTEPOPUP_PASTETITLE:
+ case ID_CONTEXTMENUNOTE_PASTETITLE:
{
wchar_t s[MAX_TITLE_LEN + 1];
if (GetClipboardText_Title(s, _countof(s))) {
@@ -1018,7 +1011,7 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARA
}
break;
- case ID_CONTEXTMENUNOTEPOPUP_RESETTITLE:
+ case ID_CONTEXTMENUNOTE_RESETTITLE:
if (SN->CustomTitle) {
if (SN->title) {
free(SN->title);
@@ -1030,48 +1023,48 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARA
}
break;
- case IDM_REMOVENOTE:
+ case ID_CONTEXTMENUNOTE_REMOVENOTE:
OnDeleteNote(hdlg, SN);
break;
- case IDM_HIDENOTE:
+ case ID_CONTEXTMENUNOTE_HIDENOTE:
SN->bVisible = false;
ShowWindow(hdlg, SW_HIDE);
JustSaveNotes();
break;
- case IDM_COPY:
+ case ID_CONTEXTMENUNOTE_COPY:
SendMessage(SN->REHwnd, WM_COPY, 0, 0);
break;
- case IDM_PASTE:
+ case ID_CONTEXTMENUNOTE_PASTE:
SendMessage(SN->REHwnd, WM_PASTE, 0, 0);
break;
- case IDM_CUT:
+ case ID_CONTEXTMENUNOTE_CUT:
SendMessage(SN->REHwnd, WM_CUT, 0, 0);
break;
- case IDM_CLEAR:
+ case ID_CONTEXTMENUNOTE_CLEAR:
SendMessage(SN->REHwnd, WM_CLEAR, 0, 0);
break;
- case IDM_UNDO:
+ case ID_CONTEXTMENUNOTE_UNDO:
SendMessage(SN->REHwnd, WM_UNDO, 0, 0);
break;
- case IDM_TOGGLEONTOP:
+ case ID_CONTEXTMENUNOTE_TOGGLEONTOP:
SN->bOnTop = !SN->bOnTop;
SetWindowPos(hdlg, SN->bOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
RedrawWindow(hdlg, nullptr, nullptr, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW);
JustSaveNotes();
break;
- case ID_CONTEXTMENUNOTEPOPUP_VIEWNOTES:
+ case ID_CONTEXTMENUNOTE_VIEWNOTES:
PluginMenuCommandViewNotes(0, 0);
break;
- case ID_CONTEXTMENUNOTEPOPUP_BRINGALLTOTOP:
+ case ID_CONTEXTMENUNOTE_BRINGALLTOTOP:
BringAllNotesToFront(SN);
break;
}
@@ -1595,18 +1588,18 @@ static BOOL DoListContextMenu(HWND AhWnd, WPARAM wParam, LPARAM lParam, STICKYNO
mii.fState = MFS_DEFAULT;
if (!pNote)
mii.fState |= MFS_GRAYED;
- SetMenuItemInfo(FhMenu, ID_CONTEXTMENUNOTELISTVIEW_EDITNOTE, FALSE, &mii);
+ SetMenuItemInfo(FhMenu, ID_CONTEXTMENUNOTE_EDITNOTE, FALSE, &mii);
if (!pNote) {
- EnableMenuItem(FhMenu, IDM_REMOVENOTE, MF_GRAYED | MF_BYCOMMAND);
- EnableMenuItem(FhMenu, ID_CONTEXTMENUNOTELISTVIEW_TOGGLEVISIBILITY, MF_GRAYED | MF_BYCOMMAND);
- EnableMenuItem(FhMenu, IDM_TOGGLEONTOP, MF_GRAYED | MF_BYCOMMAND);
+ EnableMenuItem(FhMenu, ID_CONTEXTMENUNOTE_REMOVENOTE, MF_GRAYED | MF_BYCOMMAND);
+ EnableMenuItem(FhMenu, ID_CONTEXTMENUNOTE_TOGGLEVISIBILITY, MF_GRAYED | MF_BYCOMMAND);
+ EnableMenuItem(FhMenu, ID_CONTEXTMENUNOTE_TOGGLEONTOP, MF_GRAYED | MF_BYCOMMAND);
}
else {
if (pNote->bVisible)
- CheckMenuItem(FhMenu, ID_CONTEXTMENUNOTELISTVIEW_TOGGLEVISIBILITY, MF_CHECKED | MF_BYCOMMAND);
+ CheckMenuItem(FhMenu, ID_CONTEXTMENUNOTE_TOGGLEVISIBILITY, MF_CHECKED | MF_BYCOMMAND);
if (pNote->bOnTop)
- CheckMenuItem(FhMenu, IDM_TOGGLEONTOP, MF_CHECKED | MF_BYCOMMAND);
+ CheckMenuItem(FhMenu, ID_CONTEXTMENUNOTE_TOGGLEONTOP, MF_CHECKED | MF_BYCOMMAND);
}
TranslateMenu(FhMenu);
@@ -1722,7 +1715,7 @@ static INT_PTR CALLBACK DlgProcViewNotes(HWND hwndDlg, UINT Message, WPARAM wPar
case WM_COMMAND:
switch (LOWORD(wParam)) {
- case ID_CONTEXTMENUNOTELISTVIEW_EDITNOTE:
+ case ID_CONTEXTMENUNOTE_EDITNOTE:
{
HWND H = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
if (ListView_GetSelectedCount(H)) {
@@ -1734,7 +1727,7 @@ static INT_PTR CALLBACK DlgProcViewNotes(HWND hwndDlg, UINT Message, WPARAM wPar
}
return TRUE;
- case ID_CONTEXTMENUNOTELISTVIEW_TOGGLEVISIBILITY:
+ case ID_CONTEXTMENUNOTE_TOGGLEVISIBILITY:
{
HWND H = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
if (ListView_GetSelectedCount(H)) {
@@ -1749,7 +1742,7 @@ static INT_PTR CALLBACK DlgProcViewNotes(HWND hwndDlg, UINT Message, WPARAM wPar
}
return TRUE;
- case IDM_TOGGLEONTOP:
+ case ID_CONTEXTMENUNOTE_TOGGLEONTOP:
{
HWND H = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
if (ListView_GetSelectedCount(H)) {
@@ -1770,16 +1763,16 @@ static INT_PTR CALLBACK DlgProcViewNotes(HWND hwndDlg, UINT Message, WPARAM wPar
ListNotesVisible = false;
return TRUE;
- case ID_CONTEXTMENUNOTEPOPUP_NEWNOTE:
+ case ID_CONTEXTMENUNOTE_NEWNOTE:
case IDC_ADDNEWREMINDER:
PluginMenuCommandAddNew(0, 0);
return TRUE;
- case ID_CONTEXTMENUNOTELISTVIEW_DELETEALLNOTES:
+ case ID_CONTEXTMENUNOTE_DELETEALLNOTES:
PluginMenuCommandDeleteNotes(0, 0);
return TRUE;
- case IDM_REMOVENOTE:
+ case ID_CONTEXTMENUNOTE_REMOVENOTE:
{
HWND H = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
if (ListView_GetSelectedCount(H)) {
@@ -1790,11 +1783,11 @@ static INT_PTR CALLBACK DlgProcViewNotes(HWND hwndDlg, UINT Message, WPARAM wPar
}
return TRUE;
- case ID_CONTEXTMENUNOTELISTVIEW_SHOW:
+ case ID_CONTEXTMENUNOTE_SHOW:
ShowHideNotes();
return TRUE;
- case ID_CONTEXTMENUNOTEPOPUP_BRINGALLTOTOP:
+ case ID_CONTEXTMENUNOTE_BRINGALLTOTOP:
BringAllNotesToFront(nullptr);
return TRUE;
}
diff --git a/plugins/NotesAndReminders/src/reminders.cpp b/plugins/NotesAndReminders/src/reminders.cpp
index 6a44979af6..35420ac104 100644
--- a/plugins/NotesAndReminders/src/reminders.cpp
+++ b/plugins/NotesAndReminders/src/reminders.cpp
@@ -10,10 +10,6 @@
#define DATATAG_SNDSEL 3 // %d (which sound to use, default, alt1, alt2, -1 means no sound at all)
#define DATATAG_REPEAT 4 // %d (repeateable reminder)
-#define IDM_NEWREMINDER 40001
-#define IDM_DELETEREMINDER 40002
-#define IDM_DELETEALLREMINDERS 40003
-
#define WM_RELOAD (WM_USER + 100)
#define NOTIFY_LIST() if (bListReminderVisible) PostMessage(LV,WM_RELOAD,0,0)
@@ -180,124 +176,114 @@ void JustSaveReminders(void)
void LoadReminders(void)
{
- char *Value;
- WORD Size;
- char ValueName[32];
BOOL GenerateUids = FALSE;
arReminders.destroy();
int RemindersCount = g_plugin.getDword("RemindersData", 0);
for (int i = 0; i < RemindersCount; i++) {
- Size = 65535;
- Value = nullptr;
- mir_snprintf(ValueName, "RemindersData%d", i);
+ WORD Size = 65535;
+ char *Value = nullptr;
+ char ValueName[32];
+ mir_snprintf(ValueName, "RemindersData%d", i);
ReadSettingBlob(0, MODULENAME, ValueName, &Size, (void**)&Value);
// was the blob found
- if (Size && Value) {
- REMINDERDATA rem = {};
- char *TVal;
- REMINDERDATA *TempRem;
- char *DelPos = strchr(Value, 0x1B);
+ if (!Size || !Value)
+ continue;
+
+ REMINDERDATA *TempRem = new REMINDERDATA();
+ char *DelPos = strchr(Value, 0x1B);
+
+ // ensure that read data is null-terminated
+ Value[(UINT)Size - 1] = 0;
- // ensure that read data is null-terminated
- Value[(UINT)Size - 1] = 0;
+ if (Value[0] == 'X') {
+ // new eXtended/fleXible data format
+ if (DelPos)
+ *DelPos = 0;
- if (Value[0] == 'X') {
- // new eXtended/fleXible data format
+ // uid:when
+ char *TVal = strchr(Value + 1, ':');
+ if (!TVal || (DelPos && TVal > DelPos))
+ continue;
+ *TVal++ = 0;
+ TempRem->uid = strtoul(Value + 1, nullptr, 10);
+ TempRem->When.QuadPart = _strtoui64(TVal, nullptr, 16) * FILETIME_TICKS_PER_SEC;
+
+ // optional \033 separated params
+ while (DelPos) {
+ TVal = DelPos + 1;
+ // find param end and make sure it's null-terminated (if end of data then it's already null-terminated)
+ DelPos = strchr(TVal, 0x1B);
if (DelPos)
*DelPos = 0;
- // uid:when
- TVal = strchr(Value + 1, ':');
- if (!TVal || (DelPos && TVal > DelPos))
- continue;
-
- *TVal++ = 0;
- rem.uid = strtoul(Value + 1, nullptr, 10);
- rem.When.QuadPart = _strtoui64(TVal, nullptr, 16) * FILETIME_TICKS_PER_SEC;
-
- // optional \033 separated params
- while (DelPos) {
- char *sep;
- UINT tag;
-
- TVal = DelPos + 1;
- // find param end and make sure it's null-terminated (if end of data then it's already null-terminated)
- DelPos = strchr(TVal, 0x1B);
- if (DelPos)
- *DelPos = 0;
-
- // tag:<data>
- sep = strchr(TVal, ':');
- if (!sep || (DelPos && sep > DelPos))
- goto skip;
-
- tag = strtoul(TVal, nullptr, 10);
- TVal = sep + 1;
-
- switch (tag) {
- case DATATAG_TEXT:
- rem.szText = TVal;
- break;
-
- case DATATAG_SNDREPEAT:
- rem.RepeatSound = strtoul(TVal, nullptr, 10);
- break;
-
- case DATATAG_SNDSEL:
- rem.SoundSel = strtol(TVal, nullptr, 10);
- if (rem.SoundSel > 2) rem.SoundSel = 2;
- break;
-
- case DATATAG_REPEAT:
- rem.bRepeat = strtol(TVal, nullptr, 10) != 0;
- break;
- }
- }
+ // tag:<data>
+ char *sep = strchr(TVal, ':');
+ if (!sep || (DelPos && sep > DelPos))
+ break;
- if (rem.SoundSel < 0)
- rem.RepeatSound = 0;
- }
- else {
- // old format (for DB backward compatibility)
- if (!DelPos)
- continue;
-
- DelPos[0] = 0;
- // convert time_t to (local) FILETIME
-
- time_t tt = (time_t)strtoul(Value, nullptr, 10);
- struct tm *stm = localtime(&tt);
-
- SYSTEMTIME tm;
- tm.wDayOfWeek = 0;
- tm.wSecond = 0;
- tm.wMilliseconds = 0;
- tm.wHour = stm->tm_hour;
- tm.wMinute = stm->tm_min;
- tm.wSecond = stm->tm_sec;
- tm.wYear = stm->tm_year + 1900;
- tm.wMonth = stm->tm_mon + 1;
- tm.wDay = stm->tm_mday;
- SystemTimeToFileTime(&tm, (FILETIME*)&rem.When);
+ UINT tag = strtoul(TVal, nullptr, 10);
+ TVal = sep + 1;
- TVal = DelPos + 1;
- rem.szText = TVal;
+ switch (tag) {
+ case DATATAG_TEXT:
+ TempRem->szText = TVal;
+ break;
+
+ case DATATAG_SNDREPEAT:
+ TempRem->RepeatSound = strtoul(TVal, nullptr, 10);
+ break;
+
+ case DATATAG_SNDSEL:
+ TempRem->SoundSel = strtol(TVal, nullptr, 10);
+ if (TempRem->SoundSel > 2) TempRem->SoundSel = 2;
+ break;
+
+ case DATATAG_REPEAT:
+ TempRem->bRepeat = strtol(TVal, nullptr, 10) != 0;
+ break;
+ }
}
- // queue uid generation if invalid uid is present
- if (!rem.uid)
- GenerateUids = true;
+ if (TempRem->SoundSel < 0)
+ TempRem->RepeatSound = 0;
+ }
+ else {
+ // old format (for DB backward compatibility)
+ if (!DelPos)
+ continue;
+
+ DelPos[0] = 0;
+ // convert time_t to (local) FILETIME
- TempRem = new REMINDERDATA(rem);
- arReminders.insert(TempRem);
-skip:;
+ time_t tt = (time_t)strtoul(Value, nullptr, 10);
+ struct tm *stm = localtime(&tt);
+
+ SYSTEMTIME tm;
+ tm.wDayOfWeek = 0;
+ tm.wSecond = 0;
+ tm.wMilliseconds = 0;
+ tm.wHour = stm->tm_hour;
+ tm.wMinute = stm->tm_min;
+ tm.wSecond = stm->tm_sec;
+ tm.wYear = stm->tm_year + 1900;
+ tm.wMonth = stm->tm_mon + 1;
+ tm.wDay = stm->tm_mday;
+ SystemTimeToFileTime(&tm, (FILETIME*)&TempRem->When);
+
+ TempRem->szText = DelPos + 1;
}
+ // queue uid generation if invalid uid is present
+ if (!TempRem->uid)
+ GenerateUids = true;
+
+ arReminders.insert(TempRem);
+
FreeSettingBlob(Size, Value);
}
@@ -452,7 +438,6 @@ static void FireReminder(REMINDERDATA *pReminder, DWORD *pHasPlayedSound)
}
}
-
bool CheckRemindersAndStart(void)
{
// returns TRUE if there are any triggered reminder with bSystemEventQueued, this will shorten the update interval
@@ -1744,7 +1729,7 @@ void OnListResize(HWND hwndDlg)
RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
}
-static BOOL DoListContextMenu(HWND AhWnd, WPARAM wParam, LPARAM lParam, REMINDERDATA *pReminder)
+static BOOL DoListContextMenu(HWND AhWnd, WPARAM wParam, LPARAM lParam)
{
HWND hwndListView = (HWND)wParam;
if (hwndListView != GetDlgItem(AhWnd, IDC_LISTREMINDERS))
@@ -1753,19 +1738,31 @@ static BOOL DoListContextMenu(HWND AhWnd, WPARAM wParam, LPARAM lParam, REMINDER
HMENU hMenuLoad = LoadMenuA(g_plugin.getInst(), "MNU_REMINDERPOPUP");
HMENU FhMenu = GetSubMenu(hMenuLoad, 0);
+ int idx = ListView_GetSelectionMark(hwndListView);
+ REMINDERDATA *pReminder = (idx == -1) ? nullptr : arReminders[idx];
+
MENUITEMINFO mii = {};
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STATE;
mii.fState = MFS_DEFAULT;
if (!pReminder || pReminder->bSystemEventQueued)
mii.fState |= MFS_GRAYED;
- SetMenuItemInfo(FhMenu, ID_CONTEXTMENUREMINDERLISTVIEW_EDIT, FALSE, &mii);
+ SetMenuItemInfo(FhMenu, ID_CONTEXTMENUREMINDER_EDIT, FALSE, &mii);
if (!pReminder)
- EnableMenuItem(FhMenu, IDM_DELETEREMINDER, MF_GRAYED | MF_BYCOMMAND);
+ EnableMenuItem(FhMenu, ID_CONTEXTMENUREMINDER_DELETE, MF_GRAYED | MF_BYCOMMAND);
+
+ POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
+ if (pt.x == -1 && pt.y == -1) {
+ RECT rc;
+ ListView_GetItemRect(hwndListView, idx, &rc, LVIR_LABEL);
+ pt.x = rc.left;
+ pt.y = rc.bottom;
+ ClientToScreen(hwndListView, &pt);
+ }
TranslateMenu(FhMenu);
- TrackPopupMenu(FhMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, LOWORD(lParam), HIWORD(lParam), 0, AhWnd, nullptr);
+ TrackPopupMenu(FhMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, AhWnd, nullptr);
DestroyMenu(hMenuLoad);
return TRUE;
}
@@ -1773,6 +1770,7 @@ static BOOL DoListContextMenu(HWND AhWnd, WPARAM wParam, LPARAM lParam, REMINDER
static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
{
HWND H = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
+ int idx;
switch (Message) {
case WM_SIZE:
@@ -1793,18 +1791,8 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
return TRUE;
case WM_CONTEXTMENU:
- {
- REMINDERDATA *pReminder = nullptr;
-
- if (ListView_GetSelectedCount(H)) {
- int i = ListView_GetSelectionMark(H);
- if (i != -1)
- pReminder = arReminders[i];
- }
-
- if (DoListContextMenu(hwndDlg, wParam, lParam, pReminder))
- return TRUE;
- }
+ if (DoListContextMenu(hwndDlg, wParam, lParam))
+ return TRUE;
break;
case WM_INITDIALOG:
@@ -1846,11 +1834,9 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
break;
case NM_DBLCLK:
- if (ListView_GetSelectedCount(H)) {
- int i = ListView_GetSelectionMark(H);
- if (i != -1)
- EditReminder(arReminders[i]);
- }
+ int i = ListView_GetSelectionMark(H);
+ if (i != -1)
+ EditReminder(arReminders[i]);
break;
}
}
@@ -1858,12 +1844,10 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
case WM_COMMAND:
switch (LOWORD(wParam)) {
- case ID_CONTEXTMENUREMINDERLISTVIEW_EDIT:
- if (ListView_GetSelectedCount(H)) {
- int i = ListView_GetSelectionMark(H);
- if (i != -1)
- EditReminder(arReminders[i]);
- }
+ case ID_CONTEXTMENUREMINDER_EDIT:
+ idx = ListView_GetSelectionMark(H);
+ if (idx != -1)
+ EditReminder(arReminders[idx]);
return TRUE;
case IDCANCEL:
@@ -1871,12 +1855,12 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
bListReminderVisible = false;
return TRUE;
- case IDM_NEWREMINDER:
+ case ID_CONTEXTMENUREMINDER_NEW:
case IDC_ADDNEWREMINDER:
PluginMenuCommandNewReminder(0, 0);
return TRUE;
- case IDM_DELETEALLREMINDERS:
+ case ID_CONTEXTMENUREMINDER_DELETEALL:
if (arReminders.getCount() && IDOK == MessageBox(hwndDlg, TranslateT("Are you sure you want to delete all reminders?"), _A2W(SECTIONNAME), MB_OKCANCEL)) {
SetDlgItemTextA(hwndDlg, IDC_REMINDERDATA, "");
DeleteReminders();
@@ -1884,15 +1868,13 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
}
return TRUE;
- case IDM_DELETEREMINDER:
- if (ListView_GetSelectedCount(H)) {
- int i = ListView_GetSelectionMark(H);
- if (i != -1 && IDOK == MessageBox(hwndDlg, TranslateT("Are you sure you want to delete this reminder?"), _A2W(SECTIONNAME), MB_OKCANCEL)) {
- SetDlgItemTextA(hwndDlg, IDC_REMINDERDATA, "");
- DeleteReminder(arReminders[i]);
- JustSaveReminders();
- InitListView(H);
- }
+ case ID_CONTEXTMENUREMINDER_DELETE:
+ idx = ListView_GetSelectionMark(H);
+ if (idx != -1 && IDOK == MessageBox(hwndDlg, TranslateT("Are you sure you want to delete this reminder?"), _A2W(SECTIONNAME), MB_OKCANCEL)) {
+ SetDlgItemTextA(hwndDlg, IDC_REMINDERDATA, "");
+ DeleteReminder(arReminders[idx]);
+ JustSaveReminders();
+ InitListView(H);
}
return TRUE;
}
diff --git a/plugins/NotesAndReminders/src/resource.h b/plugins/NotesAndReminders/src/resource.h
index 1cf018e1ed..a03b3755e3 100644
--- a/plugins/NotesAndReminders/src/resource.h
+++ b/plugins/NotesAndReminders/src/resource.h
@@ -64,26 +64,36 @@
#define IDC_DATE 1035
#define IDC_LISTREMINDERS 1036
-#define ID_CONTEXTMENUNOTEPOPUP_NEWNOTE 40009
-#define ID_CONTEXTMENUNOTEPOPUP_BRINGALLTOTOP 40010
-#define ID_CONTEXTMENUNOTEPOPUP_APPEARANCE 40011
-#define ID_APPEARANCE_BACKGROUNDCOLOR 40013
-#define ID_APPEARANCE_TEXTCOLOR 40014
-#define ID_APPEARANCE_CUSTOMTEXT 40015
-#define ID_APPEARANCE_CUSTOMBG 40016
-#define ID_BACKGROUNDCOLOR_RESET 40017
-#define ID_TEXTCOLOR_RESET 40018
-#define ID_CONTEXTMENUNOTEPOPUP_PASTETITLE 40019
-#define ID_CONTEXTMENUNOTEPOPUP_RESETTITLE 40020
-#define ID_CONTEXTMENUREMINDERLISTVIEW_EDIT 40021
-#define ID_CONTEXTMENUNOTELISTVIEW_EDITNOTE 40022
-#define ID_CONTEXTMENUNOTELISTVIEW_SHOW 40023
-#define ID_CONTEXTMENUNOTELISTVIEW_DELETEALLNOTES 40024
-#define ID_CONTEXTMENUNOTEPOPUP_VIEWNOTES 40025
-#define ID_CONTEXTMENUNOTELISTVIEW_TOGGLEVISIBILITY 40026
-#define ID_APPEARANCE_FONT 40027
-#define ID_APPEARANCE_CUSTOMFONT 40028
-#define ID_FONT_RESET 40029
+#define ID_CONTEXTMENUREMINDER_NEW 40001
+#define ID_CONTEXTMENUREMINDER_DELETE 40002
+#define ID_CONTEXTMENUREMINDER_DELETEALL 40003
+#define ID_CONTEXTMENUREMINDER_EDIT 40004
+
+#define ID_CONTEXTMENUNOTE_REMOVENOTE 40001
+#define ID_CONTEXTMENUNOTE_HIDENOTE 40002
+#define ID_CONTEXTMENUNOTE_TOGGLEONTOP 40003
+#define ID_CONTEXTMENUNOTE_UNDO 40004
+#define ID_CONTEXTMENUNOTE_COPY 40005
+#define ID_CONTEXTMENUNOTE_PASTE 40006
+#define ID_CONTEXTMENUNOTE_CUT 40007
+#define ID_CONTEXTMENUNOTE_CLEAR 40008
+#define ID_CONTEXTMENUNOTE_NEWNOTE 40009
+#define ID_CONTEXTMENUNOTE_BRINGALLTOTOP 40010
+#define ID_CONTEXTMENUNOTE_APPEARANCE 40011
+#define ID_CONTEXTMENUNOTE_PASTETITLE 40012
+#define ID_CONTEXTMENUNOTE_RESETTITLE 40013
+#define ID_CONTEXTMENUNOTE_EDITNOTE 40014
+#define ID_CONTEXTMENUNOTE_SHOW 40015
+#define ID_CONTEXTMENUNOTE_DELETEALLNOTES 40016
+#define ID_CONTEXTMENUNOTE_VIEWNOTES 40017
+#define ID_CONTEXTMENUNOTE_TOGGLEVISIBILITY 40018
+
+#define ID_BACKGROUNDCOLOR_CUSTOM 40019
+#define ID_BACKGROUNDCOLOR_RESET 40020
+#define ID_TEXTCOLOR_CUSTOM 40021
+#define ID_TEXTCOLOR_RESET 40022
+#define ID_FONT_CUSTOM 40023
+#define ID_FONT_RESET 40024
// Next default values for new objects
//
diff --git a/plugins/NotesAndReminders/src/stdafx.h b/plugins/NotesAndReminders/src/stdafx.h
index 58c27892ed..aa7dc0ab00 100644
--- a/plugins/NotesAndReminders/src/stdafx.h
+++ b/plugins/NotesAndReminders/src/stdafx.h
@@ -1,6 +1,7 @@
#pragma once
#include <windows.h>
+#include <windowsx.h>
#include <commctrl.h>
#include <limits.h>
#include <time.h>