summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/NotesAndReminders/NotesReminders_10.vcxproj8
-rw-r--r--plugins/NotesAndReminders/NotesReminders_12.vcxproj8
-rw-r--r--plugins/NotesAndReminders/NotesReminders_14.vcxproj8
-rw-r--r--plugins/NotesAndReminders/src/main.cpp26
-rw-r--r--plugins/NotesAndReminders/src/notes.cpp557
-rw-r--r--plugins/NotesAndReminders/src/options.cpp158
-rw-r--r--plugins/NotesAndReminders/src/reminders.cpp551
7 files changed, 611 insertions, 705 deletions
diff --git a/plugins/NotesAndReminders/NotesReminders_10.vcxproj b/plugins/NotesAndReminders/NotesReminders_10.vcxproj
index 6063bb4e36..3dc010d8a0 100644
--- a/plugins/NotesAndReminders/NotesReminders_10.vcxproj
+++ b/plugins/NotesAndReminders/NotesReminders_10.vcxproj
@@ -78,7 +78,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <WarningLevel>Level3</WarningLevel>
+ <WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<PrecompiledHeader>Use</PrecompiledHeader>
@@ -105,7 +105,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <WarningLevel>Level3</WarningLevel>
+ <WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<PrecompiledHeader>Use</PrecompiledHeader>
@@ -135,7 +135,7 @@
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
- <WarningLevel>Level3</WarningLevel>
+ <WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>globals.h</PrecompiledHeaderFile>
@@ -166,7 +166,7 @@
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
- <WarningLevel>Level3</WarningLevel>
+ <WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>globals.h</PrecompiledHeaderFile>
diff --git a/plugins/NotesAndReminders/NotesReminders_12.vcxproj b/plugins/NotesAndReminders/NotesReminders_12.vcxproj
index 6b02e0a53b..6b0d26a20a 100644
--- a/plugins/NotesAndReminders/NotesReminders_12.vcxproj
+++ b/plugins/NotesAndReminders/NotesReminders_12.vcxproj
@@ -82,7 +82,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <WarningLevel>Level3</WarningLevel>
+ <WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<PrecompiledHeader>Use</PrecompiledHeader>
@@ -110,7 +110,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <WarningLevel>Level3</WarningLevel>
+ <WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<PrecompiledHeader>Use</PrecompiledHeader>
@@ -140,7 +140,7 @@
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
- <WarningLevel>Level3</WarningLevel>
+ <WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>globals.h</PrecompiledHeaderFile>
@@ -171,7 +171,7 @@
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
- <WarningLevel>Level3</WarningLevel>
+ <WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>globals.h</PrecompiledHeaderFile>
diff --git a/plugins/NotesAndReminders/NotesReminders_14.vcxproj b/plugins/NotesAndReminders/NotesReminders_14.vcxproj
index 74aa19bc3f..53e2671707 100644
--- a/plugins/NotesAndReminders/NotesReminders_14.vcxproj
+++ b/plugins/NotesAndReminders/NotesReminders_14.vcxproj
@@ -82,7 +82,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <WarningLevel>Level3</WarningLevel>
+ <WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<PrecompiledHeader>Use</PrecompiledHeader>
@@ -110,7 +110,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <WarningLevel>Level3</WarningLevel>
+ <WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<PrecompiledHeader>Use</PrecompiledHeader>
@@ -140,7 +140,7 @@
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
- <WarningLevel>Level3</WarningLevel>
+ <WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>globals.h</PrecompiledHeaderFile>
@@ -171,7 +171,7 @@
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
- <WarningLevel>Level3</WarningLevel>
+ <WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>globals.h</PrecompiledHeaderFile>
diff --git a/plugins/NotesAndReminders/src/main.cpp b/plugins/NotesAndReminders/src/main.cpp
index fdf9140439..c4985c1b84 100644
--- a/plugins/NotesAndReminders/src/main.cpp
+++ b/plugins/NotesAndReminders/src/main.cpp
@@ -37,7 +37,7 @@ void BringAllNotesToFront(STICKYNOTE *pActive);
void CloseNotesList();
void CloseReminderList();
-INT_PTR PluginMenuCommandAddNew(WPARAM w, LPARAM l)
+INT_PTR PluginMenuCommandAddNew(WPARAM, LPARAM)
{
STICKYNOTE *PSN = NewNote(0,0,0,0,NULL,NULL,TRUE,TRUE,0);
if(PSN)
@@ -45,44 +45,44 @@ INT_PTR PluginMenuCommandAddNew(WPARAM w, LPARAM l)
return 0;
}
-INT_PTR PluginMenuCommandDeleteAll(WPARAM w, LPARAM l)
+INT_PTR PluginMenuCommandDeleteAll(WPARAM, LPARAM)
{
if (g_Stickies && MessageBox(NULL, Translate("Are you sure you want to delete all notes?"), Translate(SECTIONNAME), MB_OKCANCEL) == IDOK)
DeleteNotes();
return 0;
}
-INT_PTR PluginMenuCommandShowHide(WPARAM w, LPARAM l)
+static INT_PTR PluginMenuCommandShowHide(WPARAM, LPARAM)
{
ShowHideNotes();
return 0;
}
-INT_PTR PluginMenuCommandViewNotes(WPARAM w, LPARAM l)
+static INT_PTR PluginMenuCommandViewNotes(WPARAM, LPARAM)
{
ListNotes();
return 0;
}
-INT_PTR PluginMenuCommandAllBringFront(WPARAM w, LPARAM l)
+static INT_PTR PluginMenuCommandAllBringFront(WPARAM, LPARAM)
{
BringAllNotesToFront(NULL);
return 0;
}
-INT_PTR PluginMenuCommandNewReminder(WPARAM w, LPARAM l)
+static INT_PTR PluginMenuCommandNewReminder(WPARAM, LPARAM)
{
NewReminder();
return 0;
}
-INT_PTR PluginMenuCommandViewReminders(WPARAM w, LPARAM l)
+static INT_PTR PluginMenuCommandViewReminders(WPARAM, LPARAM)
{
ListReminders();
return 0;
}
-INT_PTR PluginMenuCommandDeleteReminders(WPARAM w, LPARAM l)
+static INT_PTR PluginMenuCommandDeleteReminders(WPARAM, LPARAM)
{
if (RemindersList && MessageBox(NULL, Translate("Are you sure you want to delete all reminders?"), Translate(SECTIONNAME), MB_OKCANCEL) == IDOK)
DeleteReminders();
@@ -114,7 +114,7 @@ void InitIcons(void)
Icon_Register(hinstance, LPGEN("Sticky Notes"), iconList, _countof(iconList), MODULENAME);
}
-int OnOptInitialise(WPARAM w, LPARAM L)
+static int OnOptInitialise(WPARAM w, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 900002000;
@@ -127,7 +127,7 @@ int OnOptInitialise(WPARAM w, LPARAM L)
return 0;
}
-int OnTopToolBarInit(WPARAM w, LPARAM L)
+int OnTopToolBarInit(WPARAM, LPARAM)
{
TTBButton ttb = { 0 };
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP;
@@ -185,7 +185,7 @@ static void addMenuItem(CMenuItem &mi)
Menu_AddMainMenuItem(&mi);
}
-int OnModulesLoaded(WPARAM wparam, LPARAM lparam)
+int OnModulesLoaded(WPARAM, LPARAM)
{
// register fonts and hotkeys
RegisterFontServiceFonts();
@@ -260,7 +260,7 @@ int OnModulesLoaded(WPARAM wparam, LPARAM lparam)
return 0;
}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
@@ -290,7 +290,7 @@ extern "C" __declspec(dllexport) int Unload(void)
return 0;
}
-BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved)
+BOOL WINAPI DllMain(HINSTANCE hinst, DWORD, LPVOID)
{
hinstance = hinst;
return TRUE;
diff --git a/plugins/NotesAndReminders/src/notes.cpp b/plugins/NotesAndReminders/src/notes.cpp
index 0708bbfcaf..a341579d21 100644
--- a/plugins/NotesAndReminders/src/notes.cpp
+++ b/plugins/NotesAndReminders/src/notes.cpp
@@ -90,9 +90,7 @@ TREEELEMENT *g_Stickies = NULL;
INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,
WPARAM wParam,LPARAM lParam);
-INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam,
- LPARAM lParam);
-void JustSaveNotes(void);
+
INT_PTR PluginMenuCommandAddNew(WPARAM w,LPARAM l);
INT_PTR PluginMenuCommandDeleteAll(WPARAM w,LPARAM l);
void GetTriggerTimeString(const ULARGE_INTEGER *When, char *s, UINT strSize, BOOL bUtc);
@@ -113,16 +111,13 @@ COLORREF GetCaptionColor(COLORREF bodyClr)
static void EnsureUniqueID(STICKYNOTE *TSN)
{
- TREEELEMENT *TTE;
-
if (!g_Stickies)
return;
try_next:
// check existing notes if id is in use
- TTE = g_Stickies;
- while (TTE)
+ for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next)
{
if (((STICKYNOTE*)TTE->ptrdata)->ID.QuadPart == TSN->ID.QuadPart)
{
@@ -131,8 +126,6 @@ try_next:
TSN->ID.QuadPart++;
goto try_next;
}
-
- TTE = (TREEELEMENT*)TTE->next;
}
}
@@ -220,7 +213,6 @@ static BOOL CreateStickyNoteFont(STICKYNOTEFONT *pCustomFont, LOGFONT *plf)
STICKYNOTE* NewNoteEx(int Ax,int Ay,int Aw,int Ah,char *Data,ULARGE_INTEGER *ID,BOOL Visible,BOOL OnTop,int scrollV,COLORREF bgClr,COLORREF fgClr,char *Title,STICKYNOTEFONT *pCustomFont,BOOL bLoading)
{
- STICKYNOTE* TSN;
WNDCLASSEX TWC = {0};
WINDOWPLACEMENT TWP;
DWORD L1,L2;
@@ -245,7 +237,7 @@ STICKYNOTE* NewNoteEx(int Ax,int Ay,int Aw,int Ah,char *Data,ULARGE_INTEGER *ID,
TWC.lpszMenuName = 0;
TWC.lpszClassName = NOTE_WND_CLASS;
TWC.cbSize = sizeof(WNDCLASSEX);
- TWC.lpfnWndProc = (WNDPROC)StickyNoteWndProc;
+ TWC.lpfnWndProc = StickyNoteWndProc;
if (!RegisterClassEx(&TWC)) return NULL;
}
@@ -258,7 +250,7 @@ STICKYNOTE* NewNoteEx(int Ax,int Ay,int Aw,int Ah,char *Data,ULARGE_INTEGER *ID,
Ay = ((TWP.rcNormalPosition.bottom - TWP.rcNormalPosition.top) / 2) - (Ah / 2);
}
- TSN = (STICKYNOTE*)malloc(sizeof(STICKYNOTE));
+ STICKYNOTE *TSN = (STICKYNOTE*)malloc(sizeof(STICKYNOTE));
if (ID)
{
@@ -367,17 +359,15 @@ STICKYNOTE* NewNote(int Ax,int Ay,int Aw,int Ah,char *Data,ULARGE_INTEGER *ID,BO
void LoadNotes(BOOL bIsStartup)
{
- int I;
- int NotesCount;
- WORD Size;
+ WORD Size = 0;
char *Value = NULL, *TVal = NULL;
char ValueName[32];
g_Stickies = NULL;
- NotesCount = db_get_dw(0,MODULENAME,"NotesData",0);
+ int NotesCount = db_get_dw(0,MODULENAME,"NotesData",0);
- for (I = 0; I < NotesCount; I++)
+ for (int I = 0; I < NotesCount; I++)
{
char *DelPos;
@@ -556,7 +546,7 @@ void LoadNotes(BOOL bIsStartup)
if (DelPos = strchr(Value,0x1B))
{ // get first delimiter
- int PartLen = DelPos - TVal;
+// int PartLen = DelPos - TVal;
Data = NULL;
ID = NULL;
@@ -661,11 +651,9 @@ void CloseNotesList()
static void PurgeNotesTree()
{
- STICKYNOTE *pt;
-
while (g_Stickies) // empty whole tree
{
- pt = (STICKYNOTE*)g_Stickies->ptrdata;
+ STICKYNOTE *pt = (STICKYNOTE*)g_Stickies->ptrdata;
if (pt->SNHwnd) DestroyWindow(pt->SNHwnd);
SAFE_FREE((void**)&pt->title);
SAFE_FREE((void**)&pt->data);
@@ -680,44 +668,18 @@ static void PurgeNotesTree()
g_Stickies = NULL;
}
-void SaveNotes(void)
-{
- JustSaveNotes();
- PurgeNotesTree();
-}
-
void PurgeNotes(void)
{
- int NotesCount, I;
char ValueName[16];
- NotesCount = db_get_dw(0,MODULENAME,"NotesData",0);
- for(I = 0; I < NotesCount; I++)
+ int NotesCount = db_get_dw(0,MODULENAME,"NotesData",0);
+ for(int I = 0; I < NotesCount; I++)
{
mir_snprintf(ValueName, "NotesData%d", I);
db_unset(0,MODULENAME,ValueName);
}
}
-void OnDeleteNote(HWND hdlg, STICKYNOTE *SN)
-{
- if (MessageBoxW(hdlg, TranslateT("Are you sure you want to delete this note?"), TranslateT(SECTIONNAME), MB_OKCANCEL) == IDOK)
- {
- if (SN->SNHwnd)
- DestroyWindow(SN->SNHwnd);
- TreeDelete(&g_Stickies,SN);
- SAFE_FREE((void**)&SN->data);
- if (SN->pCustomFont)
- {
- DeleteObject(SN->pCustomFont->hFont);
- free(SN->pCustomFont);
- }
- SAFE_FREE((void**)&SN);
- JustSaveNotes();
- NOTIFY_LIST();
- }
-}
-
void DeleteNotes(void)
{
PurgeNotes();
@@ -726,58 +688,8 @@ void DeleteNotes(void)
NOTIFY_LIST();
}
-void ShowHideNotes(void)
-{
- BOOL Visible;
-
- if (!g_Stickies)
- return;
-
- // if some notes are hidden but others visible then first make all visible
- // only toggle vis state if all are hidden or all are visible
-
- UINT nHideCount = 0, nVisCount = 0;
- TREEELEMENT *TTE = g_Stickies;
- while (TTE)
- {
- if (((STICKYNOTE*)TTE->ptrdata)->Visible)
- nVisCount++;
- else
- nHideCount++;
-
- TTE = (TREEELEMENT*)TTE->next;
- }
-
- if (!nVisCount)
- Visible = TRUE;
- else if (!nHideCount)
- Visible = FALSE;
- else
- Visible = TRUE;
-
- int bShow = Visible ? SW_SHOWNA : SW_HIDE;
-
- TTE = g_Stickies;
- while (TTE)
- {
- STICKYNOTE *SN = (STICKYNOTE*)TTE->ptrdata;
-
- if ((!Visible) != (!SN->Visible))
- {
- ShowWindow(SN->SNHwnd, bShow);
- SN->Visible = Visible;
- }
-
- TTE = (TREEELEMENT*)TTE->next;
- }
-
- JustSaveNotes();
-}
-
void BringAllNotesToFront(STICKYNOTE *pActive)
{
- TREEELEMENT *TTE;
-
if (!g_Stickies)
return;
@@ -785,9 +697,7 @@ void BringAllNotesToFront(STICKYNOTE *pActive)
// is active, it refuses to move notes to top like it should with HWND_TOP. as a workaround still doesn't
// work 100% of the time, but at least more often, we first move not to top-most then for non-always-on-top
// notes we demote them back as a non top-most window
-
- TTE = g_Stickies;
- while (TTE)
+ for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next)
{
STICKYNOTE *SN = (STICKYNOTE*)TTE->ptrdata;
@@ -797,8 +707,6 @@ void BringAllNotesToFront(STICKYNOTE *pActive)
if (!SN->OnTop)
SetWindowPos(SN->SNHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
}
-
- TTE = (TREEELEMENT*)TTE->next;
}
if (pActive)
@@ -809,12 +717,10 @@ void BringAllNotesToFront(STICKYNOTE *pActive)
}
}
-static void JustSaveNotesEx(STICKYNOTE *pModified)
+// pModified optionally points to the modified note that invoked the JustSaveNotesEx call
+static void JustSaveNotesEx(STICKYNOTE *pModified = NULL)
{
- // pModified optionally points to the modified note that invoked the JustSaveNotesEx call
-
- TREEELEMENT *TTE;
- int I, NotesCount = TreeGetCount(g_Stickies);
+ int I = 0, NotesCount = TreeGetCount(g_Stickies);
int n, l;
char ValueName[32];
WINDOWPLACEMENT wp;
@@ -828,7 +734,7 @@ static void JustSaveNotesEx(STICKYNOTE *pModified)
db_set_dw(0, MODULENAME, "NotesData", NotesCount);
- for (TTE = g_Stickies, I = 0; TTE; TTE = (TREEELEMENT*)TTE->next, I++)
+ for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next, I++)
{
STICKYNOTE *pNote = (STICKYNOTE*)TTE->ptrdata;
BOOL bDeleteTData = TRUE;
@@ -963,9 +869,73 @@ static void JustSaveNotesEx(STICKYNOTE *pModified)
NOTIFY_LIST();
}
-__inline void JustSaveNotes(void)
+void OnDeleteNote(HWND hdlg, STICKYNOTE *SN)
{
- JustSaveNotesEx(NULL);
+ if (MessageBoxW(hdlg, TranslateT("Are you sure you want to delete this note?"), TranslateT(SECTIONNAME), MB_OKCANCEL) == IDOK)
+ {
+ if (SN->SNHwnd)
+ DestroyWindow(SN->SNHwnd);
+ TreeDelete(&g_Stickies, SN);
+ SAFE_FREE((void**)&SN->data);
+ if (SN->pCustomFont)
+ {
+ DeleteObject(SN->pCustomFont->hFont);
+ free(SN->pCustomFont);
+ }
+ SAFE_FREE((void**)&SN);
+ JustSaveNotesEx();
+ NOTIFY_LIST();
+ }
+}
+
+void ShowHideNotes(void)
+{
+ BOOL Visible;
+
+ if (!g_Stickies)
+ return;
+
+ // if some notes are hidden but others visible then first make all visible
+ // only toggle vis state if all are hidden or all are visible
+
+ UINT nHideCount = 0, nVisCount = 0;
+
+ for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next)
+ {
+ if (((STICKYNOTE*)TTE->ptrdata)->Visible)
+ nVisCount++;
+ else
+ nHideCount++;
+ }
+
+ if (!nVisCount)
+ Visible = TRUE;
+ else if (!nHideCount)
+ Visible = FALSE;
+ else
+ Visible = TRUE;
+
+ int bShow = Visible ? SW_SHOWNA : SW_HIDE;
+
+
+ for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next)
+ {
+ STICKYNOTE *SN = (STICKYNOTE*)TTE->ptrdata;
+
+ if ((!Visible) != (!SN->Visible))
+ {
+ ShowWindow(SN->SNHwnd, bShow);
+ SN->Visible = Visible;
+ }
+ }
+
+ JustSaveNotesEx();
+}
+
+void SaveNotes(void)
+{
+ JustSaveNotesEx();
+ PurgeNotesTree();
}
@@ -974,9 +944,6 @@ __inline void JustSaveNotes(void)
static int FindMenuItem(HMENU h, LPTSTR lpszName)
{
- UINT i;
- char s[128];
-
int n = GetMenuItemCount(h);
if (n <= 0)
@@ -985,8 +952,10 @@ static int FindMenuItem(HMENU h, LPTSTR lpszName)
}
// searches for a menu item based on name (used to avoid hardcoding item indices for sub-menus)
- for (i=0; i<(UINT)n; i++)
+ for (UINT i=0; i<(UINT)n; i++)
{
+ char s[128];
+
if ( GetMenuString(h, i, s, 128, MF_BYPOSITION) )
{
if ( !mir_strcmp(s, lpszName) )
@@ -999,9 +968,8 @@ static int FindMenuItem(HMENU h, LPTSTR lpszName)
return -1;
}
-static BOOL DoContextMenu(HWND AhWnd,WPARAM wParam,LPARAM lParam)
+static BOOL DoContextMenu(HWND AhWnd,WPARAM,LPARAM lParam)
{
- int n, i;
STICKYNOTE *SN = (STICKYNOTE*)GetProp(AhWnd, "ctrldata");
HMENU hMenuLoad, FhMenu, hSub;
@@ -1018,16 +986,16 @@ static BOOL DoContextMenu(HWND AhWnd,WPARAM wParam,LPARAM lParam)
// NOTE: names used for FindMenuItem would need to include & chars if such shortcuts are added to the menus
- n = FindMenuItem(FhMenu, "Appearance");
+ int n = FindMenuItem(FhMenu, "Appearance");
if (n >= 0 && (hSub = GetSubMenu(FhMenu, n)))
{
HMENU hBg = GetSubMenu(hSub, FindMenuItem(hSub, "Background Color"));
HMENU hFg = GetSubMenu(hSub, FindMenuItem(hSub, "Text Color"));
- for (i=0; i<_countof(clrPresets); i++)
+ for (int i=0; i<_countof(clrPresets); i++)
InsertMenu(hBg, i, MF_BYPOSITION|MF_OWNERDRAW, IDM_COLORPRESET_BG+i, Translate(clrPresets[i].szName));
- for (i=0; i<_countof(clrPresets); i++)
+ for (int i=0; i<_countof(clrPresets); i++)
InsertMenu(hFg, i, MF_BYPOSITION|MF_OWNERDRAW, IDM_COLORPRESET_FG+i, Translate(clrPresets[i].szName));
}
@@ -1037,10 +1005,10 @@ static BOOL DoContextMenu(HWND AhWnd,WPARAM wParam,LPARAM lParam)
return TRUE;
}
-static void MeasureColorPresetMenuItem(HWND hdlg, LPMEASUREITEMSTRUCT lpMeasureItem, struct ColorPreset *clrPresets)
+static void MeasureColorPresetMenuItem(HWND hdlg, LPMEASUREITEMSTRUCT lpMeasureItem, struct ColorPreset *clrPresets2)
{
HDC hdc = GetDC(hdlg);
- LPSTR lpsz = Translate(clrPresets->szName);
+ LPSTR lpsz = Translate(clrPresets2->szName);
SIZE sz;
GetTextExtentPoint32(hdc, lpsz, (int)mir_strlen(lpsz), &sz);
ReleaseDC(hdlg, hdc);
@@ -1049,9 +1017,9 @@ static void MeasureColorPresetMenuItem(HWND hdlg, LPMEASUREITEMSTRUCT lpMeasureI
lpMeasureItem->itemHeight = (sz.cy+2)>18 ? sz.cy+2 : 18;
}
-static void PaintColorPresetMenuItem(LPDRAWITEMSTRUCT lpDrawItem, struct ColorPreset *clrPresets)
+static void PaintColorPresetMenuItem(LPDRAWITEMSTRUCT lpDrawItem, struct ColorPreset *clrPresets2)
{
- UINT n = lpDrawItem->itemID - IDM_COLORPRESET_BG;
+// UINT n = lpDrawItem->itemID - IDM_COLORPRESET_BG;
RECT rect;
rect.left = lpDrawItem->rcItem.left + 50;
rect.top = lpDrawItem->rcItem.top;
@@ -1072,7 +1040,7 @@ static void PaintColorPresetMenuItem(LPDRAWITEMSTRUCT lpDrawItem, struct ColorPr
}
SetBkMode(lpDrawItem->hDC, TRANSPARENT);
- DrawText(lpDrawItem->hDC, clrPresets->szName, -1, &rect, DT_LEFT | DT_SINGLELINE | DT_END_ELLIPSIS | DT_VCENTER);
+ DrawText(lpDrawItem->hDC, clrPresets2->szName, -1, &rect, DT_LEFT | DT_SINGLELINE | DT_END_ELLIPSIS | DT_VCENTER);
int h = lpDrawItem->rcItem.bottom - lpDrawItem->rcItem.top;
rect.left = lpDrawItem->rcItem.left + 5;
@@ -1083,7 +1051,7 @@ static void PaintColorPresetMenuItem(LPDRAWITEMSTRUCT lpDrawItem, struct ColorPr
FrameRect(lpDrawItem->hDC, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH));
rect.left++; rect.top++;
rect.right--; rect.bottom--;
- SetDCBrushColor(lpDrawItem->hDC, clrPresets->color);
+ SetDCBrushColor(lpDrawItem->hDC, clrPresets2->color);
FillRect(lpDrawItem->hDC, &rect, (HBRUSH)GetStockObject(DC_BRUSH));
}
@@ -1152,7 +1120,7 @@ static void SetNoteTextControl(STICKYNOTE *SN)
}
-static UINT_PTR CALLBACK CFHookProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static UINT_PTR CALLBACK CFHookProc(HWND hdlg, UINT msg, WPARAM, LPARAM)
{
if (msg == WM_INITDIALOG)
{
@@ -1186,6 +1154,7 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
return TRUE;
}
+
case WM_TIMER:
if (wParam == 1025)
{
@@ -1195,18 +1164,17 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
JustSaveNotesEx(SN);
}
break;
+
case WM_MOVE:
- {
- KillTimer(hdlg, 1025);
- SetTimer(hdlg, 1025, NOTE_CHANGE_COMMIT_DELAY, 0);
- return TRUE;
- }
+ KillTimer(hdlg, 1025);
+ SetTimer(hdlg, 1025, NOTE_CHANGE_COMMIT_DELAY, 0);
+ return TRUE;
+
case WM_CREATE:
{
STICKYNOTE *SN = (STICKYNOTE*)GetProp(hdlg, "ctrldata");
CREATESTRUCT *CS = (CREATESTRUCT *)lParam;
- HWND H;
DWORD mystyle;
SN = (STICKYNOTE*)CS->lpCreateParams;
@@ -1214,7 +1182,7 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
BringWindowToTop(hdlg);
mystyle = WS_CHILD | WS_VISIBLE | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN;
if (g_ShowScrollbar) mystyle |= WS_VSCROLL;
- H = CreateWindow(RICHEDIT_CLASS, 0, mystyle, 0, 0, CS->cx-3-3, CS->cy-3-(3+14), hdlg, (HMENU)1, hmiranda, 0);
+ HWND H = CreateWindow(RICHEDIT_CLASS, 0, mystyle, 0, 0, CS->cx-3-3, CS->cy-3-(3+14), hdlg, (HMENU)1, hmiranda, 0);
SN->REHwnd = H;
SendMessage(H, EM_SETTEXTMODE, TM_PLAINTEXT, 0);
SendMessage(H, EM_LIMITTEXT, MAX_NOTE_LEN, 0);
@@ -1223,8 +1191,9 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
SendMessage(H, EM_SETBKGNDCOLOR, 0, SN->BgColor ? (SN->BgColor&0xffffff) : BodyColor);
SendMessage(H, EM_AUTOURLDETECT, 1, 0);
SetNoteTextControl(SN);
- return TRUE;
}
+ return TRUE;
+
case WM_GETMINMAXINFO:
{
MINMAXINFO *mm = (MINMAXINFO*)lParam;
@@ -1234,15 +1203,16 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
mm->ptMinTrackSize.y = 3+3+14;
}
return 0;
+
case WM_ERASEBKGND:
// no BG needed as edit control takes up entire client area
return TRUE;
+
case WM_NCPAINT:
// make window borders have the same color as caption
{
STICKYNOTE *SN = (STICKYNOTE*)GetProp(hdlg,"ctrldata");
- HBRUSH hBkBrush;
RECT rect, wr, r;
//HDC hdc = GetDCEx(hdlg, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN);
HDC hdc = GetWindowDC(hdlg);
@@ -1257,7 +1227,7 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
rect = wr;
OffsetRect(&rect, -wr.left, -wr.top);
- hBkBrush = (HBRUSH)GetStockObject(DC_BRUSH);
+ HBRUSH hBkBrush = (HBRUSH)GetStockObject(DC_BRUSH);
SetDCBrushColor(hdc, GetCaptionColor((SN && SN->BgColor) ? SN->BgColor : BodyColor));
// draw all frame sides separately to avoid filling client area (which flickers)
@@ -1324,12 +1294,14 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
pRect->right -= 3;
pRect->left += 3;
pRect->top += 3+14;
- return WVR_REDRAW;
}
+ return WVR_REDRAW;
+
case WM_NCACTIVATE:
// update window (so that parts that potentially became visible through activation get redrawn immediately)
RedrawWindow(hdlg, NULL, NULL, RDW_UPDATENOW);
return TRUE;
+
case WM_NOTIFY:
if (LOWORD(wParam) == 1)
{
@@ -1353,6 +1325,7 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
return FALSE;
}
break;
+
case WM_NCHITTEST:
{
int r = DefWindowProc(hdlg,message,wParam,lParam);
@@ -1367,6 +1340,7 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
}
return r;
}
+
case WM_NCLBUTTONDOWN:
if (wParam == HTCAPTION && g_ShowNoteButtons)
{
@@ -1397,6 +1371,7 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
}
}
return DefWindowProc(hdlg,message,wParam,lParam);
+
case WM_MEASUREITEM:
{
LPMEASUREITEMSTRUCT lpMeasureItem = (LPMEASUREITEMSTRUCT)lParam;
@@ -1416,6 +1391,7 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
}
}
break;
+
case WM_DRAWITEM:
if (!wParam)
{
@@ -1436,35 +1412,31 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
}
}
break;
+
case WM_COMMAND:
{
STICKYNOTE *SN = (STICKYNOTE*)GetProp(hdlg, "ctrldata");
- HWND H;
- UINT id;
-
switch ( HIWORD(wParam) )
{
case EN_CHANGE:
case EN_VSCROLL:
case EN_HSCROLL:
- {
- KillTimer(hdlg,1025);
- SetTimer(hdlg, 1025, NOTE_CHANGE_COMMIT_DELAY, 0);
- }
+ KillTimer(hdlg,1025);
+ SetTimer(hdlg, 1025, NOTE_CHANGE_COMMIT_DELAY, 0);
break;
}
- id = (UINT) LOWORD(wParam);
+ UINT id = (UINT) LOWORD(wParam);
- H = SN->REHwnd;
+ HWND H = SN->REHwnd;
if (id >= IDM_COLORPRESET_BG && id <= IDM_COLORPRESET_BG+_countof(clrPresets))
{
SN->BgColor = clrPresets[id-IDM_COLORPRESET_BG].color | 0xff000000;
SendMessage(H, EM_SETBKGNDCOLOR, 0, SN->BgColor & 0xffffff);
RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
- JustSaveNotes();
+ JustSaveNotesEx();
return FALSE;
}
else if (id >= IDM_COLORPRESET_FG && id <= IDM_COLORPRESET_FG+_countof(clrPresets))
@@ -1476,17 +1448,16 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
CF.crTextColor = SN->FgColor & 0xffffff;
SendMessage(H, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CF);
RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
- JustSaveNotes();
+ JustSaveNotesEx();
return FALSE;
}
switch (id)
{
case ID_CONTEXTMENUNOTEPOPUP_NEWNOTE:
- {
- PluginMenuCommandAddNew(0,0);
- }
+ PluginMenuCommandAddNew(0,0);
break;
+
case ID_APPEARANCE_CUSTOMBG:
{
COLORREF custclr[16] = {0};
@@ -1503,7 +1474,7 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
SN->BgColor = cc.rgbResult | 0xff000000;
SendMessage(H, EM_SETBKGNDCOLOR, 0, SN->BgColor&0xffffff);
RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
- JustSaveNotes();
+ JustSaveNotesEx();
}
}
break;
@@ -1527,7 +1498,7 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
CF.crTextColor = SN->FgColor & 0xffffff;
SendMessage(H, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CF);
RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
- JustSaveNotes();
+ JustSaveNotesEx();
}
}
break;
@@ -1572,18 +1543,18 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
SendMessage(H, WM_SETFONT, (WPARAM)(SN->pCustomFont ? SN->pCustomFont->hFont : hBodyFont), FALSE);
SetNoteTextControl(SN);
RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
- JustSaveNotes();
+ JustSaveNotesEx();
}
}
break;
+
case ID_BACKGROUNDCOLOR_RESET:
- {
- SN->BgColor = 0;
- SendMessage(H, EM_SETBKGNDCOLOR, 0, (LPARAM)BodyColor);
- RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
- JustSaveNotes();
- }
+ SN->BgColor = 0;
+ SendMessage(H, EM_SETBKGNDCOLOR, 0, (LPARAM)BodyColor);
+ RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
+ JustSaveNotesEx();
break;
+
case ID_TEXTCOLOR_RESET:
{
CHARFORMAT CF = {0};
@@ -1593,26 +1564,26 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
CF.crTextColor = BodyFontColor;
SendMessage(H, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CF);
RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
- JustSaveNotes();
}
+ JustSaveNotesEx();
break;
+
case ID_FONT_RESET:
+ if (SN->pCustomFont)
{
- if (SN->pCustomFont)
- {
- DeleteObject(SN->pCustomFont->hFont);
- free(SN->pCustomFont);
- SN->pCustomFont = NULL;
-
- // clear text first to force a reformatting w.r.w scrollbar
- SetWindowText(H, "");
- SendMessage(H, WM_SETFONT, (WPARAM)hBodyFont, FALSE);
- SetNoteTextControl(SN);
- RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
- JustSaveNotes();
- }
+ DeleteObject(SN->pCustomFont->hFont);
+ free(SN->pCustomFont);
+ SN->pCustomFont = NULL;
+
+ // clear text first to force a reformatting w.r.w scrollbar
+ SetWindowText(H, "");
+ SendMessage(H, WM_SETFONT, (WPARAM)hBodyFont, FALSE);
+ SetNoteTextControl(SN);
+ RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
+ JustSaveNotesEx();
}
break;
+
case ID_CONTEXTMENUNOTEPOPUP_PASTETITLE:
{
char s[MAX_TITLE_LEN+1];
@@ -1623,10 +1594,11 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
SN->title = _strdup(s);
SN->CustomTitle = TRUE;
RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
- JustSaveNotes();
+ JustSaveNotesEx();
}
}
break;
+
case ID_CONTEXTMENUNOTEPOPUP_RESETTITLE:
if (SN->CustomTitle)
{
@@ -1637,41 +1609,58 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
}
InitNoteTitle(SN);
RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
- JustSaveNotes();
+ JustSaveNotesEx();
}
break;
+
case IDM_REMOVENOTE:
OnDeleteNote(hdlg, SN);
break;
+
case IDM_HIDENOTE:
- {
- SN->Visible = FALSE;
- ShowWindow(hdlg,SW_HIDE);
- JustSaveNotes();
- }
+ SN->Visible = FALSE;
+ ShowWindow(hdlg,SW_HIDE);
+ JustSaveNotesEx();
+ break;
+
+ case IDM_COPY:
+ SendMessage(H,WM_COPY,0,0);
+ break;
+
+ case IDM_PASTE:
+ SendMessage(H,WM_PASTE,0,0);
+ break;
+
+ case IDM_CUT:
+ SendMessage(H,WM_CUT,0,0);
break;
- case IDM_COPY: SendMessage(H,WM_COPY,0,0); break;
- case IDM_PASTE: SendMessage(H,WM_PASTE,0,0); break;
- case IDM_CUT: SendMessage(H,WM_CUT,0,0); break;
- case IDM_CLEAR: SendMessage(H,WM_CLEAR,0,0); break;
- case IDM_UNDO: SendMessage(H,WM_UNDO,0,0); break;
+
+ case IDM_CLEAR:
+ SendMessage(H,WM_CLEAR,0,0);
+ break;
+
+ case IDM_UNDO:
+ SendMessage(H,WM_UNDO,0,0);
+ break;
+
case IDM_TOGGLEONTOP:
- {
- SN->OnTop = !SN->OnTop;
- SetWindowPos(hdlg, SN->OnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0,0,0,0, SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);
- RedrawWindow(hdlg, NULL, NULL, RDW_FRAME|RDW_INVALIDATE|RDW_UPDATENOW);
- JustSaveNotes();
- }
+ SN->OnTop = !SN->OnTop;
+ SetWindowPos(hdlg, SN->OnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0,0,0,0, SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);
+ RedrawWindow(hdlg, NULL, NULL, RDW_FRAME|RDW_INVALIDATE|RDW_UPDATENOW);
+ JustSaveNotesEx();
break;
+
case ID_CONTEXTMENUNOTEPOPUP_VIEWNOTES:
ListNotes();
break;
+
case ID_CONTEXTMENUNOTEPOPUP_BRINGALLTOTOP:
BringAllNotesToFront(SN);
break;
}
return TRUE;
}
+
case WM_NCDESTROY:
RemoveProp(hdlg, "ctrldata");
break;
@@ -1686,23 +1675,6 @@ INT_PTR CALLBACK StickyNoteWndProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
return FALSE;
}
-
-/////////////////////////////////////////////////////////////////////
-// Notes List Dialog (uses same dialog template as reminder list)
-
-void ListNotes(void)
-{
- if (!ListNotesVisible)
- {
- CreateDialog(hinstance, MAKEINTRESOURCE(IDD_LISTREMINDERS), 0, DlgProcViewNotes);
- ListNotesVisible = TRUE;
- }
- else
- {
- BringWindowToTop(LV);
- }
-}
-
static void EditNote(STICKYNOTE *SN)
{
if (!SN)
@@ -1711,7 +1683,7 @@ static void EditNote(STICKYNOTE *SN)
if (!SN->Visible)
{
SN->Visible = TRUE;
- JustSaveNotes();
+ JustSaveNotesEx();
}
SetWindowPos(SN->SNHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
@@ -1772,12 +1744,9 @@ char* GetPreviewString(const char *lpsz)
static void InitListView(HWND AHLV)
{
- LV_ITEM lvTIt;
- int I;
+ int I = 0;
char *S;
char S1[128];
- STICKYNOTE *pNote;
- TREEELEMENT *TTE;
char *V = Translate("Visible");
char *T = Translate("Top");
@@ -1785,13 +1754,12 @@ static void InitListView(HWND AHLV)
ListView_SetHoverTime(AHLV,700);
ListView_SetExtendedListViewStyle(AHLV,LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TRACKSELECT);
ListView_DeleteAllItems(AHLV);
-
- I = 0;
- TTE = g_Stickies;
- while (TTE)
+
+ for (TREEELEMENT *TTE = g_Stickies; TTE; TTE = (TREEELEMENT*)TTE->next)
{
- pNote = (STICKYNOTE*)TTE->ptrdata;
+ STICKYNOTE *pNote = (STICKYNOTE*)TTE->ptrdata;
+ LV_ITEM lvTIt;
lvTIt.mask = LVIF_TEXT;
if (!pNote->CustomTitle || !pNote->title)
@@ -1825,7 +1793,6 @@ static void InitListView(HWND AHLV)
ListView_SetItem(AHLV,&lvTIt);
I++;
- TTE = (TREEELEMENT*)TTE->next;
}
ListView_SetItemState(AHLV,0,LVIS_SELECTED,LVIS_SELECTED);
@@ -1869,24 +1836,19 @@ static BOOL DoListContextMenu(HWND AhWnd,WPARAM wParam,LPARAM lParam,STICKYNOTE
}
-INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam,LPARAM lParam)
{
- LV_COLUMN lvCol;
- NMLISTVIEW *NM;
- char *S;
- int I;
-
switch (Message)
{
case WM_SIZE:
- {
- OnListResize(Dialog);
- UpdateGeomFromWnd(Dialog, g_notesListGeom, NULL, 0);
- break;
- }
+ OnListResize(Dialog);
+ UpdateGeomFromWnd(Dialog, g_notesListGeom, NULL, 0);
+ break;
+
case WM_MOVE:
UpdateGeomFromWnd(Dialog, g_notesListGeom, NULL, 0);
break;
+
case WM_GETMINMAXINFO:
{
MINMAXINFO *mm = (MINMAXINFO*)lParam;
@@ -1894,21 +1856,20 @@ INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam,LPARAM
mm->ptMinTrackSize.y = 300;
}
return 0;
+
case WM_RELOAD:
- {
- SetDlgItemText(Dialog,IDC_REMINDERDATA,"");
- InitListView(GetDlgItem(Dialog,IDC_LISTREMINDERS));
- return TRUE;
- }
+ SetDlgItemText(Dialog,IDC_REMINDERDATA,"");
+ InitListView(GetDlgItem(Dialog,IDC_LISTREMINDERS));
+ return TRUE;
+
case WM_CONTEXTMENU:
{
- HWND H;
STICKYNOTE *pNote = NULL;
- H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
+ HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
if ( ListView_GetSelectedCount(H) )
{
- I = ListView_GetSelectionMark(H);
+ int I = ListView_GetSelectionMark(H);
if (I != -1)
{
pNote = (STICKYNOTE*)TreeGetAt(g_Stickies, I);
@@ -1919,20 +1880,23 @@ INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam,LPARAM
return TRUE;
}
break;
+
case WM_INITDIALOG:
- {
- Window_SetIcon_IcoLib(Dialog, iconList[13].hIcolib);
+ Window_SetIcon_IcoLib(Dialog, iconList[13].hIcolib);
- SetWindowText(Dialog, LPGEN("Notes"));
+ SetWindowText(Dialog, LPGEN("Notes"));
- TranslateDialogDefault(Dialog);
+ TranslateDialogDefault(Dialog);
- SetDlgItemText(Dialog, IDC_REMINDERDATA, "");
+ SetDlgItemText(Dialog, IDC_REMINDERDATA, "");
+ {
HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
+
+ LV_COLUMN lvCol;
lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
- S = Translate("Note text");
+ char *S = Translate("Note text");
lvCol.pszText = S;
lvCol.cx = g_notesListColGeom[3];
ListView_InsertColumn(H,0,&lvCol);
@@ -1970,8 +1934,9 @@ INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam,LPARAM
wp.rcNormalPosition.bottom = g_notesListGeom[3] + g_notesListGeom[1];
SetWindowPlacement(Dialog, &wp);
}
- return TRUE;
}
+ return TRUE;
+
case WM_CLOSE:
DestroyWindow(Dialog);
ListNotesVisible = FALSE;
@@ -1986,23 +1951,21 @@ INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam,LPARAM
{
if (wParam == IDC_LISTREMINDERS)
{
- NM = (NMLISTVIEW *)lParam;
+ LPNMLISTVIEW NM = (LPNMLISTVIEW)lParam;
switch (NM->hdr.code)
{
case LVN_ITEMCHANGED:
{
- S = ((STICKYNOTE*)TreeGetAt(g_Stickies,NM->iItem))->data;
+ char *S = ((STICKYNOTE*)TreeGetAt(g_Stickies,NM->iItem))->data;
SetDlgItemText(Dialog,IDC_REMINDERDATA,S);
}
break;
case NM_DBLCLK:
{
- HWND H;
-
- H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
+ HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
if ( ListView_GetSelectedCount(H) )
{
- I = ListView_GetSelectionMark(H);
+ int I = ListView_GetSelectionMark(H);
if (I != -1)
{
EditNote((STICKYNOTE *)TreeGetAt(g_Stickies, I));
@@ -2014,7 +1977,7 @@ INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam,LPARAM
}
else if (wParam == IDC_LISTREMINDERS_HEADER)
{
- NMHEADER *NM = (NMHEADER*)lParam;
+ LPNMHEADER NM = (LPNMHEADER)lParam;
switch (NM->hdr.code)
{
case HDN_ENDTRACK:
@@ -2024,18 +1987,17 @@ INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam,LPARAM
}
}
break;
+
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case ID_CONTEXTMENUNOTELISTVIEW_EDITNOTE:
{
- HWND H;
-
- H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
+ HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
if ( ListView_GetSelectedCount(H) )
{
- I = ListView_GetSelectionMark(H);
+ int I = ListView_GetSelectionMark(H);
if (I != -1)
{
EditNote((STICKYNOTE*)TreeGetAt(g_Stickies, I));
@@ -2045,66 +2007,58 @@ INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam,LPARAM
return TRUE;
case ID_CONTEXTMENUNOTELISTVIEW_TOGGLEVISIBILITY:
{
- HWND H;
-
- H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
+ HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
if ( ListView_GetSelectedCount(H) )
{
- I = ListView_GetSelectionMark(H);
+ int I = ListView_GetSelectionMark(H);
if (I != -1)
{
STICKYNOTE *SN = (STICKYNOTE*)TreeGetAt(g_Stickies, I);
SN->Visible = !SN->Visible;
ShowWindow(SN->SNHwnd,SN->Visible?SW_SHOWNA:SW_HIDE);
- JustSaveNotes();
+ JustSaveNotesEx();
}
}
}
return TRUE;
case IDM_TOGGLEONTOP:
{
- HWND H;
-
- H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
+ HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
if ( ListView_GetSelectedCount(H) )
{
- I = ListView_GetSelectionMark(H);
+ int I = ListView_GetSelectionMark(H);
if (I != -1)
{
STICKYNOTE *SN = (STICKYNOTE*)TreeGetAt(g_Stickies,I);
SN->OnTop = !SN->OnTop;
SetWindowPos(SN->SNHwnd, SN->OnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0,0,0,0, SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);
RedrawWindow(SN->SNHwnd, NULL, NULL, RDW_FRAME|RDW_INVALIDATE|RDW_UPDATENOW);
- JustSaveNotes();
+ JustSaveNotesEx();
}
}
}
return TRUE;
+
case IDC_CLOSE:
- {
- DestroyWindow(Dialog);
- ListNotesVisible = FALSE;
- return TRUE;
- }
+ DestroyWindow(Dialog);
+ ListNotesVisible = FALSE;
+ return TRUE;
+
case ID_CONTEXTMENUNOTEPOPUP_NEWNOTE:
case IDC_ADDNEWREMINDER:
- {
- PluginMenuCommandAddNew(0,0);
- return TRUE;
- }
+ PluginMenuCommandAddNew(0,0);
+ return TRUE;
+
case ID_CONTEXTMENUNOTELISTVIEW_DELETEALLNOTES:
- {
- PluginMenuCommandDeleteAll(0,0);
- return TRUE;
- }
+ PluginMenuCommandDeleteAll(0,0);
+ return TRUE;
+
case IDM_REMOVENOTE:
{
- HWND H;
-
- H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
+ HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
if ( ListView_GetSelectedCount(H) )
{
- I = ListView_GetSelectionMark(H);
+ int I = ListView_GetSelectionMark(H);
if (I != -1)
{
OnDeleteNote(Dialog, (STICKYNOTE*)TreeGetAt(g_Stickies, I));
@@ -2113,17 +2067,32 @@ INT_PTR CALLBACK DlgProcViewNotes(HWND Dialog,UINT Message,WPARAM wParam,LPARAM
}
return TRUE;
case ID_CONTEXTMENUNOTELISTVIEW_SHOW:
- {
- ShowHideNotes();
- return TRUE;
- }
+ ShowHideNotes();
+ return TRUE;
+
case ID_CONTEXTMENUNOTEPOPUP_BRINGALLTOTOP:
- {
- BringAllNotesToFront(NULL);
- return TRUE;
- }
+ BringAllNotesToFront(NULL);
+ return TRUE;
+
}
}
}
return FALSE;
}
+
+
+/////////////////////////////////////////////////////////////////////
+// Notes List Dialog (uses same dialog template as reminder list)
+
+void ListNotes(void)
+{
+ if (!ListNotesVisible)
+ {
+ CreateDialog(hinstance, MAKEINTRESOURCE(IDD_LISTREMINDERS), 0, DlgProcViewNotes);
+ ListNotesVisible = TRUE;
+ }
+ else
+ {
+ BringWindowToTop(LV);
+ }
+}
diff --git a/plugins/NotesAndReminders/src/options.cpp b/plugins/NotesAndReminders/src/options.cpp
index fea1ee5f5c..560cf9e2bf 100644
--- a/plugins/NotesAndReminders/src/options.cpp
+++ b/plugins/NotesAndReminders/src/options.cpp
@@ -154,7 +154,7 @@ static BYTE MsgDlgGetCPDefaultCharset()
}
}
-static int CALLBACK EnumFontFamExProc(const LOGFONT *lpelfe, const TEXTMETRIC *lpntme, DWORD FontType, LPARAM lParam)
+static int CALLBACK EnumFontFamExProc(const LOGFONT *, const TEXTMETRIC *, DWORD, LPARAM lParam)
{
*(int*)lParam = 1;
return 0;
@@ -200,7 +200,7 @@ static void InitFonts()
}
-static int FS_FontsChanged(WPARAM wParam, LPARAM lParam)
+static int FS_FontsChanged(WPARAM, LPARAM)
{
InitFonts();
@@ -210,7 +210,7 @@ static int FS_FontsChanged(WPARAM wParam, LPARAM lParam)
return 0;
}
-static int FS_ColorChanged(WPARAM wParam, LPARAM lParam)
+static int FS_ColorChanged(WPARAM, LPARAM)
{
LoadNRFont(NR_FONTID_CAPTION, &lfCaption, (COLORREF*)&CaptionFontColor);
LoadNRFont(NR_FONTID_BODY, &lfBody, (COLORREF*)&BodyFontColor);
@@ -328,58 +328,52 @@ static void TrimString(char *s)
INT_PTR CALLBACK DlgProcOptions(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
- BOOL LB;
- WORD SzT;
- void *P;
- int i;
-
switch (message) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hdlg);
- SendDlgItemMessage(hdlg, IDC_SLIDER_TRANSPARENCY, TBM_SETRANGE, TRUE, MAKELONG(0, 255 - MIN_ALPHA));
- SendDlgItemMessage(hdlg, IDC_SLIDER_TRANSPARENCY, TBM_SETPOS, TRUE, 255 - g_Transparency);
-
- CheckDlgButton(hdlg, IDC_CHECK_HIDENOTES, !g_ShowNotesAtStart ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CHECK_MENUS, g_AddContListMI ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CHECK_BUTTONS, g_ShowNoteButtons ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CHECK_SCROLLBARS, g_ShowScrollbar ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CHECK_CLOSE, g_CloseAfterAddReminder ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CHECK_MSI, !g_UseDefaultPlaySound ? BST_CHECKED : BST_UNCHECKED);
- SetDlgItemInt(hdlg, IDC_EDIT_WIDTH, g_NoteWidth, FALSE);
- SetDlgItemInt(hdlg, IDC_EDIT_HEIGHT, g_NoteHeight, FALSE);
-
- SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_RESETCONTENT, 0, 0);
- for (i = 0; i < _countof(dateFormats); i++)
- SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_ADDSTRING, 0, (LPARAM)dateFormats[i].lpszUI);
- for (i = 0; i < _countof(timeFormats); i++)
- SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_ADDSTRING, 0, (LPARAM)timeFormats[i].lpszUI);
- SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_ADDSTRING, 0, (LPARAM)Translate("None"));
- SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_ADDSTRING, 0, (LPARAM)Translate("None"));
+ TranslateDialogDefault(hdlg);
+ SendDlgItemMessage(hdlg, IDC_SLIDER_TRANSPARENCY, TBM_SETRANGE, TRUE, MAKELONG(0, 255 - MIN_ALPHA));
+ SendDlgItemMessage(hdlg, IDC_SLIDER_TRANSPARENCY, TBM_SETPOS, TRUE, 255 - g_Transparency);
+
+ CheckDlgButton(hdlg, IDC_CHECK_HIDENOTES, !g_ShowNotesAtStart ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_CHECK_MENUS, g_AddContListMI ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_CHECK_BUTTONS, g_ShowNoteButtons ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_CHECK_SCROLLBARS, g_ShowScrollbar ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_CHECK_CLOSE, g_CloseAfterAddReminder ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_CHECK_MSI, !g_UseDefaultPlaySound ? BST_CHECKED : BST_UNCHECKED);
+ SetDlgItemInt(hdlg, IDC_EDIT_WIDTH, g_NoteWidth, FALSE);
+ SetDlgItemInt(hdlg, IDC_EDIT_HEIGHT, g_NoteHeight, FALSE);
+
+ SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_RESETCONTENT, 0, 0);
+ SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_RESETCONTENT, 0, 0);
+ for (int i = 0; i < _countof(dateFormats); i++)
+ SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_ADDSTRING, 0, (LPARAM)dateFormats[i].lpszUI);
+ for (int i = 0; i < _countof(timeFormats); i++)
+ SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_ADDSTRING, 0, (LPARAM)timeFormats[i].lpszUI);
+ SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_ADDSTRING, 0, (LPARAM)Translate("None"));
+ SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_ADDSTRING, 0, (LPARAM)Translate("None"));
+
+ SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_SETCURSEL, (WPARAM)(g_NoteTitleDate ? g_NoteTitleDate - 1 : SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_GETCOUNT, 0, 0) - 1), 0);
+ SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_SETCURSEL, (WPARAM)(g_NoteTitleTime ? g_NoteTitleTime - 1 : SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_GETCOUNT, 0, 0) - 1), 0);
+
+ if (g_RemindSMS)
+ SetDlgItemText(hdlg, IDC_EDIT_EMAILSMS, g_RemindSMS);
+ else
+ SetDlgItemText(hdlg, IDC_EDIT_EMAILSMS, "");
+
+ SetDlgItemText(hdlg, IDC_EDIT_ALTBROWSER, g_lpszAltBrowser ? g_lpszAltBrowser : "");
+ return TRUE;
- SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_SETCURSEL, (WPARAM)(g_NoteTitleDate ? g_NoteTitleDate - 1 : SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_GETCOUNT, 0, 0) - 1), 0);
- SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_SETCURSEL, (WPARAM)(g_NoteTitleTime ? g_NoteTitleTime - 1 : SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_GETCOUNT, 0, 0) - 1), 0);
-
- if (g_RemindSMS)
- SetDlgItemText(hdlg, IDC_EDIT_EMAILSMS, g_RemindSMS);
- else
- SetDlgItemText(hdlg, IDC_EDIT_EMAILSMS, "");
-
- SetDlgItemText(hdlg, IDC_EDIT_ALTBROWSER, g_lpszAltBrowser ? g_lpszAltBrowser : "");
- return TRUE;
- }
case WM_HSCROLL:
- {
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- return TRUE;
- }
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
g_ShowNotesAtStart = !(BOOL)IsDlgButtonChecked(hdlg, IDC_CHECK_HIDENOTES);
g_ShowNoteButtons = (BOOL)IsDlgButtonChecked(hdlg, IDC_CHECK_BUTTONS);
g_ShowScrollbar = (BOOL)IsDlgButtonChecked(hdlg, IDC_CHECK_SCROLLBARS);
g_AddContListMI = (BOOL)IsDlgButtonChecked(hdlg, IDC_CHECK_MENUS);
+ BOOL LB;
g_NoteWidth = GetDlgItemInt(hdlg, IDC_EDIT_WIDTH, &LB, FALSE);
g_NoteHeight = GetDlgItemInt(hdlg, IDC_EDIT_HEIGHT, &LB, FALSE);
g_Transparency = 255 - SendDlgItemMessage(hdlg, IDC_SLIDER_TRANSPARENCY, TBM_GETPOS, 0, 0);
@@ -395,12 +389,12 @@ INT_PTR CALLBACK DlgProcOptions(HWND hdlg, UINT message, WPARAM wParam, LPARAM l
g_NoteHeight = 35;
SetDlgItemInt(hdlg, IDC_EDIT_HEIGHT, g_NoteHeight, FALSE);
}
- SzT = (WORD)SendDlgItemMessage(hdlg, IDC_EDIT_EMAILSMS, WM_GETTEXTLENGTH, 0, 0);
+ WORD SzT = (WORD)SendDlgItemMessage(hdlg, IDC_EDIT_EMAILSMS, WM_GETTEXTLENGTH, 0, 0);
if (SzT != 0) {
g_RemindSMS = (char*)realloc(g_RemindSMS, SzT + 1);
GetDlgItemText(hdlg, IDC_EDIT_EMAILSMS, g_RemindSMS, SzT + 1);
}
- P = g_RemindSMS;
+ char *P = g_RemindSMS;
db_set_blob(0, MODULENAME, "RemindEmail", P, SzT);
SzT = (WORD)SendDlgItemMessage(hdlg, IDC_EDIT_ALTBROWSER, WM_GETTEXTLENGTH, 0, 0);
@@ -439,6 +433,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hdlg, UINT message, WPARAM wParam, LPARAM l
return TRUE;
}
break;
+
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_BTN_BROWSEBROWSER:
@@ -463,40 +458,40 @@ INT_PTR CALLBACK DlgProcOptions(HWND hdlg, UINT message, WPARAM wParam, LPARAM l
}
}
break;
+
case IDC_BUTTON_RESET:
- {
- SAFE_FREE((void**)&g_RemindSMS);
- SetDlgItemText(hdlg, IDC_EDIT_EMAILSMS, "");
- if (g_lpszAltBrowser) {
- mir_free(g_lpszAltBrowser);
- g_lpszAltBrowser = NULL;
- }
- SetDlgItemText(hdlg, IDC_EDIT_ALTBROWSER, "");
- g_ShowNotesAtStart = TRUE;
- g_AddContListMI = TRUE;
- g_ShowScrollbar = TRUE;
- g_ShowNoteButtons = TRUE;
- g_NoteTitleDate = 1;
- g_NoteTitleTime = 1;
- g_CloseAfterAddReminder = TRUE;
- g_UseDefaultPlaySound = FALSE;
- CheckDlgButton(hdlg, IDC_CHECK_HIDENOTES, !g_ShowNotesAtStart ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CHECK_MENUS, g_AddContListMI ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CHECK_SCROLLBARS, g_ShowScrollbar ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CHECK_BUTTONS, g_ShowNoteButtons ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CHECK_CLOSE, g_CloseAfterAddReminder ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CHECK_MSI, !g_UseDefaultPlaySound ? BST_CHECKED : BST_UNCHECKED);
- SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_SETCURSEL, (WPARAM)(g_NoteTitleDate - 1), 0);
- SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_SETCURSEL, (WPARAM)(g_NoteTitleTime - 1), 0);
- g_NoteWidth = 179;
- g_NoteHeight = 35;
- SetDlgItemInt(hdlg, IDC_EDIT_WIDTH, g_NoteWidth, FALSE);
- SetDlgItemInt(hdlg, IDC_EDIT_HEIGHT, g_NoteHeight, FALSE);
- g_Transparency = 255;
- SendDlgItemMessage(hdlg, IDC_SLIDER_TRANSPARENCY, TBM_SETPOS, TRUE, 0);
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); // JK optim
- return TRUE;
+ SAFE_FREE((void**)&g_RemindSMS);
+ SetDlgItemText(hdlg, IDC_EDIT_EMAILSMS, "");
+ if (g_lpszAltBrowser) {
+ mir_free(g_lpszAltBrowser);
+ g_lpszAltBrowser = NULL;
}
+ SetDlgItemText(hdlg, IDC_EDIT_ALTBROWSER, "");
+ g_ShowNotesAtStart = TRUE;
+ g_AddContListMI = TRUE;
+ g_ShowScrollbar = TRUE;
+ g_ShowNoteButtons = TRUE;
+ g_NoteTitleDate = 1;
+ g_NoteTitleTime = 1;
+ g_CloseAfterAddReminder = TRUE;
+ g_UseDefaultPlaySound = FALSE;
+ CheckDlgButton(hdlg, IDC_CHECK_HIDENOTES, !g_ShowNotesAtStart ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_CHECK_MENUS, g_AddContListMI ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_CHECK_SCROLLBARS, g_ShowScrollbar ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_CHECK_BUTTONS, g_ShowNoteButtons ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_CHECK_CLOSE, g_CloseAfterAddReminder ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_CHECK_MSI, !g_UseDefaultPlaySound ? BST_CHECKED : BST_UNCHECKED);
+ SendDlgItemMessage(hdlg, IDC_COMBODATE, CB_SETCURSEL, (WPARAM)(g_NoteTitleDate - 1), 0);
+ SendDlgItemMessage(hdlg, IDC_COMBOTIME, CB_SETCURSEL, (WPARAM)(g_NoteTitleTime - 1), 0);
+ g_NoteWidth = 179;
+ g_NoteHeight = 35;
+ SetDlgItemInt(hdlg, IDC_EDIT_WIDTH, g_NoteWidth, FALSE);
+ SetDlgItemInt(hdlg, IDC_EDIT_HEIGHT, g_NoteHeight, FALSE);
+ g_Transparency = 255;
+ SendDlgItemMessage(hdlg, IDC_SLIDER_TRANSPARENCY, TBM_SETPOS, TRUE, 0);
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0); // JK optim
+ return TRUE;
+
case IDC_EDIT_ALTBROWSER:
case IDC_EDIT_EMAILSMS:
case IDC_EDIT_WIDTH:
@@ -504,11 +499,13 @@ INT_PTR CALLBACK DlgProcOptions(HWND hdlg, UINT message, WPARAM wParam, LPARAM l
if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
break;
+
case IDC_COMBODATE:
case IDC_COMBOTIME:
if (HIWORD(wParam) == CBN_SELCHANGE)
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
break;
+
case IDC_CHECK_SCROLLBARS:
case IDC_CHECK_BUTTONS:
case IDC_CHECK_HIDENOTES:
@@ -526,9 +523,8 @@ INT_PTR CALLBACK DlgProcOptions(HWND hdlg, UINT message, WPARAM wParam, LPARAM l
void InitSettings(void)
{
void *P = NULL;
- short Sz1;
+ short Sz1 = MAX_PATH;
- Sz1 = MAX_PATH; P = NULL;
ReadSettingBlob(0, MODULENAME, "RemindEmail", (WORD*)&Sz1, &P);
if (!(Sz1 && P))
g_RemindSMS = NULL;
diff --git a/plugins/NotesAndReminders/src/reminders.cpp b/plugins/NotesAndReminders/src/reminders.cpp
index f3baa1e43a..5b43d7c7d9 100644
--- a/plugins/NotesAndReminders/src/reminders.cpp
+++ b/plugins/NotesAndReminders/src/reminders.cpp
@@ -52,13 +52,6 @@ static SOCKET S;
int WS_Send(SOCKET s,char *data,int datalen);
unsigned long WS_ResolveName(char *name,WORD *port,int defaultPort);
-INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,
- WPARAM wParam,LPARAM lParam);
-INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wParam,
- LPARAM lParam);
-INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wParam,
- LPARAM lParam);
-
void Send(char *user, char *host, char *Msg, char* server);
char* GetPreviewString(const char *lpsz);
@@ -156,13 +149,10 @@ try_next:;
static REMINDERDATA* FindReminder(DWORD uid)
{
- TREEELEMENT *TTE;
-
if (!RemindersList)
return NULL;
- TTE = RemindersList;
- while (TTE)
+ for (TREEELEMENT *TTE = RemindersList; TTE; TTE = (TREEELEMENT *) TTE->next)
{
REMINDERDATA *pReminder = (REMINDERDATA*)TTE->ptrdata;
@@ -170,8 +160,6 @@ static REMINDERDATA* FindReminder(DWORD uid)
{
return pReminder;
}
-
- TTE = (TREEELEMENT*)TTE->next;
}
return NULL;
@@ -200,11 +188,10 @@ static void RemoveReminderSystemEvent(REMINDERDATA *p)
void PurgeReminders(void)
{
- int ReminderCount,I;
char ValueName[32];
- ReminderCount = db_get_dw(0,MODULENAME,"RemindersData",0);
- for(I = 0;I < ReminderCount;I++)
+ int ReminderCount = db_get_dw(0,MODULENAME,"RemindersData",0);
+ for(int I = 0;I < ReminderCount;I++)
{
mir_snprintf(ValueName, "RemindersData%d", I);
db_unset(0, MODULENAME, ValueName);
@@ -213,12 +200,10 @@ void PurgeReminders(void)
void JustSaveReminders(void)
{
- TREEELEMENT *TTE;
- int I, n, l;
+ int I = 0, n, l;
char *tmpReminder = NULL,*Value;
char ValueName[32];
int ReminderCount;
- REMINDERDATA *pReminder;
const int OldReminderCount = db_get_dw(0, MODULENAME, "RemindersData", 0);
@@ -226,9 +211,9 @@ void JustSaveReminders(void)
db_set_dw(0,MODULENAME, "RemindersData", ReminderCount);
- for (TTE = RemindersList, I = 0; TTE; TTE = (TREEELEMENT*)TTE->next, I++)
+ for (TREEELEMENT *TTE = RemindersList; TTE; TTE = (TREEELEMENT *) TTE->next, I++)
{
- pReminder = (REMINDERDATA*)TTE->ptrdata;
+ REMINDERDATA *pReminder = (REMINDERDATA *) TTE->ptrdata;
if (pReminder->Reminder && mir_strlen(pReminder->Reminder))
tmpReminder = pReminder->Reminder;
else
@@ -295,16 +280,15 @@ void JustSaveReminders(void)
void LoadReminders(void)
{
- int I,RemindersCount;
char *Value;
WORD Size;
char ValueName[32];
BOOL GenerateUids = FALSE;
RemindersList = NULL;
- RemindersCount = db_get_dw(0, MODULENAME, "RemindersData", 0);
+ int RemindersCount = db_get_dw(0, MODULENAME, "RemindersData", 0);
- for (I = 0; I < RemindersCount; I++)
+ for (int I = 0; I < RemindersCount; I++)
{
Size = 65535;
Value = NULL;
@@ -436,53 +420,18 @@ skip:;
// generate UIDs if there are any items with an invalid UID
if (GenerateUids && RemindersList)
{
- TREEELEMENT *TTE;
-
- TTE = RemindersList;
- while (TTE)
+ for (TREEELEMENT *TTE = RemindersList; TTE; TTE = (TREEELEMENT*)TTE->next)
{
REMINDERDATA *pReminder = (REMINDERDATA*)TTE->ptrdata;
if (!pReminder->uid)
pReminder->uid = CreateUid();
-
- TTE = (TREEELEMENT*)TTE->next;
}
JustSaveReminders();
}
}
-void NewReminder(void)
-{
- if (!NewReminderVisible)
- {
- NewReminderVisible = TRUE;
- CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDREMINDER), 0, DlgProcNewReminder);
- }
-}
-
-void EditReminder(REMINDERDATA *p)
-{
- if (!p)
- return;
-
- if (!NewReminderVisible && !p->SystemEventQueued)
- {
- if (!p->RemVisible)
- {
- p->RemVisible = TRUE;
- NewReminderVisible = 2;
- pEditReminder = p;
- CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDREMINDER), 0, DlgProcNewReminder);
- }
- else
- {
- BringWindowToTop(p->handle);
- }
- }
-}
-
static void DeleteReminder(REMINDERDATA *p)
{
if (!p)
@@ -510,11 +459,9 @@ void CloseReminderList()
static void PurgeReminderTree()
{
- REMINDERDATA *pt;
-
while (RemindersList) // empty whole tree
{
- pt = (REMINDERDATA*)RemindersList->ptrdata;
+ REMINDERDATA *pt = (REMINDERDATA*)RemindersList->ptrdata;
if (pt->handle) DestroyWindow(pt->handle);
DeleteReminder(pt);
}
@@ -534,19 +481,6 @@ void DeleteReminders(void)
PurgeReminderTree();
}
-void ListReminders(void)
-{
- if (!ListReminderVisible)
- {
- CreateDialog(hinstance, MAKEINTRESOURCE(IDD_LISTREMINDERS), 0, DlgProcViewReminders);
- ListReminderVisible = TRUE;
- }
- else
- {
- BringWindowToTop(LV);
- }
-}
-
void GetTriggerTimeString(const ULARGE_INTEGER *When, char *s, UINT strSize, BOOL bUtc)
{
@@ -572,44 +506,6 @@ void GetTriggerTimeString(const ULARGE_INTEGER *When, char *s, UINT strSize, BOO
else mir_snprintf(s, strSize, "%d-%02d-%02d %02d:%02d", tm.wYear, tm.wMonth, tm.wDay, tm.wHour, tm.wMinute);
}
-
-INT_PTR OpenTriggeredReminder(WPARAM w, LPARAM l)
-{
- if (!l)
- return 0;
-
- l = ((CLISTEVENT*)l)->lParam;
-
- REMINDERDATA *pReminder = (REMINDERDATA*)FindReminder((DWORD)l);
- if (!pReminder || !pReminder->SystemEventQueued)
- return 0;
-
- pReminder->SystemEventQueued = FALSE;
- if (QueuedReminderCount)
- QueuedReminderCount--;
-
- {
- char S[MAX_PATH];
- char S1[128];
- HWND H;
- GetTriggerTimeString(&pReminder->When, S1, sizeof(S1), TRUE);
-
- pReminder->RemVisible = TRUE;
-
- pReminder->handle = H = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_NOTIFYREMINDER), 0, DlgProcNotifyReminder);
-
- mir_snprintf(S, "%s! - %s", Translate("Reminder"), S1);
- SetWindowText(H, S);
-
- if (pReminder->Reminder)
- SetDlgItemText(H, IDC_REMDATA, pReminder->Reminder);
-
- BringWindowToTop(H);
- }
-
- return 0;
-}
-
static void SkinPlaySoundPoly(LPCSTR pszSoundName)
{
if (g_UseDefaultPlaySound)
@@ -723,11 +619,8 @@ BOOL CheckRemindersAndStart(void)
// returns TRUE if there are any triggered reminder with SystemEventQueued, this will shorten the update interval
// allowing sound repeats with shorter intervals
- TREEELEMENT *TTE;
ULARGE_INTEGER curT;
- BOOL bHasPlayedSound;
BOOL bResult;
- BOOL bHasQueuedReminders;
if (!RemindersList)
return FALSE;
@@ -750,17 +643,17 @@ BOOL CheckRemindersAndStart(void)
bResult = FALSE;
// var used to avoid playing multiple alarm sounds during a single update
- bHasPlayedSound = FALSE;
+ BOOL bHasPlayedSound = FALSE;
// if there are queued (triggered) reminders then iterate through entire list, becaue of WM_TIMECHANGE events
// and for example daylight saving changes it's possible for an already triggered event to end up with When>curT
- bHasQueuedReminders = (QueuedReminderCount != 0);
+ BOOL bHasQueuedReminders = (QueuedReminderCount != 0);
// allthough count should always be correct, it's fool proof to just count them again in the loop below
QueuedReminderCount = 0;
- TTE = RemindersList;
- while (TTE && (bHasQueuedReminders || ((REMINDERDATA*)TTE->ptrdata)->When.QuadPart <= curT.QuadPart))
+
+ for(TREEELEMENT *TTE = RemindersList;TTE && (bHasQueuedReminders || ((REMINDERDATA*)TTE->ptrdata)->When.QuadPart <= curT.QuadPart); TTE = (TREEELEMENT *)TTE->next)
{
REMINDERDATA *pReminder = (REMINDERDATA*)TTE->ptrdata;
@@ -798,8 +691,6 @@ BOOL CheckRemindersAndStart(void)
}
}
}
-
- TTE = (TREEELEMENT*)TTE->next;
}
return bResult;
@@ -1144,26 +1035,20 @@ static void PopulateTimeCombo(HWND Dialog, UINT nIDTime, BOOL bRelative, const S
static void PopulateTimeOffsetCombo(HWND Dialog, UINT nIDCombo)
{
- int i, n;
- LPCSTR lpszMinutes;
- LPCSTR lpszHour;
- LPCSTR lpszHours;
- LPCSTR lpszDay;
- LPCSTR lpszDays;
- LPCSTR lpszWeek;
+ int n;
char s[MAX_PATH];
SendDlgItemMessage(Dialog,nIDCombo,CB_RESETCONTENT,0,0);
- lpszMinutes = Translate("Minutes");
- lpszHour = Translate("Hour");
- lpszHours = Translate("Hours");
- lpszDay = Translate("Day");
- lpszDays = Translate("Days");
- lpszWeek = Translate("Week");
+ LPCSTR lpszMinutes = Translate("Minutes");
+ LPCSTR lpszHour = Translate("Hour");
+ LPCSTR lpszHours = Translate("Hours");
+ LPCSTR lpszDay = Translate("Day");
+ LPCSTR lpszDays = Translate("Days");
+ LPCSTR lpszWeek = Translate("Week");
// 5 - 55 minutes (in 5 minute steps)
- for (i = 1; i < 12; i++)
+ for (int i = 1; i < 12; i++)
{
mir_snprintf(s, "%d %s", i*5, lpszMinutes);
n = SendDlgItemMessage(Dialog,nIDCombo,CB_ADDSTRING,0,(LPARAM)s);
@@ -1176,7 +1061,7 @@ static void PopulateTimeOffsetCombo(HWND Dialog, UINT nIDCombo)
SendDlgItemMessage(Dialog,nIDCombo,CB_SETITEMDATA, n, 60);
// 2, 4, 8 hours
- for (i = 2; i <= 8; i+=2)
+ for (int i = 2; i <= 8; i+=2)
{
mir_snprintf(s, "%d %s", i, lpszHours);
n = SendDlgItemMessage(Dialog,nIDCombo,CB_ADDSTRING,0,(LPARAM)s);
@@ -1189,7 +1074,7 @@ static void PopulateTimeOffsetCombo(HWND Dialog, UINT nIDCombo)
SendDlgItemMessage(Dialog,nIDCombo,CB_SETITEMDATA, n, 24*60);
// 2-4 days
- for (i = 2; i <= 4; i++)
+ for (int i = 2; i <= 4; i++)
{
mir_snprintf(s, "%d %s", i, lpszDays);
n = SendDlgItemMessage(Dialog,nIDCombo,CB_ADDSTRING,0,(LPARAM)s);
@@ -1407,7 +1292,6 @@ static BOOL GetTriggerTime(HWND Dialog, UINT nIDTime, UINT nIDRefTime, SYSTEMTIM
{
ULARGE_INTEGER li;
char buf[32];
- int n;
int h, m;
// get reference (UTC) time from hidden control
@@ -1416,7 +1300,8 @@ static BOOL GetTriggerTime(HWND Dialog, UINT nIDTime, UINT nIDRefTime, SYSTEMTIM
li.QuadPart = _strtoui64(buf, NULL, 16);
}
- if ((n = SendDlgItemMessage(Dialog, nIDTime, CB_GETCURSEL, 0, 0)) != CB_ERR)
+ int n = SendDlgItemMessage(Dialog, nIDTime, CB_GETCURSEL, 0, 0);
+ if (n != CB_ERR)
{
// use preset value
preset_value:;
@@ -1535,10 +1420,8 @@ static void OnDateChanged(HWND Dialog, UINT nDateID, UINT nTimeID, UINT nRefTime
}
-INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARAM lParam)
{
- int I;
-
switch (Message)
{
case WM_INITDIALOG:
@@ -1590,39 +1473,40 @@ INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wParam,LP
case WM_NCDESTROY:
RemoveProp(GetDlgItem(Dialog, IDC_DATEAGAIN), TEXT("OldWndProc"));
return TRUE;
+
case WM_NOTIFY:
+ if (wParam == IDC_DATEAGAIN)
{
- if (wParam == IDC_DATEAGAIN)
- {
- NMLISTVIEW *NM = (NMLISTVIEW*)lParam;
+ LPNMLISTVIEW NM = (LPNMLISTVIEW)lParam;
- switch (NM->hdr.code)
- {
- case DTN_DATETIMECHANGE:
- OnDateChanged(Dialog, IDC_DATEAGAIN, IDC_TIMEAGAIN, IDC_REFTIME);
- break;
- }
+ switch (NM->hdr.code)
+ {
+ case DTN_DATETIMECHANGE:
+ OnDateChanged(Dialog, IDC_DATEAGAIN, IDC_TIMEAGAIN, IDC_REFTIME);
+ break;
}
}
break;
+
case WM_CLOSE:
+ {
+ int ReminderCount = TreeGetCount(RemindersList);
+ for (int I = 0; I < ReminderCount; I++)
{
- int ReminderCount = TreeGetCount(RemindersList);
- for (I = 0; I < ReminderCount; I++)
- {
- REMINDERDATA *pReminder = (REMINDERDATA*)TreeGetAt(RemindersList, I);
+ REMINDERDATA *pReminder = (REMINDERDATA*)TreeGetAt(RemindersList, I);
- if (pReminder->handle == Dialog)
- {
- DeleteReminder(pReminder);
- JustSaveReminders();
- break;
- }
+ if (pReminder->handle == Dialog)
+ {
+ DeleteReminder(pReminder);
+ JustSaveReminders();
+ break;
}
- NOTIFY_LIST();
}
- DestroyWindow(Dialog);
- return TRUE;
+ NOTIFY_LIST();
+ }
+ DestroyWindow(Dialog);
+ return TRUE;
+
case WM_COMMAND:
{
switch (LOWORD(wParam))
@@ -1689,27 +1573,25 @@ INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wParam,LP
break;
case IDC_AFTER:
- {
- ShowWindow(GetDlgItem(Dialog, IDC_REMINDAGAININ), SW_SHOW);
- ShowWindow(GetDlgItem(Dialog, IDC_DATEAGAIN), SW_HIDE);
- ShowWindow(GetDlgItem(Dialog, IDC_TIMEAGAIN), SW_HIDE);
- ShowWindow(GetDlgItem(Dialog, IDC_STATIC_DATE), SW_HIDE);
- ShowWindow(GetDlgItem(Dialog, IDC_STATIC_TIME), SW_HIDE);
- return TRUE;
- }
+ ShowWindow(GetDlgItem(Dialog, IDC_REMINDAGAININ), SW_SHOW);
+ ShowWindow(GetDlgItem(Dialog, IDC_DATEAGAIN), SW_HIDE);
+ ShowWindow(GetDlgItem(Dialog, IDC_TIMEAGAIN), SW_HIDE);
+ ShowWindow(GetDlgItem(Dialog, IDC_STATIC_DATE), SW_HIDE);
+ ShowWindow(GetDlgItem(Dialog, IDC_STATIC_TIME), SW_HIDE);
+ return TRUE;
+
case IDC_ONDATE:
- {
- ShowWindow(GetDlgItem(Dialog, IDC_DATEAGAIN), SW_SHOW);
- ShowWindow(GetDlgItem(Dialog, IDC_TIMEAGAIN), SW_SHOW);
- ShowWindow(GetDlgItem(Dialog, IDC_STATIC_DATE), SW_SHOW);
- ShowWindow(GetDlgItem(Dialog, IDC_STATIC_TIME), SW_SHOW);
- ShowWindow(GetDlgItem(Dialog, IDC_REMINDAGAININ), SW_HIDE);
- return TRUE;
- }
+ ShowWindow(GetDlgItem(Dialog, IDC_DATEAGAIN), SW_SHOW);
+ ShowWindow(GetDlgItem(Dialog, IDC_TIMEAGAIN), SW_SHOW);
+ ShowWindow(GetDlgItem(Dialog, IDC_STATIC_DATE), SW_SHOW);
+ ShowWindow(GetDlgItem(Dialog, IDC_STATIC_TIME), SW_SHOW);
+ ShowWindow(GetDlgItem(Dialog, IDC_REMINDAGAININ), SW_HIDE);
+ return TRUE;
+
case IDC_DISMISS:
{
int ReminderCount = TreeGetCount(RemindersList);
- for (I = 0; I < ReminderCount; I++)
+ for (int I = 0; I < ReminderCount; I++)
{
REMINDERDATA *pReminder = (REMINDERDATA*)TreeGetAt(RemindersList, I);
@@ -1724,10 +1606,11 @@ INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wParam,LP
DestroyWindow(Dialog);
return TRUE;
}
+
case IDC_REMINDAGAIN:
{
int ReminderCount = TreeGetCount(RemindersList);
- for (I = 0; I < ReminderCount; I++)
+ for (int I = 0; I < ReminderCount; I++)
{
REMINDERDATA *pReminder = (REMINDERDATA*)TreeGetAt(RemindersList, I);
@@ -1740,12 +1623,11 @@ INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wParam,LP
ULONGLONG TT;
SYSTEMTIME tm;
ULARGE_INTEGER li;
- int n;
GetSystemTime(&tm);
SYSTEMTIMEtoFILETIME(&tm, (FILETIME*)&li);
- n = SendDlgItemMessage(Dialog, IDC_REMINDAGAININ, CB_GETCURSEL, 0, 0);
+ int n = SendDlgItemMessage(Dialog, IDC_REMINDAGAININ, CB_GETCURSEL, 0, 0);
if (n != CB_ERR)
{
TT = SendDlgItemMessage(Dialog, IDC_REMINDAGAININ, CB_GETITEMDATA, n, 0) * 60;
@@ -1837,10 +1719,12 @@ INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wParam,LP
DestroyWindow(Dialog);
return TRUE;
}
+
case IDC_NONE:
- {// create note from remainder
+ {
+ // create note from remainder
int ReminderCount = TreeGetCount(RemindersList);
- for (I = 0; I < ReminderCount; I++)
+ for (int I = 0; I < ReminderCount; I++)
{
REMINDERDATA *pReminder = (REMINDERDATA*)TreeGetAt(RemindersList, I);
@@ -1868,7 +1752,7 @@ INT_PTR CALLBACK DlgProcNotifyReminder(HWND Dialog,UINT Message,WPARAM wParam,LP
return FALSE;
}
-INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARAM lParam)
{
HICON hIcon = NULL;
switch (Message)
@@ -1922,12 +1806,11 @@ INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARA
if (NewReminderVisible == 2)
{
- int n;
char s[32];
mir_snprintf(s, "%02d:%02d", (UINT)tm.wHour, (UINT)tm.wMinute);
// search for preset first
- n = SendDlgItemMessage(Dialog, IDC_TIME, CB_FINDSTRING, (WPARAM)-1, (LPARAM)s);
+ int n = SendDlgItemMessage(Dialog, IDC_TIME, CB_FINDSTRING, (WPARAM)-1, (LPARAM)s);
if (n != CB_ERR)
SendDlgItemMessage(Dialog, IDC_TIME, CB_SETCURSEL, n, 0);
else
@@ -1943,13 +1826,12 @@ INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARA
// populate sound repeat combo
{
char s[64];
- int n;
LPCSTR lpszEvery = Translate("Every");
LPCSTR lpszSeconds = Translate("Seconds");
// NOTE: use multiples of REMINDER_UPDATE_INTERVAL_SHORT (currently 5 seconds)
- n = SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_ADDSTRING, 0, (LPARAM)Translate("Never"));
+ int n = SendDlgItemMessage(Dialog, IDC_COMBO_REPEATSND, CB_ADDSTRING, 0, (LPARAM)Translate("Never"));
SendDlgItemMessage(Dialog,IDC_COMBO_REPEATSND,CB_SETITEMDATA, n, 0);
mir_snprintf(s, "%s 5 %s", lpszEvery, lpszSeconds);
@@ -2001,8 +1883,8 @@ INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARA
if (NewReminderVisible == 2 && pEditReminder->SoundSel)
{
- const UINT n = pEditReminder->SoundSel<0 ? 3 : pEditReminder->SoundSel;
- SendDlgItemMessage(Dialog,IDC_COMBO_SOUND,CB_SETCURSEL,n,0);
+ const UINT n2 = pEditReminder->SoundSel<0 ? 3 : pEditReminder->SoundSel;
+ SendDlgItemMessage(Dialog,IDC_COMBO_SOUND,CB_SETCURSEL,n2,0);
}
else
{
@@ -2026,35 +1908,35 @@ INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARA
return FALSE;
}
+
case WM_NCDESTROY:
RemoveProp(GetDlgItem(Dialog, IDC_DATE), TEXT("OldWndProc"));
return TRUE;
+
case WM_CLOSE:
+ if (NewReminderVisible == 2)
{
- if (NewReminderVisible == 2)
- {
- pEditReminder->RemVisible = FALSE;
- }
- DestroyWindow(Dialog);
- NewReminderVisible = FALSE;
- pEditReminder = NULL;
- return TRUE;
+ pEditReminder->RemVisible = FALSE;
}
+ DestroyWindow(Dialog);
+ NewReminderVisible = FALSE;
+ pEditReminder = NULL;
+ return TRUE;
+
case WM_NOTIFY:
+ if (wParam == IDC_DATE)
{
- if (wParam == IDC_DATE)
- {
- NMLISTVIEW *NM = (NMLISTVIEW*)lParam;
+ LPNMLISTVIEW NM = (LPNMLISTVIEW)lParam;
- switch (NM->hdr.code)
- {
- case DTN_DATETIMECHANGE:
- OnDateChanged(Dialog, IDC_DATE, IDC_TIME, IDC_REFTIME);
- break;
- }
+ switch (NM->hdr.code)
+ {
+ case DTN_DATETIMECHANGE:
+ OnDateChanged(Dialog, IDC_DATE, IDC_TIME, IDC_REFTIME);
+ break;
}
}
break;
+
case WM_COMMAND:
{
switch (LOWORD(wParam))
@@ -2084,6 +1966,7 @@ INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARA
break;
}
break;
+
case IDC_COMBO_SOUND:
switch (HIWORD(wParam))
{
@@ -2111,42 +1994,38 @@ INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARA
}
}
return TRUE;
+
case IDC_CLOSE:
+ if (NewReminderVisible == 2)
{
- if (NewReminderVisible == 2)
- {
- pEditReminder->RemVisible = FALSE;
- }
- DestroyWindow(Dialog);
- NewReminderVisible = FALSE;
- pEditReminder = NULL;
- return TRUE;
+ pEditReminder->RemVisible = FALSE;
}
+ DestroyWindow(Dialog);
+ NewReminderVisible = FALSE;
+ pEditReminder = NULL;
+ return TRUE;
+
case IDC_VIEWREMINDERS:
- {
- ListReminders();
- return TRUE;
- }
+ ListReminders();
+ return TRUE;
+
case IDC_ADDREMINDER:
{
- char *ReminderText = NULL;
- int SzT;
SYSTEMTIME Date;
- REMINDERDATA* TempRem;
- int RepeatSound;
SendDlgItemMessage(Dialog,IDC_DATE,DTM_GETSYSTEMTIME,0,(LPARAM)&Date);
if ( !GetTriggerTime(Dialog, IDC_TIME, IDC_REFTIME, &Date) )
break;
- RepeatSound = SendDlgItemMessage(Dialog,IDC_COMBO_REPEATSND,CB_GETCURSEL,0,0);
+ int RepeatSound = SendDlgItemMessage(Dialog,IDC_COMBO_REPEATSND,CB_GETCURSEL,0,0);
if (RepeatSound != CB_ERR)
RepeatSound = SendDlgItemMessage(Dialog,IDC_COMBO_REPEATSND,CB_GETITEMDATA,(WPARAM)RepeatSound,0);
else
RepeatSound = 0;
- SzT = SendDlgItemMessage(Dialog,IDC_REMINDER,WM_GETTEXTLENGTH,0,0);
+ int SzT = SendDlgItemMessage(Dialog,IDC_REMINDER,WM_GETTEXTLENGTH,0,0);
+ char *ReminderText = NULL;
if (SzT)
{
if (SzT > MAX_REMINDER_LEN) SzT = MAX_REMINDER_LEN;
@@ -2157,7 +2036,7 @@ INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARA
if (NewReminderVisible != 2)
{
// new reminder
- TempRem = (REMINDERDATA*)malloc(sizeof(REMINDERDATA));
+ REMINDERDATA *TempRem = (REMINDERDATA*)malloc(sizeof(REMINDERDATA));
TempRem->uid = CreateUid();
SYSTEMTIMEtoFILETIME(&Date, (FILETIME*)&TempRem->When);
TempRem->Reminder = ReminderText;
@@ -2199,33 +2078,93 @@ INT_PTR CALLBACK DlgProcNewReminder(HWND Dialog,UINT Message,WPARAM wParam,LPARA
}
}
case WM_DESTROY:
+ IcoLib_ReleaseIcon(hIcon);
+ break;
+ }
+ return FALSE;
+}
+
+
+INT_PTR OpenTriggeredReminder(WPARAM, LPARAM l)
+{
+ if (!l)
+ return 0;
+
+ l = ((CLISTEVENT*)l)->lParam;
+
+ REMINDERDATA *pReminder = (REMINDERDATA*)FindReminder((DWORD)l);
+ if (!pReminder || !pReminder->SystemEventQueued)
+ return 0;
+
+ pReminder->SystemEventQueued = FALSE;
+ if (QueuedReminderCount)
+ QueuedReminderCount--;
+
+ {
+ char S1[128], S2[MAX_PATH];
+ GetTriggerTimeString(&pReminder->When, S1, sizeof(S1), TRUE);
+
+ pReminder->RemVisible = TRUE;
+
+ HWND H = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_NOTIFYREMINDER), 0, DlgProcNotifyReminder);
+ pReminder->handle = H;
+
+ mir_snprintf(S2, "%s! - %s", Translate("Reminder"), S1);
+ SetWindowText(H, S2);
+
+ if (pReminder->Reminder)
+ SetDlgItemText(H, IDC_REMDATA, pReminder->Reminder);
+
+ BringWindowToTop(H);
+ }
+
+ return 0;
+}
+
+void NewReminder(void)
+{
+ if (!NewReminderVisible)
+ {
+ NewReminderVisible = TRUE;
+ CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDREMINDER), 0, DlgProcNewReminder);
+ }
+}
+
+void EditReminder(REMINDERDATA *p)
+{
+ if (!p)
+ return;
+
+ if (!NewReminderVisible && !p->SystemEventQueued)
+ {
+ if (!p->RemVisible)
{
- IcoLib_ReleaseIcon(hIcon);
- break;
+ p->RemVisible = TRUE;
+ NewReminderVisible = 2;
+ pEditReminder = p;
+ CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDREMINDER), 0, DlgProcNewReminder);
+ }
+ else
+ {
+ BringWindowToTop(p->handle);
}
}
- return FALSE;
}
static void InitListView(HWND AHLV)
{
- LV_ITEM lvTIt;
- int I;
- char *S;
+ int I = 0;
char S1[128];
- REMINDERDATA *pReminder;
- TREEELEMENT *TTE;
ListView_SetHoverTime(AHLV,700);
ListView_SetExtendedListViewStyle(AHLV,LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TRACKSELECT);
ListView_DeleteAllItems(AHLV);
-
- I = 0;
- TTE = RemindersList;
- while (TTE)
+
+ for (TREEELEMENT *TTE = RemindersList; TTE; TTE = (TREEELEMENT*)TTE->next)
{
- pReminder = (REMINDERDATA*)TTE->ptrdata;
+ REMINDERDATA *pReminder = (REMINDERDATA*)TTE->ptrdata;
+ LV_ITEM lvTIt;
lvTIt.mask = LVIF_TEXT;
GetTriggerTimeString(&pReminder->When, S1, sizeof(S1), TRUE);
@@ -2235,14 +2174,13 @@ static void InitListView(HWND AHLV)
lvTIt.pszText = S1;
ListView_InsertItem(AHLV,&lvTIt);
lvTIt.mask = LVIF_TEXT;
- S = GetPreviewString(pReminder->Reminder);
+ char *S2 = GetPreviewString(pReminder->Reminder);
lvTIt.iItem = I;
lvTIt.iSubItem = 1;
- lvTIt.pszText = S;
+ lvTIt.pszText = S2;
ListView_SetItem(AHLV,&lvTIt);
I++;
- TTE = (TREEELEMENT*)TTE->next;
}
ListView_SetItemState(AHLV,0,LVIS_SELECTED,LVIS_SELECTED);
@@ -2312,10 +2250,9 @@ void UpdateGeomFromWnd(HWND Dialog, int *geom, int *colgeom, int nCols)
if (colgeom)
{
- int i;
HWND H = GetDlgItem(Dialog, IDC_LISTREMINDERS);
- for (i=0; i<nCols; i++)
+ for (int i=0; i<nCols; i++)
{
colgeom[i] = ListView_GetColumnWidth(H, i);
}
@@ -2346,24 +2283,21 @@ static BOOL DoListContextMenu(HWND AhWnd,WPARAM wParam,LPARAM lParam,REMINDERDAT
return TRUE;
}
-INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wParam,LPARAM lParam)
{
LV_COLUMN lvCol;
- NMLISTVIEW *NM;
- char *S;
- int I;
switch (Message)
{
case WM_SIZE:
- {
- OnListResize(Dialog);
- UpdateGeomFromWnd(Dialog, g_reminderListGeom, NULL, 0);
- break;
- }
+ OnListResize(Dialog);
+ UpdateGeomFromWnd(Dialog, g_reminderListGeom, NULL, 0);
+ break;
+
case WM_MOVE:
UpdateGeomFromWnd(Dialog, g_reminderListGeom, NULL, 0);
break;
+
case WM_GETMINMAXINFO:
{
MINMAXINFO *mm = (MINMAXINFO*)lParam;
@@ -2371,21 +2305,20 @@ INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wParam,LPA
mm->ptMinTrackSize.y = 300;
}
return 0;
+
case WM_RELOAD:
- {
- SetDlgItemText(Dialog, IDC_REMINDERDATA, "");
- InitListView(GetDlgItem(Dialog, IDC_LISTREMINDERS));
- return TRUE;
- }
+ SetDlgItemText(Dialog, IDC_REMINDERDATA, "");
+ InitListView(GetDlgItem(Dialog, IDC_LISTREMINDERS));
+ return TRUE;
+
case WM_CONTEXTMENU:
{
- HWND H;
REMINDERDATA *pReminder = NULL;
- H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
+ HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
if ( ListView_GetSelectedCount(H) )
{
- I = ListView_GetSelectionMark(H);
+ int I = ListView_GetSelectionMark(H);
if (I != -1)
{
pReminder = (REMINDERDATA*)TreeGetAt(RemindersList,I);
@@ -2396,21 +2329,22 @@ INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wParam,LPA
return TRUE;
}
break;
+
case WM_INITDIALOG:
- {
- Window_SetIcon_IcoLib(Dialog, iconList[6].hIcolib);
+ Window_SetIcon_IcoLib(Dialog, iconList[6].hIcolib);
- TranslateDialogDefault(Dialog);
- SetDlgItemText(Dialog,IDC_REMINDERDATA, "");
+ TranslateDialogDefault(Dialog);
+ SetDlgItemText(Dialog,IDC_REMINDERDATA, "");
+ {
HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
- S = Translate("Reminder text");
- lvCol.pszText = S;
+ char *S2 = Translate("Reminder text");
+ lvCol.pszText = S2;
lvCol.cx = g_reminderListColGeom[1];
ListView_InsertColumn(H,0,&lvCol);
lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
- S = Translate("Date of activation");
- lvCol.pszText = S;
+ S2 = Translate("Date of activation");
+ lvCol.pszText = S2;
lvCol.cx = g_reminderListColGeom[0];
ListView_InsertColumn(H,0,&lvCol);
InitListView(H);
@@ -2428,35 +2362,33 @@ INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wParam,LPA
wp.rcNormalPosition.bottom = g_reminderListGeom[3] + g_reminderListGeom[1];
SetWindowPlacement(Dialog, &wp);
}
- return TRUE;
}
+ return TRUE;
+
case WM_CLOSE:
- {
- DestroyWindow(Dialog);
- ListReminderVisible = FALSE;
- return TRUE;
- }
+ DestroyWindow(Dialog);
+ ListReminderVisible = FALSE;
+ return TRUE;
+
case WM_NOTIFY:
{
if (wParam == IDC_LISTREMINDERS)
{
- NM = (NMLISTVIEW *)lParam;
+ LPNMLISTVIEW NM = (LPNMLISTVIEW)lParam;
switch (NM->hdr.code)
{
case LVN_ITEMCHANGED:
{
- S = ((REMINDERDATA*)TreeGetAt(RemindersList,NM->iItem))->Reminder;
- SetDlgItemText(Dialog,IDC_REMINDERDATA,S);
+ char *S2 = ((REMINDERDATA*)TreeGetAt(RemindersList,NM->iItem))->Reminder;
+ SetDlgItemText(Dialog,IDC_REMINDERDATA,S2);
}
break;
case NM_DBLCLK:
{
- HWND H;
-
- H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
+ HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
if ( ListView_GetSelectedCount(H) )
{
- I = ListView_GetSelectionMark(H);
+ int I = ListView_GetSelectionMark(H);
if (I != -1)
{
EditReminder((REMINDERDATA*)TreeGetAt(RemindersList, I));
@@ -2468,7 +2400,7 @@ INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wParam,LPA
}
else if (wParam == IDC_LISTREMINDERS_HEADER)
{
- NMHEADER *NM = (NMHEADER*)lParam;
+ LPNMHEADER NM = (LPNMHEADER)lParam;
switch (NM->hdr.code)
{
case HDN_ENDTRACK:
@@ -2484,12 +2416,10 @@ INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wParam,LPA
{
case ID_CONTEXTMENUREMINDERLISTVIEW_EDIT:
{
- HWND H;
-
- H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
+ HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
if ( ListView_GetSelectedCount(H) )
{
- I = ListView_GetSelectionMark(H);
+ int I = ListView_GetSelectionMark(H);
if (I != -1)
{
EditReminder((REMINDERDATA*)TreeGetAt(RemindersList, I));
@@ -2497,18 +2427,17 @@ INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wParam,LPA
}
}
return TRUE;
+
case IDC_CLOSE:
- {
- DestroyWindow(Dialog);
- ListReminderVisible = FALSE;
- return TRUE;
- }
+ DestroyWindow(Dialog);
+ ListReminderVisible = FALSE;
+ return TRUE;
+
case IDM_NEWREMINDER:
case IDC_ADDNEWREMINDER:
- {
- NewReminder();
- return TRUE;
- }
+ NewReminder();
+ return TRUE;
+
case IDM_DELETEALLREMINDERS:
if (RemindersList && MessageBox(Dialog, Translate("Are you sure you want to delete all reminders?"), Translate(SECTIONNAME), MB_OKCANCEL) == IDOK)
{
@@ -2517,14 +2446,13 @@ INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wParam,LPA
InitListView(GetDlgItem(Dialog,IDC_LISTREMINDERS));
}
return TRUE;
+
case IDM_DELETEREMINDER:
{
- HWND H;
-
- H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
+ HWND H = GetDlgItem(Dialog,IDC_LISTREMINDERS);
if ( ListView_GetSelectedCount(H) )
{
- I = ListView_GetSelectionMark(H);
+ int I = ListView_GetSelectionMark(H);
if (I != -1
&& MessageBox(Dialog, Translate("Are you sure you want to delete this reminder?"), Translate(SECTIONNAME), MB_OKCANCEL) == IDOK)
{
@@ -2545,6 +2473,19 @@ INT_PTR CALLBACK DlgProcViewReminders(HWND Dialog,UINT Message,WPARAM wParam,LPA
return FALSE;
}
+void ListReminders(void)
+{
+ if (!ListReminderVisible)
+ {
+ CreateDialog(hinstance, MAKEINTRESOURCE(IDD_LISTREMINDERS), 0, DlgProcViewReminders);
+ ListReminderVisible = TRUE;
+ }
+ else
+ {
+ BringWindowToTop(LV);
+ }
+}
+
/////////////////////////////////////////////////////////////////////
// Email/SMS and WinSock functions