diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-07 20:50:13 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-07 20:50:13 +0000 |
commit | 5fbea6c9b7b89fd01f64a67244bddf6ecc8a7187 (patch) | |
tree | 6c7228c01a0f7d42e8dc285333f7fdb44069edcb /plugins/AutoShutdown | |
parent | 72fd4143b5a49a5842ce0af179b177551d356f91 (diff) |
more cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@4376 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AutoShutdown')
-rw-r--r-- | plugins/AutoShutdown/src/common.h | 1 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/settingsdlg.cpp | 373 |
2 files changed, 194 insertions, 180 deletions
diff --git a/plugins/AutoShutdown/src/common.h b/plugins/AutoShutdown/src/common.h index 8a0ad9b66b..fba4f10304 100644 --- a/plugins/AutoShutdown/src/common.h +++ b/plugins/AutoShutdown/src/common.h @@ -58,7 +58,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_hddinfo.h>
#include <m_toptoolbar.h>
#include <m_autoreplacer.h>
-#include <m_magneticwindows.h>
#include <m_snappingwindows.h>
#include "m_shutdown.h"
diff --git a/plugins/AutoShutdown/src/settingsdlg.cpp b/plugins/AutoShutdown/src/settingsdlg.cpp index 96e29316e6..601922f0ec 100644 --- a/plugins/AutoShutdown/src/settingsdlg.cpp +++ b/plugins/AutoShutdown/src/settingsdlg.cpp @@ -64,13 +64,15 @@ static BOOL AnyProtoHasCaps(DWORD caps1) static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg) {
- case WM_INITDIALOG:
- { LCID locale;
+ case WM_INITDIALOG:
+ {
+ LCID locale;
hwndSettingsDlg=hwndDlg;
TranslateDialogDefault(hwndDlg);
locale=CallService(MS_LANGPACK_GETLOCALE,0,0);
SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,(LPARAM)Skin_GetIcon("AutoShutdown_Header"));
- { HFONT hBoldFont;
+ {
+ HFONT hBoldFont;
LOGFONT lf;
if(GetObject((HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0),sizeof(lf),&lf)) {
lf.lfWeight=FW_BOLD;
@@ -79,7 +81,8 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_SETFONT,(WPARAM)hBoldFont,FALSE);
}
/* read-in watcher flags */
- { WORD watcherType;
+ {
+ WORD watcherType;
watcherType=db_get_w(NULL,"AutoShutdown","WatcherFlags",SETTING_WATCHERFLAGS_DEFAULT);
CheckRadioButton(hwndDlg,IDC_RADIO_STTIME,IDC_RADIO_STCOUNTDOWN,(watcherType&SDWTF_ST_TIME)?IDC_RADIO_STTIME:IDC_RADIO_STCOUNTDOWN);
CheckDlgButton(hwndDlg,IDC_CHECK_SPECIFICTIME,(watcherType&SDWTF_SPECIFICTIME)!=0);
@@ -90,14 +93,16 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR CheckDlgButton(hwndDlg,IDC_CHECK_CPUUSAGE,(watcherType&SDWTF_CPUUSAGE)!=0);
}
/* read-in countdown val */
- { SYSTEMTIME st;
+ {
+ SYSTEMTIME st;
if(!TimeStampToSystemTime((time_t)db_get_dw(NULL,"AutoShutdown","TimeStamp",SETTING_TIMESTAMP_DEFAULT),&st))
GetLocalTime(&st);
DateTime_SetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),GDT_VALID,&st);
DateTime_SetSystemtime(GetDlgItem(hwndDlg,IDC_DATE_TIMESTAMP),GDT_VALID,&st);
SendMessage(hwndDlg,M_CHECK_DATETIME,0,0);
}
- { DWORD setting;
+ {
+ DWORD setting;
setting=db_get_dw(NULL,"AutoShutdown","Countdown",SETTING_COUNTDOWN_DEFAULT);
if(setting<1) setting=SETTING_COUNTDOWN_DEFAULT;
SendDlgItemMessage(hwndDlg,IDC_SPIN_COUNTDOWN,UDM_SETRANGE,0,MAKELPARAM(UD_MAXVAL,1));
@@ -105,12 +110,13 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR SendDlgItemMessage(hwndDlg,IDC_SPIN_COUNTDOWN,UDM_SETPOS,0,MAKELPARAM(setting,0));
SetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,setting,FALSE);
}
- { HWND hwndCombo;
+ {
+ HWND hwndCombo;
DWORD lastUnit;
int i,index;
const DWORD unitValues[]={1,60,60*60,60*60*24,60*60*24*7,60*60*24*31};
const TCHAR *unitNames[]={TranslateT("Second(s)"), TranslateT("Minute(s)"), TranslateT("Hour(s)"),
- TranslateT("Day(s)"), TranslateT("Week(s)"), TranslateT("Month(s)")};
+ TranslateT("Day(s)"), TranslateT("Week(s)"), TranslateT("Month(s)")};
hwndCombo=GetDlgItem(hwndDlg,IDC_COMBO_COUNTDOWNUNIT);
lastUnit=db_get_dw(NULL,"AutoShutdown","CountdownUnit",SETTING_COUNTDOWNUNIT_DEFAULT);
SendMessage(hwndCombo,CB_SETLOCALE,(WPARAM)locale,0); /* sort order */
@@ -123,7 +129,8 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR }
}
}
- { DBVARIANT dbv;
+ {
+ DBVARIANT dbv;
if(!db_get_ts(NULL,"AutoShutdown","Message",&dbv)) {
SetDlgItemText(hwndDlg,IDC_EDIT_MESSAGE,dbv.ptszVal);
mir_free(dbv.ptszVal);
@@ -132,7 +139,8 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR CallService(MS_AUTOREPLACER_ADDWINHANDLE,0,(LPARAM)GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE));
}
/* cpuusage threshold */
- { BYTE setting;
+ {
+ BYTE setting;
setting=DBGetContactSettingRangedByte(NULL,"AutoShutdown","CpuUsageThreshold",SETTING_CPUUSAGETHRESHOLD_DEFAULT,1,100);
SendDlgItemMessage(hwndDlg,IDC_SPIN_CPUUSAGE,UDM_SETRANGE,0,MAKELPARAM(100,1));
SendDlgItemMessage(hwndDlg,IDC_EDIT_CPUUSAGE,EM_SETLIMITTEXT,(WPARAM)3,0);
@@ -140,20 +148,16 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR SetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,setting,FALSE);
}
/* shutdown types */
- { HWND hwndCombo;
- BYTE lastShutdownType;
- BYTE shutdownType;
- int index;
- TCHAR *pszText;
- hwndCombo=GetDlgItem(hwndDlg,IDC_COMBO_SHUTDOWNTYPE);
- lastShutdownType=db_get_b(NULL,"AutoShutdown","ShutdownType",SETTING_SHUTDOWNTYPE_DEFAULT);
+ {
+ HWND hwndCombo=GetDlgItem(hwndDlg,IDC_COMBO_SHUTDOWNTYPE);
+ BYTE lastShutdownType=db_get_b(NULL,"AutoShutdown","ShutdownType",SETTING_SHUTDOWNTYPE_DEFAULT);
SendMessage(hwndCombo,CB_SETLOCALE,(WPARAM)locale,0); /* sort order */
SendMessage(hwndCombo,CB_SETEXTENDEDUI,TRUE,0);
SendMessage(hwndCombo,CB_INITSTORAGE,SDSDT_MAX,SDSDT_MAX*32);
- for(shutdownType=1;shutdownType<=SDSDT_MAX;++shutdownType)
+ for(BYTE shutdownType=1;shutdownType<=SDSDT_MAX;++shutdownType)
if(ServiceIsTypeEnabled(shutdownType,0)) {
- pszText=(TCHAR*)ServiceGetTypeDescription(shutdownType,GSTDF_TCHAR); /* never fails */
- index=SendMessage(hwndCombo,CB_ADDSTRING,0,(LPARAM)pszText);
+ TCHAR *pszText=(TCHAR*)ServiceGetTypeDescription(shutdownType,GSTDF_TCHAR); /* never fails */
+ int index=SendMessage(hwndCombo,CB_ADDSTRING,0,(LPARAM)pszText);
if(index!=LB_ERR) {
SendMessage(hwndCombo,CB_SETITEMDATA,index,(LPARAM)shutdownType);
if(shutdownType==1 || shutdownType==lastShutdownType) SendMessage(hwndCombo,CB_SETCURSEL,(WPARAM)index,0);
@@ -171,83 +175,86 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR if((!AnyProtoHasCaps(PF1_FILESEND) && !AnyProtoHasCaps(PF1_FILERECV)) || !ServiceExists(MS_FILE_SENDFILE)) { /* no srfile present? */
CheckDlgButton(hwndDlg,IDC_CHECK_FILETRANSFER,FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_FILETRANSFER),FALSE);
- }
+ }
/* check if cpu usage can be detected */
if(!PollCpuUsage(DisplayCpuUsageProc,(LPARAM)GetDlgItem(hwndDlg,IDC_TEXT_CURRENTCPU),1800)) {
CheckDlgButton(hwndDlg,IDC_CHECK_CPUUSAGE,FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_CPUUSAGE),FALSE);
}
SendMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
- MagneticWindows_AddWindow(hwndDlg);
Utils_RestoreWindowPositionNoSize(hwndDlg,NULL,"AutoShutdown","SettingsDlg_");
return TRUE; /* default focus */
}
- case WM_DESTROY:
- { HICON hIcon;
- HFONT hFont;
+ case WM_DESTROY:
+ {
if(ServiceExists(MS_AUTOREPLACER_ADDWINHANDLE))
CallService(MS_AUTOREPLACER_REMWINHANDLE,0,(LPARAM)GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE));
Utils_SaveWindowPosition(hwndDlg,NULL,"AutoShutdown","SettingsDlg_");
- MagneticWindows_RemoveWindow(hwndDlg);
- hIcon=(HICON)SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,0);
+ HICON hIcon=(HICON)SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,0);
Skin_ReleaseIcon(hIcon); /* does NULL check */
- hFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0);
+ HFONT hFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0);
SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_SETFONT,0,FALSE); /* no return value */
if(hFont!=NULL) DeleteObject(hFont);
hwndSettingsDlg=NULL;
- return TRUE;
}
- case WM_CTLCOLORSTATIC:
- switch(GetDlgCtrlID((HWND)lParam)) {
- case IDC_ICON_HEADER:
- SetBkMode((HDC)wParam,TRANSPARENT);
- case IDC_RECT_HEADER:
- /* need to set COLOR_WINDOW manually for Win9x */
- SetBkColor((HDC)wParam,GetSysColor(COLOR_WINDOW));
- return (BOOL)GetSysColorBrush(COLOR_WINDOW);
- case IDC_TEXT_HEADER:
- case IDC_TEXT_HEADERDESC:
- SetBkMode((HDC)wParam,TRANSPARENT);
- return (BOOL)GetStockObject(NULL_BRUSH);
- }
- break;
- case M_ENABLE_SUBCTLS:
- { BOOL checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE)!=0;
- EnableDlgItem(hwndDlg,IDC_EDIT_MESSAGE,checked);
- checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME)!=0;
- EnableDlgItem(hwndDlg,IDC_RADIO_STTIME,checked);
- EnableDlgItem(hwndDlg,IDC_RADIO_STCOUNTDOWN,checked);
- checked=(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) && IsDlgButtonChecked(hwndDlg,IDC_RADIO_STTIME));
- EnableDlgItem(hwndDlg,IDC_TIME_TIMESTAMP,checked);
- EnableDlgItem(hwndDlg,IDC_DATE_TIMESTAMP,checked);
- checked=(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) && IsDlgButtonChecked(hwndDlg,IDC_RADIO_STCOUNTDOWN));
- EnableDlgItem(hwndDlg,IDC_EDIT_COUNTDOWN,checked);
- EnableDlgItem(hwndDlg,IDC_SPIN_COUNTDOWN,checked);
- EnableDlgItem(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,checked);
- checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE)!=0;
- EnableDlgItem(hwndDlg,IDC_URL_IDLE,checked);
- checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE)!=0;
- EnableDlgItem(hwndDlg,IDC_EDIT_CPUUSAGE,checked);
- EnableDlgItem(hwndDlg,IDC_SPIN_CPUUSAGE,checked);
- EnableDlgItem(hwndDlg,IDC_TEXT_PERCENT,checked);
- EnableDlgItem(hwndDlg,IDC_TEXT_CURRENTCPU,checked);
- checked=(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) || IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE) ||
- IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE) || IsDlgButtonChecked(hwndDlg,IDC_CHECK_STATUS) ||
- IsDlgButtonChecked(hwndDlg,IDC_CHECK_FILETRANSFER) || IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE));
- EnableDlgItem(hwndDlg,IDOK,checked);
- }
- return TRUE;
- case M_UPDATE_SHUTDOWNDESC: /* lParam=(LPARAM)(HWND)hwndCombo */
- { BYTE shutdownType;
- shutdownType=(BYTE)SendMessage((HWND)lParam,CB_GETITEMDATA,SendMessage((HWND)lParam,CB_GETCURSEL,0,0),0);
+ return TRUE;
+
+ case WM_CTLCOLORSTATIC:
+ switch(GetDlgCtrlID((HWND)lParam)) {
+ case IDC_ICON_HEADER:
+ SetBkMode((HDC)wParam,TRANSPARENT);
+ case IDC_RECT_HEADER:
+ /* need to set COLOR_WINDOW manually for Win9x */
+ SetBkColor((HDC)wParam,GetSysColor(COLOR_WINDOW));
+ return (BOOL)GetSysColorBrush(COLOR_WINDOW);
+ case IDC_TEXT_HEADER:
+ case IDC_TEXT_HEADERDESC:
+ SetBkMode((HDC)wParam,TRANSPARENT);
+ return (BOOL)GetStockObject(NULL_BRUSH);
+ }
+ break;
+
+ case M_ENABLE_SUBCTLS:
+ {
+ BOOL checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE)!=0;
+ EnableDlgItem(hwndDlg,IDC_EDIT_MESSAGE,checked);
+ checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME)!=0;
+ EnableDlgItem(hwndDlg,IDC_RADIO_STTIME,checked);
+ EnableDlgItem(hwndDlg,IDC_RADIO_STCOUNTDOWN,checked);
+ checked=(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) && IsDlgButtonChecked(hwndDlg,IDC_RADIO_STTIME));
+ EnableDlgItem(hwndDlg,IDC_TIME_TIMESTAMP,checked);
+ EnableDlgItem(hwndDlg,IDC_DATE_TIMESTAMP,checked);
+ checked=(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) && IsDlgButtonChecked(hwndDlg,IDC_RADIO_STCOUNTDOWN));
+ EnableDlgItem(hwndDlg,IDC_EDIT_COUNTDOWN,checked);
+ EnableDlgItem(hwndDlg,IDC_SPIN_COUNTDOWN,checked);
+ EnableDlgItem(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,checked);
+ checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE)!=0;
+ EnableDlgItem(hwndDlg,IDC_URL_IDLE,checked);
+ checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE)!=0;
+ EnableDlgItem(hwndDlg,IDC_EDIT_CPUUSAGE,checked);
+ EnableDlgItem(hwndDlg,IDC_SPIN_CPUUSAGE,checked);
+ EnableDlgItem(hwndDlg,IDC_TEXT_PERCENT,checked);
+ EnableDlgItem(hwndDlg,IDC_TEXT_CURRENTCPU,checked);
+ checked=(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) || IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE) ||
+ IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE) || IsDlgButtonChecked(hwndDlg,IDC_CHECK_STATUS) ||
+ IsDlgButtonChecked(hwndDlg,IDC_CHECK_FILETRANSFER) || IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE));
+ EnableDlgItem(hwndDlg,IDOK,checked);
+ }
+ return TRUE;
+ case M_UPDATE_SHUTDOWNDESC: /* lParam=(LPARAM)(HWND)hwndCombo */
+ {
+ BYTE shutdownType = (BYTE)SendMessage((HWND)lParam,CB_GETITEMDATA,SendMessage((HWND)lParam,CB_GETCURSEL,0,0),0);
SetDlgItemText(hwndDlg,IDC_TEXT_SHUTDOWNTYPE,(TCHAR*)ServiceGetTypeDescription(shutdownType,GSTDF_LONGDESC|GSTDF_TCHAR));
- return TRUE;
}
- case WM_TIMECHANGE: /* system time changed */
- SendMessage(hwndDlg,M_CHECK_DATETIME,0,0);
- return TRUE;
- case M_CHECK_DATETIME:
- { SYSTEMTIME st,stBuf;
+ return TRUE;
+
+ case WM_TIMECHANGE: /* system time changed */
+ SendMessage(hwndDlg,M_CHECK_DATETIME,0,0);
+ return TRUE;
+
+ case M_CHECK_DATETIME:
+ {
+ SYSTEMTIME st,stBuf;
time_t timestamp;
DateTime_GetSystemtime(GetDlgItem(hwndDlg,IDC_DATE_TIMESTAMP),&stBuf);
DateTime_GetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),&st);
@@ -278,111 +285,119 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR DateTime_SetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),GDT_VALID,&st);
return TRUE;
}
- case WM_NOTIFY:
- switch(((NMHDR*)lParam)->idFrom) {
- case IDC_TIME_TIMESTAMP:
- case IDC_DATE_TIMESTAMP:
- switch(((NMHDR*)lParam)->code) {
- case DTN_CLOSEUP:
- case NM_KILLFOCUS:
- PostMessage(hwndDlg,M_CHECK_DATETIME,0,0);
- return TRUE;
- }
+ case WM_NOTIFY:
+ switch(((NMHDR*)lParam)->idFrom) {
+ case IDC_TIME_TIMESTAMP:
+ case IDC_DATE_TIMESTAMP:
+ switch(((NMHDR*)lParam)->code) {
+ case DTN_CLOSEUP:
+ case NM_KILLFOCUS:
+ PostMessage(hwndDlg,M_CHECK_DATETIME,0,0);
+ return TRUE;
}
- break;
- case WM_COMMAND:
- switch(LOWORD(wParam)) {
- case IDC_CHECK_MESSAGE:
- case IDC_CHECK_FILETRANSFER:
- case IDC_CHECK_IDLE:
- case IDC_CHECK_CPUUSAGE:
- case IDC_CHECK_STATUS:
- case IDC_CHECK_SPECIFICTIME:
- case IDC_RADIO_STTIME:
- case IDC_RADIO_STCOUNTDOWN:
- SendMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
- return TRUE;
- case IDC_EDIT_COUNTDOWN:
- if(HIWORD(wParam)==EN_KILLFOCUS) {
- if((int)GetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,NULL,TRUE)<1) {
- SendDlgItemMessage(hwndDlg,IDC_SPIN_COUNTDOWN,UDM_SETPOS,0,MAKELPARAM(1,0));
- SetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,1,FALSE);
- }
- return TRUE;
- }
- break;
- case IDC_EDIT_CPUUSAGE:
- if(HIWORD(wParam)==EN_KILLFOCUS) {
- WORD val;
- val=(WORD)GetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,NULL,FALSE);
- if(val<1) val=1;
- else if(val>100) val=100;
- SendDlgItemMessage(hwndDlg,IDC_SPIN_CPUUSAGE,UDM_SETPOS,0,MAKELPARAM(val,0));
- SetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,val,FALSE);
- return TRUE;
- }
- break;
- case IDC_URL_IDLE:
- {
- OPENOPTIONSDIALOG ood;
- ood.cbSize = sizeof(ood);
- ood.pszGroup = "Status"; /* autotranslated */
- ood.pszPage = "Idle"; /* autotranslated */
- ood.pszTab = NULL;
- Options_Open(&ood);
- return TRUE;
+ }
+ break;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_CHECK_MESSAGE:
+ case IDC_CHECK_FILETRANSFER:
+ case IDC_CHECK_IDLE:
+ case IDC_CHECK_CPUUSAGE:
+ case IDC_CHECK_STATUS:
+ case IDC_CHECK_SPECIFICTIME:
+ case IDC_RADIO_STTIME:
+ case IDC_RADIO_STCOUNTDOWN:
+ SendMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
+ return TRUE;
+
+ case IDC_EDIT_COUNTDOWN:
+ if(HIWORD(wParam)==EN_KILLFOCUS) {
+ if((int)GetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,NULL,TRUE)<1) {
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_COUNTDOWN,UDM_SETPOS,0,MAKELPARAM(1,0));
+ SetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,1,FALSE);
}
- case IDC_COMBO_SHUTDOWNTYPE:
- if(HIWORD(wParam)==CBN_SELCHANGE)
- SendMessage(hwndDlg,M_UPDATE_SHUTDOWNDESC,0,lParam);
- return TRUE;
- case IDOK: /* save settings and start watcher */
- ShowWindow(hwndDlg,SW_HIDE);
- /* message text */
- { HWND hwndEdit=GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE);
- int len=GetWindowTextLength(hwndEdit)+1;
- TCHAR *pszText=(TCHAR*)mir_alloc(len*sizeof(TCHAR));
- if(pszText!=NULL && GetWindowText(hwndEdit,pszText,len+1)) {
- TrimString(pszText);
- db_set_ts(NULL,"AutoShutdown","Message",pszText);
- }
- mir_free(pszText); /* does NULL check */
- }
- /* timestamp */
- { SYSTEMTIME st;
- time_t timestamp;
- DateTime_GetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),&st); /* time gets synchronized */
- if(!SystemTimeToTimeStamp(&st,×tamp))
- timestamp=time(NULL);
- db_set_dw(NULL,"AutoShutdown","TimeStamp",(DWORD)timestamp);
- }
- /* shutdown type */
- { int index;
- index=SendDlgItemMessage(hwndDlg,IDC_COMBO_SHUTDOWNTYPE,CB_GETCURSEL,0,0);
- if(index!=LB_ERR) db_set_b(NULL,"AutoShutdown","ShutdownType",(BYTE)SendDlgItemMessage(hwndDlg,IDC_COMBO_SHUTDOWNTYPE,CB_GETITEMDATA,(WPARAM)index,0));
- index=SendDlgItemMessage(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,CB_GETCURSEL,0,0);
- if(index!=LB_ERR) db_set_dw(NULL,"AutoShutdown","CountdownUnit",(DWORD)SendDlgItemMessage(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,CB_GETITEMDATA,(WPARAM)index,0));
- db_set_dw(NULL,"AutoShutdown","Countdown",(DWORD)GetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,NULL,FALSE));
- db_set_b(NULL,"AutoShutdown","CpuUsageThreshold",(BYTE)GetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,NULL,FALSE));
- }
- /* watcher type */
- { WORD watcherType;
- watcherType=(WORD)(IsDlgButtonChecked(hwndDlg,IDC_RADIO_STTIME)?SDWTF_ST_TIME:SDWTF_ST_COUNTDOWN);
- if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME)) watcherType|=SDWTF_SPECIFICTIME;
- if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE)) watcherType|=SDWTF_MESSAGE;
- if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_FILETRANSFER)) watcherType|=SDWTF_FILETRANSFER;
- if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE)) watcherType|=SDWTF_IDLE;
- if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_STATUS)) watcherType|=SDWTF_STATUS;
- if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE)) watcherType|=SDWTF_CPUUSAGE;
- db_set_w(NULL,"AutoShutdown","WatcherFlags",watcherType);
- ServiceStartWatcher(0,watcherType);
- }
- /* fall through */
- case IDCANCEL: /* WM_CLOSE */
- DestroyWindow(hwndDlg);
- return TRUE;
+ return TRUE;
}
break;
+
+ case IDC_EDIT_CPUUSAGE:
+ if(HIWORD(wParam)==EN_KILLFOCUS) {
+ WORD val;
+ val=(WORD)GetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,NULL,FALSE);
+ if(val<1) val=1;
+ else if(val>100) val=100;
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_CPUUSAGE,UDM_SETPOS,0,MAKELPARAM(val,0));
+ SetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,val,FALSE);
+ return TRUE;
+ }
+ break;
+
+ case IDC_URL_IDLE:
+ {
+ OPENOPTIONSDIALOG ood;
+ ood.cbSize = sizeof(ood);
+ ood.pszGroup = "Status"; /* autotranslated */
+ ood.pszPage = "Idle"; /* autotranslated */
+ ood.pszTab = NULL;
+ Options_Open(&ood);
+ return TRUE;
+ }
+
+ case IDC_COMBO_SHUTDOWNTYPE:
+ if(HIWORD(wParam)==CBN_SELCHANGE)
+ SendMessage(hwndDlg,M_UPDATE_SHUTDOWNDESC,0,lParam);
+ return TRUE;
+
+ case IDOK: /* save settings and start watcher */
+ ShowWindow(hwndDlg,SW_HIDE);
+ /* message text */
+ {
+ HWND hwndEdit=GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE);
+ int len=GetWindowTextLength(hwndEdit)+1;
+ TCHAR *pszText=(TCHAR*)mir_alloc(len*sizeof(TCHAR));
+ if(pszText!=NULL && GetWindowText(hwndEdit,pszText,len+1)) {
+ TrimString(pszText);
+ db_set_ts(NULL,"AutoShutdown","Message",pszText);
+ }
+ mir_free(pszText); /* does NULL check */
+ }
+ /* timestamp */
+ {
+ SYSTEMTIME st;
+ time_t timestamp;
+ DateTime_GetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),&st); /* time gets synchronized */
+ if(!SystemTimeToTimeStamp(&st,×tamp))
+ timestamp=time(NULL);
+ db_set_dw(NULL,"AutoShutdown","TimeStamp",(DWORD)timestamp);
+ }
+ /* shutdown type */
+ {
+ int index = SendDlgItemMessage(hwndDlg,IDC_COMBO_SHUTDOWNTYPE,CB_GETCURSEL,0,0);
+ if(index!=LB_ERR) db_set_b(NULL,"AutoShutdown","ShutdownType",(BYTE)SendDlgItemMessage(hwndDlg,IDC_COMBO_SHUTDOWNTYPE,CB_GETITEMDATA,(WPARAM)index,0));
+ index=SendDlgItemMessage(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,CB_GETCURSEL,0,0);
+ if(index!=LB_ERR) db_set_dw(NULL,"AutoShutdown","CountdownUnit",(DWORD)SendDlgItemMessage(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,CB_GETITEMDATA,(WPARAM)index,0));
+ db_set_dw(NULL,"AutoShutdown","Countdown",(DWORD)GetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,NULL,FALSE));
+ db_set_b(NULL,"AutoShutdown","CpuUsageThreshold",(BYTE)GetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,NULL,FALSE));
+ }
+ /* watcher type */
+ {
+ WORD watcherType = (WORD)(IsDlgButtonChecked(hwndDlg,IDC_RADIO_STTIME)?SDWTF_ST_TIME:SDWTF_ST_COUNTDOWN);
+ if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME)) watcherType|=SDWTF_SPECIFICTIME;
+ if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE)) watcherType|=SDWTF_MESSAGE;
+ if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_FILETRANSFER)) watcherType|=SDWTF_FILETRANSFER;
+ if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE)) watcherType|=SDWTF_IDLE;
+ if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_STATUS)) watcherType|=SDWTF_STATUS;
+ if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE)) watcherType|=SDWTF_CPUUSAGE;
+ db_set_w(NULL,"AutoShutdown","WatcherFlags",watcherType);
+ ServiceStartWatcher(0,watcherType);
+ }
+ /* fall through */
+ case IDCANCEL: /* WM_CLOSE */
+ DestroyWindow(hwndDlg);
+ return TRUE;
+ }
+ break;
}
CallSnappingWindowProc(hwndDlg,msg,wParam,lParam); /* Snapping Windows plugin */
return FALSE;
|