static INT_PTR CALLBACK TlenPopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { TlenProtocol *proto = (TlenProtocol *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { BYTE delayMode; proto = (TlenProtocol *)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)proto); TranslateDialogDefault(hwndDlg); CheckDlgButton(hwndDlg, IDC_ENABLEPOPUP, db_get_b(NULL, proto->m_szModuleName, "MailPopupEnabled", TRUE)); SendDlgItemMessage(hwndDlg, IDC_COLORBKG, CPM_SETCOLOUR, 0, db_get_dw(NULL, proto->m_szModuleName, "MailPopupBack", POPUP_DEFAULT_COLORBKG)); SendDlgItemMessage(hwndDlg, IDC_COLORTXT, CPM_SETCOLOUR, 0, db_get_dw(NULL, proto->m_szModuleName, "MailPopupText", POPUP_DEFAULT_COLORTXT)); SetDlgItemInt(hwndDlg, IDC_DELAY, db_get_dw(NULL, proto->m_szModuleName, "MailPopupDelay", 4), FALSE); delayMode = db_get_b(NULL, proto->m_szModuleName, "MailPopupDelayMode", 0); if (delayMode == 1) { CheckDlgButton(hwndDlg, IDC_DELAY_CUSTOM, TRUE); } else if (delayMode == 2) { CheckDlgButton(hwndDlg, IDC_DELAY_PERMANENT, TRUE); } else { CheckDlgButton(hwndDlg, IDC_DELAY_POPUP, TRUE); } return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_COLORTXT: case IDC_COLORBKG: case IDC_ENABLEPOPUP: case IDC_DELAY: case IDC_DELAY_POPUP: case IDC_DELAY_CUSTOM: case IDC_DELAY_PERMANENT: MarkChanges(8, hwndDlg); break; case IDC_PREVIEW: { int delay; TCHAR title[256]; if (IsDlgButtonChecked(hwndDlg, IDC_DELAY_POPUP)) { delay=0; } else if (IsDlgButtonChecked(hwndDlg, IDC_DELAY_PERMANENT)) { delay=-1; } else { delay=GetDlgItemInt(hwndDlg, IDC_DELAY, NULL, FALSE); } mir_sntprintf(title, SIZEOF(title), TranslateT("%S mail"), proto->m_szModuleName); MailPopupPreview((DWORD) SendDlgItemMessage(hwndDlg,IDC_COLORBKG,CPM_GETCOLOUR,0,0), (DWORD) SendDlgItemMessage(hwndDlg,IDC_COLORTXT,CPM_GETCOLOUR,0,0), title, _T("From: [email protected]\nSubject: test"), delay); } } break; case WM_NOTIFY: switch (((LPNMHDR) lParam)->code) { case PSN_APPLY: { BYTE delayMode; db_set_b(NULL, proto->m_szModuleName, "MailPopupEnabled", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ENABLEPOPUP)); db_set_dw(NULL, proto->m_szModuleName, "MailPopupBack", (DWORD) SendDlgItemMessage(hwndDlg,IDC_COLORBKG,CPM_GETCOLOUR,0,0)); db_set_dw(NULL, proto->m_szModuleName, "MailPopupText", (DWORD) SendDlgItemMessage(hwndDlg,IDC_COLORTXT,CPM_GETCOLOUR,0,0)); db_set_dw(NULL, proto->m_szModuleName, "MailPopupDelay", (DWORD) GetDlgItemInt(hwndDlg,IDC_DELAY, NULL, FALSE)); delayMode=0; if (IsDlgButtonChecked(hwndDlg, IDC_DELAY_CUSTOM)) { delayMode=1; } else if (IsDlgButtonChecked(hwndDlg, IDC_DELAY_PERMANENT)) { delayMode=2; } db_set_b(NULL, proto->m_szModuleName, "MailPopupDelayMode", delayMode); ApplyChanges(proto, 8); return TRUE; } } break; } return FALSE; }
static BOOL CALLBACK TlenPopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: { BYTE delayMode; TranslateDialogDefault(hwndDlg); CheckDlgButton(hwndDlg, IDC_ENABLEPOPUP, DBGetContactSettingByte(NULL, jabberProtoName, "MailPopupEnabled", TRUE)); SendDlgItemMessage(hwndDlg, IDC_COLORBKG, CPM_SETCOLOUR, 0, DBGetContactSettingDword(NULL, jabberProtoName, "MailPopupBack", POPUP_DEFAULT_COLORBKG)); SendDlgItemMessage(hwndDlg, IDC_COLORTXT, CPM_SETCOLOUR, 0, DBGetContactSettingDword(NULL, jabberProtoName, "MailPopupText", POPUP_DEFAULT_COLORTXT)); SetDlgItemInt(hwndDlg, IDC_DELAY, DBGetContactSettingDword(NULL, jabberProtoName, "MailPopupDelay", 4), FALSE); delayMode = DBGetContactSettingByte(NULL, jabberProtoName, "MailPopupDelayMode", 0); if (delayMode==1) { CheckDlgButton(hwndDlg, IDC_DELAY_CUSTOM, TRUE); } else if (delayMode==2) { CheckDlgButton(hwndDlg, IDC_DELAY_PERMANENT, TRUE); } else { CheckDlgButton(hwndDlg, IDC_DELAY_POPUP, TRUE); } return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_COLORTXT: case IDC_COLORBKG: case IDC_ENABLEPOPUP: case IDC_DELAY: case IDC_DELAY_POPUP: case IDC_DELAY_CUSTOM: case IDC_DELAY_PERMANENT: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_PREVIEW: { int delay; if (IsDlgButtonChecked(hwndDlg, IDC_DELAY_POPUP)) { delay=0; } else if (IsDlgButtonChecked(hwndDlg, IDC_DELAY_PERMANENT)) { delay=-1; } else { delay=GetDlgItemInt(hwndDlg, IDC_DELAY, NULL, FALSE); } MailPopupPreview((DWORD) SendDlgItemMessage(hwndDlg,IDC_COLORBKG,CPM_GETCOLOUR,0,0), (DWORD) SendDlgItemMessage(hwndDlg,IDC_COLORTXT,CPM_GETCOLOUR,0,0), "New mail", "From: [email protected]\nSubject: test", delay); } } break; case WM_NOTIFY: switch (((LPNMHDR) lParam)->code) { case PSN_APPLY: { BYTE delayMode; DBWriteContactSettingByte(NULL, jabberProtoName, "MailPopupEnabled", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ENABLEPOPUP)); DBWriteContactSettingDword(NULL, jabberProtoName, "MailPopupBack", (DWORD) SendDlgItemMessage(hwndDlg,IDC_COLORBKG,CPM_GETCOLOUR,0,0)); DBWriteContactSettingDword(NULL, jabberProtoName, "MailPopupText", (DWORD) SendDlgItemMessage(hwndDlg,IDC_COLORTXT,CPM_GETCOLOUR,0,0)); DBWriteContactSettingDword(NULL, jabberProtoName, "MailPopupDelay", (DWORD) GetDlgItemInt(hwndDlg,IDC_DELAY, NULL, FALSE)); delayMode=0; if (IsDlgButtonChecked(hwndDlg, IDC_DELAY_CUSTOM)) { delayMode=1; } else if (IsDlgButtonChecked(hwndDlg, IDC_DELAY_PERMANENT)) { delayMode=2; } DBWriteContactSettingByte(NULL, jabberProtoName, "MailPopupDelayMode", delayMode); return TRUE; } } break; } return FALSE; }