summaryrefslogtreecommitdiff
path: root/worldtime/options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'worldtime/options.cpp')
-rw-r--r--worldtime/options.cpp543
1 files changed, 543 insertions, 0 deletions
diff --git a/worldtime/options.cpp b/worldtime/options.cpp
new file mode 100644
index 0000000..7bac536
--- /dev/null
+++ b/worldtime/options.cpp
@@ -0,0 +1,543 @@
+#include "common.h"
+#include "plugwin.h"
+//#include "commctrl.h"
+
+void save_listbox_items() {
+ DBWriteContactSettingDword(0, "WorldTime", "NumEntries", listbox_items.size());
+ int index = 0;
+ for(ITEMLIST::iterator i = listbox_items.begin(); i != listbox_items.end(); i++, index++) {
+ std::ostringstream p1, p2, p3, p4;
+
+ p1 << "Label" << index;
+ p2 << "Index" << index;
+ p3 << "Sunrise" << index;
+ p4 << "Sunset" << index;
+
+ DBWriteContactSettingString(0, "WorldTime", p1.str().c_str(), i->pszText);
+ DBWriteContactSettingDword(0, "WorldTime", p2.str().c_str(), i->timezone_list_index);
+ DBWriteContactSettingDword(0, "WorldTime", p3.str().c_str(), i->sunrise.wHour * 60 + i->sunrise.wMinute);
+ DBWriteContactSettingDword(0, "WorldTime", p4.str().c_str(), i->sunset.wHour * 60 + i->sunset.wMinute);
+ }
+}
+
+void set_minmax(bool mm) {
+ hook_window_behaviour_to_clist = mm;
+ if(hook_window_behaviour_to_clist) {
+ BYTE state = DBGetContactSettingByte(NULL, "CList", "Setting", SETTING_STATE_NORMAL);
+
+ if(pluginwind) {
+ if(state == SETTING_STATE_NORMAL)
+ ShowWindow(pluginwind, SW_SHOW);
+ else
+ ShowWindow(pluginwind, SW_HIDE);
+ }
+ }
+}
+
+void set_set_format(bool sf) {
+ set_format = sf;
+}
+
+void set_time_format(const char *sf) {
+ strncpy(format_string, sf, 512);
+}
+
+void set_date_format(const char *sf) {
+ strncpy(date_format_string, sf, 512);
+}
+
+void set_show_icons(bool si) {
+ show_icons = si;
+}
+
+void set_hide_menu(bool hm) {
+ hide_menu = hm;
+}
+
+ITEMLIST temp_listbox_items;
+
+void fill_timezone_list_control(HWND hwndDlg) {
+ int index = 0;
+
+ HWND hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES);
+ SendMessage(hw, LB_RESETCONTENT, 0, 0);
+
+ if(IsDlgButtonChecked(hwndDlg, IDC_RAD_ALPHA)) {
+
+ for(TimeList::iterator i = timezone_list.begin(); i != timezone_list.end(); i++, index++) {
+ SendMessage(hw, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)i->tcName);
+ SendMessage(hw, LB_SETITEMDATA, (WPARAM)index, (LPARAM)i->list_index);
+ }
+ } else {
+ for(TimeList::iterator i = geo_timezone_list.begin(); i != geo_timezone_list.end(); i++, index++) {
+ SendMessage(hw, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)i->tcName);
+ SendMessage(hw, LB_SETITEMDATA, (WPARAM)index, (LPARAM)i->list_index);
+ }
+ }
+}
+
+
+LISTITEM add_edit_item;
+
+static BOOL CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+ HWND hw;
+ int sel;
+ char buf[MAX_NAME_LENGTH];
+
+ switch ( msg ) {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault( hwndDlg );
+
+ CheckDlgButton(hwndDlg, IDC_RAD_ALPHA, 1);
+ CheckDlgButton(hwndDlg, IDC_RAD_GEO, 0);
+
+ fill_timezone_list_control(hwndDlg);
+
+ if(add_edit_item.timezone_list_index != -1) {
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES);
+ SendMessage(hw, LB_SELECTSTRING, (WPARAM)-1, (LPARAM)timezone_list[add_edit_item.timezone_list_index].tcName);
+ SetDlgItemText(hwndDlg, IDC_ED_LABEL, add_edit_item.pszText);
+
+ hw = GetDlgItem(hwndDlg, IDC_ED_LABEL);
+ EnableWindow(hw, TRUE);
+ hw = GetDlgItem(hwndDlg, IDOK);
+ EnableWindow(hw, TRUE);
+
+ SendDlgItemMessage(hwndDlg, IDC_TIME_SUNRISE, DTM_SETSYSTEMTIME, (WPARAM)GDT_VALID, (LPARAM)&add_edit_item.sunrise);
+ SendDlgItemMessage(hwndDlg, IDC_TIME_SUNSET, DTM_SETSYSTEMTIME, (WPARAM)GDT_VALID, (LPARAM)&add_edit_item.sunset);
+
+ hw = GetDlgItem(hwndDlg, IDC_ED_DISP);
+ SetWindowText(hw, timezone_list[add_edit_item.timezone_list_index].tcDisp);
+ } else {
+ SYSTEMTIME systime = {0};
+
+ GetSystemTime(&systime);
+
+ systime.wHour = 6;
+ systime.wMinute = 0;
+ systime.wSecond = 0;
+ SendDlgItemMessage(hwndDlg, IDC_TIME_SUNRISE, DTM_SETSYSTEMTIME, (WPARAM)GDT_VALID, (LPARAM)&systime);
+ systime.wHour = 18;
+ SendDlgItemMessage(hwndDlg, IDC_TIME_SUNSET, DTM_SETSYSTEMTIME, (WPARAM)GDT_VALID, (LPARAM)&systime);
+
+ }
+ }
+ break;
+
+ case WM_COMMAND:
+ if (HIWORD( wParam ) == LBN_SELCHANGE && LOWORD(wParam) == IDC_LIST_TIMES) {
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES);
+ sel = SendMessage(hw, LB_GETCURSEL, 0, 0);
+ if(sel != LB_ERR) {
+ hw = GetDlgItem(hwndDlg, IDC_ED_LABEL);
+ EnableWindow(hw, sel != -1);
+ if(sel == -1)
+ add_edit_item.timezone_list_index = -1;
+ else {
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES);
+ add_edit_item.timezone_list_index = (int)SendMessage(hw, LB_GETITEMDATA, sel, 0);
+
+ hw = GetDlgItem(hwndDlg, IDC_ED_DISP);
+ SetWindowText(hw, timezone_list[add_edit_item.timezone_list_index].tcDisp);
+ }
+ }
+ }
+
+ if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
+ switch( LOWORD( wParam )) {
+ case IDC_ED_LABEL:
+ GetDlgItemText(hwndDlg, IDC_ED_LABEL, buf, MAX_NAME_LENGTH);
+ hw = GetDlgItem(hwndDlg, IDOK);
+ EnableWindow(hw, (strlen(buf) > 0));
+ strncpy(add_edit_item.pszText, buf, MAX_NAME_LENGTH);
+ }
+ }
+
+ if ( HIWORD( wParam ) == BN_CLICKED ) {
+ switch( LOWORD( wParam )) {
+ case IDC_RAD_ALPHA:
+ CheckDlgButton(hwndDlg, IDC_RAD_GEO, 0);
+ fill_timezone_list_control(hwndDlg);
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES);
+ if(add_edit_item.timezone_list_index != -1)
+ SendMessage(hw, LB_SELECTSTRING, (WPARAM)-1, (LPARAM)timezone_list[add_edit_item.timezone_list_index].tcName);
+ break;
+ case IDC_RAD_GEO:
+ CheckDlgButton(hwndDlg, IDC_RAD_ALPHA, 0);
+ fill_timezone_list_control(hwndDlg);
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES);
+ if(add_edit_item.timezone_list_index != -1)
+ SendMessage(hw, LB_SELECTSTRING, (WPARAM)-1, (LPARAM)timezone_list[add_edit_item.timezone_list_index].tcName);
+ break;
+ case IDOK:
+ if(SendDlgItemMessage(hwndDlg, IDC_TIME_SUNRISE, DTM_GETSYSTEMTIME, 0, (LPARAM)&add_edit_item.sunrise) != GDT_VALID) {
+ add_edit_item.sunrise.wHour = 6;
+ add_edit_item.sunrise.wMinute = 0;
+ add_edit_item.sunrise.wSecond = 0;
+ }
+ if(SendDlgItemMessage(hwndDlg, IDC_TIME_SUNSET, DTM_GETSYSTEMTIME, 0, (LPARAM)&add_edit_item.sunset) != GDT_VALID) {
+ add_edit_item.sunset.wHour = 18;
+ add_edit_item.sunset.wMinute = 0;
+ add_edit_item.sunset.wSecond = 0;
+ }
+ EndDialog(hwndDlg, IDOK);
+ break;
+ case IDCANCEL:
+ EndDialog(hwndDlg, IDCANCEL);
+ break;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+
+ HWND hw;
+ int sel, index;
+ DBVARIANT dbv;
+
+ switch ( msg ) {
+ case WM_INITDIALOG: {
+ TranslateDialogDefault( hwndDlg );
+
+ SendMessage(GetDlgItem(hwndDlg, IDC_SPIN1), UDM_SETRANGE, 0, (LPARAM)MAKELONG(50, 5));
+ if(!DBGetContactSetting(NULL,"WorldTime","FontSize",&dbv)
+ || !DBGetContactSetting(NULL,"CLC","Font0Size",&dbv))
+ {
+ SendMessage(GetDlgItem(hwndDlg, IDC_SPIN1), UDM_SETPOS, 0, dbv.bVal);
+ }
+
+ SendMessage(GetDlgItem(hwndDlg, IDC_SP_INDENT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(500, 0));
+ SendMessage(GetDlgItem(hwndDlg, IDC_SP_INDENT), UDM_SETPOS, 0, DBGetContactSettingWord(NULL, "WorldTime", "Indent", 0));
+ SendMessage(GetDlgItem(hwndDlg, IDC_SP_ROWHEIGHT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(500, 6));
+ SendMessage(GetDlgItem(hwndDlg, IDC_SP_ROWHEIGHT), UDM_SETPOS, 0, DBGetContactSettingWord(NULL, "WorldTime", "RowHeight", GetSystemMetrics(SM_CYSMICON)));
+
+ temp_listbox_items = listbox_items;
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2);
+
+ index = 0;
+ for(ITEMLIST::iterator ili = temp_listbox_items.begin(); ili != temp_listbox_items.end(); ili++, index++) {
+ sel = SendMessage(hw, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)&ili->pszText);
+ }
+
+ if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ bool minmax = (DBGetContactSettingByte(NULL, "WorldTime", "MinMax", DEFAULT_MINMAX ? 1 : 0) == 1);
+ CheckDlgButton(hwndDlg, IDC_CHK_MINMAX, minmax);
+ bool hide_menu = (DBGetContactSettingByte(NULL, "WorldTime", "HideMenu", 0) == 1);
+ CheckDlgButton(hwndDlg, IDC_CHK_HIDEMENU, hide_menu ? 1 : 0);
+ } else {
+ CheckDlgButton(hwndDlg, IDC_CHK_HIDEMENU, TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_HIDEMENU), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_SHOW), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_MINMAX), FALSE);
+ }
+
+ bool set_format = (DBGetContactSettingByte(NULL, "WorldTime", "EnableTimeFormat", 0) == 1);
+ CheckDlgButton(hwndDlg, IDC_CHK_FORMAT, set_format ? 1 : 0);
+ bool show_icons = (DBGetContactSettingByte(NULL, "WorldTime", "ShowIcons", 1) == 1);
+ CheckDlgButton(hwndDlg, IDC_CHK_ICONS, show_icons ? 1 : 0);
+ DBVARIANT dbv;
+ if(!DBGetContactSetting(NULL, "WorldTime", "TimeFormat", &dbv))
+ strcpy(format_string, dbv.pszVal);
+ DBFreeVariant(&dbv);
+ SetDlgItemText(hwndDlg, IDC_ED_FORMAT, format_string);
+ if(!DBGetContactSetting(NULL, "WorldTime", "DateFormat", &dbv))
+ strcpy(date_format_string, dbv.pszVal);
+ DBFreeVariant(&dbv);
+ SetDlgItemText(hwndDlg, IDC_ED_DATE_FORMAT, date_format_string);
+
+ if(!set_format) {
+ hw = GetDlgItem(hwndDlg, IDC_ED_FORMAT);
+ EnableWindow(hw, FALSE);
+ hw = GetDlgItem(hwndDlg, IDC_ED_DATE_FORMAT);
+ EnableWindow(hw, FALSE);
+ }
+
+ SendDlgItemMessage(hwndDlg, IDC_TEXTCOL, CPM_SETCOLOUR, 0, DBGetContactSettingDword(NULL, "WorldTime", "FontCol", GetSysColor(COLOR_WINDOWTEXT)));
+ SendDlgItemMessage(hwndDlg, IDC_BGCOL, CPM_SETCOLOUR, 0, DBGetContactSettingDword(NULL, "WorldTime", "BgColour", GetSysColor(COLOR_3DFACE)));
+
+ if(ServiceExists(MS_FONT_REGISTER)) {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_STATICH), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_STATICH2), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SPIN1), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_ED_FSIZE), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_TEXTCOL), SW_HIDE);
+
+ ShowWindow(GetDlgItem(hwndDlg, IDC_STATFS), SW_SHOW);
+
+ }
+
+ //return TRUE;
+ return FALSE;
+ }
+ case WM_COMMAND:
+ if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
+ switch( LOWORD( wParam )) {
+ case IDC_ED_FORMAT:
+ case IDC_ED_DATE_FORMAT:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+
+ if (HIWORD( wParam ) == LBN_SELCHANGE && LOWORD(wParam) == IDC_LIST_TIMES2) {
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2);
+ sel = SendMessage(hw, LB_GETCURSEL, 0, 0);
+ if(sel != LB_ERR) {
+ hw = GetDlgItem(hwndDlg, IDC_BTN_REM);
+ EnableWindow(hw, sel != -1);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT);
+ EnableWindow(hw, sel != -1);
+
+ hw = GetDlgItem(hwndDlg, IDC_BTN_UP);
+ EnableWindow(hw, (sel > 0));
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2);
+ int count = SendMessage(hw, LB_GETCOUNT, 0, 0);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_DOWN);
+ EnableWindow(hw, (sel < count - 1));
+ }
+ }
+
+ if ( HIWORD( wParam ) == BN_CLICKED ) {
+ switch( LOWORD( wParam )) {
+ case IDC_BTN_SHOW:
+ ShowWindow(pluginwind, SW_SHOW);
+ break;
+ case IDC_BTN_EDIT:
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2);
+ sel = SendMessage(hw, LB_GETCURSEL, 0, 0);
+ if(sel != LB_ERR && sel != -1) {
+
+ add_edit_item = temp_listbox_items[sel];
+ if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hwndDlg, DlgProcOpts2) == IDOK) {
+ temp_listbox_items[sel] = add_edit_item;
+
+ SendMessage(hw, LB_DELETESTRING, (WPARAM)sel, (LPARAM)0);
+ SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel, (LPARAM)add_edit_item.pszText);
+ SendMessage(hw, LB_SETCURSEL, (WPARAM)sel, 0);
+
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ }
+ }
+ break;
+
+ case IDC_BTN_ADD:
+
+ add_edit_item.pszText[0] = '\0';
+ add_edit_item.timezone_list_index = -1;
+
+ if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hwndDlg, DlgProcOpts2) == IDOK) {
+ temp_listbox_items.push_back(add_edit_item);
+
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2);
+ sel = SendMessage(hw, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)add_edit_item.pszText);
+ SendMessage(hw, LB_SETCURSEL, (WPARAM)sel, 0);
+
+ hw = GetDlgItem(hwndDlg, IDC_BTN_REM);
+ EnableWindow(hw, TRUE);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT);
+ EnableWindow(hw, TRUE);
+
+ sel = temp_listbox_items.size() - 1;
+ hw = GetDlgItem(hwndDlg, IDC_BTN_UP);
+ EnableWindow(hw, (sel > 0));
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2);
+ int count = SendMessage(hw, LB_GETCOUNT, 0, 0);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_DOWN);
+ EnableWindow(hw, (sel < count - 1));
+
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ }
+ break;
+
+ case IDC_BTN_REM:
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2);
+ sel = SendMessage(hw, LB_GETCURSEL, 0, 0);
+ if(sel != LB_ERR) {
+ SendMessage(hw, LB_DELETESTRING, (WPARAM)sel, 0);
+
+ {
+ ITEMLIST::iterator i = temp_listbox_items.begin();
+ for(int j = 0; j < sel; j++)
+ i++;
+ temp_listbox_items.erase(i);
+ }
+
+ hw = GetDlgItem(hwndDlg, IDC_BTN_REM);
+ EnableWindow(hw, FALSE);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT);
+ EnableWindow(hw, FALSE);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_UP);
+ EnableWindow(hw, FALSE);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_DOWN);
+ EnableWindow(hw, FALSE);
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ }
+ break;
+ case IDC_BTN_DOWN:
+ {
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2);
+ int sel2 = SendMessage(hw, LB_GETCURSEL, 0, 0);
+ if(sel2 != LB_ERR) {
+ add_edit_item = temp_listbox_items[sel2];
+ temp_listbox_items[sel2] = temp_listbox_items[sel2 + 1];
+ temp_listbox_items[sel2 + 1] = add_edit_item;
+
+ SendMessage(hw, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0);
+ SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)temp_listbox_items[sel2].pszText);
+ SendMessage(hw, LB_DELETESTRING, (WPARAM)(sel2 + 1), (LPARAM)0);
+ SendMessage(hw, LB_INSERTSTRING, (WPARAM)(sel2 + 1), (LPARAM)temp_listbox_items[sel2 + 1].pszText);
+ SendMessage(hw, LB_SETCURSEL, (WPARAM)(sel2 + 1), 0);
+
+ hw = GetDlgItem(hwndDlg, IDC_BTN_UP);
+ EnableWindow(hw, (sel2 + 1 > 0));
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2);
+ int count = SendMessage(hw, LB_GETCOUNT, 0, 0);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_DOWN);
+ EnableWindow(hw, (sel2 + 1 < count - 1));
+
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ }
+ }
+ break;
+ case IDC_BTN_UP:
+ {
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2);
+ int sel2 = SendMessage(hw, LB_GETCURSEL, 0, 0);
+ if(sel2 != LB_ERR) {
+ add_edit_item = temp_listbox_items[sel2];
+ temp_listbox_items[sel2] = temp_listbox_items[sel2 - 1];
+ temp_listbox_items[sel2 - 1] = add_edit_item;
+
+ SendMessage(hw, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0);
+ SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)temp_listbox_items[sel2].pszText);
+ SendMessage(hw, LB_DELETESTRING, (WPARAM)(sel2 - 1), (LPARAM)0);
+ SendMessage(hw, LB_INSERTSTRING, (WPARAM)(sel2 - 1), (LPARAM)temp_listbox_items[sel2 - 1].pszText);
+ SendMessage(hw, LB_SETCURSEL, (WPARAM)(sel2 - 1), 0);
+
+ hw = GetDlgItem(hwndDlg, IDC_BTN_UP);
+ EnableWindow(hw, (sel2 - 1 > 0));
+ hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2);
+ int count = SendMessage(hw, LB_GETCOUNT, 0, 0);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_DOWN);
+ EnableWindow(hw, (sel2 - 1 < count - 1));
+
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ }
+ }
+ break;
+ case IDC_CHK_ICONS:
+ case IDC_CHK_MINMAX:
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ break;
+ case IDC_CHK_HIDEMENU:
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ break;
+ case IDC_CHK_FORMAT:
+ hw = GetDlgItem(hwndDlg, IDC_ED_FORMAT);
+ EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_CHK_FORMAT));
+ hw = GetDlgItem(hwndDlg, IDC_ED_DATE_FORMAT);
+ EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_CHK_FORMAT));
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ break;
+ }
+ }
+ if(LOWORD(wParam) == IDC_TEXTCOL || LOWORD(wParam) == IDC_BGCOL
+ || LOWORD(wParam) == IDC_SPIN1 || LOWORD(wParam) == IDC_SP_INDENT || LOWORD(wParam) == IDC_SP_ROWHEIGHT)
+ {
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ }
+ break;
+
+ case WM_NOTIFY:
+ if(((LPNMHDR)lParam)->code == UDN_DELTAPOS ) {
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ }
+ if(((LPNMHDR)lParam)->code == PSN_APPLY ) {
+ bool new_minmax = IsDlgButtonChecked(hwndDlg, IDC_CHK_MINMAX) == BST_CHECKED;
+ DBWriteContactSettingByte(NULL, "WorldTime", "MinMax", new_minmax ? 1 : 0);
+ set_minmax(new_minmax);
+
+ bool new_set_format = IsDlgButtonChecked(hwndDlg, IDC_CHK_FORMAT) == BST_CHECKED;
+ DBWriteContactSettingByte(NULL, "WorldTime", "EnableTimeFormat", new_set_format ? 1 : 0);
+ set_set_format(new_set_format);
+
+ bool new_show_icons = IsDlgButtonChecked(hwndDlg, IDC_CHK_ICONS) == BST_CHECKED;
+ DBWriteContactSettingByte(NULL, "WorldTime", "ShowIcons", new_show_icons ? 1 : 0);
+ set_show_icons(new_show_icons);
+
+ bool new_hide_menu = IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDEMENU) == BST_CHECKED;
+ DBWriteContactSettingByte(NULL, "WorldTime", "HideMenu", new_hide_menu ? 1 : 0);
+ set_hide_menu(new_hide_menu);
+
+ char buf[512];
+ GetDlgItemText(hwndDlg, IDC_ED_FORMAT, buf, 512);
+ DBWriteContactSettingString(NULL, "WorldTime", "TimeFormat", buf);
+ set_time_format(buf);
+
+ GetDlgItemText(hwndDlg, IDC_ED_DATE_FORMAT, buf, 512);
+ DBWriteContactSettingString(NULL, "WorldTime", "DateFormat", buf);
+ set_date_format(buf);
+
+ listbox_items = temp_listbox_items;
+ save_listbox_items();
+
+ if(!ServiceExists(MS_FONT_REGISTER)) {
+ DBWriteContactSettingDword(NULL, "WorldTime", "FontCol", ContactFontColour = SendDlgItemMessage(hwndDlg, IDC_TEXTCOL, CPM_GETCOLOUR, 0, 0));
+ DBWriteContactSettingByte(0, "WorldTime", "FontSize", (BYTE)SendMessage(GetDlgItem(hwndDlg, IDC_SPIN1), UDM_GETPOS, 0, 0) & 255);
+ }
+
+ DBWriteContactSettingDword(NULL, "WorldTime", "BgColour", SendDlgItemMessage(hwndDlg, IDC_BGCOL, CPM_GETCOLOUR, 0, 0));
+
+ DBWriteContactSettingWord(0, "WorldTime", "Indent", (WORD)SendMessage(GetDlgItem(hwndDlg, IDC_SP_INDENT), UDM_GETPOS, 0, 0));
+ DBWriteContactSettingWord(0, "WorldTime", "RowHeight", (WORD)SendMessage(GetDlgItem(hwndDlg, IDC_SP_ROWHEIGHT), UDM_GETPOS, 0, 0));
+
+ DeleteObject(ContactFont);
+ ContactFont = (HFONT)GetFont();
+
+ if(pluginwind) {
+ /*
+ RECT r;
+ SIZE textSize;
+ GetWindowRect(pluginwind, &r);
+ HFONT hOldFont = (HFONT)SelectObject(GetDC(pluginwind), ContactFont);
+ GetTextExtentPoint32(GetDC(pluginwind),"X",1,&textSize);
+ SelectObject(GetDC(pluginwind), hOldFont);
+ SetWindowPos(pluginwind, 0, 0, 0, r.right - r.left, textSize.cy * listbox_items.size(), SWP_NOZORDER | SWP_NOMOVE);
+ if(Frameid != -1) {
+ CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, (WPARAM)MAKELONG(FO_HEIGHT, Frameid), (LPARAM)DBGetContactSettingByte(0, "WorldTime", "FontSize", 10) * listbox_items.size());
+ }
+ */
+ FillList(0, 0);
+ }
+
+ return TRUE;
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+int WorldTimeOptInit(WPARAM wParam,LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = { 0 };
+#define OPTIONPAGE_OLD_SIZE2 60
+
+ //odp.cbSize = sizeof(odp);
+ odp.cbSize = OPTIONPAGE_OLD_SIZE2;
+ odp.position = -790000000;
+ odp.hInstance = hInst;
+ odp.pszTemplate = MAKEINTRESOURCE(IDD_DIALOG1);
+ odp.pszTitle = Translate("World Time");
+ odp.pszGroup = Translate("Plugins");
+ odp.flags = ODPF_BOLDGROUPS;
+ //odp.nIDBottomSimpleControl = IDC_PPM;
+ odp.pfnDlgProc = DlgProcOpts;
+ CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
+
+ return 0;
+}
+