diff options
author | George Hazan <george.hazan@gmail.com> | 2014-05-30 15:31:28 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-05-30 15:31:28 +0000 |
commit | 581204a18bc5a50d1c8a7412e147e560503d11b8 (patch) | |
tree | 59f78fa2cc227e4feae48c9cf4e10544c80c4c71 /plugins/Utils | |
parent | fd0d38e50db088692bfff7608df3b765d804e847 (diff) |
db_mc_getMostOnline - a handy helper for MS_MC_GETMOSTONLINECONTACT
git-svn-id: http://svn.miranda-ng.org/main/trunk@9372 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Utils')
-rw-r--r-- | plugins/Utils/mir_options.cpp | 448 |
1 files changed, 215 insertions, 233 deletions
diff --git a/plugins/Utils/mir_options.cpp b/plugins/Utils/mir_options.cpp index f1960d30d5..ce4a474bb2 100644 --- a/plugins/Utils/mir_options.cpp +++ b/plugins/Utils/mir_options.cpp @@ -35,17 +35,15 @@ Boston, MA 02111-1307, USA. static TCHAR* MyDBGetContactSettingTString(MCONTACT hContact, char* module, char* setting, TCHAR* out, size_t len, TCHAR *def)
{
- DBVARIANT dbv = {0};
+ DBVARIANT dbv = { 0 };
out[0] = _T('\0');
- if ( !db_get_ts(hContact, module, setting, &dbv))
- {
+ if (!db_get_ts(hContact, module, setting, &dbv)) {
lstrcpyn(out, dbv.ptszVal, (int)len);
db_free(&dbv);
}
- else
- {
+ else {
if (def != NULL)
lstrcpyn(out, def, (int)len);
}
@@ -54,46 +52,45 @@ static TCHAR* MyDBGetContactSettingTString(MCONTACT hContact, char* module, char }
-static TCHAR dbPath[MAX_PATH] = {0}; // database profile path (read at startup only)
+static TCHAR dbPath[MAX_PATH] = { 0 }; // database profile path (read at startup only)
static int PathIsAbsolute(const TCHAR *path)
{
- if ( !path || !(lstrlen(path) > 2))
+ if (!path || !(lstrlen(path) > 2))
return 0;
- if ((path[1]==_T(':') && path[2]==_T('\\')) || (path[0]==_T('\\')&&path[1]==_T('\\')))
+ if ((path[1] == _T(':') && path[2] == _T('\\')) || (path[0] == _T('\\') && path[1] == _T('\\')))
return 1;
return 0;
}
static void PathToRelative(TCHAR *pOut, size_t outSize, const TCHAR *pSrc)
{
- if ( !PathIsAbsolute(pSrc))
+ if (!PathIsAbsolute(pSrc))
lstrcpyn(pOut, pSrc, (int)outSize);
else {
if (dbPath[0] == _T('\0')) {
char tmp[1024];
- CallService(MS_DB_GETPROFILEPATH, SIZEOF(tmp), (LPARAM) tmp);
+ CallService(MS_DB_GETPROFILEPATH, SIZEOF(tmp), (LPARAM)tmp);
mir_sntprintf(dbPath, SIZEOF(dbPath), _T("%S\\"), tmp);
}
size_t len = lstrlen(dbPath);
- if (_tcsnicmp(pSrc, dbPath, len))
+ if (_tcsnicmp(pSrc, dbPath, len))
mir_sntprintf(pOut, outSize, _T("%s"), pSrc + len);
- else
+ else
lstrcpyn(pOut, pSrc, (int)outSize);
}
}
static void PathToAbsolute(TCHAR *pOut, size_t outSize, const TCHAR *pSrc)
{
- if (PathIsAbsolute(pSrc) || !isalnum(pSrc[0]))
+ if (PathIsAbsolute(pSrc) || !isalnum(pSrc[0]))
lstrcpyn(pOut, pSrc, (int)outSize);
else {
- if (dbPath[0] == _T('\0'))
- {
+ if (dbPath[0] == _T('\0')) {
char tmp[1024];
- CallService(MS_DB_GETPROFILEPATH, SIZEOF(tmp), (LPARAM) tmp);
+ CallService(MS_DB_GETPROFILEPATH, SIZEOF(tmp), (LPARAM)tmp);
mir_sntprintf(dbPath, SIZEOF(dbPath), _T("%S\\"), tmp);
}
@@ -105,219 +102,209 @@ static void LoadOpt(OptPageControl *ctrl, char *module) {
if (ctrl->var == NULL)
return;
-
- switch(ctrl->type) {
+
+ TCHAR tmp[1024];
+ switch (ctrl->type) {
case CONTROL_CHECKBOX:
- *((BYTE *) ctrl->var) = db_get_b(NULL, module, ctrl->setting, ctrl->dwDefValue);
+ *((BYTE *)ctrl->var) = db_get_b(NULL, module, ctrl->setting, ctrl->dwDefValue);
break;
case CONTROL_SPIN:
- *((WORD *) ctrl->var) = db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue);
+ *((WORD *)ctrl->var) = db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue);
break;
case CONTROL_COLOR:
- *((COLORREF *) ctrl->var) = (COLORREF) db_get_dw(NULL, module, ctrl->setting, ctrl->dwDefValue);
+ *((COLORREF *)ctrl->var) = (COLORREF)db_get_dw(NULL, module, ctrl->setting, ctrl->dwDefValue);
break;
case CONTROL_RADIO:
- *((WORD *) ctrl->var) = db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue);
+ *((WORD *)ctrl->var) = db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue);
break;
case CONTROL_COMBO:
- *((WORD *) ctrl->var) = db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue);
+ *((WORD *)ctrl->var) = db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue);
break;
case CONTROL_PROTOCOL_LIST:
break;
case CONTROL_TEXT:
- MyDBGetContactSettingTString(NULL, module, ctrl->setting, ((TCHAR *) ctrl->var), min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue));
+ MyDBGetContactSettingTString(NULL, module, ctrl->setting, ((TCHAR *)ctrl->var), min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue));
break;
case CONTROL_INT:
- *((int *) ctrl->var) = (int) db_get_dw(NULL, module, ctrl->setting, ctrl->dwDefValue);
+ *((int *)ctrl->var) = (int)db_get_dw(NULL, module, ctrl->setting, ctrl->dwDefValue);
break;
case CONTROL_FILE:
- {
- TCHAR tmp[1024];
- MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : ctrl->tszDefValue);
- PathToAbsolute(((TCHAR *) ctrl->var), min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), tmp);
- }
+ MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : ctrl->tszDefValue);
+ PathToAbsolute(((TCHAR *)ctrl->var), min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), tmp);
break;
case CONTROL_COMBO_TEXT:
case CONTROL_COMBO_ITEMDATA:
- MyDBGetContactSettingTString(NULL, module, ctrl->setting, ((TCHAR *) ctrl->var), min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue));
+ MyDBGetContactSettingTString(NULL, module, ctrl->setting, ((TCHAR *)ctrl->var), min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue));
break;
}
}
void LoadOpts(OptPageControl *controls, int controlsSize, char *module)
{
- for (int i = 0 ; i < controlsSize ; i++)
+ for (int i = 0; i < controlsSize; i++)
LoadOpt(&controls[i], module);
}
INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, char *module, HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ TCHAR tmp[1024];
+
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- {
- for (int i = 0 ; i < controlsSize ; i++) {
- OptPageControl *ctrl = &controls[i];
- if (GetDlgItem(hwndDlg, ctrl->nID) == NULL)
- continue;
+ for (int i = 0; i < controlsSize; i++) {
+ OptPageControl *ctrl = &controls[i];
- switch(ctrl->type) {
- case CONTROL_CHECKBOX:
- CheckDlgButton(hwndDlg, ctrl->nID, db_get_b(NULL, module, ctrl->setting, ctrl->dwDefValue) == 1 ? BST_CHECKED : BST_UNCHECKED);
- break;
+ if (GetDlgItem(hwndDlg, ctrl->nID) == NULL)
+ continue;
- case CONTROL_SPIN:
- SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, ctrl->nID),0);
- SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETRANGE, 0, MAKELONG(ctrl->max, ctrl->min));
- SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETPOS,0, MAKELONG(db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue), 0));
- break;
+ switch (ctrl->type) {
+ case CONTROL_CHECKBOX:
+ CheckDlgButton(hwndDlg, ctrl->nID, db_get_b(NULL, module, ctrl->setting, ctrl->dwDefValue) == 1 ? BST_CHECKED : BST_UNCHECKED);
+ break;
- case CONTROL_COLOR:
- SendDlgItemMessage(hwndDlg, ctrl->nID, CPM_SETCOLOUR, 0, (COLORREF) db_get_dw(NULL, module, ctrl->setting, ctrl->dwDefValue));
- break;
+ case CONTROL_SPIN:
+ SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, ctrl->nID), 0);
+ SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETRANGE, 0, MAKELONG(ctrl->max, ctrl->min));
+ SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue), 0));
+ break;
- case CONTROL_RADIO:
- CheckDlgButton(hwndDlg, ctrl->nID, db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue) == ctrl->value ? BST_CHECKED : BST_UNCHECKED);
- break;
+ case CONTROL_COLOR:
+ SendDlgItemMessage(hwndDlg, ctrl->nID, CPM_SETCOLOUR, 0, (COLORREF)db_get_dw(NULL, module, ctrl->setting, ctrl->dwDefValue));
+ break;
- case CONTROL_COMBO:
- SendDlgItemMessage(hwndDlg, ctrl->nID, CB_SETCURSEL, db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue), 0);
- break;
+ case CONTROL_RADIO:
+ CheckDlgButton(hwndDlg, ctrl->nID, db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue) == ctrl->value ? BST_CHECKED : BST_UNCHECKED);
+ break;
- case CONTROL_PROTOCOL_LIST:
- {
- // Fill list view
- HWND hwndProtocols = GetDlgItem(hwndDlg, ctrl->nID);
- LVCOLUMN lvc;
- LVITEM lvi;
+ case CONTROL_COMBO:
+ SendDlgItemMessage(hwndDlg, ctrl->nID, CB_SETCURSEL, db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue), 0);
+ break;
- ListView_SetExtendedListViewStyle(hwndProtocols, LVS_EX_CHECKBOXES);
+ case CONTROL_PROTOCOL_LIST:
+ {
+ // Fill list view
+ HWND hwndProtocols = GetDlgItem(hwndDlg, ctrl->nID);
+ LVCOLUMN lvc;
+ LVITEM lvi;
- ZeroMemory(&lvc, sizeof(lvc));
- lvc.mask = LVCF_FMT;
- lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT;
- ListView_InsertColumn(hwndProtocols, 0, &lvc);
+ ListView_SetExtendedListViewStyle(hwndProtocols, LVS_EX_CHECKBOXES);
- ZeroMemory(&lvi, sizeof(lvi));
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.iSubItem = 0;
- lvi.iItem = 1000;
+ ZeroMemory(&lvc, sizeof(lvc));
+ lvc.mask = LVCF_FMT;
+ lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT;
+ ListView_InsertColumn(hwndProtocols, 0, &lvc);
- int count;
- PROTOACCOUNT **protos;
- ProtoEnumAccounts(&count,&protos);
+ ZeroMemory(&lvi, sizeof(lvi));
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ lvi.iSubItem = 0;
+ lvi.iItem = 1000;
- for (int i = 0; i < count; i++) {
- PROTOACCOUNT *p = protos[i];
- if (p->szModuleName == NULL || p->szModuleName[0] == '\0')
- continue;
+ int count;
+ PROTOACCOUNT **protos;
+ ProtoEnumAccounts(&count, &protos);
- if (ctrl->allowProtocol != NULL && !ctrl->allowProtocol(p->szModuleName))
- continue;
+ for (int i = 0; i < count; i++) {
+ PROTOACCOUNT *p = protos[i];
+ if (p->szModuleName == NULL || p->szModuleName[0] == '\0')
+ continue;
- char *setting = (char *) mir_alloc(128 * sizeof(char));
- mir_snprintf(setting, 128, ctrl->setting, p->szModuleName);
+ if (ctrl->allowProtocol != NULL && !ctrl->allowProtocol(p->szModuleName))
+ continue;
- BOOL show = (BOOL)db_get_b(NULL, module, setting, ctrl->dwDefValue);
+ char *setting = (char *)mir_alloc(128 * sizeof(char));
+ mir_snprintf(setting, 128, ctrl->setting, p->szModuleName);
- lvi.lParam = (LPARAM)setting;
- lvi.pszText = p->tszAccountName;
- lvi.iItem = ListView_InsertItem(hwndProtocols, &lvi);
- ListView_SetItemState(hwndProtocols, lvi.iItem, INDEXTOSTATEIMAGEMASK(show?2:1), LVIS_STATEIMAGEMASK);
- }
+ BOOL show = (BOOL)db_get_b(NULL, module, setting, ctrl->dwDefValue);
- ListView_SetColumnWidth(hwndProtocols, 0, LVSCW_AUTOSIZE);
- ListView_Arrange(hwndProtocols, LVA_ALIGNLEFT | LVA_ALIGNTOP);
- }
- break;
- case CONTROL_TEXT:
- {
- TCHAR tmp[1024];
- SetDlgItemText(hwndDlg, ctrl->nID, MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue)));
- SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), 0);
- }
- break;
- case CONTROL_INT:
- {
- DWORD var = db_get_dw(NULL, module, ctrl->setting, ctrl->dwDefValue);
- SetDlgItemInt(hwndDlg, ctrl->nID, var, ctrl->min <= 0);
- SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, 9, 0);
+ lvi.lParam = (LPARAM)setting;
+ lvi.pszText = p->tszAccountName;
+ lvi.iItem = ListView_InsertItem(hwndProtocols, &lvi);
+ ListView_SetItemState(hwndProtocols, lvi.iItem, INDEXTOSTATEIMAGEMASK(show ? 2 : 1), LVIS_STATEIMAGEMASK);
}
- break;
- case CONTROL_FILE:
- {
- TCHAR tmp[1024];
- MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : ctrl->tszDefValue);
- TCHAR abs[1024];
- PathToAbsolute(abs, 1024, tmp);
- SetDlgItemText(hwndDlg, ctrl->nID, abs);
- SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), 0);
- }
- break;
- case CONTROL_COMBO_TEXT:
- {
- TCHAR tmp[1024];
- MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue));
- SendDlgItemMessage(hwndDlg, ctrl->nID, CB_SELECTSTRING, 0, (WPARAM) tmp);
- }
- break;
- case CONTROL_COMBO_ITEMDATA:
- {
- TCHAR tmp[1024];
- MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue));
- int count = SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCOUNT, 0, 0);
- int i;
- for (i = 0; i < count; i++)
- {
- TCHAR *id = (TCHAR *) SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETITEMDATA, (WPARAM) i, 0);
- if (lstrcmp(id, tmp) == 0)
- break;
- }
- if (i < count)
- SendDlgItemMessage(hwndDlg, ctrl->nID, CB_SETCURSEL, i, 0);
+ ListView_SetColumnWidth(hwndProtocols, 0, LVSCW_AUTOSIZE);
+ ListView_Arrange(hwndProtocols, LVA_ALIGNLEFT | LVA_ALIGNTOP);
+ }
+ break;
+
+ case CONTROL_TEXT:
+ SetDlgItemText(hwndDlg, ctrl->nID, MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue)));
+ SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), 0);
+ break;
+
+ case CONTROL_INT:
+ SetDlgItemInt(hwndDlg, ctrl->nID, db_get_dw(NULL, module, ctrl->setting, ctrl->dwDefValue), ctrl->min <= 0);
+ SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, 9, 0);
+ break;
+
+ case CONTROL_FILE:
+ MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : ctrl->tszDefValue);
+ {
+ TCHAR abs[1024];
+ PathToAbsolute(abs, 1024, tmp);
+ SetDlgItemText(hwndDlg, ctrl->nID, abs);
+ }
+ SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), 0);
+ break;
+
+ case CONTROL_COMBO_TEXT:
+ MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue));
+ SendDlgItemMessage(hwndDlg, ctrl->nID, CB_SELECTSTRING, 0, (WPARAM)tmp);
+ break;
+
+ case CONTROL_COMBO_ITEMDATA:
+ MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue));
+ {
+ int count = SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCOUNT, 0, 0);
+ int i;
+ for (i = 0; i < count; i++) {
+ TCHAR *id = (TCHAR *)SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETITEMDATA, (WPARAM)i, 0);
+ if (lstrcmp(id, tmp) == 0)
+ break;
}
- break;
+ if (i < count)
+ SendDlgItemMessage(hwndDlg, ctrl->nID, CB_SETCURSEL, i, 0);
}
+ break;
}
- break;
}
- case WM_COMMAND:
- {
- for (int i = 0 ; i < controlsSize ; i++) {
- OptPageControl *ctrl = &controls[i];
+ break;
- if (LOWORD(wParam) == ctrl->nID) {
- switch(ctrl->type) {
- case CONTROL_TEXT:
- case CONTROL_SPIN:
- case CONTROL_INT:
- // Don't make apply enabled during buddy set
- if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())
- return 0;
+ case WM_COMMAND:
+ for (int i = 0; i < controlsSize; i++) {
+ OptPageControl *ctrl = &controls[i];
- break;
+ if (LOWORD(wParam) == ctrl->nID) {
+ switch (ctrl->type) {
+ case CONTROL_TEXT:
+ case CONTROL_SPIN:
+ case CONTROL_INT:
+ // Don't make apply enabled during buddy set
+ if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())
+ return 0;
- case CONTROL_COMBO_ITEMDATA:
- case CONTROL_COMBO_TEXT:
- case CONTROL_COMBO:
- if (HIWORD(wParam) != CBN_SELCHANGE || (HWND)lParam != GetFocus())
- return 0;
- break;
- }
+ break;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ case CONTROL_COMBO_ITEMDATA:
+ case CONTROL_COMBO_TEXT:
+ case CONTROL_COMBO:
+ if (HIWORD(wParam) != CBN_SELCHANGE || (HWND)lParam != GetFocus())
+ return 0;
+ break;
}
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
}
break;
@@ -326,95 +313,94 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha {
LPNMHDR lpnmhdr = (LPNMHDR)lParam;
if (lpnmhdr->idFrom == 0 && lpnmhdr->code == PSN_APPLY) {
- for (int i = 0 ; i < controlsSize ; i++) {
+ for (int i = 0; i < controlsSize; i++) {
OptPageControl *ctrl = &controls[i];
if (GetDlgItem(hwndDlg, ctrl->nID) == NULL)
continue;
- switch(ctrl->type) {
+ switch (ctrl->type) {
case CONTROL_CHECKBOX:
- db_set_b(NULL, module, ctrl->setting, (BYTE) IsDlgButtonChecked(hwndDlg, ctrl->nID));
+ db_set_b(NULL, module, ctrl->setting, (BYTE)IsDlgButtonChecked(hwndDlg, ctrl->nID));
break;
case CONTROL_SPIN:
- db_set_w(NULL, module, ctrl->setting, (WORD) SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_GETPOS, 0, 0));
+ db_set_w(NULL, module, ctrl->setting, (WORD)SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_GETPOS, 0, 0));
break;
case CONTROL_COLOR:
- db_set_dw(NULL, module, ctrl->setting, (DWORD) SendDlgItemMessage(hwndDlg, ctrl->nID, CPM_GETCOLOUR, 0, 0));
+ db_set_dw(NULL, module, ctrl->setting, (DWORD)SendDlgItemMessage(hwndDlg, ctrl->nID, CPM_GETCOLOUR, 0, 0));
break;
case CONTROL_RADIO:
if (IsDlgButtonChecked(hwndDlg, ctrl->nID))
- db_set_w(NULL, module, ctrl->setting, (BYTE) ctrl->value);
+ db_set_w(NULL, module, ctrl->setting, (BYTE)ctrl->value);
break;
case CONTROL_COMBO:
- db_set_w(NULL, module, ctrl->setting, (WORD) SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCURSEL, 0, 0));
+ db_set_w(NULL, module, ctrl->setting, (WORD)SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCURSEL, 0, 0));
break;
case CONTROL_PROTOCOL_LIST:
- {
- LVITEM lvi = {0};
- HWND hwndProtocols = GetDlgItem(hwndDlg, ctrl->nID);
- int i;
+ {
+ LVITEM lvi = { 0 };
+ HWND hwndProtocols = GetDlgItem(hwndDlg, ctrl->nID);
+ int i;
- lvi.mask = (UINT) LVIF_PARAM;
+ lvi.mask = (UINT)LVIF_PARAM;
- for (i = 0; i < ListView_GetItemCount(hwndProtocols); i++)
- {
- lvi.iItem = i;
- ListView_GetItem(hwndProtocols, &lvi);
+ for (i = 0; i < ListView_GetItemCount(hwndProtocols); i++) {
+ lvi.iItem = i;
+ ListView_GetItem(hwndProtocols, &lvi);
- char *setting = (char *)lvi.lParam;
- db_set_b(NULL, module, setting, (BYTE)ListView_GetCheckState(hwndProtocols, i));
- }
+ char *setting = (char *)lvi.lParam;
+ db_set_b(NULL, module, setting, (BYTE)ListView_GetCheckState(hwndProtocols, i));
}
+ }
break;
case CONTROL_TEXT:
- {
- TCHAR tmp[1024];
- GetDlgItemText(hwndDlg, ctrl->nID, tmp, SIZEOF(tmp));
- db_set_ts(NULL, module, ctrl->setting, tmp);
- }
+ {
+ TCHAR tmp[1024];
+ GetDlgItemText(hwndDlg, ctrl->nID, tmp, SIZEOF(tmp));
+ db_set_ts(NULL, module, ctrl->setting, tmp);
+ }
break;
case CONTROL_INT:
- {
- BOOL trans;
- int val = GetDlgItemInt(hwndDlg, ctrl->nID, &trans, ctrl->min <= 0);
- if ( !trans)
- val = ctrl->dwDefValue;
- if (ctrl->max != 0)
- val = min(val, ctrl->max);
- if (ctrl->min != 0)
- val = max(val, ctrl->min);
- db_set_dw(NULL, module, ctrl->setting, val);
- }
+ {
+ BOOL trans;
+ int val = GetDlgItemInt(hwndDlg, ctrl->nID, &trans, ctrl->min <= 0);
+ if (!trans)
+ val = ctrl->dwDefValue;
+ if (ctrl->max != 0)
+ val = min(val, ctrl->max);
+ if (ctrl->min != 0)
+ val = max(val, ctrl->min);
+ db_set_dw(NULL, module, ctrl->setting, val);
+ }
break;
case CONTROL_FILE:
- {
- TCHAR tmp[1024];
- GetDlgItemText(hwndDlg, ctrl->nID, tmp, 1024);
- TCHAR rel[1024];
- PathToRelative(rel, 1024, tmp);
- db_set_ts(NULL, module, ctrl->setting, rel);
- }
+ {
+ TCHAR tmp[1024];
+ GetDlgItemText(hwndDlg, ctrl->nID, tmp, 1024);
+ TCHAR rel[1024];
+ PathToRelative(rel, 1024, tmp);
+ db_set_ts(NULL, module, ctrl->setting, rel);
+ }
break;
case CONTROL_COMBO_TEXT:
- {
- TCHAR tmp[1024];
- GetDlgItemText(hwndDlg, ctrl->nID, tmp, 1024);
- db_set_ts(NULL, module, ctrl->setting, tmp);
- }
+ {
+ TCHAR tmp[1024];
+ GetDlgItemText(hwndDlg, ctrl->nID, tmp, 1024);
+ db_set_ts(NULL, module, ctrl->setting, tmp);
+ }
break;
case CONTROL_COMBO_ITEMDATA:
- {
- int sel = SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCURSEL, 0, 0);
- db_set_ts(NULL, module, ctrl->setting, (TCHAR *) SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETITEMDATA, (WPARAM) sel, 0));
- }
+ {
+ int sel = SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCURSEL, 0, 0);
+ db_set_ts(NULL, module, ctrl->setting, (TCHAR *)SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETITEMDATA, (WPARAM)sel, 0));
+ }
break;
}
@@ -423,10 +409,9 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha return TRUE;
}
- else if (lpnmhdr->idFrom != 0 && lpnmhdr->code == LVN_ITEMCHANGED)
- {
+ else if (lpnmhdr->idFrom != 0 && lpnmhdr->code == LVN_ITEMCHANGED) {
// Changed for protocols
- for (int i = 0 ; i < controlsSize ; i++) {
+ for (int i = 0; i < controlsSize; i++) {
OptPageControl *ctrl = &controls[i];
if (ctrl->type == CONTROL_PROTOCOL_LIST && ctrl->nID == lpnmhdr->idFrom) {
@@ -439,36 +424,33 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha }
}
}
- break;
}
+ break;
+
case WM_DESTROY:
- {
- for (int i = 0 ; i < controlsSize ; i++) {
- OptPageControl *ctrl = &controls[i];
+ for (int i = 0; i < controlsSize; i++) {
+ OptPageControl *ctrl = &controls[i];
- if (GetDlgItem(hwndDlg, ctrl->nID) == NULL)
- continue;
+ if (GetDlgItem(hwndDlg, ctrl->nID) == NULL)
+ continue;
- switch(ctrl->type) {
- case CONTROL_PROTOCOL_LIST:
- {
- LVITEM lvi = {0};
- HWND hwndProtocols = GetDlgItem(hwndDlg, ctrl->nID);
- int i;
+ switch (ctrl->type) {
+ case CONTROL_PROTOCOL_LIST:
+ LVITEM lvi = { 0 };
+ HWND hwndProtocols = GetDlgItem(hwndDlg, ctrl->nID);
+ int i;
- lvi.mask = (UINT) LVIF_PARAM;
+ lvi.mask = (UINT)LVIF_PARAM;
- for (i = 0; i < ListView_GetItemCount(hwndProtocols); i++) {
- lvi.iItem = i;
- ListView_GetItem(hwndProtocols, &lvi);
- mir_free((char *) lvi.lParam);
- }
- break;
- }
+ for (i = 0; i < ListView_GetItemCount(hwndProtocols); i++) {
+ lvi.iItem = i;
+ ListView_GetItem(hwndProtocols, &lvi);
+ mir_free((char *)lvi.lParam);
}
+ break;
}
- break;
}
+ break;
}
return 0;
|