From b9342641f520a5418fb2a8b2993148a66ea8e33b Mon Sep 17 00:00:00 2001
From: George Hazan <george.hazan@gmail.com>
Date: Sat, 2 Jun 2012 15:43:18 +0000
Subject: 64-bit compilation fixes

git-svn-id: http://svn.miranda-ng.org/main/trunk@263 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 plugins/Alarms/alarm_win.cpp        |   94 +--
 plugins/Alarms/alarm_win.h          |    2 +-
 plugins/Alarms/alarmlist.cpp        |  113 +--
 plugins/Alarms/alarmlist.h          |   18 +-
 plugins/Alarms/alarms.cpp           |   14 +-
 plugins/Alarms/frame.cpp            |  139 ++--
 plugins/Alarms/icons.cpp            |   12 +-
 plugins/Alarms/options.cpp          | 1347 +++++++++++++++++------------------
 plugins/Alarms/options.h            |    2 +-
 plugins/Alarms/trigger.cpp          |   16 +-
 plugins/LangMan/options.c           |    4 +-
 plugins/ListeningTo/listeningto.cpp |  151 ++--
 plugins/ListeningTo/options.cpp     |   12 +-
 13 files changed, 936 insertions(+), 988 deletions(-)

diff --git a/plugins/Alarms/alarm_win.cpp b/plugins/Alarms/alarm_win.cpp
index 250dcdaf31..dd878d94d2 100644
--- a/plugins/Alarms/alarm_win.cpp
+++ b/plugins/Alarms/alarm_win.cpp
@@ -36,12 +36,12 @@ bool TransparencyEnabled() {
 	return MySetLayeredWindowAttributes != 0;
 }
 
-BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
-
+INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
 	switch ( msg ) {
 	case WM_INITDIALOG: 
+		TranslateDialogDefault( hwndDlg );
 		{
-			TranslateDialogDefault( hwndDlg );
 			Utils_RestoreWindowPositionNoSize(hwndDlg, 0, MODULE, "Notify");
 			SetFocus(GetDlgItem(hwndDlg, IDC_SNOOZE));
 
@@ -50,7 +50,7 @@ BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 			wd->alarm = 0;
 			wd->win_num = win_num++;
 
-			if(wd->win_num > 0) {
+			if (wd->win_num > 0) {
 				RECT r;
 				GetWindowRect(hwndDlg, &r);
 				r.top += 20;
@@ -60,28 +60,29 @@ BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 				Utils_SaveWindowPosition(hwndDlg, 0, MODULE, "Notify");
 			}
 
-			SetWindowLong(hwndDlg, GWL_USERDATA, (LONG)wd);
+			SetWindowLong(hwndDlg, GWLP_USERDATA, (LONG)wd);
 
 			// options
 			SendMessage(hwndDlg, WMU_SETOPT, 0, 0);
 		
 			// fonts
 			SendMessage(hwndDlg, WMU_SETFONTS, 0, 0);
-
 		}
 		return FALSE;
+
 	case WMU_REFRESH:
 		InvalidateRect(hwndDlg, 0, TRUE);
 		return TRUE;
+
 	case WM_CTLCOLORSTATIC:
 		{
 			HDC hdc = (HDC)wParam;
 			HWND hwndCtrl = (HWND)lParam;
 
-			if(hBackgroundBrush) {
-				if(hTitleFont && GetDlgItem(hwndDlg, IDC_TITLE) == hwndCtrl)
+			if (hBackgroundBrush) {
+				if (hTitleFont && GetDlgItem(hwndDlg, IDC_TITLE) == hwndCtrl)
 					SetTextColor(hdc, title_font_colour);
-				else if(hWindowFont)
+				else if (hWindowFont)
 					SetTextColor(hdc, window_font_colour);
 
 				SetBkMode(hdc, TRANSPARENT);
@@ -90,30 +91,30 @@ BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 		}
 		break;
 	case WM_CTLCOLORDLG:
-		if(hBackgroundBrush)
+		if (hBackgroundBrush)
 			return (BOOL)hBackgroundBrush;
 		break;
 	case WMU_SETFONTS:
 		// fonts
-		if(hWindowFont)
+		if (hWindowFont)
 			SendMessage(hwndDlg, WM_SETFONT, (WPARAM)hWindowFont, (LPARAM)TRUE);
-		if(hTitleFont)
+		if (hTitleFont)
 			SendDlgItemMessage(hwndDlg, IDC_TITLE, WM_SETFONT, (WPARAM)hTitleFont, (LPARAM)TRUE);
 
-		if(hBackgroundBrush) {
-			SetClassLong(hwndDlg, GCL_HBRBACKGROUND, (LONG)hBackgroundBrush);
+		if (hBackgroundBrush) {
+			SetClassLong(hwndDlg, GCLP_HBRBACKGROUND, (LONG)hBackgroundBrush);
 			InvalidateRect(hwndDlg, 0, TRUE);
 		}
-
 		return TRUE;
+
 	case WMU_SETOPT:
 		{
 			Options *opt;
-			if(lParam) opt = (Options *)lParam;
+			if (lParam) opt = (Options *)lParam;
 			else opt = &options;
 			
 			// round corners
-			if(opt->aw_roundcorners) {
+			if (opt->aw_roundcorners) {
 				HRGN hRgn1;
 				RECT r;
 				int v,h;
@@ -142,11 +143,12 @@ BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 			SetWindowLong(hwndDlg, GWL_EXSTYLE, GetWindowLong(hwndDlg, GWL_EXSTYLE) | WS_EX_LAYERED);
 #endif
 #ifdef LWA_ALPHA
-			if(MySetLayeredWindowAttributes) 
+			if (MySetLayeredWindowAttributes) 
 				MySetLayeredWindowAttributes(hwndDlg, RGB(0,0,0), (int)((100 - opt->aw_trans) / 100.0 * 255), LWA_ALPHA);
 #endif
 		}
 		return TRUE;
+
 	case WMU_SETALARM:
 		{
 			ALARM *data = (ALARM *)lParam;
@@ -155,12 +157,12 @@ BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 			SetWindowText(hw, data->szTitle);
 
 			SetDlgItemText(hwndDlg, IDC_ED_DESC, data->szDesc);
-			((WindowData *)GetWindowLong(hwndDlg, GWL_USERDATA))->alarm = data;
+			((WindowData *)GetWindowLong(hwndDlg, GWLP_USERDATA))->alarm = data;
 
-			if(data->action & AAF_SOUND && options.loop_sound) {
-				if(data->sound_num <= 3)
+			if (data->action & AAF_SOUND && options.loop_sound) {
+				if (data->sound_num <= 3)
 					SetTimer(hwndDlg, ID_TIMER_SOUND, SOUND_REPEAT_PERIOD, 0);	
-				else if(data->sound_num == 4) 
+				else if (data->sound_num == 4) 
 					SetTimer(hwndDlg, ID_TIMER_SOUND, SPEACH_REPEAT_PERIOD, 0);	
 			}
 
@@ -169,6 +171,7 @@ BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 			ShowWindow(hw, (data->flags & ALF_NOSNOOZE) ? SW_HIDE : SW_SHOWNA);
 		}
 		return TRUE;
+
 	case WMU_FAKEALARM:
 		{
 			SetWindowText(hwndDlg, Translate("Example Alarm"));
@@ -177,18 +180,19 @@ BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 			SetDlgItemText(hwndDlg, IDC_ED_DESC, Translate("Some example text. Example, example, example."));
 		}
 		return TRUE;
+
 	case WM_TIMER: 
 		{
-			if(wParam == ID_TIMER_SOUND) {
-				WindowData *dw = (WindowData *)GetWindowLong(hwndDlg, GWL_USERDATA);
-				if(dw) {
+			if (wParam == ID_TIMER_SOUND) {
+				WindowData *dw = (WindowData *)GetWindowLong(hwndDlg, GWLP_USERDATA);
+				if (dw) {
 					ALARM *data = dw->alarm;
-					if(data && data->action & AAF_SOUND) {
-						if(data->sound_num <= 3) {
+					if (data && data->action & AAF_SOUND) {
+						if (data->sound_num <= 3) {
 							char buff[128];
 							sprintf(buff, "Triggered%d", data->sound_num);
 							SkinPlaySound(buff);
-						} else if(data->sound_num == 4) {
+						} else if (data->sound_num == 4) {
 							if (data->szTitle != NULL && data->szTitle[0] != '\0') {
 								if (ServiceExists("Speak/Say")) {
 									CallService("Speak/Say", 0, (LPARAM)data->szTitle);
@@ -202,18 +206,18 @@ BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 		return TRUE;
 	case WM_MOVE:
 		{
-			//WindowData *wd = (WindowData *)GetWindowLong(hwndDlg, GWL_USERDATA);
+			//WindowData *wd = (WindowData *)GetWindowLong(hwndDlg, GWLP_USERDATA);
 			Utils_SaveWindowPosition(hwndDlg, 0, MODULE, "Notify");
 		}
 		break;
 
 	case WMU_ADDSNOOZER:
 		{
-			WindowData *wd = (WindowData *)GetWindowLong(hwndDlg, GWL_USERDATA);
-			if(wd) {
+			WindowData *wd = (WindowData *)GetWindowLong(hwndDlg, GWLP_USERDATA);
+			if (wd) {
 				ALARM *data = wd->alarm;
 
-				if(data) {
+				if (data) {
 					// add snooze minutes to current time
 					FILETIME ft;
 					GetLocalTime(&data->time);
@@ -252,16 +256,16 @@ BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 				//drop through
 			case IDC_DISMISS:
 				{
-					WindowData *window_data = (WindowData *)GetWindowLong(hwndDlg, GWL_USERDATA);
+					WindowData *window_data = (WindowData *)GetWindowLong(hwndDlg, GWLP_USERDATA);
 					KillTimer(hwndDlg, ID_TIMER_SOUND);
-					if(window_data) {
-						if(window_data->alarm) {
+					if (window_data) {
+						if (window_data->alarm) {
 							free_alarm_data(window_data->alarm);
 							delete window_data->alarm;
 						}
 						delete window_data;
 					}
-					SetWindowLong(hwndDlg, GWL_USERDATA, 0);
+					SetWindowLong(hwndDlg, GWLP_USERDATA, 0);
 
 					win_num--;
 					//EndDialog(hwndDlg, IDOK); // not modal!
@@ -284,7 +288,7 @@ BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 #define AddItem(x)							\
 		mmi.wID++;							\
 		mmi.dwTypeData = Translate(x);		\
-		mmi.cch = strlen(mmi.dwTypeData);	\
+		mmi.cch = ( UINT )strlen(mmi.dwTypeData);	\
 		InsertMenuItem(hMenu, mmi.wID, FALSE, &mmi);
 
 					AddItem("5 mins");
@@ -317,7 +321,7 @@ BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 		return TRUE;
 
 	case WM_MOUSEMOVE:
-		if(wParam & MK_LBUTTON) {
+		if (wParam & MK_LBUTTON) {
 			SetCapture(hwndDlg);
 
 			POINT newp;
@@ -326,8 +330,8 @@ BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 
 			ClientToScreen(hwndDlg, &newp);
 
-			WindowData *window_data = (WindowData *)GetWindowLong(hwndDlg, GWL_USERDATA);
-			if(!window_data->moving) {
+			WindowData *window_data = (WindowData *)GetWindowLong(hwndDlg, GWLP_USERDATA);
+			if (!window_data->moving) {
 				window_data->moving = true;
 			} else {
 				RECT r;
@@ -339,7 +343,7 @@ BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 			window_data->p.y = newp.y;			
 		} else {
 			ReleaseCapture();
-			WindowData *window_data = (WindowData *)GetWindowLong(hwndDlg, GWL_USERDATA);
+			WindowData *window_data = (WindowData *)GetWindowLong(hwndDlg, GWLP_USERDATA);
 			window_data->moving = false;
 		}
 		return TRUE;
@@ -367,7 +371,7 @@ int ReloadFonts(WPARAM wParam, LPARAM lParam) {
 }
 
 int AlarmWinModulesLoaded(WPARAM wParam, LPARAM lParam) {
-	if(ServiceExists(MS_FONT_REGISTER)) {
+	if (ServiceExists(MS_FONT_REGISTER)) {
 		title_font_id.cbSize = sizeof(FontID);
 		strcpy(title_font_id.group, Translate("Alarms"));
 		strcpy(title_font_id.name, Translate("Title"));
@@ -423,8 +427,8 @@ void DeinitAlarmWin() {
 
 	FreeLibrary(hUserDll);
 
-	if(hBackgroundBrush) DeleteObject(hBackgroundBrush);
-	if(hTitleFont) DeleteObject(hTitleFont);
-	if(hWindowFont) DeleteObject(hWindowFont);
+	if (hBackgroundBrush) DeleteObject(hBackgroundBrush);
+	if (hTitleFont) DeleteObject(hTitleFont);
+	if (hWindowFont) DeleteObject(hWindowFont);
 }
 
diff --git a/plugins/Alarms/alarm_win.h b/plugins/Alarms/alarm_win.h
index da3517a353..19576050c6 100644
--- a/plugins/Alarms/alarm_win.h
+++ b/plugins/Alarms/alarm_win.h
@@ -4,7 +4,7 @@
 #include "options.h"
 #include "alarmlist.h"
 
-BOOL CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
 
 #define WMU_SETALARM				(WM_USER + 0x100)
 #define WMU_FAKEALARM				(WM_USER + 0x101)
diff --git a/plugins/Alarms/alarmlist.cpp b/plugins/Alarms/alarmlist.cpp
index 57171fc9c0..9bce8b546b 100644
--- a/plugins/Alarms/alarmlist.cpp
+++ b/plugins/Alarms/alarmlist.cpp
@@ -18,10 +18,10 @@ bool startup = true;
 bool is_idle = false;
 
 void free_alarm_data(ALARM *alarm) {
-	if(alarm->szTitle) {free(alarm->szTitle); alarm->szTitle = 0;}
-	if(alarm->szDesc) {free(alarm->szDesc); alarm->szDesc = 0;}
-	if(alarm->szCommand) {free(alarm->szCommand); alarm->szCommand = 0;}
-	if(alarm->szCommandParams) {free(alarm->szCommandParams); alarm->szCommandParams = 0;}
+	if (alarm->szTitle) {free(alarm->szTitle); alarm->szTitle = 0;}
+	if (alarm->szDesc) {free(alarm->szDesc); alarm->szDesc = 0;}
+	if (alarm->szCommand) {free(alarm->szCommand); alarm->szCommand = 0;}
+	if (alarm->szCommandParams) {free(alarm->szCommandParams); alarm->szCommandParams = 0;}
 }
 
 void copy_alarm_data(ALARM *dest, ALARM *src) {
@@ -48,7 +48,7 @@ void GetPluginTime(SYSTEMTIME *t) {
 }
 
 int MinutesInFuture(SYSTEMTIME time, Occurrence occ) {
-	if(!UpdateAlarm(time, occ)) return 0;
+	if (!UpdateAlarm(time, occ)) return 0;
 
 	SYSTEMTIME now;
 	GetPluginTime(&now);
@@ -65,7 +65,7 @@ int MinutesInFuture(SYSTEMTIME time, Occurrence occ) {
 
 	diff.QuadPart = uli_then.QuadPart - uli_now.QuadPart;
 	bool inc = false;
-	if(diff.QuadPart % mult.QuadPart >= mult.QuadPart / 2)
+	if (diff.QuadPart % mult.QuadPart >= mult.QuadPart / 2)
 		inc = true;
 	return (int)(diff.QuadPart / mult.QuadPart + (inc ? 1 : 0));
 }
@@ -112,7 +112,7 @@ bool UpdateAlarm(SYSTEMTIME &time, Occurrence occ) {
 	
 	switch(occ) {
 	case OC_ONCE:
-		if(CompareFileTime(&ft_then, &ft_now) < 0)
+		if (CompareFileTime(&ft_then, &ft_now) < 0)
 			return false;
 		break;
 	case OC_YEARLY:
@@ -123,7 +123,7 @@ bool UpdateAlarm(SYSTEMTIME &time, Occurrence occ) {
 		break;
 	case OC_MONTHLY:
 		while(CompareFileTime(&ft_then, &ft_now) < 0) {
-			if(time.wMonth == 12) {
+			if (time.wMonth == 12) {
 				time.wMonth = 1;
 				time.wYear++;
 			} else
@@ -138,7 +138,7 @@ bool UpdateAlarm(SYSTEMTIME &time, Occurrence occ) {
 			uli_then.LowPart = ft_then.dwLowDateTime;
 			FileTimeToSystemTime(&ft_then, &temp);
 			do {
-				if(temp.wDayOfWeek != time.wDayOfWeek || CompareFileTime(&ft_then, &ft_now) < 0) {
+				if (temp.wDayOfWeek != time.wDayOfWeek || CompareFileTime(&ft_then, &ft_now) < 0) {
 					uli_then.QuadPart += mult.QuadPart * (ULONGLONG)24 * (ULONGLONG)60;
 					ft_then.dwHighDateTime = uli_then.HighPart;
 					ft_then.dwLowDateTime = uli_then.LowPart;
@@ -154,7 +154,7 @@ bool UpdateAlarm(SYSTEMTIME &time, Occurrence occ) {
 			uli_then.LowPart = ft_then.dwLowDateTime;
 			do {
 				FileTimeToSystemTime(&ft_then, &temp);
-				if(temp.wDayOfWeek == 0 || temp.wDayOfWeek == 6 || CompareFileTime(&ft_then, &ft_now) < 0) {
+				if (temp.wDayOfWeek == 0 || temp.wDayOfWeek == 6 || CompareFileTime(&ft_then, &ft_now) < 0) {
 					uli_then.QuadPart += mult.QuadPart * (ULONGLONG)24 * (ULONGLONG)60;
 					ft_then.dwHighDateTime = uli_then.HighPart;
 					ft_then.dwLowDateTime = uli_then.LowPart;
@@ -192,14 +192,14 @@ void LoadAlarms() {
 		memset(&alarm, 0, sizeof(ALARM));
 
 		sprintf(buff, "Title%d", i);
-		if(!DBGetContactSetting(0, MODULE, buff, &dbv)) {
-			if(dbv.pszVal && strlen(dbv.pszVal))
+		if (!DBGetContactSetting(0, MODULE, buff, &dbv)) {
+			if (dbv.pszVal && strlen(dbv.pszVal))
 				alarm.szTitle = _strdup(dbv.pszVal);
 			DBFreeVariant(&dbv);
 		}
 		sprintf(buff, "Desc%d", i);
-		if(!DBGetContactSetting(0, MODULE, buff, &dbv)) {
-			if(dbv.pszVal && strlen(dbv.pszVal))
+		if (!DBGetContactSetting(0, MODULE, buff, &dbv)) {
+			if (dbv.pszVal && strlen(dbv.pszVal))
 				alarm.szDesc = _strdup(dbv.pszVal);
 			DBFreeVariant(&dbv);
 		}
@@ -246,18 +246,18 @@ void LoadAlarms() {
 		sprintf(buff, "TriggerID%d", i);
 		alarm.trigger_id = DBGetContactSettingDword(0, MODULE, buff, 0);
 
-		if(UpdateAlarm(alarm.time, alarm.occurrence)) {
+		if (UpdateAlarm(alarm.time, alarm.occurrence)) {
 			sprintf(buff, "ActionFlags%d", i);
 			alarm.action = (unsigned short)DBGetContactSettingDword(0, MODULE, buff, AAF_POPUP | AAF_SOUND);
-			if(alarm.action & AAF_COMMAND) {
+			if (alarm.action & AAF_COMMAND) {
 				sprintf(buff, "ActionCommand%d", i);
-				if(!DBGetContactSetting(0, MODULE, buff, &dbv)) {
-					if(dbv.pszVal && strlen(dbv.pszVal))
+				if (!DBGetContactSetting(0, MODULE, buff, &dbv)) {
+					if (dbv.pszVal && strlen(dbv.pszVal))
 						alarm.szCommand = _strdup(dbv.pszVal);
 					DBFreeVariant(&dbv);
 					sprintf(buff, "ActionParams%d", i);
-					if(!DBGetContactSetting(0, MODULE, buff, &dbv)) {
-						if(dbv.pszVal && strlen(dbv.pszVal))
+					if (!DBGetContactSetting(0, MODULE, buff, &dbv)) {
+						if (dbv.pszVal && strlen(dbv.pszVal))
 							alarm.szCommandParams = _strdup(dbv.pszVal);
 						DBFreeVariant(&dbv);
 					}
@@ -286,7 +286,7 @@ void LoadAlarms() {
 			alarms.push_back(&alarm);
 
 		} else { // else ignore it - it's an expired one-off alarm (but clean up triggers)
-			if(alarm.trigger_id != 0 && ServiceExists(MS_TRIGGER_REPORTEVENT)) {
+			if (alarm.trigger_id != 0 && ServiceExists(MS_TRIGGER_REPORTEVENT)) {
 				REPORTINFO ri = {0};
 				ri.cbSize = sizeof(ri);
 				ri.triggerID = alarm.trigger_id;
@@ -344,11 +344,11 @@ void SaveAlarms() {
 		}
 		sprintf(buff, "ActionFlags%d", index);
 		DBWriteContactSettingDword(0, MODULE, buff, i->action);
-		if(i->action & AAF_COMMAND) {
-			if(strlen(i->szCommand)) {
+		if (i->action & AAF_COMMAND) {
+			if (strlen(i->szCommand)) {
 				sprintf(buff, "ActionCommand%d", index);
 				DBWriteContactSettingString(0, MODULE, buff, i->szCommand);
-				if(strlen(i->szCommandParams)) {
+				if (strlen(i->szCommandParams)) {
 					sprintf(buff, "ActionParams%d", index);
 					DBWriteContactSettingString(0, MODULE, buff, i->szCommandParams);
 				}
@@ -387,7 +387,7 @@ void copy_list(AlarmList &copy, SYSTEMTIME &start, SYSTEMTIME &end) {
 	ALARM *i;
 	EnterCriticalSection(&alarm_cs);
 	for(alarms.reset(); i = alarms.current(); alarms.next()) {
-		if(IsBetween(i->time, start, end))
+		if (IsBetween(i->time, start, end))
 			copy.push_back(i);
 	}
 	LeaveCriticalSection(&alarm_cs);
@@ -407,7 +407,7 @@ void set_list(AlarmList &copy) {
 
 void append_to_list(ALARM *alarm) {
 	EnterCriticalSection(&alarm_cs);
-	if(!alarm->id)
+	if (!alarm->id)
 		alarm->id = next_alarm_id++;
 	alarms.push_back(alarm);
 	LeaveCriticalSection(&alarm_cs);
@@ -418,18 +418,18 @@ void append_to_list(ALARM *alarm) {
 void alter_alarm_list(ALARM *alarm) {
 	bool found = false;
 	EnterCriticalSection(&alarm_cs);
-	if(alarm->id != 0) {
+	if (alarm->id != 0) {
 		ALARM *i;
 		for(alarms.reset(); i = alarms.current(); alarms.next()) {
-			if(i->id == alarm->id) {
+			if (i->id == alarm->id) {
 				copy_alarm_data(i, alarm);
 				found = true;
 				break;
 			}
 		}
 	}
-	if(!found) {
-		if(!alarm->id)
+	if (!found) {
+		if (!alarm->id)
 			alarm->id = next_alarm_id++;
 		alarms.push_back(alarm);
 	}
@@ -443,8 +443,8 @@ void remove(unsigned short alarm_id) {
 	EnterCriticalSection(&alarm_cs);
 	ALARM *i;
 	for(alarms.reset(); i = alarms.current(); alarms.next()) {
-		if(i->id == alarm_id) {
-			if(i->trigger_id != 0 && ServiceExists(MS_TRIGGER_REPORTEVENT)) {
+		if (i->id == alarm_id) {
+			if (i->trigger_id != 0 && ServiceExists(MS_TRIGGER_REPORTEVENT)) {
 				REPORTINFO ri = {0};
 				ri.cbSize = sizeof(ri);
 				ri.triggerID = i->trigger_id;
@@ -464,7 +464,7 @@ void suspend(unsigned short alarm_id) {
 	EnterCriticalSection(&alarm_cs);
 	ALARM *i;
 	for(alarms.reset(); i = alarms.current(); alarms.next()) {
-		if(i->id == alarm_id && i->occurrence != OC_ONCE) {
+		if (i->id == alarm_id && i->occurrence != OC_ONCE) {
 			i->flags |= ALF_SUSPENDED;
 			break;
 		}
@@ -482,7 +482,7 @@ static int CALLBACK PopupAlarmDlgProc(HWND hWnd, UINT message, WPARAM wParam, LP
 				ALARM *mpd = NULL;
 				mpd = (ALARM *)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd,(LPARAM)mpd);
 
-				if(mpd->flags & ALF_NOSNOOZE)
+				if (mpd->flags & ALF_NOSNOOZE)
 					return TRUE;
 
 				// add snooze minutes to current time
@@ -531,7 +531,7 @@ static int CALLBACK PopupAlarmDlgProc(HWND hWnd, UINT message, WPARAM wParam, LP
 }
 
 void ShowPopup(ALARM *alarm) {
-	if(ServiceExists(MS_POPUP_ADDPOPUP)) {
+	if (ServiceExists(MS_POPUP_ADDPOPUP)) {
 		ALARM *data = new ALARM;
 		memset(data, 0, sizeof(ALARM));
 		copy_alarm_data(data, alarm);
@@ -568,14 +568,14 @@ void DoAlarm(ALARM *alarm) {
 	alarminfo.action = alarm->action;
 	alarminfo.sound_num = alarm->sound_num;
 
-	if(!NotifyEventHooks(hAlarmTriggeredEvent, 0, (LPARAM)&alarminfo)) {
+	if (!NotifyEventHooks(hAlarmTriggeredEvent, 0, (LPARAM)&alarminfo)) {
 
-		if(alarm->action & AAF_SOUND) {
-			if(alarm->sound_num > 0 && alarm->sound_num <= 3) {
+		if (alarm->action & AAF_SOUND) {
+			if (alarm->sound_num > 0 && alarm->sound_num <= 3) {
 				char buff[128];
 				sprintf(buff, "Triggered%d", alarm->sound_num);
 				SkinPlaySound(buff);
-			} else if(alarm->sound_num == 4) {
+			} else if (alarm->sound_num == 4) {
 				if (alarm->szTitle != NULL && alarm->szTitle[0] != '\0') {
 					if (ServiceExists("Speak/Say")) {
 						CallService("Speak/Say", 0, (LPARAM)alarm->szTitle);
@@ -583,8 +583,8 @@ void DoAlarm(ALARM *alarm) {
 				}
 			}
 		}
-		if(alarm->action & AAF_POPUP) {
-			if(options.use_popup_module && ServiceExists(MS_POPUP_ADDPOPUP)) 
+		if (alarm->action & AAF_POPUP) {
+			if (options.use_popup_module && ServiceExists(MS_POPUP_ADDPOPUP)) 
 				ShowPopup(alarm);
 			else {
 				HWND hwndDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ALARM), GetDesktopWindow(), DlgProcAlarm);
@@ -594,7 +594,7 @@ void DoAlarm(ALARM *alarm) {
 				memset(data, 0, sizeof(ALARM));
 				copy_alarm_data(data, alarm);
 				SendMessage(hwndDlg, WMU_SETALARM, 0, (LPARAM)data);
-				if(is_idle || !options.aw_dontstealfocus)
+				if (is_idle || !options.aw_dontstealfocus)
 					ShowWindow(hwndDlg, SW_SHOW);
 				else
 					ShowWindow(hwndDlg, SW_SHOWNOACTIVATE);
@@ -602,21 +602,21 @@ void DoAlarm(ALARM *alarm) {
 			}
 		}
 
-		if(alarm->trigger_id != 0 && ServiceExists(MS_TRIGGER_REPORTEVENT)) {
+		if (alarm->trigger_id != 0 && ServiceExists(MS_TRIGGER_REPORTEVENT)) {
 			REPORTINFO ri = {0};
 			ri.cbSize = sizeof(ri);
 			ri.triggerID = alarm->trigger_id;
 			ri.flags = TRG_PERFORM;
-			if(alarm->occurrence == OC_ONCE)
+			if (alarm->occurrence == OC_ONCE)
 				ri.flags |= TRG_CLEANUP;
 			CallService(MS_TRIGGER_REPORTEVENT, 0, (LPARAM)&ri);
 		}
 		
-		if(alarm->action & AAF_COMMAND) {
+		if (alarm->action & AAF_COMMAND) {
 			ShellExecute(0, 0, alarm->szCommand, alarm->szCommandParams, 0, SW_NORMAL);
 		}
 
-		if(alarm->action & AAF_SYSTRAY)
+		if (alarm->action & AAF_SYSTRAY)
 		{
 			CLISTEVENT cle = {0};
 			cle.cbSize = sizeof(cle);
@@ -652,7 +652,7 @@ void CheckAlarms() {
 	EnterCriticalSection(&alarm_cs);
 	ALARM *i;
 	for(alarms.reset(); i = alarms.current(); alarms.next()) {
-		if(!UpdateAlarm(i->time, i->occurrence)) { 
+		if (!UpdateAlarm(i->time, i->occurrence)) { 
 			// somehow an expired one-off alarm is in our list
 			remove_list.push_back(i);
 			continue;
@@ -660,18 +660,18 @@ void CheckAlarms() {
 
 		switch(i->occurrence) {
 		case OC_ONCE:
-			if(IsBetween(i->time, last_check, time)) {
-				if(!startup || !(i->flags & ALF_NOSTARTUP)) triggered_list.push_back(i);
+			if (IsBetween(i->time, last_check, time)) {
+				if (!startup || !(i->flags & ALF_NOSTARTUP)) triggered_list.push_back(i);
 				// erase and fix iterator - alarm has now been triggered and has therefore expired
 				remove_list.push_back(i);
 			}
 			break;
 		default:
-			if(IsBetween(i->time, last_check, time)) {
-				if(i->flags & ALF_SUSPENDED)
+			if (IsBetween(i->time, last_check, time)) {
+				if (i->flags & ALF_SUSPENDED)
 					i->flags = i->flags & ~ALF_SUSPENDED;
 				else
-					if(!startup || !(i->flags & ALF_NOSTARTUP)) triggered_list.push_back(i);
+					if (!startup || !(i->flags & ALF_NOSTARTUP)) triggered_list.push_back(i);
 			}
 			break;
 		}
@@ -696,7 +696,8 @@ VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) {
 }
 
 
-int AddAlarmService(WPARAM wParam, LPARAM lParam) {
+INT_PTR AddAlarmService(WPARAM wParam, LPARAM lParam)
+{
 	ALARMINFO *alarm_info = (ALARMINFO *)lParam;
 	ALARM alarm = {0};
 	alarm.action = alarm_info->action;
@@ -715,9 +716,9 @@ int AddAlarmService(WPARAM wParam, LPARAM lParam) {
 	return 0;
 }
 
-int IdleChanged(WPARAM wParam, LPARAM lParam) {
+int IdleChanged(WPARAM wParam, LPARAM lParam)
+{
 	is_idle = (lParam & IDF_ISIDLE);
-
 	return 0;
 }
 
@@ -737,7 +738,7 @@ void InitList() {
 	dbv.type = DBVT_BLOB;
 	dbv.cpbVal = sizeof(SYSTEMTIME);
 
-	if(!CallService(MS_DB_CONTACT_GETSETTING, 0, (LPARAM)&dbcgs)) {
+	if (!CallService(MS_DB_CONTACT_GETSETTING, 0, (LPARAM)&dbcgs)) {
 		memcpy(&last_check, dbv.pbVal, sizeof(SYSTEMTIME));
 		DBFreeVariant(&dbv);
 	} else {
diff --git a/plugins/Alarms/alarmlist.h b/plugins/Alarms/alarmlist.h
index 8fdc4b3ac1..af8e90b666 100644
--- a/plugins/Alarms/alarmlist.h
+++ b/plugins/Alarms/alarmlist.h
@@ -25,14 +25,14 @@ public:
 	virtual ~AlarmList() {clear();}
 
 	void sort() {
-		if(count < 2) return;
+		if (count < 2) return;
 
 		Node *c1 = head, *c2;
 		// bubble sort...hey, i'm lazy :)
 		while(c1) {
 			c2 = c1->next;
 			while(c2) {
-				if(c2->alarm < c1->alarm) {
+				if (c2->alarm < c1->alarm) {
 					swap (c1, c2);
 				}
 				c2 = c2->next;
@@ -70,12 +70,12 @@ public:
 	ALARM *current() {return (it_current ? &it_current->alarm : 0);}
 	void next() {it_current = it_current->next;}
 	void erase() {
-		if(it_current) {
-			if(it_current->next) it_current->next->prev = it_current->prev;
-			if(it_current->prev) it_current->prev->next = it_current->next;
+		if (it_current) {
+			if (it_current->next) it_current->next->prev = it_current->prev;
+			if (it_current->prev) it_current->prev->next = it_current->next;
 
-			if(tail == it_current) tail = tail->prev;
-			if(head == it_current) head = head->next;
+			if (tail == it_current) tail = tail->prev;
+			if (head == it_current) head = head->next;
 
 			free_alarm_data(&it_current->alarm);
 			delete it_current;
@@ -91,10 +91,10 @@ public:
 		copy_alarm_data(&nn->alarm, alarm);
 
 		nn->prev = tail;
-		if(tail) tail->next = nn;
+		if (tail) tail->next = nn;
 		tail = nn;
 
-		if(!head) head = tail;
+		if (!head) head = tail;
 		count++;
 	}
 
diff --git a/plugins/Alarms/alarms.cpp b/plugins/Alarms/alarms.cpp
index d95979ef74..7882173482 100644
--- a/plugins/Alarms/alarms.cpp
+++ b/plugins/Alarms/alarms.cpp
@@ -92,7 +92,7 @@ static int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
 }
 
 void ShowPopup(HANDLE hContact, const char *msg) {
-	if(ServiceExists(MS_POPUP_ADDPOPUP)) {
+	if (ServiceExists(MS_POPUP_ADDPOPUP)) {
 		POPUPDATAEX ppd;
 		char *lpzContactName;
 
@@ -136,14 +136,14 @@ static int PluginMessageReceived(WPARAM wParam,LPARAM lParam)
 	
 	char msg[1024], buff[1024];
 
-	if(strncmp(ppre->szMessage, szGamePrefix, strlen(szGamePrefix)))
+	if (strncmp(ppre->szMessage, szGamePrefix, strlen(szGamePrefix)))
 		return CallService( MS_PROTO_CHAINRECV, wParam, lParam );
 
 	strcpy(msg, ppre->szMessage + strlen(szGamePrefix));
 
 	savedMsg = ppre->szMessage;
 	
-	if(!strcmp(msg, " ffw")) {
+	if (!strcmp(msg, " ffw")) {
 		sprintf(buff, "Fast forward!");
 		
 		hWnd = FindWindow(0, "Windows Media Player");
@@ -225,7 +225,7 @@ static int InitTopToolbarButton(WPARAM wParam, LPARAM lParam) {
 }
 
 static int MainInit(WPARAM wparam,LPARAM lparam) {
-	if(ServiceExists(MS_UPDATE_REGISTER)) {
+	if (ServiceExists(MS_UPDATE_REGISTER)) {
 		// register with updater
 		Update update = {0};
 		char szVersion[16];
@@ -234,7 +234,7 @@ static int MainInit(WPARAM wparam,LPARAM lparam) {
 
 		update.szComponentName = pluginInfo.shortName;
 		update.pbVersion = (BYTE *)CreateVersionString(pluginInfo.version, szVersion);
-		update.cpbVersion = strlen((char *)update.pbVersion);
+		update.cpbVersion = (int)strlen((char *)update.pbVersion);
 
 		update.szUpdateURL = UPDATER_AUTOREGISTER;
 		
@@ -246,7 +246,7 @@ static int MainInit(WPARAM wparam,LPARAM lparam) {
 		update.szBetaVersionURL = "http://www.scottellis.com.au/miranda_plugins/ver_alarms.html";
 		update.pbBetaVersionPrefix = (BYTE *)" version ";
 		
-		update.cpbBetaVersionPrefix = strlen((char *)update.pbBetaVersionPrefix);
+		update.cpbBetaVersionPrefix = (int)strlen((char *)update.pbBetaVersionPrefix);
 
 		CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update);
 	}
@@ -268,7 +268,7 @@ static int MainInit(WPARAM wparam,LPARAM lparam) {
 
 	while( hContact )
 	{
-		if( !CallService( MS_PROTO_ISPROTOONCONTACT, ( WPARAM )hContact, ( LPARAM )SERVICENAME ))
+		if ( !CallService( MS_PROTO_ISPROTOONCONTACT, ( WPARAM )hContact, ( LPARAM )SERVICENAME ))
 			CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM )hContact, ( LPARAM )SERVICENAME );
 
 		hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT, ( WPARAM )hContact, 0 );
diff --git a/plugins/Alarms/frame.cpp b/plugins/Alarms/frame.cpp
index 6999d10b0c..498accc30e 100644
--- a/plugins/Alarms/frame.cpp
+++ b/plugins/Alarms/frame.cpp
@@ -31,7 +31,7 @@ int height_client_to_frame(int client_height, LONG style, LONG ex_style) {
 	RECT tr;
 	tr.top = tr.right = tr.left = 0;
 	tr.bottom = client_height;
-	if(AdjustWindowRectEx(&tr, style, FALSE, ex_style))
+	if (AdjustWindowRectEx(&tr, style, FALSE, ex_style))
 		return tr.bottom - tr.top;
 	return 0;
 }
@@ -41,7 +41,7 @@ LRESULT CALLBACK FrameContainerWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LP
 		case WM_CREATE:
 			return TRUE;
 		case WM_SHOWWINDOW:
-			if((BOOL)wParam) {
+			if ((BOOL)wParam) {
 				DBWriteContactSettingByte(0, MODULE, "ReminderFrameVisible", 1);
 				Utils_RestoreWindowPosition(hwnd, 0, MODULE, "reminders_window");
 				PostMessage(hwnd, WM_SIZE, 0, 0);
@@ -52,7 +52,7 @@ LRESULT CALLBACK FrameContainerWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LP
 			break;
 		case WM_SIZE:
 			{
-				HWND child = (HWND)GetWindowLong(hwnd, GWL_USERDATA);
+				HWND child = (HWND)GetWindowLong(hwnd, GWLP_USERDATA);
 				RECT r;
 				GetClientRect(hwnd, &r);
 
@@ -73,7 +73,7 @@ LRESULT CALLBACK FrameContainerWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LP
 }
 
 bool FrameIsFloating() {
-	if(frame_id == -1) 
+	if (frame_id == -1) 
 		return true; // no frames, always floating
 	
 	return (CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLOATING, frame_id), 0) != 0);
@@ -109,7 +109,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 
 		case WM_DRAWITEM:
 			dis = (DRAWITEMSTRUCT *)lParam;
-			if(dis->itemID != (DWORD)-1) {
+			if (dis->itemID != (DWORD)-1) {
 				ALARM alarm = {0};
 				EnterCriticalSection(&list_cs);
 				ALARM &list_alarm = alarm_list.at(dis->itemData);
@@ -135,7 +135,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 				GetTextExtentPoint32(dis->hDC,alarm.szTitle,lstrlen(alarm.szTitle),&textSize);
 
 				char buff[100];
-				if(min >= 60) {
+				if (min >= 60) {
 					mir_snprintf(buff, 100, Translate("%dh %dm"), min / 60, min % 60);
 				} else {
 					mir_snprintf(buff, 100, Translate("%dm"), min);
@@ -143,11 +143,11 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 
 				GetTextExtentPoint32(dis->hDC,buff,lstrlen(buff),&timeSize);
 
-				if(textSize.cx > (dis->rcItem.right - dis->rcItem.left) - (GetSystemMetrics(SM_CXSMICON) + 4) - timeSize.cx - 2 - 4) {
+				if (textSize.cx > (dis->rcItem.right - dis->rcItem.left) - (GetSystemMetrics(SM_CXSMICON) + 4) - timeSize.cx - 2 - 4) {
 					// need elipsis
 					char titlebuff[512];
 					int len = lstrlen(alarm.szTitle);
-					if(len > 511) len = 511;
+					if (len > 511) len = 511;
 					while(len > 0 && textSize.cx > (dis->rcItem.right - dis->rcItem.left) - (GetSystemMetrics(SM_CXSMICON) + 4) - timeSize.cx - 2 - 4) {
 						len--;
 						strncpy(titlebuff, alarm.szTitle, len);
@@ -194,7 +194,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 		case WM_PAINT:
 			{
 				RECT r;
-				if(GetUpdateRect(hwnd, &r, FALSE)) {
+				if (GetUpdateRect(hwnd, &r, FALSE)) {
 					PAINTSTRUCT ps;
 					HDC hdc = BeginPaint(hwnd, &ps);
 					SendMessage(hwnd, WM_PRINTCLIENT, (WPARAM)hdc, (LPARAM)(PRF_CLIENT | PRF_CHILDREN));
@@ -204,14 +204,14 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 			return TRUE;
 
 		case WM_SHOWWINDOW:
-			if((BOOL)wParam) PostMessage(hwnd, WMU_SIZE_LIST, 0, 0);
+			if ((BOOL)wParam) PostMessage(hwnd, WMU_SIZE_LIST, 0, 0);
 			break;
 
 		case WM_SIZE:
-			if(IsWindowVisible(hwnd)) {
+			if (IsWindowVisible(hwnd)) {
 				SendMessage(hwnd, WMU_SIZE_LIST, 0, 0);
 			
-				if(frame_id != -1) {
+				if (frame_id != -1) {
 					//CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)(FU_TBREDRAW | FU_FMREDRAW));
 					CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)FU_TBREDRAW);
 				}
@@ -221,20 +221,20 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 
 		case WMU_SIZE_LIST:
 			{
-				if(SendMessage(hwnd_list, LB_GETITEMHEIGHT, 0, 0) != options.row_height)
+				if (SendMessage(hwnd_list, LB_GETITEMHEIGHT, 0, 0) != options.row_height)
 					SendMessage(hwnd_list, LB_SETITEMHEIGHT, 0, options.row_height);
 
 				int itemheight = SendMessage(hwnd_list, LB_GETITEMHEIGHT, 0, 0),
 					count = SendMessage(hwnd_list, LB_GETCOUNT, 0, 0);
 				
-				if(options.auto_size_vert && IsWindowVisible(hwnd)) {
-					if(FrameIsFloating()) {
+				if (options.auto_size_vert && IsWindowVisible(hwnd)) {
+					if (FrameIsFloating()) {
 						
 #define CLUIFrameTitleBarClassName				"CLUIFrameTitleBar"
 						
 						int height = height_client_to_frame(itemheight * count, GetWindowLong(GetParent(hwnd), GWL_STYLE), GetWindowLong(GetParent(hwnd), GWL_EXSTYLE));
 						HWND titleBarHwnd = FindWindowEx(GetParent(hwnd), 0, CLUIFrameTitleBarClassName, 0);
-						if(titleBarHwnd) {
+						if (titleBarHwnd) {
 							RECT tbr;
 							GetWindowRect(titleBarHwnd, &tbr);
 							height += (tbr.bottom - tbr.top);
@@ -249,11 +249,11 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 						GetWindowRect(GetParent(hwnd), &rp_window);
 						GetWindowRect(hwnd, &r_window);
 						int diff = (rp_window.bottom - rp_window.top) - (rp_client.bottom - rp_client.top);
-						if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
+						if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
 							diff += rp_window.top - r_window.top;
 						SetWindowPos(GetParent(hwnd), 0, 0, 0, rp_window.right - rp_window.left, count * itemheight + diff, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
 						*/
-					} else if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME) && frame_id != -1) {
+					} else if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME) && frame_id != -1) {
 						int flags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, frame_id), 0);
 						CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, frame_id), (LPARAM)(count * itemheight));
 						CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)(FU_TBREDRAW | FU_FMREDRAW | FU_FMPOS));
@@ -269,28 +269,28 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 				winheight = r.bottom - r.top;
 
 				height = min(count * itemheight, winheight - (winheight % itemheight));
-				if(r2.right - r2.left != width || (r.bottom - r.top > 0 && r2.bottom - r2.top != height)) {
+				if (r2.right - r2.left != width || (r.bottom - r.top > 0 && r2.bottom - r2.top != height)) {
 					SetWindowPos(hwnd_list, 0, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
 					InvalidateRect(hwnd_list, 0, FALSE);
 				}
 				
-				if(options.auto_showhide) {
-					if(ServiceExists(MS_CLIST_FRAMES_SHFRAME) && frame_id != -1) {
-						if(IsWindowVisible(hwnd) && count == 0) {
+				if (options.auto_showhide) {
+					if (ServiceExists(MS_CLIST_FRAMES_SHFRAME) && frame_id != -1) {
+						if (IsWindowVisible(hwnd) && count == 0) {
 							CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
-						} else if(!IsWindowVisible(hwnd) && count > 0) {
+						} else if (!IsWindowVisible(hwnd) && count > 0) {
 							// we have reminders - show if not linked to clist or if clist is visible
-							if((!options.hide_with_clist && FrameIsFloating()) || IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0))) {
+							if ((!options.hide_with_clist && FrameIsFloating()) || IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0))) {
 								CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);						
 								CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)(FU_FMREDRAW | FU_FMPOS));
 							}
 						}
 					} else {
-						if(IsWindowVisible(hwnd) && count == 0)
+						if (IsWindowVisible(hwnd) && count == 0)
 							SetReminderFrameVisible(false);
-						else if(!IsWindowVisible(hwnd) && count > 0)
+						else if (!IsWindowVisible(hwnd) && count > 0)
 							// we have reminders - show if not linked to clist or if clist is visible
-							if(!options.hide_with_clist || IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0)))
+							if (!options.hide_with_clist || IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0)))
 								SetReminderFrameVisible(true);
 					}
 				}
@@ -316,7 +316,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 				int index = 0;
 				ALARM *i;
 				for(alarm_list.reset(); i = alarm_list.current(); alarm_list.next(), index++) {
-					if(i->flags & (ALF_HIDDEN | ALF_SUSPENDED | ALF_NOREMINDER))
+					if (i->flags & (ALF_HIDDEN | ALF_SUSPENDED | ALF_NOREMINDER))
 						continue;
 					SendMessage(hwnd_list, LB_ADDSTRING, 0, (LPARAM)index);
 				}
@@ -325,30 +325,30 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 				SendMessage(hwnd, WMU_SIZE_LIST, 0, 0);
 				SendMessage(hwnd_list, WM_SETREDRAW, (WPARAM)TRUE, 0);
 
-				if(sel != LB_ERR && sel < index) SendMessage(hwnd_list, LB_SETCURSEL, (WPARAM)sel, 0);
-				if(top != LB_ERR && top < index) SendMessage(hwnd_list, LB_SETTOPINDEX, (WPARAM)top, 0);
+				if (sel != LB_ERR && sel < index) SendMessage(hwnd_list, LB_SETCURSEL, (WPARAM)sel, 0);
+				if (top != LB_ERR && top < index) SendMessage(hwnd_list, LB_SETTOPINDEX, (WPARAM)top, 0);
 
 			}
 			return TRUE;
 		
 		case WM_TIMER:
-			if(wParam == ID_FRAME_UPDATE_TIMER)
+			if (wParam == ID_FRAME_UPDATE_TIMER)
 				SendMessage(hwnd, WMU_FILL_LIST, 0, 0);
-			else if(wParam == ID_FRAME_SHOWHIDE_TIMER && options.hide_with_clist) { // link show/hide with clist
+			else if (wParam == ID_FRAME_SHOWHIDE_TIMER && options.hide_with_clist) { // link show/hide with clist
 				// hide if we're visible and clist isn't (possible only when floating if frames are present)
-				if(!IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0)) && IsWindowVisible(hwnd)) {
-					if(ServiceExists(MS_CLIST_FRAMES_SHFRAME))
+				if (!IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0)) && IsWindowVisible(hwnd)) {
+					if (ServiceExists(MS_CLIST_FRAMES_SHFRAME))
 						CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
 					else
 						SetReminderFrameVisible(false);
 				}
 				// we're not visible but clist is - show depending on hide_with_clist and auto_showhide options
-				if(!IsWindowVisible(hwnd) && IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0))) {
+				if (!IsWindowVisible(hwnd) && IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0))) {
 					// if not auto show/hide, show (reminders or not) if we're not visible and the clist is
 					// otherwise, show only if there are reminders
 					int count = SendMessage(hwnd_list, LB_GETCOUNT, 0, 0);
-					if(!options.auto_showhide || count > 0) {
-						if(ServiceExists(MS_CLIST_FRAMES_SHFRAME))
+					if (!options.auto_showhide || count > 0) {
+						if (ServiceExists(MS_CLIST_FRAMES_SHFRAME))
 							CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
 						else
 							SetReminderFrameVisible(true);
@@ -371,14 +371,14 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 				HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)), submenu = GetSubMenu(menu, 0);
 				CallService(MS_LANGPACK_TRANSLATEMENU,(WPARAM)submenu,0);
 	
-				if(HIWORD(item) == 0) {
+				if (HIWORD(item) == 0) {
 					int sel = LOWORD(item);
-					if(sel >= 0) {
+					if (sel >= 0) {
 						// one-off alarms can't be suspended
 						int index = SendMessage(hwnd_list, LB_GETITEMDATA, (WPARAM)sel, 0);
 						ALARM &list_alarm = alarm_list.at(index);
 						copy_alarm_data(&context_menu_alarm, &list_alarm);
-						if(context_menu_alarm.occurrence == OC_ONCE)
+						if (context_menu_alarm.occurrence == OC_ONCE)
 							EnableMenuItem(submenu, ID_REMINDERFRAMECONTEXT_SUSPEND, MF_BYCOMMAND | MF_GRAYED);
 
 					}
@@ -394,7 +394,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 				
 				BOOL ret = TrackPopupMenu(submenu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL);
 				DestroyMenu(menu);
-				if(ret) PostMessage(hwnd, WM_COMMAND, ret, 0);
+				if (ret) PostMessage(hwnd, WM_COMMAND, ret, 0);
 			}
 			return TRUE;
 
@@ -411,10 +411,10 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 					}
 					break;
 				case ID_REMINDERFRAMECONTEXT_SUSPEND:
-					if(context_menu_alarm.occurrence != OC_ONCE) {
+					if (context_menu_alarm.occurrence != OC_ONCE) {
 						suspend(context_menu_alarm.id);
 						PostMessage(hwnd, WMU_FILL_LIST, 0, 0);
-						if(hwndOptionsDialog) {
+						if (hwndOptionsDialog) {
 							// refresh options list
 							PostMessage(hwndOptionsDialog, WMU_INITOPTLIST, 0, 0);
 						}
@@ -426,7 +426,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 				case ID_REMINDERFRAMECONTEXT_DELETE:
 					remove(context_menu_alarm.id);
 					PostMessage(hwnd, WMU_FILL_LIST, 0, 0);
-					if(hwndOptionsDialog) {
+					if (hwndOptionsDialog) {
 						// refresh options list
 						PostMessage(hwndOptionsDialog, WMU_INITOPTLIST, 0, 0);
 					}
@@ -448,7 +448,8 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
 	return DefWindowProc(hwnd, msg, wParam, lParam);
 }
 
-int ReloadFont(WPARAM wParam, LPARAM lParam) {
+int ReloadFont(WPARAM wParam, LPARAM lParam)
+{
 	DeleteObject(hFont);
 
 	LOGFONT log_font;
@@ -463,16 +464,17 @@ int ReloadFont(WPARAM wParam, LPARAM lParam) {
 	return 0;
 }
 
-void FixMainMenu() {
+void FixMainMenu()
+{
 	CLISTMENUITEM mi = {0};
 	mi.cbSize = sizeof(CLISTMENUITEM);
-	if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
-		if(options.hide_with_clist || options.auto_showhide) {
+	if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+		if (options.hide_with_clist || options.auto_showhide)
 			mi.flags = CMIM_FLAGS | CMIF_GRAYED;
-		} else {
+		else {
 			mi.flags = CMIM_NAME | CMIM_FLAGS;
 
-			if(ReminderFrameVisible())
+			if (ReminderFrameVisible())
 				mi.pszName = Translate("Hide Reminders");
 			else
 				mi.pszName = Translate("Show Reminders");
@@ -483,21 +485,24 @@ void FixMainMenu() {
 
 /////////////////////////
 // only used when no multiwindow functionality is available
-bool ReminderFrameVisible() {
+bool ReminderFrameVisible()
+{
 	return IsWindowVisible(hwnd_frame) ? true : false;
 }
 
-void SetReminderFrameVisible(bool visible) {
-	if(frame_id == -1 && hwnd_frame != 0) 
+void SetReminderFrameVisible(bool visible)
+{
+	if (frame_id == -1 && hwnd_frame != 0) 
 		ShowWindow(hwnd_frame, visible ? SW_SHOW : SW_HIDE);
 }
 
-int ShowHideMenuFunc(WPARAM wParam, LPARAM lParam) {
-	if(ReminderFrameVisible())
+INT_PTR ShowHideMenuFunc(WPARAM wParam, LPARAM lParam)
+{
+	if (ReminderFrameVisible())
 		SendMessage(hwnd_frame, WM_CLOSE, 0, 0);
-	else {
+	else
 		ShowWindow(hwnd_frame, SW_SHOW);
-	}
+
 	FixMainMenu();
 	return 0;
 }
@@ -518,7 +523,7 @@ int CreateFrame()
 	wndclass.lpszClassName = "AlarmsFrame";
 	RegisterClass(&wndclass);
 
-	if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+	if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
 
 		hwnd_plugin = CreateWindow("AlarmsFrame",Translate("Alarms"), 
 			WS_CHILD | WS_CLIPCHILDREN, 
@@ -556,7 +561,7 @@ int CreateFrame()
 			WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE,
 			0,0,10,10, hwnd_frame, NULL,hInst,NULL);
 
-		SetWindowLong(hwnd_frame, GWL_USERDATA, (LONG)hwnd_plugin);
+		SetWindowLong(hwnd_frame, GWLP_USERDATA, (LONG)hwnd_plugin);
 
 		///////////////////////
 		// create menu item
@@ -575,16 +580,16 @@ int CreateFrame()
 		hMenuShowReminders = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM)&menu);
 		/////////////////////
 
-		if(!options.auto_showhide) {
-			if(options.hide_with_clist) {
-				if(IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0))) {
+		if (!options.auto_showhide) {
+			if (options.hide_with_clist) {
+				if (IsWindowVisible((HWND)CallService(MS_CLUI_GETHWND, 0, 0))) {
 					ShowWindow(hwnd_frame, SW_SHOW);
 					RefreshReminderFrame();
 				} else {
 					ShowWindow(hwnd_frame, SW_HIDE);
 				}
 			} else {
-				if(DBGetContactSettingByte(0, MODULE, "ReminderFrameVisible", 1) == 1) {
+				if (DBGetContactSettingByte(0, MODULE, "ReminderFrameVisible", 1) == 1) {
 					ShowWindow(hwnd_frame, SW_SHOW);
 					RefreshReminderFrame();
 				} else {
@@ -598,7 +603,7 @@ int CreateFrame()
 
 	SendMessage(hwnd_plugin, WMU_INITIALIZE, 0, 0);
 
-	if(ServiceExists(MS_FONT_REGISTER)) {
+	if (ServiceExists(MS_FONT_REGISTER)) {
 		font_id.cbSize = sizeof(FontID);
 		strncpy(font_id.group, Translate("Frames"), sizeof(font_id.group));
 		strncpy(font_id.name, Translate("Alarm Reminders"), sizeof(font_id.name));
@@ -651,7 +656,7 @@ int CreateFrame()
 void RefreshReminderFrame() {
 	SendMessage(hwnd_plugin, WMU_FILL_LIST, 0, 0);
 
-	if(frame_id == -1) {
+	if (frame_id == -1) {
 		InvalidateRect(hwnd_frame, 0, TRUE);
 	} else
 		InvalidateRect(hwnd_plugin, 0, TRUE);
@@ -666,11 +671,11 @@ void InitFrames()
 
 void DeinitFrames()
 {
-	if(ServiceExists(MS_CLIST_FRAMES_REMOVEFRAME)) {
+	if (ServiceExists(MS_CLIST_FRAMES_REMOVEFRAME)) {
 		CallService(MS_CLIST_FRAMES_REMOVEFRAME, (WPARAM)frame_id, 0);
 	}
 	DestroyWindow(hwnd_plugin);
-	if(hwnd_frame) DestroyWindow(hwnd_frame);
+	if (hwnd_frame) DestroyWindow(hwnd_frame);
 
 	DeleteObject(bk_brush);
 
diff --git a/plugins/Alarms/icons.cpp b/plugins/Alarms/icons.cpp
index ecc7f5539c..fe6abf834d 100644
--- a/plugins/Alarms/icons.cpp
+++ b/plugins/Alarms/icons.cpp
@@ -9,7 +9,7 @@ int ReloadIcons(WPARAM wParam, LPARAM lParam) {
 	hIconMenuSet = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_menu_set");
 	hIconList1 = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_list1");
 	hIconList2 = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_list2");
-	if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
+	if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
 		hIconMenuShowHide = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_menu_showhide");
 
 	RefreshReminderFrame();
@@ -17,7 +17,7 @@ int ReloadIcons(WPARAM wParam, LPARAM lParam) {
 }
 
 void InitIcons() {
-	if(ServiceExists(MS_SKIN2_ADDICON)) {
+	if (ServiceExists(MS_SKIN2_ADDICON)) {
 		SKINICONDESC sid = {0};
 
 		sid.cbSize = sizeof(SKINICONDESC);
@@ -51,7 +51,7 @@ void InitIcons() {
 		sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAINMENU), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
 		CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
 
-		if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+		if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
 			sid.pszDescription = Translate("Menu: Show/Hide Reminders");
 			sid.pszName = "alarms_menu_showhide";
 			sid.pszDefaultFile = "alarms.dll";
@@ -73,19 +73,19 @@ void InitIcons() {
 		hIconList1 = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_LIST1), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
 		hIconList2 = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_LIST2), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
 		hIconSystray = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAINMENU), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
-		if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
+		if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
 			hIconMenuShowHide = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAINMENU), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
 	}
 }
 
 
 void DeinitIcons() {
-	if(!ServiceExists(MS_SKIN2_ADDICON)) {
+	if (!ServiceExists(MS_SKIN2_ADDICON)) {
 		DestroyIcon(hIconMenuSet);
 		DestroyIcon(hIconList1);
 		DestroyIcon(hIconList2);
 		DestroyIcon(hIconSystray);
-		if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
+		if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
 			DestroyIcon(hIconMenuShowHide);
 	}
 }
diff --git a/plugins/Alarms/options.cpp b/plugins/Alarms/options.cpp
index 0f22a57fb0..0013b7f39c 100644
--- a/plugins/Alarms/options.cpp
+++ b/plugins/Alarms/options.cpp
@@ -22,35 +22,36 @@ HANDLE hMainMenuItem = 0, hGroupMenuItem;
 // store options dialog window handle statically so it can be refreshed by non-modal add alarm dialog
 HWND hwndOptionsDialog = 0;
 
-static BOOL CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+	ALARM *add_edit_alarm = (ALARM *)GetWindowLong(hwndDlg, GWLP_USERDATA);
+	HWND hw;
 
 	switch ( msg ) {
-		case WM_INITDIALOG: {
-			TranslateDialogDefault( hwndDlg );
-
-			SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 0, (LPARAM)Translate("Sunday"));
-			SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 1, (LPARAM)Translate("Monday"));
-			SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 2, (LPARAM)Translate("Tuesday"));
-			SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 3, (LPARAM)Translate("Wednesday"));
-			SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 4, (LPARAM)Translate("Thursday"));
-			SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 5, (LPARAM)Translate("Friday"));
-			SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 6, (LPARAM)Translate("Saturday"));
-			SendDlgItemMessage(hwndDlg, IDC_DAY, CB_SETCURSEL, 0, 0);
+	case WM_INITDIALOG:
+		TranslateDialogDefault( hwndDlg );
 
+		SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 0, (LPARAM)Translate("Sunday"));
+		SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 1, (LPARAM)Translate("Monday"));
+		SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 2, (LPARAM)Translate("Tuesday"));
+		SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 3, (LPARAM)Translate("Wednesday"));
+		SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 4, (LPARAM)Translate("Thursday"));
+		SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 5, (LPARAM)Translate("Friday"));
+		SendDlgItemMessage(hwndDlg, IDC_DAY, CB_INSERTSTRING, 6, (LPARAM)Translate("Saturday"));
+		SendDlgItemMessage(hwndDlg, IDC_DAY, CB_SETCURSEL, 0, 0);
+		{
 			char buff[10];
 			for(int i = 1; i <= 31; i++) {
 				SendDlgItemMessage(hwndDlg, IDC_DAYNUM, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)itoa(i, buff, 10));
 			}
 			SendDlgItemMessage(hwndDlg, IDC_DAYNUM, CB_SETCURSEL, 0, 0);
-
 			{
 				HWND hw = GetDlgItem(hwndDlg, IDOK);
 				EnableWindow(hw, FALSE);
 			}
 
-			if (!ServiceExists("Speak/Say")) {
+			if (!ServiceExists("Speak/Say"))
 				EnableWindow(GetDlgItem(hwndDlg, IDC_RAD_SPK), FALSE);
-			}
 
 			AddEditParam *param = (AddEditParam *)lParam;
 			SendMessage(hwndDlg, WMU_OPTSETALARM, (WPARAM)param->edit, (LPARAM)param->alarm_ptr);
@@ -62,98 +63,99 @@ static BOOL CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
 
 			Utils_RestoreWindowPositionNoSize(hwndDlg, 0, MODULE, "AddEdit");
 
-			if(GetDlgCtrlID((HWND)wParam) != IDC_TITLE) { 
+			if (GetDlgCtrlID((HWND)wParam) != IDC_TITLE) { 
 				SetFocus(GetDlgItem(hwndDlg, IDC_TITLE)); 
 				return FALSE; 
-			} 		
-			return TRUE;
+			}
 		}
-		case WMU_OPTSETALARM: {
+		return TRUE;
+
+	case WMU_OPTSETALARM:
+		{
 			BOOL edit = (BOOL)wParam;
-			ALARM *add_edit_alarm = (ALARM *)lParam;
-			SetWindowLong(hwndDlg, GWL_USERDATA, (LONG)add_edit_alarm);
+			add_edit_alarm = (ALARM *)lParam;
+			SetWindowLong(hwndDlg, GWLP_USERDATA, (LONG)add_edit_alarm);
 
-			if(edit) {
+			if (edit) {
 				SetDlgItemText(hwndDlg, IDC_TITLE, add_edit_alarm->szTitle);
 				SetDlgItemText(hwndDlg, IDC_DESC, add_edit_alarm->szDesc);
 				switch(add_edit_alarm->occurrence) {
-					case OC_DAILY: {
-							CheckDlgButton(hwndDlg, IDC_RAD_DAILY, TRUE);
-							HWND hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_DATE);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_DAY);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
-							EnableWindow(hw, TRUE);
-					}
+				case OC_DAILY:
+					CheckDlgButton(hwndDlg, IDC_RAD_DAILY, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_DATE);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_DAY);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
+					EnableWindow(hw, TRUE);
 					break;
-					case OC_WEEKDAYS: {
-							CheckDlgButton(hwndDlg, IDC_RAD_WEEKDAYS, TRUE);
-							HWND hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_DATE);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_DAY);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_RELMIN);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
-							EnableWindow(hw, TRUE);
-					}
+
+				case OC_WEEKDAYS:
+					CheckDlgButton(hwndDlg, IDC_RAD_WEEKDAYS, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_DATE);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_DAY);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_RELMIN);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
+					EnableWindow(hw, TRUE);
 					break;
-					case OC_ONCE: {
-							CheckDlgButton(hwndDlg, IDC_RAD_ONCE, TRUE);
-							HWND hw = GetDlgItem(hwndDlg, IDC_DAY);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
-							EnableWindow(hw, FALSE);
-					}
+	
+				case OC_ONCE:
+					CheckDlgButton(hwndDlg, IDC_RAD_ONCE, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_DAY);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
+					EnableWindow(hw, FALSE);
 					break;
-					case OC_WEEKLY: {
-							CheckDlgButton(hwndDlg, IDC_RAD_WEEKLY, TRUE);
-							HWND hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_DATE);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_RELMIN);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
-							EnableWindow(hw, TRUE);
-					}
+	
+				case OC_WEEKLY:
+					CheckDlgButton(hwndDlg, IDC_RAD_WEEKLY, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_DATE);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_RELMIN);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
+					EnableWindow(hw, TRUE);
 					break;
-					case OC_MONTHLY: {
-							CheckDlgButton(hwndDlg, IDC_RAD_MONTHLY, TRUE);
-							HWND hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_DATE);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_DAY);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_RELMIN);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
-							EnableWindow(hw, TRUE);
-					}
+			
+				case OC_MONTHLY:
+					CheckDlgButton(hwndDlg, IDC_RAD_MONTHLY, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_DATE);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_DAY);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_RELMIN);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
+					EnableWindow(hw, TRUE);
 					break;
-					case OC_YEARLY: {
-							CheckDlgButton(hwndDlg, IDC_RAD_YEARLY, TRUE);
-							HWND hw = GetDlgItem(hwndDlg, IDC_DAY);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
-							EnableWindow(hw, TRUE);
-					}
+	
+				case OC_YEARLY:
+					CheckDlgButton(hwndDlg, IDC_RAD_YEARLY, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_DAY);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
+					EnableWindow(hw, TRUE);
 					break;
 				}
 				
@@ -167,7 +169,7 @@ static BOOL CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
 				SendDlgItemMessage(hwndDlg, IDC_DAYNUM, CB_SETCURSEL, add_edit_alarm->time.wDay - 1, 0);
 				SetDlgItemInt(hwndDlg, IDC_RELMIN, MinutesInFuture(add_edit_alarm->time, add_edit_alarm->occurrence), FALSE);
 
-				if(add_edit_alarm->action & AAF_SOUND) {
+				if (add_edit_alarm->action & AAF_SOUND) {
 					CheckDlgButton(hwndDlg, IDC_CHK_ASOUND, TRUE);
 					switch(add_edit_alarm->sound_num) {
 						case 1:
@@ -187,8 +189,9 @@ static BOOL CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
 								CheckDlgButton(hwndDlg, IDC_RAD_SPK, TRUE);
 							
 							break;
-					};
-				} else {
+					}
+				} 
+				else {
 					HWND hw = GetDlgItem(hwndDlg, IDC_RAD_SND1);
 					EnableWindow(hw, FALSE);
 					hw = GetDlgItem(hwndDlg, IDC_RAD_SND2);
@@ -196,19 +199,21 @@ static BOOL CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
 					hw = GetDlgItem(hwndDlg, IDC_RAD_SND3);
 					EnableWindow(hw, FALSE);
 				}
-				if(add_edit_alarm->action & AAF_POPUP) CheckDlgButton(hwndDlg, IDC_CHK_APOPUP, TRUE);
-				if(add_edit_alarm->action & AAF_COMMAND) {
+				if (add_edit_alarm->action & AAF_POPUP)
+					CheckDlgButton(hwndDlg, IDC_CHK_APOPUP, TRUE);
+				if (add_edit_alarm->action & AAF_COMMAND) {
 					CheckDlgButton(hwndDlg, IDC_CHK_ACOMMAND, TRUE);
 					SetDlgItemText(hwndDlg, IDC_ED_COMMAND, add_edit_alarm->szCommand);
 					SetDlgItemText(hwndDlg, IDC_ED_PARAMS, add_edit_alarm->szCommandParams);
-				} else {
+				}
+				else {
 					HWND hw = GetDlgItem(hwndDlg, IDC_ED_COMMAND);
 					EnableWindow(hw, FALSE);
 					hw = GetDlgItem(hwndDlg, IDC_ED_PARAMS);
 					EnableWindow(hw, FALSE);
 				}
-
-			} else {
+			}
+			else {
 				SYSTEMTIME now;
 				GetPluginTime(&now);
 				
@@ -237,434 +242,417 @@ static BOOL CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
 				hw = GetDlgItem(hwndDlg, IDC_ED_PARAMS);
 				EnableWindow(hw, FALSE);
 			}
-			return TRUE;
 		}
+		return TRUE;
 
-		case WMU_UPDATETIME: {
-			ALARM *add_edit_alarm = (ALARM *)GetWindowLong(hwndDlg, GWL_USERDATA);
-
-			if(IsDlgButtonChecked(hwndDlg, IDC_RAD_ONCE))
-				add_edit_alarm->occurrence = OC_ONCE;
-			else if(IsDlgButtonChecked(hwndDlg, IDC_RAD_DAILY))
-				add_edit_alarm->occurrence = OC_DAILY;
-			else if(IsDlgButtonChecked(hwndDlg, IDC_RAD_WEEKDAYS))
-				add_edit_alarm->occurrence = OC_WEEKDAYS;
-			else if(IsDlgButtonChecked(hwndDlg, IDC_RAD_WEEKLY))
-				add_edit_alarm->occurrence = OC_WEEKLY;
-			else if(IsDlgButtonChecked(hwndDlg, IDC_RAD_MONTHLY))
-				add_edit_alarm->occurrence = OC_MONTHLY;
-			else if(IsDlgButtonChecked(hwndDlg, IDC_RAD_YEARLY)) {
-				add_edit_alarm->occurrence = OC_YEARLY;
+	case WMU_UPDATETIME: 
+		if (IsDlgButtonChecked(hwndDlg, IDC_RAD_ONCE))
+			add_edit_alarm->occurrence = OC_ONCE;
+		else if (IsDlgButtonChecked(hwndDlg, IDC_RAD_DAILY))
+			add_edit_alarm->occurrence = OC_DAILY;
+		else if (IsDlgButtonChecked(hwndDlg, IDC_RAD_WEEKDAYS))
+			add_edit_alarm->occurrence = OC_WEEKDAYS;
+		else if (IsDlgButtonChecked(hwndDlg, IDC_RAD_WEEKLY))
+			add_edit_alarm->occurrence = OC_WEEKLY;
+		else if (IsDlgButtonChecked(hwndDlg, IDC_RAD_MONTHLY))
+			add_edit_alarm->occurrence = OC_MONTHLY;
+		else if (IsDlgButtonChecked(hwndDlg, IDC_RAD_YEARLY)) {
+			add_edit_alarm->occurrence = OC_YEARLY;
 				
-				// set date range to 1 year (now to 1 year in future)
-				SYSTEMTIME r[2];
-				GetPluginTime(&r[0]);
-				TimeForMinutesInFuture(365 * 24 * 60, &r[1]);
-				SendDlgItemMessage(hwndDlg, IDC_DATE, DTM_SETRANGE, (WPARAM)(GDTR_MIN | GDTR_MAX), (LPARAM)r);
-			}
-
-			if(add_edit_alarm->occurrence == OC_ONCE || add_edit_alarm->occurrence == OC_YEARLY) {
-				SendDlgItemMessage(hwndDlg, IDC_DATE, DTM_GETSYSTEMTIME, 0, (LPARAM)&add_edit_alarm->time);
-			}
+			// set date range to 1 year (now to 1 year in future)
+			SYSTEMTIME r[2];
+			GetPluginTime(&r[0]);
+			TimeForMinutesInFuture(365 * 24 * 60, &r[1]);
+			SendDlgItemMessage(hwndDlg, IDC_DATE, DTM_SETRANGE, (WPARAM)(GDTR_MIN | GDTR_MAX), (LPARAM)r);
+		}
 
-			if(add_edit_alarm->occurrence == OC_WEEKLY) {
-				add_edit_alarm->time.wDayOfWeek = (unsigned short)SendDlgItemMessage(hwndDlg, IDC_DAY, CB_GETCURSEL, 0, 0);
-			}
-			if(add_edit_alarm->occurrence == OC_MONTHLY) {
-				add_edit_alarm->time.wDay = (WORD)SendDlgItemMessage(hwndDlg, IDC_DAYNUM, CB_GETCURSEL, 0, 0) + 1;
-			}
+		if (add_edit_alarm->occurrence == OC_ONCE || add_edit_alarm->occurrence == OC_YEARLY)
+			SendDlgItemMessage(hwndDlg, IDC_DATE, DTM_GETSYSTEMTIME, 0, (LPARAM)&add_edit_alarm->time);
 
-			SYSTEMTIME temp_time;
-			SendDlgItemMessage(hwndDlg, IDC_TIME, DTM_GETSYSTEMTIME, 0, (LPARAM)&temp_time);
-			add_edit_alarm->time.wHour = temp_time.wHour;
-			add_edit_alarm->time.wMinute = temp_time.wMinute;
-			add_edit_alarm->time.wSecond = temp_time.wSecond;
+		if (add_edit_alarm->occurrence == OC_WEEKLY)
+			add_edit_alarm->time.wDayOfWeek = (unsigned short)SendDlgItemMessage(hwndDlg, IDC_DAY, CB_GETCURSEL, 0, 0);
 
-			UpdateAlarm(add_edit_alarm->time, add_edit_alarm->occurrence);
+		if (add_edit_alarm->occurrence == OC_MONTHLY)
+			add_edit_alarm->time.wDay = (WORD)SendDlgItemMessage(hwndDlg, IDC_DAYNUM, CB_GETCURSEL, 0, 0) + 1;
 
-			return TRUE;
-		}
+		SYSTEMTIME temp_time;
+		SendDlgItemMessage(hwndDlg, IDC_TIME, DTM_GETSYSTEMTIME, 0, (LPARAM)&temp_time);
+		add_edit_alarm->time.wHour = temp_time.wHour;
+		add_edit_alarm->time.wMinute = temp_time.wMinute;
+		add_edit_alarm->time.wSecond = temp_time.wSecond;
 
-		case WMU_SETTIME: {
-			ALARM *add_edit_alarm = (ALARM *)GetWindowLong(hwndDlg, GWL_USERDATA);
+		UpdateAlarm(add_edit_alarm->time, add_edit_alarm->occurrence);
+		return TRUE;
 
+	case WMU_SETTIME:
+		{
 			SYSTEMTIME temp_time;
 			SendDlgItemMessage(hwndDlg, IDC_DATE, MCM_GETCURSEL, 0, (LPARAM)&temp_time);
-			if(memcmp(&temp_time, &add_edit_alarm->time, sizeof(SYSTEMTIME)) != 0)
+			if (memcmp(&temp_time, &add_edit_alarm->time, sizeof(SYSTEMTIME)) != 0)
 				SendDlgItemMessage(hwndDlg, IDC_DATE, MCM_SETCURSEL, 0, (LPARAM)&add_edit_alarm->time);
 
 			SendDlgItemMessage(hwndDlg, IDC_DAY, CB_SETCURSEL, add_edit_alarm->time.wDayOfWeek, 0);
 			SendDlgItemMessage(hwndDlg, IDC_TIME, DTM_SETSYSTEMTIME, (WPARAM)GDT_VALID, (LPARAM)&add_edit_alarm->time);
 			SendDlgItemMessage(hwndDlg, IDC_DAYNUM, CB_SETCURSEL, add_edit_alarm->time.wDay - 1, 0);
 			SetDlgItemInt(hwndDlg, IDC_RELMIN, MinutesInFuture(add_edit_alarm->time, add_edit_alarm->occurrence), FALSE);
-
-			return TRUE;
 		}
-		case WM_NOTIFY: {
-			ALARM *add_edit_alarm = (ALARM *)GetWindowLong(hwndDlg, GWL_USERDATA);
-			
-			if ( ((LPNMHDR)lParam)->code == DTN_DATETIMECHANGE) {
-				switch( ((LPNMHDR)lParam)->idFrom ) {
-					case IDC_TIME: 
-						{
-							HWND hw = GetDlgItem(hwndDlg, IDOK);
-							EnableWindow(hw, TRUE);
-
-							SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
-							SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
-						}
-						break;
+		return TRUE;
 
-					case IDC_DATE: 
-						{
-							HWND hw = GetDlgItem(hwndDlg, IDOK);
-							EnableWindow(hw, TRUE);
+	case WM_NOTIFY:
+		if ( ((LPNMHDR)lParam)->code == DTN_DATETIMECHANGE) {
+			switch( ((LPNMHDR)lParam)->idFrom ) {
+			case IDC_TIME: 
+				hw = GetDlgItem(hwndDlg, IDOK);
+				EnableWindow(hw, TRUE);
 
-							SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
-							SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
-						}
-						break;
-				}
-				return TRUE;
+				SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
+				SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
+				break;
+
+			case IDC_DATE: 
+				hw = GetDlgItem(hwndDlg, IDOK);
+				EnableWindow(hw, TRUE);
+
+				SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
+				SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
+				break;
 			}
+			return TRUE;
 		}
 		break;
 
-		case WM_COMMAND: {
-			ALARM *add_edit_alarm = (ALARM *)GetWindowLong(hwndDlg, GWL_USERDATA);
-
-			if ( HIWORD(wParam) == CBN_SELCHANGE ) {
-				switch( LOWORD(wParam) ) {
-					case IDC_DAY: 
-					case IDC_DAYNUM: {
-						HWND hw = GetDlgItem(hwndDlg, IDOK);
-						EnableWindow(hw, TRUE);
+	case WM_COMMAND:
+		if ( HIWORD(wParam) == CBN_SELCHANGE ) {
+			switch( LOWORD(wParam) ) {
+			case IDC_DAY: 
+			case IDC_DAYNUM:
+				hw = GetDlgItem(hwndDlg, IDOK);
+				EnableWindow(hw, TRUE);
 
-						SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
-						SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
-					}
-					break;
-				}
-				return TRUE;
+				SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
+				SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
+				break;
 			}
-			if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
-				switch( LOWORD( wParam )) {
-					case IDC_RELMIN: {
-						BOOL translated;
-						int mins;
-						mins = GetDlgItemInt(hwndDlg, IDC_RELMIN, &translated, FALSE);
-						SYSTEMTIME newtime;
-						TimeForMinutesInFuture(mins, &newtime);
-
-						SendDlgItemMessage(hwndDlg, IDC_TIME, DTM_SETSYSTEMTIME, (WPARAM)GDT_VALID, (LPARAM)&newtime);
-						SendDlgItemMessage(hwndDlg, IDC_DATE, DTM_SETSYSTEMTIME, (WPARAM)GDT_VALID, (LPARAM)&newtime);
-						SendDlgItemMessage(hwndDlg, IDC_DAY, CB_SETCURSEL, newtime.wDayOfWeek, 0);
-						SendDlgItemMessage(hwndDlg, IDC_DAYNUM, CB_SETCURSEL, newtime.wDay - 1, 0);
-
-						add_edit_alarm->time = newtime;
+			return TRUE;
+		}
+		if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
+			switch( LOWORD( wParam )) {
+			case IDC_RELMIN: 
+				{
+					BOOL translated;
+					int mins;
+					mins = GetDlgItemInt(hwndDlg, IDC_RELMIN, &translated, FALSE);
+					SYSTEMTIME newtime;
+					TimeForMinutesInFuture(mins, &newtime);
+
+					SendDlgItemMessage(hwndDlg, IDC_TIME, DTM_SETSYSTEMTIME, (WPARAM)GDT_VALID, (LPARAM)&newtime);
+					SendDlgItemMessage(hwndDlg, IDC_DATE, DTM_SETSYSTEMTIME, (WPARAM)GDT_VALID, (LPARAM)&newtime);
+					SendDlgItemMessage(hwndDlg, IDC_DAY, CB_SETCURSEL, newtime.wDayOfWeek, 0);
+					SendDlgItemMessage(hwndDlg, IDC_DAYNUM, CB_SETCURSEL, newtime.wDay - 1, 0);
+
+					add_edit_alarm->time = newtime;
 						
-						SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
-					}
-						// drop through
-					case IDC_TITLE:
-					case IDC_DESC:
-					case IDC_ED_COMMAND:
-					case IDC_ED_PARAMS: {
-							HWND hw = GetDlgItem(hwndDlg, IDOK);
-							EnableWindow(hw, TRUE);
-					}
-					break;
+					SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
 				}
-				return TRUE;
-			}
-			if ( HIWORD( wParam ) == BN_CLICKED ) {
-				switch( LOWORD( wParam )) {
-					case IDC_RAD_ONCE: {
-						HWND hw = GetDlgItem(hwndDlg, IDC_DAY);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDC_DATE);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDOK);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_RELMIN);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
-						EnableWindow(hw, FALSE);
-						SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
-						SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
-					}
-					break;
-					case IDC_RAD_DAILY: {
-						HWND hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_DAY);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_DATE);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDOK);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_RELMIN);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
-						EnableWindow(hw, TRUE);
-						SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
-						SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
-					}
-					break;
-					case IDC_RAD_WEEKLY: {
-						HWND hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_DATE);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_DAY);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDOK);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_RELMIN);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
-						EnableWindow(hw, TRUE);
-						SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
-						SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
-					}
-					break;
-					case IDC_RAD_WEEKDAYS: {
-						HWND hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_DATE);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_DAY);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDOK);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_RELMIN);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
-						EnableWindow(hw, TRUE);
-						SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
-						SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
-					}
-					break;
-					case IDC_RAD_MONTHLY: {
-						HWND hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_DATE);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_DAY);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDOK);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDC_RELMIN);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
-						EnableWindow(hw, TRUE);
-						SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
-						SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
-					}
-					break;
-					case IDC_RAD_YEARLY: {
-						HWND hw = GetDlgItem(hwndDlg, IDC_DAY);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDC_DATE);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDOK);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
-						EnableWindow(hw, FALSE);
-						hw = GetDlgItem(hwndDlg, IDC_RELMIN);
-						EnableWindow(hw, TRUE);
-						hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
-						EnableWindow(hw, TRUE);
-						SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
-						SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
-					}
-					break;
-					case IDC_CHK_ACOMMAND: {
-						if(IsDlgButtonChecked(hwndDlg, IDC_CHK_ACOMMAND)) {
-							HWND hw = GetDlgItem(hwndDlg, IDC_ED_COMMAND);
-							EnableWindow(hw, TRUE);
-							hw = GetDlgItem(hwndDlg, IDC_ED_PARAMS);
-							EnableWindow(hw, TRUE);
-						} else {
-							HWND hw = GetDlgItem(hwndDlg, IDC_ED_COMMAND);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_ED_PARAMS);
-							EnableWindow(hw, FALSE);
-						}
-					}
 					// drop through
-					case IDC_CHK_ASOUND: {
-						if(IsDlgButtonChecked(hwndDlg, IDC_CHK_ASOUND)) {
-							HWND hw = GetDlgItem(hwndDlg, IDC_RAD_SND1);
-							EnableWindow(hw, TRUE);
-							hw = GetDlgItem(hwndDlg, IDC_RAD_SND2);
-							EnableWindow(hw, TRUE);
-							hw = GetDlgItem(hwndDlg, IDC_RAD_SND3);
-							EnableWindow(hw, TRUE);
-							hw = GetDlgItem(hwndDlg, IDC_RAD_SPK);
-							EnableWindow(hw, TRUE);
-						} else {
-							HWND hw = GetDlgItem(hwndDlg, IDC_RAD_SND1);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_RAD_SND2);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_RAD_SND3);
-							EnableWindow(hw, FALSE);
-							hw = GetDlgItem(hwndDlg, IDC_RAD_SPK);
-							EnableWindow(hw, FALSE);
-						}
+			case IDC_TITLE:
+			case IDC_DESC:
+			case IDC_ED_COMMAND:
+			case IDC_ED_PARAMS:
+				HWND hw = GetDlgItem(hwndDlg, IDOK);
+				EnableWindow(hw, TRUE);
+			}
+			return TRUE;
+		}
+		if ( HIWORD( wParam ) == BN_CLICKED ) {
+			switch( LOWORD( wParam )) {
+			case IDC_RAD_ONCE:
+				hw = GetDlgItem(hwndDlg, IDC_DAY);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDC_DATE);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDOK);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_RELMIN);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
+				EnableWindow(hw, FALSE);
+				SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
+				SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
+				break;
 
-					}
-					// drop though
-					case IDC_RAD_SND1:
-					case IDC_RAD_SND2:
-					case IDC_RAD_SND3:
-					case IDC_RAD_SPK:
-					case IDC_CHK_SUSPEND:
-					case IDC_CHK_NOSTARTUP:
-					case IDC_CHK_NOREMINDER:
-					case IDC_CHK_APOPUP: {
-						HWND hw = GetDlgItem(hwndDlg, IDOK);
-						EnableWindow(hw, TRUE);
-					}
-					break;
-					case IDOK: {
+			case IDC_RAD_DAILY:
+				hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_DAY);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_DATE);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDOK);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_RELMIN);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
+				EnableWindow(hw, TRUE);
+				SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
+				SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
+				break;
 
-						char buff[MAX_PATH];
-						GetDlgItemText(hwndDlg, IDC_TITLE, buff, MAX_PATH);
-						if(add_edit_alarm->szTitle) free(add_edit_alarm->szTitle);
-						add_edit_alarm->szTitle = _strdup(buff);
+			case IDC_RAD_WEEKLY:
+				hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_DATE);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_DAY);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDOK);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_RELMIN);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
+				EnableWindow(hw, TRUE);
+				SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
+				SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
+				break;
 
-						GetDlgItemText(hwndDlg, IDC_DESC, buff, MAX_PATH);
-						if(add_edit_alarm->szDesc) free(add_edit_alarm->szDesc);
-						add_edit_alarm->szDesc = _strdup(buff);
+			case IDC_RAD_WEEKDAYS:
+				hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_DATE);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_DAY);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDOK);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_RELMIN);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
+				EnableWindow(hw, TRUE);
+				SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
+				SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
+				break;
 
-						if(add_edit_alarm->szTitle == 0 || strlen(add_edit_alarm->szTitle) == 0) {
-							MessageBox(hwndDlg, Translate("Please enter a title for this alarm."), Translate("Error"), MB_OK | MB_ICONERROR);
-							return TRUE;
-						}
+			case IDC_RAD_MONTHLY:
+				hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_DATE);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_DAY);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDOK);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDC_RELMIN);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
+				EnableWindow(hw, TRUE);
+				SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
+				SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
+				break;
+				
+			case IDC_RAD_YEARLY:
+				hw = GetDlgItem(hwndDlg, IDC_DAY);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_BTN_CAL);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDC_DATE);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDOK);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDC_DAYNUM);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_RELMIN);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDC_CHK_SUSPEND);
+				EnableWindow(hw, TRUE);
+				SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
+				SendMessage(hwndDlg, WMU_SETTIME, 0, 0);
+				break;
+				
+			case IDC_CHK_ACOMMAND:
+				if (IsDlgButtonChecked(hwndDlg, IDC_CHK_ACOMMAND)) {
+					HWND hw = GetDlgItem(hwndDlg, IDC_ED_COMMAND);
+					EnableWindow(hw, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_ED_PARAMS);
+					EnableWindow(hw, TRUE);
+				} else {
+					HWND hw = GetDlgItem(hwndDlg, IDC_ED_COMMAND);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_ED_PARAMS);
+					EnableWindow(hw, FALSE);
+				}
 
-						SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
+			// drop through
+			case IDC_CHK_ASOUND:
+				if (IsDlgButtonChecked(hwndDlg, IDC_CHK_ASOUND)) {
+					hw = GetDlgItem(hwndDlg, IDC_RAD_SND1);
+					EnableWindow(hw, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_RAD_SND2);
+					EnableWindow(hw, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_RAD_SND3);
+					EnableWindow(hw, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_RAD_SPK);
+					EnableWindow(hw, TRUE);
+				} 
+				else {
+					hw = GetDlgItem(hwndDlg, IDC_RAD_SND1);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_RAD_SND2);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_RAD_SND3);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_RAD_SPK);
+					EnableWindow(hw, FALSE);
+				}
 
-						if(!UpdateAlarm(add_edit_alarm->time, add_edit_alarm->occurrence)) {
-							MessageBox(hwndDlg, Translate("The alarm time you have selected is in the past."), Translate("Error"), MB_OK | MB_ICONERROR);
-							return TRUE;
-						}
+			// drop though
+			case IDC_RAD_SND1:
+			case IDC_RAD_SND2:
+			case IDC_RAD_SND3:
+			case IDC_RAD_SPK:
+			case IDC_CHK_SUSPEND:
+			case IDC_CHK_NOSTARTUP:
+			case IDC_CHK_NOREMINDER:
+			case IDC_CHK_APOPUP:
+				hw = GetDlgItem(hwndDlg, IDOK);
+				EnableWindow(hw, TRUE);
+				break;
+				
+			case IDOK: 
+				{
+					char buff[MAX_PATH];
+					GetDlgItemText(hwndDlg, IDC_TITLE, buff, MAX_PATH);
+					if (add_edit_alarm->szTitle) free(add_edit_alarm->szTitle);
+					add_edit_alarm->szTitle = _strdup(buff);
+
+					GetDlgItemText(hwndDlg, IDC_DESC, buff, MAX_PATH);
+					if (add_edit_alarm->szDesc) free(add_edit_alarm->szDesc);
+					add_edit_alarm->szDesc = _strdup(buff);
+
+					if (add_edit_alarm->szTitle == 0 || strlen(add_edit_alarm->szTitle) == 0) {
+						MessageBox(hwndDlg, Translate("Please enter a title for this alarm."), Translate("Error"), MB_OK | MB_ICONERROR);
+						return TRUE;
+					}
 
-						add_edit_alarm->action = (IsDlgButtonChecked(hwndDlg, IDC_CHK_ASOUND) ? AAF_SOUND : 0);
-						add_edit_alarm->action |= (IsDlgButtonChecked(hwndDlg, IDC_CHK_APOPUP) ? AAF_POPUP : 0);
-						add_edit_alarm->action |= (IsDlgButtonChecked(hwndDlg, IDC_CHK_ACOMMAND) ? AAF_COMMAND : 0);
+					SendMessage(hwndDlg, WMU_UPDATETIME, 0, 0);
 
-						add_edit_alarm->flags = add_edit_alarm->flags & ~(ALF_SUSPENDED | ALF_NOSTARTUP | ALF_NOREMINDER);
-						if(add_edit_alarm->occurrence != OC_ONCE) {
-							add_edit_alarm->flags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_SUSPEND) ? ALF_SUSPENDED : 0;
-						}
-						add_edit_alarm->flags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_NOSTARTUP) ? ALF_NOSTARTUP : 0;
-						add_edit_alarm->flags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_NOREMINDER) ? ALF_NOREMINDER: 0;
-
-						if(add_edit_alarm->action & AAF_COMMAND) {
-							GetDlgItemText(hwndDlg, IDC_ED_COMMAND, buff, MAX_PATH);
-							if(add_edit_alarm->szCommand) free(add_edit_alarm->szCommand);
-							add_edit_alarm->szCommand = _strdup(buff);
-							GetDlgItemText(hwndDlg, IDC_ED_PARAMS, buff, MAX_PATH);
-							if(add_edit_alarm->szCommandParams) free(add_edit_alarm->szCommandParams);
-							add_edit_alarm->szCommandParams = _strdup(buff);
-						}
+					if (!UpdateAlarm(add_edit_alarm->time, add_edit_alarm->occurrence)) {
+						MessageBox(hwndDlg, Translate("The alarm time you have selected is in the past."), Translate("Error"), MB_OK | MB_ICONERROR);
+						return TRUE;
+					}
 
-						if(add_edit_alarm->action & AAF_SOUND) {
-							if(IsDlgButtonChecked(hwndDlg, IDC_RAD_SND1))
-								add_edit_alarm->sound_num = 1;
-							else if(IsDlgButtonChecked(hwndDlg, IDC_RAD_SND2))
-								add_edit_alarm->sound_num = 2;
-							else if(IsDlgButtonChecked(hwndDlg, IDC_RAD_SND3))
-								add_edit_alarm->sound_num = 3;
-							else if(IsDlgButtonChecked(hwndDlg, IDC_RAD_SPK))
-								add_edit_alarm->sound_num = 4;
-						} else
-							add_edit_alarm->sound_num = 0;
-
-
-						Utils_SaveWindowPosition(hwndDlg, 0, MODULE, "AddEdit");
-
-						// self-add (setting stored in invisible checkbox - see comments in WM_INITDIALOG
-						if(IsDlgButtonChecked(hwndDlg, IDC_CHK_INVIS)) {
-							alter_alarm_list(add_edit_alarm);
-							RefreshReminderFrame();
-							if(hwndOptionsDialog) {
-								// refresh options list
-								PostMessage(hwndOptionsDialog, WMU_INITOPTLIST, 0, 0);
-							}
-						}
+					add_edit_alarm->action = (IsDlgButtonChecked(hwndDlg, IDC_CHK_ASOUND) ? AAF_SOUND : 0);
+					add_edit_alarm->action |= (IsDlgButtonChecked(hwndDlg, IDC_CHK_APOPUP) ? AAF_POPUP : 0);
+					add_edit_alarm->action |= (IsDlgButtonChecked(hwndDlg, IDC_CHK_ACOMMAND) ? AAF_COMMAND : 0);
 
-						// self-add (setting stored in invisible checkbox - see comments in WM_INITDIALOG
-						if(IsDlgButtonChecked(hwndDlg, IDC_CHK_INVIS)) {
-							free_alarm_data(add_edit_alarm);
-							delete add_edit_alarm;
-						}
+					add_edit_alarm->flags = add_edit_alarm->flags & ~(ALF_SUSPENDED | ALF_NOSTARTUP | ALF_NOREMINDER);
+					if (add_edit_alarm->occurrence != OC_ONCE) {
+						add_edit_alarm->flags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_SUSPEND) ? ALF_SUSPENDED : 0;
+					}
+					add_edit_alarm->flags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_NOSTARTUP) ? ALF_NOSTARTUP : 0;
+					add_edit_alarm->flags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_NOREMINDER) ? ALF_NOREMINDER: 0;
+
+					if (add_edit_alarm->action & AAF_COMMAND) {
+						GetDlgItemText(hwndDlg, IDC_ED_COMMAND, buff, MAX_PATH);
+						if (add_edit_alarm->szCommand) free(add_edit_alarm->szCommand);
+						add_edit_alarm->szCommand = _strdup(buff);
+						GetDlgItemText(hwndDlg, IDC_ED_PARAMS, buff, MAX_PATH);
+						if (add_edit_alarm->szCommandParams) free(add_edit_alarm->szCommandParams);
+						add_edit_alarm->szCommandParams = _strdup(buff);
+					}
 
-						// inform options dialog of change
+					if (add_edit_alarm->action & AAF_SOUND) {
+						if (IsDlgButtonChecked(hwndDlg, IDC_RAD_SND1))
+							add_edit_alarm->sound_num = 1;
+						else if (IsDlgButtonChecked(hwndDlg, IDC_RAD_SND2))
+							add_edit_alarm->sound_num = 2;
+						else if (IsDlgButtonChecked(hwndDlg, IDC_RAD_SND3))
+							add_edit_alarm->sound_num = 3;
+						else if (IsDlgButtonChecked(hwndDlg, IDC_RAD_SPK))
+							add_edit_alarm->sound_num = 4;
+					} else
+						add_edit_alarm->sound_num = 0;
+
+
+					Utils_SaveWindowPosition(hwndDlg, 0, MODULE, "AddEdit");
+
+					// self-add (setting stored in invisible checkbox - see comments in WM_INITDIALOG
+					if (IsDlgButtonChecked(hwndDlg, IDC_CHK_INVIS)) {
+						alter_alarm_list(add_edit_alarm);
+						RefreshReminderFrame();
+						if (hwndOptionsDialog) {
+							// refresh options list
+							PostMessage(hwndOptionsDialog, WMU_INITOPTLIST, 0, 0);
+						}
+					}
 
-						// deal with modal and non-modal modes
-						PostMessage(hwndDlg, WMU_MYDESTROY, 0, 0);
-						EndDialog(hwndDlg, IDOK);
+					// self-add (setting stored in invisible checkbox - see comments in WM_INITDIALOG
+					if (IsDlgButtonChecked(hwndDlg, IDC_CHK_INVIS)) {
+						free_alarm_data(add_edit_alarm);
+						delete add_edit_alarm;
 					}
-					break;
-					case IDCANCEL: {
 
-						// self-add (setting stored in invisible checkbox - see comments in WM_INITDIALOG
-						if(IsDlgButtonChecked(hwndDlg, IDC_CHK_INVIS)) {
-							ALARM *add_edit_alarm = (ALARM *)GetWindowLong(hwndDlg, GWL_USERDATA);
-							free_alarm_data(add_edit_alarm);
-							delete add_edit_alarm;
-						}
+					// inform options dialog of change
+
+					// deal with modal and non-modal modes
+					PostMessage(hwndDlg, WMU_MYDESTROY, 0, 0);
+					EndDialog(hwndDlg, IDOK);
+				}
+				break;
+				
+			case IDCANCEL:
+				// self-add (setting stored in invisible checkbox - see comments in WM_INITDIALOG
+				if (IsDlgButtonChecked(hwndDlg, IDC_CHK_INVIS)) {
+					ALARM *add_edit_alarm = (ALARM *)GetWindowLong(hwndDlg, GWLP_USERDATA);
+					free_alarm_data(add_edit_alarm);
+					delete add_edit_alarm;
+				}
 						
-						Utils_SaveWindowPosition(hwndDlg, 0, MODULE, "AddEdit");
+				Utils_SaveWindowPosition(hwndDlg, 0, MODULE, "AddEdit");
 	
-						// deal with modal and non-modal modes
-						PostMessage(hwndDlg, WMU_MYDESTROY, 0, 0);
-						EndDialog(hwndDlg, IDCANCEL);
-					}
-					break;
+				// deal with modal and non-modal modes
+				PostMessage(hwndDlg, WMU_MYDESTROY, 0, 0);
+				EndDialog(hwndDlg, IDCANCEL);
+				break;
 		
-					default:
-					return TRUE;
-				}
+			default:
+				return TRUE;
 			}
-			break;
 		}
-		case WMU_MYDESTROY:
-			DestroyWindow(hwndDlg);
-			return TRUE;
+		break;
+
+	case WMU_MYDESTROY:
+		DestroyWindow(hwndDlg);
+		return TRUE;
 	}
 
 	return FALSE;
 }
 
-BOOL Edit(HWND hwnd, ALARM &alarm, bool modal) {
+BOOL Edit(HWND hwnd, ALARM &alarm, bool modal)
+{
 	AddEditParam *param = new AddEditParam;
 	param->alarm_ptr = &alarm;
 	param->edit = TRUE;
 
-	if(modal) {
+	if (modal) {
 		param->self_add = FALSE;
-		if(DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hwnd, DlgProcAddEdit, (LPARAM)param) == IDOK) {
+		if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hwnd, DlgProcAddEdit, (LPARAM)param) == IDOK) {
 			return TRUE;
 		}
-	} else {
+	}
+	else {
 		param->self_add = TRUE;
 		HWND hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hwnd, DlgProcAddEdit, (LPARAM)param);
 
@@ -676,24 +664,25 @@ BOOL Edit(HWND hwnd, ALARM &alarm, bool modal) {
 	return FALSE;
 }
 
-BOOL New(HWND hwnd, ALARM &alarm, bool modal) {
+BOOL New(HWND hwnd, ALARM &alarm, bool modal)
+{
 	AddEditParam *param = new AddEditParam;
 	param->alarm_ptr = &alarm;
 	param->edit = FALSE;
 
-	if(modal) {
+	if (modal) {
 		param->self_add = FALSE;
-		if(DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hwnd, DlgProcAddEdit, (LPARAM)param) == IDOK) {
+		if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hwnd, DlgProcAddEdit, (LPARAM)param) == IDOK)
 			return TRUE;
-		}
-	} else {
+	}
+	else {
 		param->self_add = TRUE;
 		HWND hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hwnd, DlgProcAddEdit, (LPARAM)param);
 
 		//SetActiveWindow(hwndDlg);
 		//SetWindowPos(hwndDlg, 
 		SetForegroundWindow(hwndDlg);
-		if(ServiceExists(MS_TTB_SETBUTTONSTATE)) {
+		if (ServiceExists(MS_TTB_SETBUTTONSTATE)) {
 			Sleep(100);
 			CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTopToolbarButton, (LPARAM)TTBST_RELEASED);
 		}
@@ -703,8 +692,9 @@ BOOL New(HWND hwnd, ALARM &alarm, bool modal) {
 	return FALSE;
 }
 
-void AddMenuItem() {
-	if(hMainMenuItem) return;
+void AddMenuItem()
+{
+	if (hMainMenuItem) return;
 
 	CLISTMENUITEM menu = {0};
 
@@ -715,32 +705,20 @@ void AddMenuItem() {
 	menu.pszName = Translate("Set Alarm");
 	menu.pszService= MODULE "/NewAlarm";
 	menu.position = 500010000;
-	if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
+	if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
 		menu.pszPopupName = Translate("Alarms");
 	if (ServiceExists(MS_CLIST_ADDGROUPMENUITEM)) {
 		GroupMenuParam gmp = {0};
 		hGroupMenuItem = (HANDLE)CallService(MS_CLIST_ADDGROUPMENUITEM,(WPARAM)&gmp,(LPARAM)&menu);
 	}
 	hMainMenuItem = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&menu);
-	/////////////////////
 }
 
-/*
-void RemoveMenuItem() {
-	if(!hMainMenuItem) return;
+///////////////////////
+// create menu item
 
-	CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)hMainMenuItem, 0);
-	if(ServiceExists(MS_CLIST_REMOVEGROUPMENUITEM)) {
-		CallService(MS_CLIST_REMOVEGROUPMENUITEM, (WPARAM)hGroupMenuItem, 0);
-	}
-	hMainMenuItem = 0;
-
-}
-*/
-
-int OptionsModulesLoaded(WPARAM wParam, LPARAM lParam) {
-	///////////////////////
-	// create menu item
+int OptionsModulesLoaded(WPARAM wParam, LPARAM lParam)
+{
 	CreateServiceFunction(MODULE "/NewAlarm", NewAlarmMenuFunc);
 
 	AddMenuItem();
@@ -785,10 +763,12 @@ protected:
 ShortList deleted_list;			// same with deleted items
 
 Options temp_options;
-static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+	int sel;
 
 	switch ( msg ) {
-	case WM_INITDIALOG: {
+	case WM_INITDIALOG:
 		hwndOptionsDialog = hwndDlg;
 		added_list.clear();
 		modified_list.clear();
@@ -800,78 +780,97 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
 
 		PostMessage(hwndDlg, WMU_INITOPTLIST, 0, 0);
 		return TRUE;
-	}
-	case WMU_INITOPTLIST: {
+
+	case WMU_INITOPTLIST:
 		copy_list(temp_list);
-		// add added alarms, in case this is a list refresh from non-modal add alarm dialog
-		ALARM *i, *j;
-		for(added_list.reset(); i = added_list.current(); added_list.next()) {
-			temp_list.push_back(i);
-		}
-		// modify modified alarms, in case this is a list refresh from non-modal add alarm dialog
-		for(temp_list.reset(); i = temp_list.current(); temp_list.next()) {
-			for(modified_list.reset(); j = modified_list.current(); modified_list.next()) {
-				if(i->id == j->id) {
-					copy_alarm_data(i, j);
-				}
+		{
+			// add added alarms, in case this is a list refresh from non-modal add alarm dialog
+			ALARM *i, *j;
+			for(added_list.reset(); i = added_list.current(); added_list.next()) {
+				temp_list.push_back(i);
 			}
-		}
-		// remove deleted alarms, in case this is a list refresh from non-modal add alarm dialog
-
-		ShortList::Node *k = deleted_list.get_head();
-		while(k) {
+			// modify modified alarms, in case this is a list refresh from non-modal add alarm dialog
 			for(temp_list.reset(); i = temp_list.current(); temp_list.next()) {
-				if(i->id == k->value) {
-					temp_list.erase();
-					break;
+				for(modified_list.reset(); j = modified_list.current(); modified_list.next()) {
+					if (i->id == j->id) {
+						copy_alarm_data(i, j);
+					}
 				}
 			}
-			k = k->next;
-		}
+			// remove deleted alarms, in case this is a list refresh from non-modal add alarm dialog
 
-		SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_RESETCONTENT, 0, 0);
-
-		if(temp_list.size() > 0) {
-			int pos = -1;
-			ALARM *i;
-			for(temp_list.reset(); i = temp_list.current(); temp_list.next()) {
-				if(!(i->flags & ALF_HIDDEN)) {
-					pos = SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_ADDSTRING, 0, (LPARAM)i->szTitle);
-					SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_SETITEMDATA, pos, (LPARAM)i->id);
+			ShortList::Node *k = deleted_list.get_head();
+			while(k) {
+				for(temp_list.reset(); i = temp_list.current(); temp_list.next()) {
+					if (i->id == k->value) {
+						temp_list.erase();
+						break;
+					}
 				}
+				k = k->next;
 			}
-			SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_SETCURSEL, pos, 0);
-			HWND hw;
-			hw = GetDlgItem(hwndDlg, IDC_EDIT);
-			EnableWindow(hw, TRUE);
-			hw = GetDlgItem(hwndDlg, IDC_DEL);
-			EnableWindow(hw, TRUE);
-		} else {
-			HWND hw;
-			hw = GetDlgItem(hwndDlg, IDC_EDIT);
-			EnableWindow(hw, FALSE);
-			hw = GetDlgItem(hwndDlg, IDC_DEL);
-			EnableWindow(hw, FALSE);
-		}
 
-		if(ServiceExists(MS_POPUP_ADDPOPUP)) {
-			CheckDlgButton(hwndDlg, IDC_CHK_POPUPS, temp_options.use_popup_module ? TRUE : FALSE);
-			if(options.use_popup_module) {
-				HWND hw = GetDlgItem(hwndDlg, IDC_CHK_LOOPSOUND);
-				EnableWindow(hw, FALSE);
-				hw = GetDlgItem(hwndDlg, IDC_CHK_AWROUND);
-				EnableWindow(hw, FALSE);
-				hw = GetDlgItem(hwndDlg, IDC_CHK_AWNOACTIVATE);
-				EnableWindow(hw, FALSE);
-				hw = GetDlgItem(hwndDlg, IDC_SPIN_TRANS);
-				EnableWindow(hw, FALSE);
-				hw = GetDlgItem(hwndDlg, IDC_ED_TRANS);
+			SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_RESETCONTENT, 0, 0);
+
+			if (temp_list.size() > 0) {
+				int pos = -1;
+				ALARM *i;
+				for(temp_list.reset(); i = temp_list.current(); temp_list.next()) {
+					if (!(i->flags & ALF_HIDDEN)) {
+						pos = SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_ADDSTRING, 0, (LPARAM)i->szTitle);
+						SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_SETITEMDATA, pos, (LPARAM)i->id);
+					}
+				}
+				SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_SETCURSEL, pos, 0);
+				HWND hw;
+				hw = GetDlgItem(hwndDlg, IDC_EDIT);
+				EnableWindow(hw, TRUE);
+				hw = GetDlgItem(hwndDlg, IDC_DEL);
+				EnableWindow(hw, TRUE);
+			} else {
+				HWND hw;
+				hw = GetDlgItem(hwndDlg, IDC_EDIT);
 				EnableWindow(hw, FALSE);
-				hw = GetDlgItem(hwndDlg, IDC_BTN_PREVIEW);
+				hw = GetDlgItem(hwndDlg, IDC_DEL);
 				EnableWindow(hw, FALSE);
+			}
+
+			if (ServiceExists(MS_POPUP_ADDPOPUP)) {
+				CheckDlgButton(hwndDlg, IDC_CHK_POPUPS, temp_options.use_popup_module ? TRUE : FALSE);
+				if (options.use_popup_module) {
+					HWND hw = GetDlgItem(hwndDlg, IDC_CHK_LOOPSOUND);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_CHK_AWROUND);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_CHK_AWNOACTIVATE);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_SPIN_TRANS);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_ED_TRANS);
+					EnableWindow(hw, FALSE);
+					hw = GetDlgItem(hwndDlg, IDC_BTN_PREVIEW);
+					EnableWindow(hw, FALSE);
+				} else {
+					CheckDlgButton(hwndDlg, IDC_CHK_LOOPSOUND, temp_options.loop_sound ? TRUE : FALSE);
+					HWND hw = GetDlgItem(hwndDlg, IDC_CHK_LOOPSOUND);
+					EnableWindow(hw, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_CHK_AWROUND);
+					EnableWindow(hw, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_CHK_AWNOACTIVATE);
+					EnableWindow(hw, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_SPIN_TRANS);
+					EnableWindow(hw, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_ED_TRANS);
+					EnableWindow(hw, TRUE);
+					hw = GetDlgItem(hwndDlg, IDC_BTN_PREVIEW);
+					EnableWindow(hw, TRUE);
+				}
 			} else {
+				HWND hw = GetDlgItem(hwndDlg, IDC_CHK_POPUPS);
+				EnableWindow(hw, FALSE);
 				CheckDlgButton(hwndDlg, IDC_CHK_LOOPSOUND, temp_options.loop_sound ? TRUE : FALSE);
-				HWND hw = GetDlgItem(hwndDlg, IDC_CHK_LOOPSOUND);
+			
+				hw = GetDlgItem(hwndDlg, IDC_CHK_LOOPSOUND);
 				EnableWindow(hw, TRUE);
 				hw = GetDlgItem(hwndDlg, IDC_CHK_AWROUND);
 				EnableWindow(hw, TRUE);
@@ -884,41 +883,24 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
 				hw = GetDlgItem(hwndDlg, IDC_BTN_PREVIEW);
 				EnableWindow(hw, TRUE);
 			}
-		} else {
-			HWND hw = GetDlgItem(hwndDlg, IDC_CHK_POPUPS);
-			EnableWindow(hw, FALSE);
-			CheckDlgButton(hwndDlg, IDC_CHK_LOOPSOUND, temp_options.loop_sound ? TRUE : FALSE);
-			
-			hw = GetDlgItem(hwndDlg, IDC_CHK_LOOPSOUND);
-			EnableWindow(hw, TRUE);
-			hw = GetDlgItem(hwndDlg, IDC_CHK_AWROUND);
-			EnableWindow(hw, TRUE);
-			hw = GetDlgItem(hwndDlg, IDC_CHK_AWNOACTIVATE);
-			EnableWindow(hw, TRUE);
-			hw = GetDlgItem(hwndDlg, IDC_SPIN_TRANS);
-			EnableWindow(hw, TRUE);
-			hw = GetDlgItem(hwndDlg, IDC_ED_TRANS);
-			EnableWindow(hw, TRUE);
-			hw = GetDlgItem(hwndDlg, IDC_BTN_PREVIEW);
-			EnableWindow(hw, TRUE);
-		}
 
-		SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_SNOOZE), UDM_SETRANGE, 0, (LPARAM)MAKELONG(360, 0));
-		SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_SNOOZE), UDM_SETPOS, 0, temp_options.snooze_minutes);
+			SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_SNOOZE), UDM_SETRANGE, 0, (LPARAM)MAKELONG(360, 0));
+			SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_SNOOZE), UDM_SETPOS, 0, temp_options.snooze_minutes);
 
-		SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_ROWHEIGHT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 5));
-		SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_ROWHEIGHT), UDM_SETPOS, 0, temp_options.row_height);
+			SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_ROWHEIGHT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 5));
+			SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_ROWHEIGHT), UDM_SETPOS, 0, temp_options.row_height);
 
-		SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_INDENT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 0));
-		SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_INDENT), UDM_SETPOS, 0, temp_options.indent);
+			SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_INDENT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 0));
+			SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_INDENT), UDM_SETPOS, 0, temp_options.indent);
 
-		SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_TRANS), UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 0));
-		SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_TRANS), UDM_SETPOS, 0, temp_options.aw_trans);
-		if(!TransparencyEnabled()) {
-			HWND hw = GetDlgItem(hwndDlg, IDC_SPIN_TRANS);
-			EnableWindow(hw, FALSE);
-			hw = GetDlgItem(hwndDlg, IDC_ED_TRANS);
-			EnableWindow(hw, FALSE);
+			SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_TRANS), UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 0));
+			SendMessage(GetDlgItem(hwndDlg, IDC_SPIN_TRANS), UDM_SETPOS, 0, temp_options.aw_trans);
+			if (!TransparencyEnabled()) {
+				HWND hw = GetDlgItem(hwndDlg, IDC_SPIN_TRANS);
+				EnableWindow(hw, FALSE);
+				hw = GetDlgItem(hwndDlg, IDC_ED_TRANS);
+				EnableWindow(hw, FALSE);
+			}
 		}
 
 		CheckDlgButton(hwndDlg, IDC_SHOWHIDE, temp_options.auto_showhide ? TRUE : FALSE);
@@ -933,40 +915,41 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
 
 		SendMessage( GetParent( hwndDlg ), PSM_UNCHANGED, 0, 0 ); 
 		return TRUE;
-	}
+
 	case WM_COMMAND:
-		if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
+		if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus())
 			SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
-		}
+
 		if ( HIWORD( wParam ) == BN_CLICKED ) {
 			switch( LOWORD( wParam )) {
-				case IDC_BTN_PREVIEW:
-					{
-						HWND hwndDlgPrev = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ALARM), GetDesktopWindow(), DlgProcAlarm);
-						WindowList_Add(hAlarmWindowList, hwndDlgPrev, 0);
-						SendMessage(hwndDlgPrev, WMU_FAKEALARM, 0, 0);
-						SendMessage(hwndDlgPrev, WMU_SETOPT, 0, (LPARAM)&temp_options);
-						ShowWindow(hwndDlgPrev, SW_SHOW);
-						SetWindowPos(hwndDlgPrev, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
-					}
-					break;
-				case IDC_SHOWHIDE:
-					temp_options.auto_showhide = IsDlgButtonChecked(hwndDlg, IDC_SHOWHIDE) ? true : false;
-					SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
-					break;
-				case IDC_SHOWHIDE2:
-					temp_options.hide_with_clist = IsDlgButtonChecked(hwndDlg, IDC_SHOWHIDE2) ? true : false;
-					SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
-					break;
-				case IDC_AUTOSIZEVERT:
-					temp_options.auto_size_vert = IsDlgButtonChecked(hwndDlg, IDC_AUTOSIZEVERT) ? true : false;
-					SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
-					break;
-				case IDC_NEW: {
+			case IDC_BTN_PREVIEW:
+				{
+					HWND hwndDlgPrev = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ALARM), GetDesktopWindow(), DlgProcAlarm);
+					WindowList_Add(hAlarmWindowList, hwndDlgPrev, 0);
+					SendMessage(hwndDlgPrev, WMU_FAKEALARM, 0, 0);
+					SendMessage(hwndDlgPrev, WMU_SETOPT, 0, (LPARAM)&temp_options);
+					ShowWindow(hwndDlgPrev, SW_SHOW);
+					SetWindowPos(hwndDlgPrev, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+				}
+				break;
+			case IDC_SHOWHIDE:
+				temp_options.auto_showhide = IsDlgButtonChecked(hwndDlg, IDC_SHOWHIDE) ? true : false;
+				SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+				break;
+			case IDC_SHOWHIDE2:
+				temp_options.hide_with_clist = IsDlgButtonChecked(hwndDlg, IDC_SHOWHIDE2) ? true : false;
+				SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+				break;
+			case IDC_AUTOSIZEVERT:
+				temp_options.auto_size_vert = IsDlgButtonChecked(hwndDlg, IDC_AUTOSIZEVERT) ? true : false;
+				SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+				break;
+			case IDC_NEW: 
+				{
 					ALARM new_alarm = {0};
 					GetPluginTime(&new_alarm.time);
 					new_alarm.id = next_alarm_id++;
-					if(New(hwndDlg, new_alarm, true)) {
+					if (New(hwndDlg, new_alarm, true)) {
 						new_alarm.id = next_alarm_id++;
 						temp_list.push_back(&new_alarm);
 						added_list.push_back(&new_alarm);
@@ -984,57 +967,52 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
 					}
 				}
 				break;
-				case IDC_EDIT: {
-					int sel = SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_GETCURSEL, 0, 0);
-					if(sel != -1) {
-						unsigned short id = (unsigned short)SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_GETITEMDATA, sel, 0);
-						ALARM *i;
-						for(temp_list.reset(); i = temp_list.current(); temp_list.next()) {
-							if(i->id == id) {
-								ALARM a = {0};
-								copy_alarm_data(&a, i);
-								if(Edit(hwndDlg, a, true)) {
-									modified_list.push_back(&a);
-									SendMessage(hwndDlg, WMU_INITOPTLIST, 0, 0);
-									SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_SETCURSEL, sel, 0);
-									SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
-								}
-								free_alarm_data(&a);
-								break;
+
+			case IDC_EDIT: 
+				sel = SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_GETCURSEL, 0, 0);
+				if (sel != -1) {
+					unsigned short id = (unsigned short)SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_GETITEMDATA, sel, 0);
+					ALARM *i;
+					for(temp_list.reset(); i = temp_list.current(); temp_list.next()) {
+						if (i->id == id) {
+							ALARM a = {0};
+							copy_alarm_data(&a, i);
+							if (Edit(hwndDlg, a, true)) {
+								modified_list.push_back(&a);
+								SendMessage(hwndDlg, WMU_INITOPTLIST, 0, 0);
+								SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_SETCURSEL, sel, 0);
+								SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
 							}
+							free_alarm_data(&a);
+							break;
 						}
 					}
 				}
 				break;
-				case IDC_DEL: {
-					int sel = SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_GETCURSEL, 0, 0);
-					if(sel != -1) {
-						unsigned short id = (unsigned short)SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_GETITEMDATA, sel, 0);
-
-						ALARM *i;
-						for(temp_list.reset(); i = temp_list.current(); temp_list.next()) {
-							if(i->id == id) {
-								deleted_list.push_back(i->id);
-								//temp_list.erase();
-								break;
-							}
-						}
-							
-						SendMessage(hwndDlg, WMU_INITOPTLIST, 0, 0);
 
-						//HWND hw;
-						//hw = GetDlgItem(hwndDlg, IDC_EDIT);
-						//EnableWindow(hw, FALSE);
-						//hw = GetDlgItem(hwndDlg, IDC_DEL);
-						//EnableWindow(hw, FALSE);
+			case IDC_DEL:
+				sel = SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_GETCURSEL, 0, 0);
+				if (sel != -1) {
+					unsigned short id = (unsigned short)SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_GETITEMDATA, sel, 0);
 
-						SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+					ALARM *i;
+					for(temp_list.reset(); i = temp_list.current(); temp_list.next()) {
+						if (i->id == id) {
+							deleted_list.push_back(i->id);
+							//temp_list.erase();
+							break;
+						}
 					}
+							
+					SendMessage( hwndDlg, WMU_INITOPTLIST, 0, 0 );
+					SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
 				}
 				break;
-				case IDC_CHK_POPUPS: {
+				
+			case IDC_CHK_POPUPS: 
+				{
 					BOOL chk = IsDlgButtonChecked(hwndDlg, IDC_CHK_POPUPS);
-					if(chk) CheckDlgButton(hwndDlg, IDC_CHK_LOOPSOUND, FALSE);
+					if (chk) CheckDlgButton(hwndDlg, IDC_CHK_LOOPSOUND, FALSE);
 					else CheckDlgButton(hwndDlg, IDC_CHK_LOOPSOUND, temp_options.loop_sound);
 
 					HWND hw = GetDlgItem(hwndDlg, IDC_CHK_LOOPSOUND);
@@ -1054,24 +1032,25 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
 					SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); 
 				}
 				break;
-				case IDC_CHK_LOOPSOUND: {
-					temp_options.loop_sound = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOOPSOUND) ? true : false;
-					SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); 
-				}
+				
+			case IDC_CHK_LOOPSOUND:
+				temp_options.loop_sound = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOOPSOUND) ? true : false;
+				SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); 
 				break;
-				case IDC_CHK_AWROUND: {
-					temp_options.aw_roundcorners = IsDlgButtonChecked(hwndDlg, IDC_CHK_AWROUND) ? true : false;
-					SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); 										
-				}
+
+			case IDC_CHK_AWROUND:
+				temp_options.aw_roundcorners = IsDlgButtonChecked(hwndDlg, IDC_CHK_AWROUND) ? true : false;
+				SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); 										
 				break;
-				case IDC_CHK_AWNOACTIVATE: {
-					temp_options.aw_dontstealfocus = IsDlgButtonChecked(hwndDlg, IDC_CHK_AWNOACTIVATE) ? true : false;
-					SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); 										
-				}
+
+			case IDC_CHK_AWNOACTIVATE:
+				temp_options.aw_dontstealfocus = IsDlgButtonChecked(hwndDlg, IDC_CHK_AWNOACTIVATE) ? true : false;
+				SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); 										
 				break;
 			}
 			return TRUE;
 		}
+
 		if (HIWORD( wParam ) == LBN_SELCHANGE) {
 			HWND hw;
 			hw = GetDlgItem(hwndDlg, IDC_EDIT);
@@ -1082,16 +1061,17 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
 			//SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
 			return TRUE;
 		}
+
 		if (HIWORD( wParam ) == LBN_DBLCLK) {
 			int sel = SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_GETCURSEL, 0, 0);
-			if(sel != -1) {
+			if (sel != -1) {
 				unsigned short id = (unsigned short)SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_GETITEMDATA, sel, 0);
 				ALARM *i;
 				for(temp_list.reset(); i = temp_list.current(); temp_list.next()) {
-					if(i->id == id) {
+					if (i->id == id) {
 						ALARM a = {0};
 						copy_alarm_data(&a, i);
-						if(Edit(hwndDlg, a, true)) {
+						if (Edit(hwndDlg, a, true)) {
 							modified_list.push_back(&a);
 							SendMessage(hwndDlg, WMU_INITOPTLIST, 0, 0);
 							SendDlgItemMessage(hwndDlg, IDC_ALIST, LB_SETCURSEL, sel, 0);
@@ -1106,10 +1086,10 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
 		break;
 
 	case WM_NOTIFY:
-		if(((LPNMHDR)lParam)->code == UDN_DELTAPOS ) {
+		if (((LPNMHDR)lParam)->code == UDN_DELTAPOS ) {
 			BOOL translated;
 			int trans = GetDlgItemInt(hwndDlg, IDC_ED_TRANS, &translated, FALSE);
-			if(translated) temp_options.aw_trans = trans;
+			if (translated) temp_options.aw_trans = trans;
 			SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
 			return TRUE;
 		}
@@ -1119,13 +1099,13 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
 
 			BOOL translated;
 			int snooze_mins = GetDlgItemInt(hwndDlg, IDC_ED_SNOOZE, &translated, FALSE);
-			if(translated) temp_options.snooze_minutes = snooze_mins;
+			if (translated) temp_options.snooze_minutes = snooze_mins;
 			int row_height = GetDlgItemInt(hwndDlg, IDC_ED_ROWHEIGHT, &translated, FALSE);
-			if(translated) temp_options.row_height = row_height;
+			if (translated) temp_options.row_height = row_height;
 			int indent = GetDlgItemInt(hwndDlg, IDC_ED_INDENT, &translated, FALSE);
-			if(translated) temp_options.indent = indent;
+			if (translated) temp_options.indent = indent;
 			int trans = GetDlgItemInt(hwndDlg, IDC_ED_TRANS, &translated, FALSE);
-			if(translated) temp_options.aw_trans = trans;
+			if (translated) temp_options.aw_trans = trans;
 
 			temp_options.use_popup_module = IsDlgButtonChecked(hwndDlg, IDC_CHK_POPUPS) ? true : false;
 			temp_options.auto_showhide = IsDlgButtonChecked(hwndDlg, IDC_SHOWHIDE) ? true : false;
@@ -1135,9 +1115,9 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
 			temp_options.aw_dontstealfocus = IsDlgButtonChecked(hwndDlg, IDC_CHK_AWNOACTIVATE) ? true : false;
 
 			int reminder_period = GetDlgItemInt(hwndDlg, IDC_ED_PERIOD, &translated, FALSE);
-			if(translated) temp_options.reminder_period = reminder_period;
+			if (translated) temp_options.reminder_period = reminder_period;
 
-			if(!ServiceExists(MS_POPUP_ADDPOPUP) || !options.use_popup_module)
+			if (!ServiceExists(MS_POPUP_ADDPOPUP) || !options.use_popup_module)
 				temp_options.loop_sound = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOOPSOUND) ? true : false;
 
 			options = temp_options;
@@ -1153,6 +1133,7 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
 		}
 
 		break;
+
 	case WM_DESTROY:
 		hwndOptionsDialog = 0;
 		added_list.clear();
@@ -1182,7 +1163,8 @@ int OptInit(WPARAM wParam,LPARAM lParam)
 	return 0;
 }
 
-void LoadOptions() {
+void LoadOptions()
+{
 	options.use_popup_module = (DBGetContactSettingByte(0, MODULE, "UsePopupModule", 0) == 1);
 	options.snooze_minutes = (int)DBGetContactSettingDword(0, MODULE, "SnoozeMinutes", 10);
 	options.row_height = (int)DBGetContactSettingDword(0, MODULE, "RowHeight", 20);
@@ -1199,7 +1181,8 @@ void LoadOptions() {
 	HookEvent(ME_SYSTEM_MODULESLOADED, OptionsModulesLoaded);
 }
 
-void SaveOptions() {
+void SaveOptions()
+{
 	DBWriteContactSettingByte(0, MODULE, "UsePopupModule", options.use_popup_module ? 1 : 0);
 	DBWriteContactSettingDword(0, MODULE, "SnoozeMinutes", options.snooze_minutes);
 	DBWriteContactSettingDword(0, MODULE, "RowHeight", options.row_height);
@@ -1214,7 +1197,8 @@ void SaveOptions() {
 	DBWriteContactSettingDword(0, MODULE, "ReminderPeriod", options.reminder_period);
 }
 
-int NewAlarmMenuFunc(WPARAM wParam, LPARAM lParam) {
+INT_PTR NewAlarmMenuFunc(WPARAM wParam, LPARAM lParam)
+{
 	ALARM *new_alarm = new ALARM;
 	memset(new_alarm, 0, sizeof(ALARM));
 	new_alarm->id = next_alarm_id++;
@@ -1226,7 +1210,8 @@ int NewAlarmMenuFunc(WPARAM wParam, LPARAM lParam) {
 	return 0;
 }
 
-void EditNonModal(ALARM &alarm) {
+void EditNonModal(ALARM &alarm)
+{
 	ALARM *new_alarm = new ALARM;
 	memset(new_alarm, 0, sizeof(ALARM));
 	copy_alarm_data(new_alarm, &alarm);
diff --git a/plugins/Alarms/options.h b/plugins/Alarms/options.h
index be2686f505..030ccb77ba 100644
--- a/plugins/Alarms/options.h
+++ b/plugins/Alarms/options.h
@@ -30,7 +30,7 @@ int OptInit(WPARAM wParam,LPARAM lParam);
 void LoadOptions();
 void SaveOptions();
 
-int NewAlarmMenuFunc(WPARAM wParam, LPARAM lParam);
+INT_PTR NewAlarmMenuFunc(WPARAM wParam, LPARAM lParam);
 void EditNonModal(ALARM &alarm);
 
 // provide access the options window, for refresh (== 0 when not displayed)
diff --git a/plugins/Alarms/trigger.cpp b/plugins/Alarms/trigger.cpp
index 78878cd72a..b52ff8f654 100644
--- a/plugins/Alarms/trigger.cpp
+++ b/plugins/Alarms/trigger.cpp
@@ -7,18 +7,18 @@ TRIGGERDATA td;
 
 unsigned short last_selected_id = 0;
 
-static BOOL CALLBACK DlgProcTriggerOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+static INT_PTR CALLBACK DlgProcTriggerOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
 	switch(msg) {
 	case WM_INITDIALOG:
 		TranslateDialogDefault(hwndDlg);
-
 		{
 			copy_list(alist);
 			ALARM *i;
 			for(alist.reset(); i = alist.current(); alist.next()) {
 				int pos = SendDlgItemMessage(hwndDlg, IDC_LST_TRIGLIST, LB_ADDSTRING, (WPARAM)-1, (LPARAM)i->szTitle);
 				SendDlgItemMessage(hwndDlg, IDC_LST_TRIGLIST, LB_SETITEMDATA, (WPARAM)pos, (LPARAM)i->id);
-				if(i->trigger_id == (unsigned int)lParam)
+				if (i->trigger_id == (unsigned int)lParam)
 					SendDlgItemMessage(hwndDlg, IDC_LST_TRIGLIST, LB_SETCURSEL, (WPARAM)pos, 0);
 			}
 		}
@@ -27,7 +27,7 @@ static BOOL CALLBACK DlgProcTriggerOptions(HWND hwndDlg, UINT msg, WPARAM wParam
 	case WM_COMMAND:
 		if (HIWORD( wParam ) == LBN_SELCHANGE) {
 			int pos = SendDlgItemMessage(hwndDlg, IDC_LST_TRIGLIST, LB_GETCURSEL, 0, 0);
-			if(pos != LB_ERR) {
+			if (pos != LB_ERR) {
 				last_selected_id = (unsigned short)SendDlgItemMessage(hwndDlg, IDC_LST_TRIGLIST, LB_GETITEMDATA, pos, 0);
 			}
 			return TRUE;
@@ -40,7 +40,7 @@ static BOOL CALLBACK DlgProcTriggerOptions(HWND hwndDlg, UINT msg, WPARAM wParam
 
 			ALARM *i;
 			for(alist.reset(); i = alist.current(); alist.next()) {
-				if(i->trigger_id == wParam) {
+				if (i->trigger_id == wParam) {
 					//sti.cbSize = sizeof(sti);
 					//sti.triggerID = wParam;
 					//sti.pszSummary = i->szTitle;
@@ -59,7 +59,7 @@ static BOOL CALLBACK DlgProcTriggerOptions(HWND hwndDlg, UINT msg, WPARAM wParam
 		{
 			ALARM *i;
 			for(alist.reset(); i = alist.current(); alist.next()) {
-				if(i->id == last_selected_id) {
+				if (i->id == last_selected_id) {
 					i->trigger_id = wParam;
 					alter_alarm_list(i);
 					break;
@@ -71,7 +71,7 @@ static BOOL CALLBACK DlgProcTriggerOptions(HWND hwndDlg, UINT msg, WPARAM wParam
 		{
 			ALARM *i;
 			for(alist.reset(); i = alist.current(); alist.next()) {
-				if(i->trigger_id == wParam) {
+				if (i->trigger_id == wParam) {
 					i->trigger_id = 0;
 					alter_alarm_list(i);
 					break;
@@ -90,7 +90,7 @@ static BOOL CALLBACK DlgProcTriggerOptions(HWND hwndDlg, UINT msg, WPARAM wParam
 }
 
 int LoadTriggerSupport() {
-	if(ServiceExists(MS_TRIGGER_REGISTERTRIGGER)) {
+	if (ServiceExists(MS_TRIGGER_REGISTERTRIGGER)) {
 		TRIGGERREGISTER treg = {0};
 	
 		treg.cbSize = sizeof(treg);
diff --git a/plugins/LangMan/options.c b/plugins/LangMan/options.c
index f8676a6b0f..487461a2d2 100644
--- a/plugins/LangMan/options.c
+++ b/plugins/LangMan/options.c
@@ -383,7 +383,7 @@ static int CALLBACK CompareListItem(LPARAM lParam1,LPARAM lParam2,LPARAM lParamS
 
 static HWND hwndLangOpt;
 
-static BOOL CALLBACK LangOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK LangOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
 {
 	switch(msg) {
 		case WM_INITDIALOG:
@@ -534,7 +534,7 @@ static BOOL CALLBACK LangOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l
 			break;
 #if defined(_UNICODE)
 		case WM_NOTIFYFORMAT:
-			SetWindowLong(hwndDlg,DWL_MSGRESULT,NFR_UNICODE);
+			SetWindowLong(hwndDlg,DWLP_MSGRESULT,NFR_UNICODE);
 			return TRUE;
 #endif
 		case WM_NOTIFY:
diff --git a/plugins/ListeningTo/listeningto.cpp b/plugins/ListeningTo/listeningto.cpp
index 6960855ac2..575c28dcb6 100644
--- a/plugins/ListeningTo/listeningto.cpp
+++ b/plugins/ListeningTo/listeningto.cpp
@@ -90,20 +90,20 @@ int TopToolBarLoaded(WPARAM wParam, LPARAM lParam);
 int ClistExtraListRebuild(WPARAM wParam, LPARAM lParam);
 int SettingChanged(WPARAM wParam,LPARAM lParam);
 
-int MainMenuClicked(WPARAM wParam, LPARAM lParam);
-BOOL ListeningToEnabled(char *proto, BOOL ignoreGlobal = FALSE);
-int ListeningToEnabled(WPARAM wParam, LPARAM lParam);
-int EnableListeningTo(WPARAM wParam,LPARAM lParam);
-int GetTextFormat(WPARAM wParam,LPARAM lParam);
-int GetParsedFormat(WPARAM wParam,LPARAM lParam);
-int GetOverrideContactOption(WPARAM wParam,LPARAM lParam);
-int GetUnknownText(WPARAM wParam,LPARAM lParam);
-int SetNewSong(WPARAM wParam,LPARAM lParam);
-void SetExtraIcon(HANDLE hContact, BOOL set);
-void SetListeningInfos(LISTENINGTOINFO *lti);
-int HotkeysEnable(WPARAM wParam,LPARAM lParam);
-int HotkeysDisable(WPARAM wParam,LPARAM lParam);
-int HotkeysToggle(WPARAM wParam,LPARAM lParam);
+INT_PTR MainMenuClicked(WPARAM wParam, LPARAM lParam);
+BOOL    ListeningToEnabled(char *proto, BOOL ignoreGlobal = FALSE);
+INT_PTR ListeningToEnabled(WPARAM wParam, LPARAM lParam);
+INT_PTR EnableListeningTo(WPARAM wParam,LPARAM lParam);
+INT_PTR GetTextFormat(WPARAM wParam,LPARAM lParam);
+INT_PTR GetParsedFormat(WPARAM wParam,LPARAM lParam);
+INT_PTR GetOverrideContactOption(WPARAM wParam,LPARAM lParam);
+INT_PTR GetUnknownText(WPARAM wParam,LPARAM lParam);
+INT_PTR SetNewSong(WPARAM wParam,LPARAM lParam);
+void    SetExtraIcon(HANDLE hContact, BOOL set);
+void    SetListeningInfos(LISTENINGTOINFO *lti);
+INT_PTR HotkeysEnable(WPARAM wParam,LPARAM lParam);
+INT_PTR HotkeysDisable(WPARAM wParam,LPARAM lParam);
+INT_PTR HotkeysToggle(WPARAM wParam,LPARAM lParam);
 
 TCHAR* VariablesParseInfo(ARGUMENTSINFO *ai);
 TCHAR* VariablesParseType(ARGUMENTSINFO *ai);
@@ -175,8 +175,6 @@ OutputDebugStringA("\n");
 
 extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) 
 {
-//	EnumWindows(EnumWindowsProc, 0);
-
 	pluginLink = link;
 
 	mir_getMMI(&mmi);
@@ -188,17 +186,17 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
 	CoInitialize(NULL);
 
 	// Services
-	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_ENABLED, ListeningToEnabled) );
-	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_ENABLE, EnableListeningTo) );
-	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_GETTEXTFORMAT, GetTextFormat) );
-	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_GETPARSEDTEXT, GetParsedFormat) );
-	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_OVERRIDECONTACTOPTION, GetOverrideContactOption) );
-	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_GETUNKNOWNTEXT, GetUnknownText) );
-	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_MAINMENU, MainMenuClicked) );
-	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_SET_NEW_SONG, SetNewSong) );
-	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_HOTKEYS_ENABLE, HotkeysEnable) );
-	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_HOTKEYS_DISABLE, HotkeysDisable) );
-	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_HOTKEYS_TOGGLE, HotkeysToggle) );
+	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_ENABLED, ListeningToEnabled));
+	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_ENABLE, EnableListeningTo));
+	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_GETTEXTFORMAT, GetTextFormat));
+	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_GETPARSEDTEXT, GetParsedFormat));
+	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_OVERRIDECONTACTOPTION, GetOverrideContactOption));
+	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_GETUNKNOWNTEXT, GetUnknownText));
+	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_MAINMENU, MainMenuClicked));
+	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_SET_NEW_SONG, SetNewSong));
+	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_HOTKEYS_ENABLE, HotkeysEnable));
+	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_HOTKEYS_DISABLE, HotkeysDisable));
+	hServices.push_back( CreateServiceFunction(MS_LISTENINGTO_HOTKEYS_TOGGLE, HotkeysToggle));
 	
 	// Hooks
 	hHooks.push_back( HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded) );
@@ -292,7 +290,7 @@ void RegisterProtocol(char *proto, TCHAR *account)
 		!ProtoServiceExists(proto, PS_ICQ_SETCUSTOMSTATUSEX))
 		return;
 
-	int id = proto_itens.size();
+	size_t id = proto_itens.size();
 	proto_itens.resize(id+1);
 
 	strncpy(proto_itens[id].proto, proto, MAX_REGS(proto_itens[id].proto));
@@ -596,17 +594,12 @@ int PreShutdown(WPARAM wParam, LPARAM lParam)
 	return 0;
 }
 
-
-int TopToolBarClick(WPARAM wParam, LPARAM lParam)
+static INT_PTR TopToolBarClick(WPARAM wParam, LPARAM lParam)
 {
-	BOOL enabled = !ListeningToEnabled(NULL, TRUE);
-
-	EnableListeningTo(NULL, enabled);
-
+	EnableListeningTo(NULL, !ListeningToEnabled(NULL, TRUE));
 	return 0;
 }
 
-
 // Toptoolbar hook to put an icon in the toolbar
 int TopToolBarLoaded(WPARAM wParam, LPARAM lParam) 
 {
@@ -628,8 +621,7 @@ int TopToolBarLoaded(WPARAM wParam, LPARAM lParam)
 	return 0;
 }
 
-
-int MainMenuClicked(WPARAM wParam, LPARAM lParam)
+INT_PTR MainMenuClicked(WPARAM wParam, LPARAM lParam)
 {
 	if (!loaded)
 		return -1;
@@ -643,7 +635,6 @@ int MainMenuClicked(WPARAM wParam, LPARAM lParam)
 	return 0;
 }
 
-
 BOOL ListeningToEnabled(char *proto, BOOL ignoreGlobal) 
 {
 	if (!ignoreGlobal && !opts.enable_sending)
@@ -673,8 +664,7 @@ BOOL ListeningToEnabled(char *proto, BOOL ignoreGlobal)
 	}
 }
 
-
-int ListeningToEnabled(WPARAM wParam, LPARAM lParam) 
+INT_PTR ListeningToEnabled(WPARAM wParam, LPARAM lParam) 
 {
 	if (!loaded)
 		return -1;
@@ -682,7 +672,6 @@ int ListeningToEnabled(WPARAM wParam, LPARAM lParam)
 	return ListeningToEnabled((char *)wParam) ;
 }
 
-
 ProtocolInfo *GetProtoInfo(char *proto)
 {
 	for (unsigned int i = 1; i < proto_itens.size(); i++)
@@ -694,25 +683,16 @@ ProtocolInfo *GetProtoInfo(char *proto)
 
 void SetListeningInfo(char *proto, LISTENINGTOINFO *lti)
 {
-//	m_log(_T("SetListeningInfo"), _T("proto=%S  lti=%d  title=%s"), 
-//		proto, (int) lti, lti == NULL ? _T("") : lti->ptszTitle);
-		
 	if (proto == NULL)
 		return;
 
 	if (!ListeningToEnabled(proto))
-	{
 		lti = NULL;
-//		m_log(_T("SetListeningInfo"), _T("DISABLED -> lti = NULL"));
-	}
-
 
 	if (ProtoServiceExists(proto, PS_SET_LISTENINGTO))
-	{
 		CallProtoService(proto, PS_SET_LISTENINGTO, 0, (LPARAM) lti);
-	}
-	else if (ProtoServiceExists(proto, PS_ICQ_SETCUSTOMSTATUSEX))
-	{
+
+	else if (ProtoServiceExists(proto, PS_ICQ_SETCUSTOMSTATUSEX)) {
 		if (opts.xstatus_set == IGNORE_XSTATUS)
 			return;
 
@@ -876,8 +856,7 @@ void SetListeningInfo(char *proto, LISTENINGTOINFO *lti)
 	}
 }
 
-
-int EnableListeningTo(WPARAM wParam,LPARAM lParam) 
+INT_PTR EnableListeningTo(WPARAM wParam,LPARAM lParam) 
 {
 	if (!loaded)
 		return -1;
@@ -931,35 +910,30 @@ int EnableListeningTo(WPARAM wParam,LPARAM lParam)
 	return 0;
 }
 
-
-int HotkeysEnable(WPARAM wParam,LPARAM lParam) 
+INT_PTR HotkeysEnable(WPARAM wParam,LPARAM lParam) 
 {
 	return EnableListeningTo(lParam, TRUE);
 }
 
-
-int HotkeysDisable(WPARAM wParam,LPARAM lParam) 
+INT_PTR HotkeysDisable(WPARAM wParam,LPARAM lParam) 
 {
 	return EnableListeningTo(lParam, FALSE);
 }
 
-
-int HotkeysToggle(WPARAM wParam,LPARAM lParam) 
+INT_PTR HotkeysToggle(WPARAM wParam,LPARAM lParam) 
 {
 	return EnableListeningTo(lParam, !ListeningToEnabled((char *)lParam, TRUE));
 }
 
-
-int GetTextFormat(WPARAM wParam,LPARAM lParam) 
+INT_PTR GetTextFormat(WPARAM wParam,LPARAM lParam) 
 {
 	if (!loaded)
 		return NULL;
 
-	return (int) mir_tstrdup(opts.templ);
+	return ( INT_PTR )mir_tstrdup(opts.templ);
 }
 
-
-int GetParsedFormat(WPARAM wParam,LPARAM lParam) 
+INT_PTR GetParsedFormat(WPARAM wParam,LPARAM lParam) 
 {
 	if (!loaded)
 		return NULL;
@@ -986,64 +960,54 @@ int GetParsedFormat(WPARAM wParam,LPARAM lParam)
 	return (int) ret.detach();
 }
 
-
-int GetOverrideContactOption(WPARAM wParam,LPARAM lParam) 
+INT_PTR GetOverrideContactOption(WPARAM wParam,LPARAM lParam) 
 {
-	return (int) opts.override_contact_template;
+	return ( INT_PTR )opts.override_contact_template;
 }
 
 
-int GetUnknownText(WPARAM wParam,LPARAM lParam) 
+INT_PTR GetUnknownText(WPARAM wParam,LPARAM lParam) 
 {
-	return (int) opts.unknown;
+	return ( INT_PTR )opts.unknown;
 }
 
-
 void SetListeningInfos(LISTENINGTOINFO *lti)
 {
 	for (unsigned int i = 1; i < proto_itens.size(); ++i)
-	{
 		SetListeningInfo(proto_itens[i].proto, lti);
-	}
 
 	TCHAR *fr = NULL; 
 	char *info = NULL;
 
-	if (lti) 
-	{
+	if (lti) {
 		fr = (TCHAR *)GetParsedFormat(0, (WPARAM) lti);
 		if (fr) info = mir_t2a(fr);
 	}
 
 	NotifyEventHooks(hListeningInfoChangedEvent, (WPARAM)info, (LPARAM)NULL);
 
-	if (lti) 
-	{
+	if (lti) {
 		if (fr) mir_free(fr);
 		if (info) mir_free(info);
 	}
 }
 
-static void CALLBACK GetInfoTimer(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
+static void CALLBACK GetInfoTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
 {
-	if (hTimer != NULL)
-	{
+	if (hTimer != NULL) {
 		KillTimer(NULL, hTimer);
 		hTimer = NULL;
 	}
 
 	// Check if we can set it now...
 	DWORD now = GetTickCount();
-	if (now < lastInfoSetTime + MIN_TIME_BEETWEEN_SETS)
-	{
+	if (now < lastInfoSetTime + MIN_TIME_BEETWEEN_SETS) {
 		hTimer = SetTimer(NULL, NULL, lastInfoSetTime + MIN_TIME_BEETWEEN_SETS - now, GetInfoTimer);
 		return;
 	}
 	lastInfoSetTime = GetTickCount(); // TODO Move this to inside the if that really sets
 
-	if (!opts.enable_sending)
-	{
-//		m_log(_T("GetInfoTimer"), _T("!opts.enable_sending"));
+	if (!opts.enable_sending) {
 		SetListeningInfos(NULL);
 		return;
 	}
@@ -1051,15 +1015,9 @@ static void CALLBACK GetInfoTimer(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTi
 	// Set it
 	int changed = ChangedListeningInfo();
 	if (changed < 0)
-	{
-//		m_log(_T("GetInfoTimer"), _T("changed < 0"));
 		SetListeningInfos(NULL);
-	}
 	else if (changed > 0)
-	{
-//		m_log(_T("GetInfoTimer"), _T("changed > 0"));
 		SetListeningInfos(GetListeningInfo());
-	}
 
 	StartTimer();
 }
@@ -1192,28 +1150,23 @@ int SettingChanged(WPARAM wParam,LPARAM lParam)
 	return 0;
 }
 
-
-int SetNewSong(WPARAM wParam,LPARAM lParam)
+INT_PTR SetNewSong(WPARAM wParam,LPARAM lParam)
 {
 	if (lParam == NULL)
 		return -1;
 
-	if (lParam == LISTENINGTO_ANSI)
-	{
+	if (lParam == LISTENINGTO_ANSI) {
 		CharToWchar data((char *) wParam);
 		((GenericPlayer *) players[GENERIC])->NewData(data, wcslen(data));
 	}
-	else
-	{
+	else {
 		WCHAR *data = (WCHAR *) wParam;
 		((GenericPlayer *) players[GENERIC])->NewData(data, wcslen(data));
 	}
 
-
 	return 0;
 }
 
-
 TCHAR* VariablesParseInfo(ARGUMENTSINFO *ai)
 {
 	if (ai->cbSize < sizeof(ARGUMENTSINFO))
diff --git a/plugins/ListeningTo/options.cpp b/plugins/ListeningTo/options.cpp
index 84f5067278..5ec98f1d15 100644
--- a/plugins/ListeningTo/options.cpp
+++ b/plugins/ListeningTo/options.cpp
@@ -35,9 +35,9 @@ BOOL ListeningToEnabled(char *proto, BOOL ignoreGlobal = FALSE);
 
 
 
-static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static BOOL CALLBACK PlayersDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static BOOL CALLBACK FormatDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+static INT_PTR CALLBACK PlayersDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+static INT_PTR CALLBACK FormatDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
 
 
 static OptPageControl optionsControls[] = { 
@@ -203,7 +203,7 @@ static void OptionsEnableDisableCtrls(HWND hwndDlg)
 }
 
 
-static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) 
+static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) 
 {
 	BOOL ret;
 	if (msg != WM_INITDIALOG)
@@ -310,7 +310,7 @@ static void PlayersEnableDisableCtrls(HWND hwndDlg)
 	EnableWindow(GetDlgItem(hwndDlg, IDC_CODE_INJECTION), enabled);
 }
 
-static BOOL CALLBACK PlayersDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) 
+static INT_PTR CALLBACK PlayersDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) 
 {
 	BOOL ret = SaveOptsDlgProc(playersControls, MAX_REGS(playersControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
 
@@ -345,7 +345,7 @@ static BOOL CALLBACK PlayersDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
 	return ret;
 }
 
-static BOOL CALLBACK FormatDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) 
+static INT_PTR CALLBACK FormatDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) 
 {
 	return SaveOptsDlgProc(formatControls, MAX_REGS(formatControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
 }
-- 
cgit v1.2.3