summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/NotesAndReminders/src/notes.cpp87
-rw-r--r--plugins/NotesAndReminders/src/options.cpp92
-rw-r--r--plugins/NotesAndReminders/src/reminders.cpp235
-rw-r--r--plugins/NotesAndReminders/src/stdafx.h6
4 files changed, 183 insertions, 237 deletions
diff --git a/plugins/NotesAndReminders/src/notes.cpp b/plugins/NotesAndReminders/src/notes.cpp
index a958988b7d..6be78efa48 100644
--- a/plugins/NotesAndReminders/src/notes.cpp
+++ b/plugins/NotesAndReminders/src/notes.cpp
@@ -86,7 +86,7 @@ struct STICKYNOTEFONT : public MZeroedObject
char size;
BYTE style; // see the DBFONTF_* flags
BYTE charset;
- char szFace[LF_FACESIZE];
+ wchar_t szFace[LF_FACESIZE];
};
struct STICKYNOTE : public MZeroedObject
@@ -176,10 +176,10 @@ static void InitNoteTitle(STICKYNOTE *TSN)
TSN->CustomTitle = FALSE;
}
-static void InitStickyNoteLogFont(STICKYNOTEFONT *pCustomFont, LOGFONTA *lf)
+static void InitStickyNoteLogFont(STICKYNOTEFONT *pCustomFont, LOGFONT *lf)
{
if (!pCustomFont->size) {
- SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, FALSE);
+ SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(*lf), &lf, FALSE);
lf->lfHeight = 10;
HDC hdc = GetDC(nullptr);
lf->lfHeight = -MulDiv(lf->lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
@@ -189,8 +189,7 @@ static void InitStickyNoteLogFont(STICKYNOTEFONT *pCustomFont, LOGFONTA *lf)
lf->lfHeight = pCustomFont->size;
}
- mir_strcpy(lf->lfFaceName, pCustomFont->szFace);
-
+ wcsncpy_s(lf->lfFaceName, pCustomFont->szFace, _TRUNCATE);
lf->lfWidth = lf->lfEscapement = lf->lfOrientation = 0;
lf->lfWeight = pCustomFont->style & DBFONTF_BOLD ? FW_BOLD : FW_NORMAL;
lf->lfItalic = (pCustomFont->style & DBFONTF_ITALIC) != 0;
@@ -203,9 +202,9 @@ static void InitStickyNoteLogFont(STICKYNOTEFONT *pCustomFont, LOGFONTA *lf)
lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
}
-static BOOL CreateStickyNoteFont(STICKYNOTEFONT *pCustomFont, LOGFONTA *plf)
+static bool CreateStickyNoteFont(STICKYNOTEFONT *pCustomFont, LOGFONT *plf)
{
- LOGFONTA lf = {0};
+ LOGFONT lf = {};
if (!plf) {
InitStickyNoteLogFont(pCustomFont, &lf);
@@ -215,8 +214,7 @@ static BOOL CreateStickyNoteFont(STICKYNOTEFONT *pCustomFont, LOGFONTA *plf)
if (pCustomFont->hFont)
DeleteObject(pCustomFont->hFont);
- pCustomFont->hFont = CreateFontIndirectA(plf);
-
+ pCustomFont->hFont = CreateFontIndirectW(plf);
return pCustomFont->hFont != nullptr;
}
@@ -579,7 +577,7 @@ static BOOL GetClipboardText_Title(wchar_t *pOut, int size)
static void SetNoteTextControl(STICKYNOTE *SN)
{
- CHARFORMAT CF = {0};
+ CHARFORMAT CF = {};
CF.cbSize = sizeof(CHARFORMAT);
CF.dwMask = CFM_COLOR;
CF.crTextColor = SN->FgColor ? (SN->FgColor & 0xffffff) : BodyFontColor;
@@ -877,13 +875,16 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARA
JustSaveNotesEx();
return FALSE;
}
- else if (id >= IDM_COLORPRESET_FG && id <= IDM_COLORPRESET_FG + _countof(clrPresets)) {
- CHARFORMAT CF = {0};
+
+ if (id >= IDM_COLORPRESET_FG && id <= IDM_COLORPRESET_FG + _countof(clrPresets)) {
SN->FgColor = clrPresets[id - IDM_COLORPRESET_FG].color | 0xff000000;
+
+ CHARFORMAT CF = {};
CF.cbSize = sizeof(CHARFORMAT);
CF.dwMask = CFM_COLOR;
CF.crTextColor = SN->FgColor & 0xffffff;
SendMessage(SN->REHwnd, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CF);
+
RedrawWindow(SN->SNHwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW);
JustSaveNotesEx();
return FALSE;
@@ -916,8 +917,9 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARA
case ID_APPEARANCE_CUSTOMTEXT:
{
COLORREF custclr[16] = {0};
- CHOOSECOLOR cc = {0};
COLORREF orgclr = SN->FgColor ? (COLORREF)(SN->FgColor & 0xffffff) : (COLORREF)(BodyFontColor & 0xffffff);
+
+ CHOOSECOLOR cc = {0};
cc.lStructSize = sizeof(cc);
cc.hwndOwner = SN->SNHwnd;
cc.rgbResult = orgclr;
@@ -925,12 +927,14 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARA
cc.lpCustColors = custclr;
if (ChooseColor(&cc) && cc.rgbResult != orgclr) {
- CHARFORMAT CF = {0};
SN->FgColor = cc.rgbResult | 0xff000000;
+
+ CHARFORMAT CF = {0};
CF.cbSize = sizeof(CHARFORMAT);
CF.dwMask = CFM_COLOR;
CF.crTextColor = SN->FgColor & 0xffffff;
SendMessage(SN->REHwnd, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CF);
+
RedrawWindow(SN->SNHwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW);
JustSaveNotesEx();
}
@@ -939,44 +943,43 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARA
case ID_APPEARANCE_CUSTOMFONT:
{
- CHOOSEFONTA cf = {0};
- LOGFONTA lf = {0};
-
+ LOGFONT lf = {};
if (SN->pCustomFont)
InitStickyNoteLogFont(SN->pCustomFont, &lf);
else
LoadNRFont(NR_FONTID_BODY, &lf, nullptr);
+ CHOOSEFONT cf = {};
cf.lStructSize = sizeof(cf);
cf.hwndOwner = SN->SNHwnd;
cf.lpLogFont = &lf;
cf.Flags = CF_EFFECTS | CF_FORCEFONTEXIST | CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_ENABLEHOOK;
cf.lpfnHook = CFHookProc;
+ if (!ChooseFontW(&cf))
+ break;
- if (ChooseFontA(&cf)) {
- if (!SN->pCustomFont) {
- SN->pCustomFont = (STICKYNOTEFONT*)malloc(sizeof(STICKYNOTEFONT));
- SN->pCustomFont->hFont = nullptr;
- }
-
- SN->pCustomFont->size = (char)lf.lfHeight;
- SN->pCustomFont->style = (lf.lfWeight >= FW_BOLD ? DBFONTF_BOLD : 0) | (lf.lfItalic ? DBFONTF_ITALIC : 0) | (lf.lfUnderline ? DBFONTF_UNDERLINE : 0) | (lf.lfStrikeOut ? DBFONTF_STRIKEOUT : 0);
- SN->pCustomFont->charset = lf.lfCharSet;
- mir_strcpy(SN->pCustomFont->szFace, lf.lfFaceName);
+ if (!SN->pCustomFont) {
+ SN->pCustomFont = (STICKYNOTEFONT*)malloc(sizeof(STICKYNOTEFONT));
+ SN->pCustomFont->hFont = nullptr;
+ }
- if (!CreateStickyNoteFont(SN->pCustomFont, &lf)) {
- // failed
- free(SN->pCustomFont);
- SN->pCustomFont = nullptr;
- }
+ SN->pCustomFont->size = (char)lf.lfHeight;
+ SN->pCustomFont->style = (lf.lfWeight >= FW_BOLD ? DBFONTF_BOLD : 0) | (lf.lfItalic ? DBFONTF_ITALIC : 0) | (lf.lfUnderline ? DBFONTF_UNDERLINE : 0) | (lf.lfStrikeOut ? DBFONTF_STRIKEOUT : 0);
+ SN->pCustomFont->charset = lf.lfCharSet;
+ wcsncpy_s(SN->pCustomFont->szFace, lf.lfFaceName, _TRUNCATE);
- // clear text first to force a reformatting w.r.w scrollbar
- SetWindowTextA(SN->REHwnd, "");
- SendMessage(SN->REHwnd, WM_SETFONT, (WPARAM)(SN->pCustomFont ? SN->pCustomFont->hFont : hBodyFont), FALSE);
- SetNoteTextControl(SN);
- RedrawWindow(SN->SNHwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW);
- JustSaveNotesEx();
+ if (!CreateStickyNoteFont(SN->pCustomFont, &lf)) {
+ // failed
+ free(SN->pCustomFont);
+ SN->pCustomFont = nullptr;
}
+
+ // clear text first to force a reformatting w.r.w scrollbar
+ SetWindowTextA(SN->REHwnd, "");
+ SendMessage(SN->REHwnd, WM_SETFONT, (WPARAM)(SN->pCustomFont ? SN->pCustomFont->hFont : hBodyFont), FALSE);
+ SetNoteTextControl(SN);
+ RedrawWindow(SN->SNHwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW);
+ JustSaveNotesEx();
}
break;
@@ -988,15 +991,15 @@ LRESULT CALLBACK StickyNoteWndProc(HWND hdlg, UINT message, WPARAM wParam, LPARA
break;
case ID_TEXTCOLOR_RESET:
+ SN->FgColor = 0;
{
- CHARFORMAT CF = {0};
- SN->FgColor = 0;
+ CHARFORMAT CF = {};
CF.cbSize = sizeof(CHARFORMAT);
CF.dwMask = CFM_COLOR;
CF.crTextColor = BodyFontColor;
SendMessage(SN->REHwnd, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CF);
- RedrawWindow(SN->SNHwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW);
}
+ RedrawWindow(SN->SNHwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW);
JustSaveNotesEx();
break;
@@ -1369,7 +1372,7 @@ void LoadNotes(BOOL bIsStartup)
pCustomFont->size = (char)fsize;
pCustomFont->style = (BYTE)fstyle;
pCustomFont->charset = (BYTE)fcharset;
- mir_strcpy(pCustomFont->szFace, TVal2);
+ wcsncpy_s(pCustomFont->szFace, _A2T(TVal2), _TRUNCATE);
pCustomFont->hFont = nullptr;
if (!CreateStickyNoteFont(pCustomFont, nullptr)) {
diff --git a/plugins/NotesAndReminders/src/options.cpp b/plugins/NotesAndReminders/src/options.cpp
index 928d9e6d3f..97d6dd6905 100644
--- a/plugins/NotesAndReminders/src/options.cpp
+++ b/plugins/NotesAndReminders/src/options.cpp
@@ -5,10 +5,10 @@
HICON g_hReminderIcon = nullptr;
-LOGFONTA lfBody, lfCaption;
+LOGFONT lfBody, lfCaption;
HFONT hBodyFont = nullptr, hCaptionFont = nullptr;
long BodyColor;
-long CaptionFontColor, BodyFontColor;
+COLORREF CaptionFontColor, BodyFontColor;
int g_NoteTitleDate, g_NoteTitleTime;
int g_NoteWidth, g_NoteHeight;
int g_Transparency;
@@ -64,17 +64,17 @@ static timeFormats[] =
struct FontOptionsList
{
- char *szDescr;
+ wchar_t *szDescr;
COLORREF defColour;
- char *szDefFace;
+ wchar_t *szDefFace;
BYTE defStyle;
int defSize;
- char *szBkgName;
+ wchar_t *szBkgName;
}
static fontOptionsList[] =
{
- { LPGEN("Sticky Note Caption"), RGB(0, 0, 0), "Small Fonts", 0, 7, LPGEN("Sticky Note Background Color") },
- { LPGEN("Sticky Note Body"), RGB(0, 0, 0), "System", DBFONTF_BOLD, 10, LPGEN("Sticky Note Background Color") },
+ { LPGENW("Sticky Note Caption"), RGB(0, 0, 0), L"Small Fonts", 0, 7, LPGENW("Sticky Note Background Color") },
+ { LPGENW("Sticky Note Body"), RGB(0, 0, 0), L"System", DBFONTF_BOLD, 10, LPGENW("Sticky Note Background Color") },
};
@@ -105,16 +105,16 @@ static void InitFonts()
memset(&lfBody, 0, sizeof(lfBody));
memset(&lfCaption, 0, sizeof(lfCaption));
- LoadNRFont(NR_FONTID_CAPTION, &lfCaption, (COLORREF*)&CaptionFontColor);
- LoadNRFont(NR_FONTID_BODY, &lfBody, (COLORREF*)&BodyFontColor);
+ LoadNRFont(NR_FONTID_CAPTION, &lfCaption, &CaptionFontColor);
+ LoadNRFont(NR_FONTID_BODY, &lfBody, &BodyFontColor);
if (hBodyFont)
DeleteObject(hBodyFont);
if (hCaptionFont)
DeleteObject(hCaptionFont);
- hBodyFont = CreateFontIndirectA(&lfBody);
- hCaptionFont = CreateFontIndirectA(&lfCaption);
+ hBodyFont = CreateFontIndirectW(&lfBody);
+ hCaptionFont = CreateFontIndirectW(&lfCaption);
}
@@ -145,10 +145,10 @@ void RegisterFontServiceFonts()
{
char szTemp[100];
- FontID fontid = {};
- strncpy(fontid.group, SECTIONNAME, _countof(fontid.group));
- strncpy(fontid.backgroundGroup, SECTIONNAME, _countof(fontid.backgroundGroup));
- strncpy(fontid.dbSettingsGroup, MODULENAME, _countof(fontid.dbSettingsGroup));
+ FontIDW fontid = {};
+ wcsncpy_s(fontid.group, _A2W(SECTIONNAME), _TRUNCATE);
+ wcsncpy_s(fontid.backgroundGroup, _A2W(SECTIONNAME), _TRUNCATE);
+ strncpy_s(fontid.dbSettingsGroup, MODULENAME, _TRUNCATE);
fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID | FIDF_SAVEPOINTSIZE;
HDC hDC = GetDC(nullptr);
@@ -158,8 +158,8 @@ void RegisterFontServiceFonts()
for (int i = 0; i < _countof(fontOptionsList); i++) {
fontid.order = i;
mir_snprintf(szTemp, "Font%d", i);
- strncpy(fontid.setting, szTemp, _countof(fontid.setting));
- strncpy(fontid.name, fontOptionsList[i].szDescr, _countof(fontid.name));
+ strncpy_s(fontid.setting, szTemp, _countof(fontid.setting));
+ wcsncpy_s(fontid.name, fontOptionsList[i].szDescr, _TRUNCATE);
fontid.deffontsettings.colour = fontOptionsList[i].defColour;
fontid.deffontsettings.size = (char)-MulDiv(fontOptionsList[i].defSize, nFontScale, 72);
@@ -167,23 +167,22 @@ void RegisterFontServiceFonts()
fontid.deffontsettings.style = fontOptionsList[i].defStyle;
fontid.deffontsettings.charset = DEFAULT_CHARSET;
- strncpy(fontid.deffontsettings.szFace, fontOptionsList[i].szDefFace, _countof(fontid.deffontsettings.szFace));
- strncpy(fontid.backgroundName, fontOptionsList[i].szBkgName, _countof(fontid.backgroundName));
+ wcsncpy_s(fontid.deffontsettings.szFace, fontOptionsList[i].szDefFace, _TRUNCATE);
+ wcsncpy_s(fontid.backgroundName, fontOptionsList[i].szBkgName, _TRUNCATE);
g_plugin.addFont(&fontid);
}
ColourID colorid = {};
- strncpy(colorid.group, SECTIONNAME, _countof(colorid.group));
- strncpy(colorid.dbSettingsGroup, MODULENAME, _countof(fontid.dbSettingsGroup));
+ strncpy_s(colorid.group, SECTIONNAME, _TRUNCATE);
+ strncpy_s(colorid.dbSettingsGroup, MODULENAME, _TRUNCATE);
colorid.flags = 0;
for (int i = 0; i < _countof(colourOptionsList); i++) {
colorid.order = i;
- strncpy(colorid.name, colourOptionsList[i].szName, _countof(colorid.name));
+ strncpy_s(colorid.name, colourOptionsList[i].szName, _TRUNCATE);
colorid.defcolour = colourOptionsList[i].defColour;
- strncpy(colorid.setting, colourOptionsList[i].szSettingName, _countof(colorid.setting));
-
+ strncpy_s(colorid.setting, colourOptionsList[i].szSettingName, _TRUNCATE);
g_plugin.addColor(&colorid);
}
@@ -191,48 +190,13 @@ void RegisterFontServiceFonts()
HookEvent(ME_COLOUR_RELOAD, FS_ColorChanged);
}
-void LoadNRFont(int i, LOGFONTA *lf, COLORREF *colour)
+void LoadNRFont(int i, LOGFONT *lf, COLORREF *colour)
{
- COLORREF col = Font_Get(SECTIONNAME, fontOptionsList[i].szDescr, lf);
+ COLORREF col = Font_GetW(_A2W(SECTIONNAME), fontOptionsList[i].szDescr, lf);
if (colour)
*colour = col;
}
-
-static void TrimString(char *s)
-{
- if (!s || !*s)
- return;
-
- char *start = s;
- UINT n = UINT(mir_strlen(s) - 1);
-
- char *end = s + n;
-
- if (!iswspace(*start) && !iswspace(*end)) {
- // nothing to trim
- return;
- }
-
- // scan past leading spaces
- while (*start && iswspace(*start)) start++;
-
- if (!*start) {
- // empty string
- *s = 0;
- return;
- }
-
- // trim trailing spaces
- while (iswspace(*end)) end--;
- end[1] = 0;
-
- if (start > s) {
- // remove leading spaces
- memmove(s, start, ((UINT)(end - start) + 2) * sizeof(wchar_t));
- }
-}
-
static void FillValues(HWND hdlg)
{
CheckDlgButton(hdlg, IDC_CHECK_HIDENOTES, g_plugin.bShowNotesAtStart ? BST_UNCHECKED : BST_CHECKED); // reversed
@@ -258,8 +222,6 @@ static INT_PTR CALLBACK DlgProcOptions(HWND hdlg, UINT message, WPARAM wParam, L
TranslateDialogDefault(hdlg);
SendDlgItemMessage(hdlg, IDC_SLIDER_TRANSPARENCY, TBM_SETRANGE, TRUE, MAKELONG(0, 255 - MIN_ALPHA));
- FillValues(hdlg);
-
SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_RESETCONTENT, 0, 0);
SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_RESETCONTENT, 0, 0);
for (auto &it : dateFormats)
@@ -269,6 +231,8 @@ static INT_PTR CALLBACK DlgProcOptions(HWND hdlg, UINT message, WPARAM wParam, L
SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_ADDSTRING, 0, (LPARAM)TranslateT("None"));
SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("None"));
+ FillValues(hdlg);
+
if (g_RemindSMS)
SetDlgItemTextA(hdlg, IDC_EDIT_EMAILSMS, g_RemindSMS);
else
@@ -318,7 +282,7 @@ static INT_PTR CALLBACK DlgProcOptions(HWND hdlg, UINT message, WPARAM wParam, L
if (SzT != 0) {
g_lpszAltBrowser = (char*)mir_realloc(g_lpszAltBrowser, SzT + 1);
GetDlgItemTextA(hdlg, IDC_EDIT_ALTBROWSER, g_lpszAltBrowser, SzT + 1);
- TrimString(g_lpszAltBrowser);
+ rtrim(g_lpszAltBrowser);
if (!*g_lpszAltBrowser) {
mir_free(g_lpszAltBrowser);
g_lpszAltBrowser = nullptr;
diff --git a/plugins/NotesAndReminders/src/reminders.cpp b/plugins/NotesAndReminders/src/reminders.cpp
index 1990714449..f98a4c235f 100644
--- a/plugins/NotesAndReminders/src/reminders.cpp
+++ b/plugins/NotesAndReminders/src/reminders.cpp
@@ -324,13 +324,8 @@ void LoadReminders(void)
if (!rem.uid)
GenerateUids = true;
- TempRem = (REMINDERDATA*)malloc(sizeof(REMINDERDATA));
- if (TempRem) {
- *TempRem = rem;
- arReminders.insert(TempRem);
- }
- else if (rem.Reminder)
- free(rem.Reminder);
+ TempRem = new REMINDERDATA(rem);
+ arReminders.insert(TempRem);
skip:;
}
@@ -1472,58 +1467,58 @@ static INT_PTR CALLBACK DlgProcNewReminder(HWND hwndDlg, UINT Message, WPARAM wP
HICON hIcon = nullptr;
switch (Message) {
case WM_INITDIALOG:
- {
- ULARGE_INTEGER li;
- SYSTEMTIME tm;
+ TranslateDialogDefault(hwndDlg);
- if (NewReminderVisible == 2) {
- // opening the edit reminder dialog (uses same dialog resource as add reminder)
- SetWindowText(hwndDlg, TranslateT("Reminder"));
- SetDlgItemText(hwndDlg, IDC_ADDREMINDER, TranslateT("&Update Reminder"));
- ShowWindow(GetDlgItem(hwndDlg, IDC_VIEWREMINDERS), SW_HIDE);
+ ULARGE_INTEGER li;
+ SYSTEMTIME tm;
- li = pEditReminder->When;
- FileTimeToSystemTime((FILETIME*)&li, &tm);
- }
- else {
- GetSystemTime(&tm);
- SystemTimeToFileTime(&tm, (FILETIME*)&li);
- }
+ if (NewReminderVisible == 2) {
+ // opening the edit reminder dialog (uses same dialog resource as add reminder)
+ SetWindowText(hwndDlg, TranslateT("Reminder"));
+ SetDlgItemText(hwndDlg, IDC_ADDREMINDER, TranslateT("&Update Reminder"));
+ ShowWindow(GetDlgItem(hwndDlg, IDC_VIEWREMINDERS), SW_HIDE);
- TranslateDialogDefault(hwndDlg);
+ li = pEditReminder->When;
+ FileTimeToSystemTime((FILETIME*)&li, &tm);
+ }
+ else {
+ GetSystemTime(&tm);
+ SystemTimeToFileTime(&tm, (FILETIME*)&li);
+ }
- // save reference time in hidden control, is needed when adding reminder to properly detect if speicifed
- // time wrapped around to tomorrow or not (dialog could in theory be open for a longer period of time
- // which could potentially mess up things otherwise)
- wchar_t s[64];
- mir_snwprintf(s, L"%I64x", li.QuadPart);
- SetDlgItemText(hwndDlg, IDC_REFTIME, s);
+ // save reference time in hidden control, is needed when adding reminder to properly detect if speicifed
+ // time wrapped around to tomorrow or not (dialog could in theory be open for a longer period of time
+ // which could potentially mess up things otherwise)
+ wchar_t s[64];
+ mir_snwprintf(s, L"%I64x", li.QuadPart);
+ SetDlgItemText(hwndDlg, IDC_REFTIME, s);
- PopulateTimeCombo(hwndDlg, IDC_TIME, NewReminderVisible != 2, &tm);
+ PopulateTimeCombo(hwndDlg, IDC_TIME, NewReminderVisible != 2, &tm);
- FileTimeToTzLocalST((FILETIME*)&li, &tm);
+ FileTimeToTzLocalST((FILETIME*)&li, &tm);
- // make sure date picker uses reference time
- SendDlgItemMessage(hwndDlg, IDC_DATE, DTM_SETSYSTEMTIME, 0, (LPARAM)&tm);
- InitDatePicker(hwndDlg, IDC_DATE);
+ // make sure date picker uses reference time
+ SendDlgItemMessage(hwndDlg, IDC_DATE, DTM_SETSYSTEMTIME, 0, (LPARAM)&tm);
+ InitDatePicker(hwndDlg, IDC_DATE);
- SendDlgItemMessage(hwndDlg, IDC_REMINDER, EM_LIMITTEXT, MAX_REMINDER_LEN, 0);
+ SendDlgItemMessage(hwndDlg, IDC_REMINDER, EM_LIMITTEXT, MAX_REMINDER_LEN, 0);
- if (NewReminderVisible == 2) {
- mir_snwprintf(s, L"%02d:%02d", tm.wHour, tm.wMinute);
+ if (NewReminderVisible == 2) {
+ mir_snwprintf(s, L"%02d:%02d", tm.wHour, tm.wMinute);
- // search for preset first
- int n = SendDlgItemMessageA(hwndDlg, IDC_TIME, CB_FINDSTRING, (WPARAM)-1, (LPARAM)s);
- if (n != CB_ERR)
- SendDlgItemMessage(hwndDlg, IDC_TIME, CB_SETCURSEL, n, 0);
- else
- SetDlgItemText(hwndDlg, IDC_TIME, s);
+ // search for preset first
+ int n = SendDlgItemMessageA(hwndDlg, IDC_TIME, CB_FINDSTRING, (WPARAM)-1, (LPARAM)s);
+ if (n != CB_ERR)
+ SendDlgItemMessage(hwndDlg, IDC_TIME, CB_SETCURSEL, n, 0);
+ else
+ SetDlgItemText(hwndDlg, IDC_TIME, s);
- SetDlgItemTextA(hwndDlg, IDC_REMINDER, pEditReminder->Reminder);
- }
- else SendDlgItemMessage(hwndDlg, IDC_TIME, CB_SETCURSEL, 0, 0);
+ SetDlgItemTextA(hwndDlg, IDC_REMINDER, pEditReminder->Reminder);
+ }
+ else SendDlgItemMessage(hwndDlg, IDC_TIME, CB_SETCURSEL, 0, 0);
- // populate sound repeat combo
+ // populate sound repeat combo
+ {
wchar_t *lpszEvery = TranslateT("Every");
wchar_t *lpszSeconds = TranslateT("Seconds");
@@ -1871,7 +1866,6 @@ void OnListResize(HWND hwndDlg)
MoveWindow(hBtnNew, clsr.left, clsr.top, btnw, btnh, FALSE);
RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
- //UpdateWindow(hwndDlg);
}
void UpdateGeomFromWnd(HWND hwndDlg, int *geom, int *colgeom, int nCols)
@@ -1879,7 +1873,6 @@ void UpdateGeomFromWnd(HWND hwndDlg, int *geom, int *colgeom, int nCols)
if (geom) {
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
-
GetWindowPlacement(hwndDlg, &wp);
geom[0] = wp.rcNormalPosition.left;
@@ -1891,20 +1884,21 @@ void UpdateGeomFromWnd(HWND hwndDlg, int *geom, int *colgeom, int nCols)
if (colgeom) {
HWND H = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
- for (int i = 0; i < nCols; i++) {
+ for (int i = 0; i < nCols; i++)
colgeom[i] = ListView_GetColumnWidth(H, i);
- }
}
}
static BOOL DoListContextMenu(HWND AhWnd, WPARAM wParam, LPARAM lParam, REMINDERDATA *pReminder)
{
HWND hwndListView = (HWND)wParam;
- if (hwndListView != GetDlgItem(AhWnd, IDC_LISTREMINDERS)) return FALSE;
+ if (hwndListView != GetDlgItem(AhWnd, IDC_LISTREMINDERS))
+ return FALSE;
+
HMENU hMenuLoad = LoadMenuA(g_plugin.getInst(), "MNU_REMINDERPOPUP");
HMENU FhMenu = GetSubMenu(hMenuLoad, 0);
- MENUITEMINFO mii = {0};
+ MENUITEMINFO mii = {};
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STATE;
mii.fState = MFS_DEFAULT;
@@ -1923,7 +1917,7 @@ static BOOL DoListContextMenu(HWND AhWnd, WPARAM wParam, LPARAM lParam, REMINDER
static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
{
- LV_COLUMN lvCol;
+ HWND H = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
switch (Message) {
case WM_SIZE:
@@ -1952,7 +1946,6 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
{
REMINDERDATA *pReminder = nullptr;
- HWND H = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
if (ListView_GetSelectedCount(H)) {
int i = ListView_GetSelectionMark(H);
if (i != -1)
@@ -1969,33 +1962,32 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
TranslateDialogDefault(hwndDlg);
SetDlgItemTextA(hwndDlg, IDC_REMINDERDATA, "");
- {
- HWND H = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
- lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
- lvCol.pszText = TranslateT("Reminder text");
- lvCol.cx = g_reminderListColGeom[1];
- ListView_InsertColumn(H, 0, &lvCol);
-
- lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
- lvCol.pszText = TranslateT("Date of activation");
- lvCol.cx = g_reminderListColGeom[0];
- ListView_InsertColumn(H, 0, &lvCol);
-
- InitListView(H);
-
- SetWindowLongPtr(GetDlgItem(H, 0), GWL_ID, IDC_LISTREMINDERS_HEADER);
- LV = hwndDlg;
-
- if (g_reminderListGeom[1] && g_reminderListGeom[2]) {
- WINDOWPLACEMENT wp;
- wp.length = sizeof(WINDOWPLACEMENT);
- GetWindowPlacement(hwndDlg, &wp);
- wp.rcNormalPosition.left = g_reminderListGeom[0];
- wp.rcNormalPosition.top = g_reminderListGeom[1];
- wp.rcNormalPosition.right = g_reminderListGeom[2] + g_reminderListGeom[0];
- wp.rcNormalPosition.bottom = g_reminderListGeom[3] + g_reminderListGeom[1];
- SetWindowPlacement(hwndDlg, &wp);
- }
+
+ LV_COLUMN lvCol;
+ lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
+ lvCol.pszText = TranslateT("Reminder text");
+ lvCol.cx = g_reminderListColGeom[1];
+ ListView_InsertColumn(H, 0, &lvCol);
+
+ lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
+ lvCol.pszText = TranslateT("Date of activation");
+ lvCol.cx = g_reminderListColGeom[0];
+ ListView_InsertColumn(H, 0, &lvCol);
+
+ InitListView(H);
+
+ SetWindowLongPtr(GetDlgItem(H, 0), GWL_ID, IDC_LISTREMINDERS_HEADER);
+ LV = hwndDlg;
+
+ if (g_reminderListGeom[1] && g_reminderListGeom[2]) {
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(WINDOWPLACEMENT);
+ GetWindowPlacement(hwndDlg, &wp);
+ wp.rcNormalPosition.left = g_reminderListGeom[0];
+ wp.rcNormalPosition.top = g_reminderListGeom[1];
+ wp.rcNormalPosition.right = g_reminderListGeom[2] + g_reminderListGeom[0];
+ wp.rcNormalPosition.bottom = g_reminderListGeom[3] + g_reminderListGeom[1];
+ SetWindowPlacement(hwndDlg, &wp);
}
return TRUE;
@@ -2005,35 +1997,28 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
return TRUE;
case WM_NOTIFY:
- {
- if (wParam == IDC_LISTREMINDERS) {
- LPNMLISTVIEW NM = (LPNMLISTVIEW)lParam;
- switch (NM->hdr.code) {
- case LVN_ITEMCHANGED:
- {
- char *S2 = arReminders[NM->iItem]->Reminder;
- SetDlgItemTextA(hwndDlg, IDC_REMINDERDATA, S2);
- }
- break;
- case NM_DBLCLK:
- {
- HWND H = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
- if (ListView_GetSelectedCount(H)) {
- int i = ListView_GetSelectionMark(H);
- if (i != -1)
- EditReminder(arReminders[i]);
- }
- }
- break;
+ if (wParam == IDC_LISTREMINDERS) {
+ LPNMLISTVIEW NM = (LPNMLISTVIEW)lParam;
+ switch (NM->hdr.code) {
+ case LVN_ITEMCHANGED:
+ SetDlgItemTextA(hwndDlg, IDC_REMINDERDATA, arReminders[NM->iItem]->Reminder);
+ break;
+
+ case NM_DBLCLK:
+ if (ListView_GetSelectedCount(H)) {
+ int i = ListView_GetSelectionMark(H);
+ if (i != -1)
+ EditReminder(arReminders[i]);
}
+ break;
}
- else if (wParam == IDC_LISTREMINDERS_HEADER) {
- LPNMHEADER NM = (LPNMHEADER)lParam;
- switch (NM->hdr.code) {
- case HDN_ENDTRACK:
- UpdateGeomFromWnd(hwndDlg, nullptr, g_reminderListColGeom, _countof(g_reminderListColGeom));
- break;
- }
+ }
+ else if (wParam == IDC_LISTREMINDERS_HEADER) {
+ LPNMHEADER NM = (LPNMHEADER)lParam;
+ switch (NM->hdr.code) {
+ case HDN_ENDTRACK:
+ UpdateGeomFromWnd(hwndDlg, nullptr, g_reminderListColGeom, _countof(g_reminderListColGeom));
+ break;
}
}
break;
@@ -2041,13 +2026,10 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
case WM_COMMAND:
switch (LOWORD(wParam)) {
case ID_CONTEXTMENUREMINDERLISTVIEW_EDIT:
- {
- HWND H = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
- if (ListView_GetSelectedCount(H)) {
- int i = ListView_GetSelectionMark(H);
- if (i != -1)
- EditReminder(arReminders[i]);
- }
+ if (ListView_GetSelectedCount(H)) {
+ int i = ListView_GetSelectionMark(H);
+ if (i != -1)
+ EditReminder(arReminders[i]);
}
return TRUE;
@@ -2070,19 +2052,16 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
return TRUE;
case IDM_DELETEREMINDER:
- {
- HWND H = GetDlgItem(hwndDlg, IDC_LISTREMINDERS);
- 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);
- }
+ 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);
}
- return TRUE;
}
+ return TRUE;
}
break;
@@ -2098,7 +2077,7 @@ static INT_PTR CALLBACK DlgProcViewReminders(HWND hwndDlg, UINT Message, WPARAM
INT_PTR PluginMenuCommandNewReminder(WPARAM, LPARAM)
{
if (!NewReminderVisible) {
- NewReminderVisible = TRUE;
+ NewReminderVisible = true;
CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ADDREMINDER), nullptr, DlgProcNewReminder);
}
return 0;
diff --git a/plugins/NotesAndReminders/src/stdafx.h b/plugins/NotesAndReminders/src/stdafx.h
index 16da30b03a..207896706d 100644
--- a/plugins/NotesAndReminders/src/stdafx.h
+++ b/plugins/NotesAndReminders/src/stdafx.h
@@ -65,7 +65,7 @@ bool CheckRemindersAndStart(void);
void InitSettings(void);
void TermSettings(void);
-void LoadNRFont(int i, LOGFONTA *lf, COLORREF *colour);
+void LoadNRFont(int i, LOGFONT *lf, COLORREF *colour);
BOOL WS_Init();
void WS_CleanUp();
@@ -77,11 +77,11 @@ extern HINSTANCE hmiranda;
extern HICON g_hReminderIcon;
-extern LOGFONTA lfBody, lfCaption;
+extern LOGFONT lfBody, lfCaption;
extern HFONT hBodyFont, hCaptionFont;
extern long BodyColor;
-extern long CaptionFontColor, BodyFontColor;
+extern COLORREF CaptionFontColor, BodyFontColor;
extern int g_NoteTitleDate, g_NoteTitleTime;