INT_PTR CALLBACK AdvOptDlg(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam) { static bool inFocus = false; switch (msg) { case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); g_fOptionsOpen = true; minutes = DBGetContactSettingByte(NULL,MOD_NAME,"time",10); char szMinutes[4] = {0}; _itoa(minutes, szMinutes, 10); SendDlgItemMessage(hwndDlg,IDC_MAINOPT_TIME,EM_LIMITTEXT,2,0); SendDlgItemMessage(hwndDlg, IDC_MAINOPT_SPIN_TIME, UDM_SETRANGE32, (WPARAM)1, (LPARAM)99); SetDlgItemTextA(hwndDlg, IDC_MAINOPT_TIME, szMinutes); CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFLOCK,(g_wMaskAdv & OPT_HIDEIFLOCK) ? (BST_CHECKED) : (BST_UNCHECKED)); CheckDlgButton(hwndDlg,IDC_MAINOPT_MENUITEM,(g_wMaskAdv & OPT_MENUITEM) ? (BST_CHECKED) : (BST_UNCHECKED)); CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFWINIDLE,(g_wMaskAdv & OPT_HIDEIFWINIDLE) ? (BST_CHECKED) : (BST_UNCHECKED)); CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFMIRIDLE,(g_wMaskAdv & OPT_HIDEIFMIRIDLE) ? (BST_CHECKED) : (BST_UNCHECKED)); CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFSCRSVR,(g_wMaskAdv & OPT_HIDEIFSCRSVR) ? (BST_CHECKED) : (BST_UNCHECKED)); CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEONSTART,(g_wMaskAdv & OPT_HIDEONSTART) ? (BST_CHECKED) : (BST_UNCHECKED)); CheckDlgButton(hwndDlg,IDC_MAINOPT_RESTORE,(g_wMaskAdv & OPT_RESTORE) ? (BST_CHECKED) : (BST_UNCHECKED)); return(true); } break; case WM_NOTIFY: { NMHDR* nmhdr = (NMHDR*)lParam; switch (nmhdr->code) { case PSN_APPLY: { WORD wMaskAdv = 0; if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFLOCK) == BST_CHECKED) wMaskAdv |= OPT_HIDEIFLOCK; if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFWINIDLE) == BST_CHECKED) wMaskAdv |= OPT_HIDEIFWINIDLE; if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFMIRIDLE) == BST_CHECKED) wMaskAdv |= OPT_HIDEIFMIRIDLE; if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFSCRSVR) == BST_CHECKED) wMaskAdv |= OPT_HIDEIFSCRSVR; if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEONSTART) == BST_CHECKED) wMaskAdv |= OPT_HIDEONSTART; if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_RESTORE) == BST_CHECKED) wMaskAdv |= OPT_RESTORE; if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_MENUITEM) == BST_CHECKED ) { if (g_hMenuItem == 0) BossKeyMenuItemInit(); wMaskAdv |= OPT_MENUITEM; } else if (g_hMenuItem != 0) BossKeyMenuItemUnInit(); char szMinutes[4] = {0}; GetDlgItemTextA(hwndDlg,IDC_MAINOPT_TIME,szMinutes,3); (atoi(szMinutes) > 0) ? minutes = atoi(szMinutes) : minutes = 1; DBWriteContactSettingByte(NULL,MOD_NAME,"time",minutes); DBWriteContactSettingWord(NULL,MOD_NAME,"optsmaskadv",wMaskAdv); g_wMaskAdv = wMaskAdv; return(true); } break; } } break; case WM_COMMAND: { switch (HIWORD(wParam)) { case BN_CLICKED: { switch(LOWORD(wParam)) { case IDC_MAINOPT_MENUITEM: case IDC_MAINOPT_HIDEIFLOCK: case IDC_MAINOPT_HIDEIFSCRSVR: case IDC_MAINOPT_HIDEONSTART: case IDC_MAINOPT_RESTORE: { SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); return(true); } break; case IDC_MAINOPT_HIDEIFWINIDLE: { if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFWINIDLE) == BST_CHECKED) CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFMIRIDLE,BST_UNCHECKED); SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); return(true); } break; case IDC_MAINOPT_HIDEIFMIRIDLE: { if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_HIDEIFMIRIDLE) == BST_CHECKED) CheckDlgButton(hwndDlg,IDC_MAINOPT_HIDEIFWINIDLE,BST_UNCHECKED); SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); return(true); } break; } return(0); } break; case EN_SETFOCUS: { inFocus = true; return(0); } break; case EN_UPDATE: { switch( LOWORD( wParam )) { case IDC_MAINOPT_TIME: if(inFocus) SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0); } } break; default:break; } } break; case WM_DESTROY: { g_fOptionsOpen = false; return(0); } break; } return(false); }
INT_PTR CALLBACK AdvOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static bool inFocus = false; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { g_fOptionsOpen = true; minutes = db_get_b(NULL, MOD_NAME, "time", 10); TCHAR szMinutes[4] = { 0 }; _itot(minutes, szMinutes, 10); SendDlgItemMessage(hwndDlg, IDC_MAINOPT_TIME, EM_LIMITTEXT, 2, 0); SendDlgItemMessage(hwndDlg, IDC_MAINOPT_SPIN_TIME, UDM_SETRANGE32, 1, (LPARAM)99); SetDlgItemText(hwndDlg, IDC_MAINOPT_TIME, szMinutes); CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEIFLOCK, (g_wMaskAdv & OPT_HIDEIFLOCK) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_MAINOPT_MENUITEM, (g_wMaskAdv & OPT_MENUITEM) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEIFWINIDLE, (g_wMaskAdv & OPT_HIDEIFWINIDLE) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEIFMIRIDLE, (g_wMaskAdv & OPT_HIDEIFMIRIDLE) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEIFSCRSVR, (g_wMaskAdv & OPT_HIDEIFSCRSVR) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEONSTART, (g_wMaskAdv & OPT_HIDEONSTART) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_MAINOPT_RESTORE, (g_wMaskAdv & OPT_RESTORE) ? BST_CHECKED : BST_UNCHECKED); } return true; case WM_NOTIFY: { NMHDR* nmhdr = (NMHDR*)lParam; switch (nmhdr->code) { case PSN_APPLY: WORD wMaskAdv = 0; if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEIFLOCK) == BST_CHECKED) wMaskAdv |= OPT_HIDEIFLOCK; if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEIFWINIDLE) == BST_CHECKED) wMaskAdv |= OPT_HIDEIFWINIDLE; if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEIFMIRIDLE) == BST_CHECKED) wMaskAdv |= OPT_HIDEIFMIRIDLE; if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEIFSCRSVR) == BST_CHECKED) wMaskAdv |= OPT_HIDEIFSCRSVR; if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEONSTART) == BST_CHECKED) wMaskAdv |= OPT_HIDEONSTART; if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_RESTORE) == BST_CHECKED) wMaskAdv |= OPT_RESTORE; if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_MENUITEM) == BST_CHECKED) { if (g_hMenuItem == 0) BossKeyMenuItemInit(); wMaskAdv |= OPT_MENUITEM; } else if (g_hMenuItem != 0) BossKeyMenuItemUnInit(); TCHAR szMinutes[4] = { 0 }; GetDlgItemText(hwndDlg, IDC_MAINOPT_TIME, szMinutes, _countof(szMinutes)); minutes = _ttoi(szMinutes); if (minutes < 1) minutes = 1; db_set_b(NULL, MOD_NAME, "time", minutes); db_set_w(NULL, MOD_NAME, "optsmaskadv", wMaskAdv); g_wMaskAdv = wMaskAdv; return true; } } break; case WM_COMMAND: switch (HIWORD(wParam)) { case BN_CLICKED: switch (LOWORD(wParam)) { case IDC_MAINOPT_MENUITEM: case IDC_MAINOPT_HIDEIFLOCK: case IDC_MAINOPT_HIDEIFSCRSVR: case IDC_MAINOPT_HIDEONSTART: case IDC_MAINOPT_RESTORE: SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0); return true; case IDC_MAINOPT_HIDEIFWINIDLE: if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEIFWINIDLE) == BST_CHECKED) CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEIFMIRIDLE, BST_UNCHECKED); SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0); return true; case IDC_MAINOPT_HIDEIFMIRIDLE: if (IsDlgButtonChecked(hwndDlg, IDC_MAINOPT_HIDEIFMIRIDLE) == BST_CHECKED) CheckDlgButton(hwndDlg, IDC_MAINOPT_HIDEIFWINIDLE, BST_UNCHECKED); SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0); return true; } return 0; case EN_SETFOCUS: inFocus = true; return 0; case EN_UPDATE: switch (LOWORD(wParam)) { case IDC_MAINOPT_TIME: if (inFocus) SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0); } break; } break; case WM_DESTROY: g_fOptionsOpen = false; return 0; } return false; }
int MirandaLoaded(WPARAM,LPARAM) { g_wMask = db_get_w(NULL,MOD_NAME,"optsmask",DEFAULTSETTING); RegisterCoreHotKeys(); g_hWinHook = SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_SHOW, NULL, WinEventProc, GetCurrentProcessId(), 0, 0); HookEvent(ME_TTB_MODULELOADED, TopToolbarInit); HookEvent(ME_OPT_INITIALISE, OptsDlgInit); HookEvent(ME_MSG_WINDOWEVENT, MsgWinOpening); HookEvent(ME_PROTO_ACCLISTCHANGED, EnumProtos); HookEvent(ME_MSG_TOOLBARLOADED, TabsrmmButtonsInit); HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed); GetWindowThreadProcessId(pcli->hwndContactList, &g_dwMirandaPID); WNDCLASS winclass = {0}; winclass.lpfnWndProc = ListenWndProc; winclass.hInstance = g_hInstance; winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszClassName = BOSSKEY_LISTEN_INFO; if (RegisterClass(&winclass)) { g_hListenWindow = CreateWindow(BOSSKEY_LISTEN_INFO,BOSSKEY_LISTEN_INFO,WS_POPUP,0,0,5,5,pcli->hwndContactList,NULL,g_hInstance,NULL); WTSRegisterSessionNotification(g_hListenWindow, 0); } if (IsWinVerVistaPlus()) { hDwmApi = LoadLibrary(_T("dwmapi.dll")); if (hDwmApi) dwmIsCompositionEnabled = (PFNDwmIsCompositionEnabled)GetProcAddress(hDwmApi,"DwmIsCompositionEnabled"); } if (g_wMaskAdv & OPT_MENUITEM) BossKeyMenuItemInit(); // Register token for variables plugin if (ServiceExists(MS_VARS_REGISTERTOKEN)) { TOKENREGISTER tr = {0}; tr.cbSize = sizeof(TOKENREGISTER); tr.memType = TR_MEM_OWNER; tr.flags = TRF_FIELD | TRF_TCHAR | TRF_PARSEFUNC; tr.tszTokenString = _T("bosskeyname"); tr.parseFunctionT = VariablesBossKey; tr.szHelpText = LPGEN("BossKey")"\t"LPGEN("get the BossKey name"); CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr); } EnumProtos(0, 0); InitIdleTimer(); if (g_bOldSetting && !(g_wMaskAdv & OPT_RESTORE)) // Restore settings if Miranda was crushed or killed in hidden mode and "Restore hiding on startup after failure" option is disabled RestoreOldSettings(); if ((g_wMaskAdv & OPT_HIDEONSTART) || (g_wMaskAdv & OPT_RESTORE && g_bOldSetting)) BossKeyHideMiranda(0, 0); return 0; }