From 81b4e8014fa8abf16b800f089357b0718305676c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 13 Aug 2015 21:54:08 +0000 Subject: 64-bit compatibility git-svn-id: http://svn.miranda-ng.org/main/trunk@14948 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Alarms/src/alarm_win.cpp | 285 ++++++++++++++++++--------------------- 1 file changed, 134 insertions(+), 151 deletions(-) (limited to 'plugins') diff --git a/plugins/Alarms/src/alarm_win.cpp b/plugins/Alarms/src/alarm_win.cpp index 6ba0aba565..d211b0c43b 100644 --- a/plugins/Alarms/src/alarm_win.cpp +++ b/plugins/Alarms/src/alarm_win.cpp @@ -31,6 +31,8 @@ void SetAlarmWinOptions() INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { + WindowData *wd = (WindowData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); @@ -38,7 +40,7 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar Utils_RestoreWindowPositionNoSize(hwndDlg, 0, MODULE, "Notify"); SetFocus(GetDlgItem(hwndDlg, IDC_SNOOZE)); - WindowData *wd = new WindowData; + wd = new WindowData; wd->moving = false; wd->alarm = 0; wd->win_num = win_num++; @@ -79,14 +81,14 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar SetTextColor(hdc, window_font_colour); SetBkMode(hdc, TRANSPARENT); - return hBackgroundBrush != NULL; + return (INT_PTR)hBackgroundBrush; } } break; case WM_CTLCOLORDLG: if (hBackgroundBrush) - return hBackgroundBrush != NULL; + return (INT_PTR)hBackgroundBrush; break; case WMU_SETFONTS: @@ -103,56 +105,53 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar return TRUE; case WMU_SETOPT: - { - Options *opt; - if (lParam) - opt = (Options*)lParam; - else - opt = &options; - - // round corners - if (opt->aw_roundcorners) { - HRGN hRgn1; - RECT r; - int w = 10; - GetWindowRect(hwndDlg, &r); - int h = (r.right - r.left) > (w * 2) ? w : (r.right - r.left); - int v = (r.bottom - r.top) > (w * 2) ? w : (r.bottom - r.top); - h = (h(w * 2) ? w : (r.right - r.left); - int v = (r.bottom - r.top) > (w * 2) ? w : (r.bottom - r.top); - h = (h < v) ? h : v; - hRgn1 = CreateRectRgn(0, 0, (r.right - r.left + 1), (r.bottom - r.top + 1)); - SetWindowRgn(hwndDlg, hRgn1, 1); - } - // transparency - - #ifdef WS_EX_LAYERED - SetWindowLongPtr(hwndDlg, GWL_EXSTYLE, GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) | WS_EX_LAYERED); - #endif - #ifdef LWA_ALPHA - SetLayeredWindowAttributes(hwndDlg, RGB(0, 0, 0), (int)((100 - opt->aw_trans) / 100.0 * 255), LWA_ALPHA); - #endif + Options *opt; + if (lParam) + opt = (Options*)lParam; + else + opt = &options; + + // round corners + if (opt->aw_roundcorners) { + HRGN hRgn1; + RECT r; + int w = 10; + GetWindowRect(hwndDlg, &r); + int h = (r.right - r.left) > (w * 2) ? w : (r.right - r.left); + int v = (r.bottom - r.top) > (w * 2) ? w : (r.bottom - r.top); + h = (h(w * 2) ? w : (r.right - r.left); + int v = (r.bottom - r.top) > (w * 2) ? w : (r.bottom - r.top); + h = (h < v) ? h : v; + hRgn1 = CreateRectRgn(0, 0, (r.right - r.left + 1), (r.bottom - r.top + 1)); + SetWindowRgn(hwndDlg, hRgn1, 1); } + // transparency + + #ifdef WS_EX_LAYERED + SetWindowLongPtr(hwndDlg, GWL_EXSTYLE, GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) | WS_EX_LAYERED); + #endif + #ifdef LWA_ALPHA + SetLayeredWindowAttributes(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; SetWindowText(hwndDlg, data->szTitle); - HWND hw = GetDlgItem(hwndDlg, IDC_TITLE); - SetWindowText(hw, data->szTitle); + SetWindowText(GetDlgItem(hwndDlg, IDC_TITLE), data->szTitle); SetDlgItemText(hwndDlg, IDC_ED_DESC, data->szDesc); - ((WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA))->alarm = data; + wd->alarm = data; if (data->action & AAF_SOUND && options.loop_sound) { if (data->sound_num <= 3) @@ -161,36 +160,31 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar SetTimer(hwndDlg, ID_TIMER_SOUND, SPEACH_REPEAT_PERIOD, 0); } - hw = GetDlgItem(hwndDlg, IDC_SNOOZE); + HWND hw = GetDlgItem(hwndDlg, IDC_SNOOZE); EnableWindow(hw, !(data->flags & ALF_NOSNOOZE)); ShowWindow(hw, (data->flags & ALF_NOSNOOZE) ? SW_HIDE : SW_SHOWNA); } return TRUE; case WMU_FAKEALARM: - { - SetWindowText(hwndDlg, TranslateT("Example alarm")); - SetDlgItemText(hwndDlg, IDC_TITLE, TranslateT("Example alarm")); - SetDlgItemText(hwndDlg, IDC_ED_DESC, TranslateT("Some example text. Example, example, example.")); - } + SetWindowText(hwndDlg, TranslateT("Example alarm")); + SetDlgItemText(hwndDlg, IDC_TITLE, TranslateT("Example alarm")); + SetDlgItemText(hwndDlg, IDC_ED_DESC, TranslateT("Some example text. Example, example, example.")); return TRUE; case WM_TIMER: - if (wParam == ID_TIMER_SOUND) { - WindowData *dw = (WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (dw) { - ALARM *data = dw->alarm; - if (data && data->action & AAF_SOUND) { - if (data->sound_num <= 3) { - char buff[128]; - mir_snprintf(buff, "Triggered%d", data->sound_num); - SkinPlaySound(buff); - } - 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); - } + if (wParam == ID_TIMER_SOUND && wd) { + ALARM *data = wd->alarm; + if (data && data->action & AAF_SOUND) { + if (data->sound_num <= 3) { + char buff[128]; + mir_snprintf(buff, "Triggered%d", data->sound_num); + SkinPlaySound(buff); + } + 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); } } } @@ -203,36 +197,33 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar break; case WMU_ADDSNOOZER: - { - WindowData *wd = (WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (wd) { - ALARM *data = wd->alarm; + if (wd) { + ALARM *data = wd->alarm; + if (data) { + // add snooze minutes to current time + FILETIME ft; + GetLocalTime(&data->time); + SystemTimeToFileTime(&data->time, &ft); + + ULARGE_INTEGER uli; + uli.LowPart = ft.dwLowDateTime; + uli.HighPart = ft.dwHighDateTime; - if (data) { - // add snooze minutes to current time - FILETIME ft; - GetLocalTime(&data->time); - SystemTimeToFileTime(&data->time, &ft); - ULARGE_INTEGER uli; - uli.LowPart = ft.dwLowDateTime; - uli.HighPart = ft.dwHighDateTime; + // there are 10000000 100-nanosecond blocks in a second... + uli.QuadPart += mult.QuadPart * (int)(wParam); - // there are 10000000 100-nanosecond blocks in a second... - uli.QuadPart += mult.QuadPart * (int)(wParam); + ft.dwHighDateTime = uli.HighPart; + ft.dwLowDateTime = uli.LowPart; - ft.dwHighDateTime = uli.HighPart; - ft.dwLowDateTime = uli.LowPart; + FileTimeToSystemTime(&ft, &data->time); - FileTimeToSystemTime(&ft, &data->time); + data->occurrence = OC_ONCE; + data->snoozer = true; + data->flags = data->flags & ~ALF_NOSTARTUP; - data->occurrence = OC_ONCE; - data->snoozer = true; - data->flags = data->flags & ~ALF_NOSTARTUP; + data->id = next_alarm_id++; - data->id = next_alarm_id++; - - append_to_list(data); - } + append_to_list(data); } } return TRUE; @@ -247,67 +238,61 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar //drop through case IDC_DISMISS: - { - WindowData *window_data = (WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - KillTimer(hwndDlg, ID_TIMER_SOUND); - if (window_data) { - if (window_data->alarm) { - free_alarm_data(window_data->alarm); - delete window_data->alarm; - } - delete window_data; + KillTimer(hwndDlg, ID_TIMER_SOUND); + if (wd) { + if (wd->alarm) { + free_alarm_data(wd->alarm); + delete wd->alarm; } - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); - - win_num--; - //EndDialog(hwndDlg, IDOK); // not modal! - WindowList_Remove(hAlarmWindowList, hwndDlg); - DestroyWindow(hwndDlg); + delete wd; } + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); + + win_num--; + WindowList_Remove(hAlarmWindowList, hwndDlg); + DestroyWindow(hwndDlg); break; case IDC_SNOOZELIST: - { - POINT pt, pt_rel; - GetCursorPos(&pt); - pt_rel = pt; - ScreenToClient(hwndDlg, &pt_rel); - - HMENU hMenu = CreatePopupMenu(); - MENUITEMINFO mii = { 0 }; - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_ID | MIIM_STRING; - - #define AddItem(x) \ - mii.wID++; \ - mii.dwTypeData = TranslateT(x); \ - mii.cch = ( UINT )mir_tstrlen(mii.dwTypeData); \ - InsertMenuItem(hMenu, mii.wID, FALSE, &mii); - - AddItem(LPGEN("5 mins")); - AddItem(LPGEN("15 mins")); - AddItem(LPGEN("30 mins")); - AddItem(LPGEN("1 hour")); - AddItem(LPGEN("1 day")); - AddItem(LPGEN("1 week")); - - TPMPARAMS tpmp = { 0 }; - tpmp.cbSize = sizeof(tpmp); - LRESULT ret = (LRESULT)TrackPopupMenuEx(hMenu, TPM_RETURNCMD, pt.x, pt.y, hwndDlg, &tpmp); - switch (ret) { - case 0: DestroyMenu(hMenu); return 0; // dismis menu - case 1: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)5, 0); break; - case 2: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)15, 0); break; - case 3: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)30, 0); break; - case 4: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)60, 0); break; - case 5: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)(60 * 24), 0); break; - case 6: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)(60 * 24 * 7), 0); break; - } + POINT pt, pt_rel; + GetCursorPos(&pt); + pt_rel = pt; + ScreenToClient(hwndDlg, &pt_rel); + + HMENU hMenu = CreatePopupMenu(); + MENUITEMINFO mii = { 0 }; + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_ID | MIIM_STRING; + + #define AddItem(x) \ + mii.wID++; \ + mii.dwTypeData = TranslateT(x); \ + mii.cch = ( UINT )mir_tstrlen(mii.dwTypeData); \ + InsertMenuItem(hMenu, mii.wID, FALSE, &mii); + + AddItem(LPGEN("5 mins")); + AddItem(LPGEN("15 mins")); + AddItem(LPGEN("30 mins")); + AddItem(LPGEN("1 hour")); + AddItem(LPGEN("1 day")); + AddItem(LPGEN("1 week")); + + TPMPARAMS tpmp = { 0 }; + tpmp.cbSize = sizeof(tpmp); + LRESULT ret = (LRESULT)TrackPopupMenuEx(hMenu, TPM_RETURNCMD, pt.x, pt.y, hwndDlg, &tpmp); + switch (ret) { + case 0: DestroyMenu(hMenu); return 0; // dismis menu + case 1: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)5, 0); break; + case 2: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)15, 0); break; + case 3: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)30, 0); break; + case 4: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)60, 0); break; + case 5: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)(60 * 24), 0); break; + case 6: SendMessage(hwndDlg, WMU_ADDSNOOZER, (WPARAM)(60 * 24 * 7), 0); break; + } - DestroyMenu(hMenu); + DestroyMenu(hMenu); - SendMessage(hwndDlg, WM_COMMAND, IDC_DISMISS, 0); - } + SendMessage(hwndDlg, WM_COMMAND, IDC_DISMISS, 0); break; } } @@ -322,22 +307,20 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar newp.y = (short)HIWORD(lParam); ClientToScreen(hwndDlg, &newp); - WindowData *window_data = (WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (!window_data->moving) - window_data->moving = true; + if (!wd->moving) + wd->moving = true; else { RECT r; GetWindowRect(hwndDlg, &r); - SetWindowPos(hwndDlg, 0, r.left + (newp.x - window_data->p.x), r.top + (newp.y - window_data->p.y), 0, 0, SWP_NOSIZE | SWP_NOZORDER); + SetWindowPos(hwndDlg, 0, r.left + (newp.x - wd->p.x), r.top + (newp.y - wd->p.y), 0, 0, SWP_NOSIZE | SWP_NOZORDER); } - window_data->p.x = newp.x; - window_data->p.y = newp.y; + wd->p.x = newp.x; + wd->p.y = newp.y; } else { ReleaseCapture(); - WindowData *window_data = (WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - window_data->moving = false; + wd->moving = false; } return TRUE; } -- cgit v1.2.3