diff options
Diffstat (limited to 'plugins/SimpleStatusMsg/src/msgbox.cpp')
-rw-r--r-- | plugins/SimpleStatusMsg/src/msgbox.cpp | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/plugins/SimpleStatusMsg/src/msgbox.cpp b/plugins/SimpleStatusMsg/src/msgbox.cpp index 9d02ca54c3..70a53b2bd5 100644 --- a/plugins/SimpleStatusMsg/src/msgbox.cpp +++ b/plugins/SimpleStatusMsg/src/msgbox.cpp @@ -106,7 +106,7 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) HWND handle = CreateWindowEx(0, WC_COMBOBOXEX, nullptr, WS_TABSTOP | CBS_NOINTEGRALHEIGHT | WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST, - 0, 0, 0, 240, hwndDlg, nullptr, g_hInst, nullptr); + 0, 0, 0, 240, hwndDlg, nullptr, g_plugin.getInst(), nullptr); COMBOBOXEXITEM cbei = { 0 }; if (!(data->m_iDlgFlags & DLG_SHOW_STATUS_ICONS)) @@ -221,7 +221,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) HWND handle = CreateWindowEx(0, WC_COMBOBOXEX, nullptr, WS_TABSTOP | CBS_NOINTEGRALHEIGHT | WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST, - 0, 0, 0, 300, hwndDlg, nullptr, g_hInst, nullptr); + 0, 0, 0, 300, hwndDlg, nullptr, g_plugin.getInst(), nullptr); COMBOBOXEXITEM cbei = { 0 }; if (!(data->m_iDlgFlags & DLG_SHOW_LIST_ICONS)) @@ -229,7 +229,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) else cbei.mask = CBEIF_LPARAM | CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE; - int j = db_get_w(NULL, "SimpleStatusMsg", "LMMsg", 1); + int j = db_get_w(NULL, MODULENAME, "LMMsg", 1); for (int i = 1; i <= data->max_hist_msgs; ++i) { // history messages @@ -238,7 +238,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) mir_snprintf(buff, "SMsg%d", j); j--; - wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", buff); + wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, buff); if (tszStatusMsg != nullptr) { if (*tszStatusMsg != '\0') { found = TRUE; @@ -332,7 +332,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) for (int i = 1; i <= data->num_def_msgs; ++i) { // predefined messages mir_snprintf(buff, "DefMsg%d", i); - wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", buff); + wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, buff); if (tszStatusMsg != nullptr) { if (*tszStatusMsg != '\0') { cbei.iItem = -1; @@ -353,7 +353,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) } } - if (db_get_b(NULL, "SimpleStatusMsg", "PutDefInList", 0)) { + if (db_get_b(NULL, MODULENAME, "PutDefInList", 0)) { cbei.iItem = -1; cbei.pszText = (LPTSTR)GetDefaultMessage(data->m_iStatus); if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) { @@ -391,7 +391,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, HWND edit_control) { - HMENU hmenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_EDITMENU)); + HMENU hmenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_EDITMENU)); if (hmenu == nullptr) return; @@ -640,9 +640,9 @@ void ClearHistory(struct MsgBoxData *data, int cur_sel) for (i = 1; i <= data->max_hist_msgs; i++) { mir_snprintf(text, "SMsg%d", i); - db_set_ws(NULL, "SimpleStatusMsg", text, L""); + db_set_ws(NULL, MODULENAME, text, L""); } - db_set_s(NULL, "SimpleStatusMsg", "LastMsg", ""); + db_set_s(NULL, MODULENAME, "LastMsg", ""); for (i = 0; i < accounts->count; i++) { auto *pa = accounts->pa[i]; if (!pa->IsEnabled()) @@ -655,9 +655,9 @@ void ClearHistory(struct MsgBoxData *data, int cur_sel) continue; mir_snprintf(buff2, "Last%sMsg", pa->szModuleName); - db_set_s(NULL, "SimpleStatusMsg", buff2, ""); + db_set_s(NULL, MODULENAME, buff2, ""); } - db_set_w(NULL, "SimpleStatusMsg", "LMMsg", (WORD)data->max_hist_msgs); + db_set_w(NULL, MODULENAME, "LMMsg", (WORD)data->max_hist_msgs); SendMessage(data->recent_cbex, CB_SETCURSEL, -1, 0); num_items = SendMessage(data->recent_cbex, CB_GETCOUNT, 0, 0); if (num_items == CB_ERR) @@ -685,7 +685,7 @@ void DisplayCharsCount(struct MsgBoxData *dlg_data, HWND hwndDlg) return; len = GetDlgItemText(hwndDlg, IDC_EDIT1, msg, _countof(msg)); - if (db_get_b(NULL, "SimpleStatusMsg", "RemoveCR", 0)) { + if (db_get_b(NULL, MODULENAME, "RemoveCR", 0)) { int index, num_lines = SendDlgItemMessage(hwndDlg, IDC_EDIT1, EM_GETLINECOUNT, 0, 0); for (int i = 1; i < num_lines; ++i) { index = SendDlgItemMessage(hwndDlg, IDC_EDIT1, EM_LINEINDEX, (WPARAM)i, 0); @@ -706,7 +706,7 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus) num_start -= data->num_def_msgs + 1; mir_snprintf(setting, "%sFlags", data->m_szProto ? data->m_szProto : ""); - flags = db_get_b(NULL, "SimpleStatusMsg", (char *)StatusModeToDbSetting(iStatus, setting), STATUS_DEFAULT); + flags = db_get_b(NULL, MODULENAME, (char *)StatusModeToDbSetting(iStatus, setting), STATUS_DEFAULT); if (flags & STATUS_LAST_MSG) { if (data->m_szProto) @@ -714,10 +714,10 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus) else mir_snprintf(setting, "LastMsg"); - char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting); + char *szSetting = db_get_sa(NULL, MODULENAME, setting); if (szSetting != nullptr) { if (*szSetting != '\0') { - wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting); + wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, szSetting); if (tszStatusMsg != nullptr) { if (*tszStatusMsg != '\0') { SetDlgItemText(hwndDlg, IDC_EDIT1, tszStatusMsg); @@ -734,7 +734,7 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus) else if (flags & STATUS_DEFAULT_MSG) { SetDlgItemText(hwndDlg, IDC_EDIT1, GetDefaultMessage(iStatus)); - if (db_get_b(NULL, "SimpleStatusMsg", "PutDefInList", 0)) { + if (db_get_b(NULL, MODULENAME, "PutDefInList", 0)) { fcursel = SendMessage(data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)GetDefaultMessage(iStatus)); if (fcursel != CB_ERR) SendMessage(data->recent_cbex, CB_SETCURSEL, (WPARAM)fcursel, 0); @@ -932,9 +932,9 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, DM_SIMPAWAY_SHUTDOWN); HookEventMessage(ME_SKIN2_ICONSCHANGED, hwndDlg, DM_SIMPAWAY_CHANGEICONS); - copy_init_data->num_def_msgs = db_get_w(NULL, "SimpleStatusMsg", "DefMsgCount", 0); - copy_init_data->max_hist_msgs = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10); - copy_init_data->m_iDlgFlags = db_get_b(NULL, "SimpleStatusMsg", "DlgFlags", DLG_SHOW_DEFAULT); + copy_init_data->num_def_msgs = db_get_w(NULL, MODULENAME, "DefMsgCount", 0); + copy_init_data->max_hist_msgs = db_get_b(NULL, MODULENAME, "MaxHist", 10); + copy_init_data->m_iDlgFlags = db_get_b(NULL, MODULENAME, "DlgFlags", DLG_SHOW_DEFAULT); copy_init_data->m_szProto = init_data->m_szProto; copy_init_data->m_iStatus = init_data->m_iStatus; copy_init_data->m_iStatusModes = init_data->m_iStatusModes; @@ -1045,8 +1045,8 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA } } - if (db_get_b(NULL, "SimpleStatusMsg", "AutoClose", 1) && init_data->m_bOnEvent) { - copy_init_data->m_iCountdown = db_get_b(NULL, "SimpleStatusMsg", "DlgTime", 5); + if (db_get_b(NULL, MODULENAME, "AutoClose", 1) && init_data->m_bOnEvent) { + copy_init_data->m_iCountdown = db_get_b(NULL, MODULENAME, "DlgTime", 5); SendMessage(hwndDlg, WM_TIMER, 0, 0); SetTimer(hwndDlg, 1, 1000, nullptr); } @@ -1068,15 +1068,15 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA mir_free(init_data); - if (!db_get_b(NULL, "SimpleStatusMsg", "WinCentered", 1)) { + if (!db_get_b(NULL, MODULENAME, "WinCentered", 1)) { WINDOWPLACEMENT wp; int x, y; wp.length = sizeof(wp); GetWindowPlacement(hwndDlg, &wp); - x = (int)db_get_dw(NULL, "SimpleStatusMsg", "Winx", -1); - y = (int)db_get_dw(NULL, "SimpleStatusMsg", "Winy", -1); + x = (int)db_get_dw(NULL, MODULENAME, "Winx", -1); + y = (int)db_get_dw(NULL, MODULENAME, "Winy", -1); if (x != -1) { OffsetRect(&wp.rcNormalPosition, x - wp.rcNormalPosition.left, y - wp.rcNormalPosition.top); @@ -1127,13 +1127,13 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA char szSetting[80]; if (msgbox_data->m_szProto) { mir_snprintf(szSetting, "Last%sMsg", msgbox_data->m_szProto); - db_set_s(NULL, "SimpleStatusMsg", szSetting, ""); + db_set_s(NULL, MODULENAME, szSetting, ""); mir_snprintf(szSetting, "%sMsg", msgbox_data->m_szProto); db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, szSetting), L""); } else { - db_set_s(NULL, "SimpleStatusMsg", "LastMsg", ""); + db_set_s(NULL, MODULENAME, "LastMsg", ""); for (int j = 0; j < accounts->count; j++) { auto *pa = accounts->pa[j]; if (!pa->IsEnabled()) @@ -1149,7 +1149,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA continue; mir_snprintf(szSetting, "Last%sMsg", pa->szModuleName); - db_set_s(NULL, "SimpleStatusMsg", szSetting, ""); + db_set_s(NULL, MODULENAME, szSetting, ""); mir_snprintf(szSetting, "%sMsg", pa->szModuleName); iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName); @@ -1172,19 +1172,19 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA for (int i = 1; i <= msgbox_data->max_hist_msgs; i++) { mir_snprintf(buff, "SMsg%d", i); - wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", buff); + wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, buff); if (tszStatusMsg != nullptr) { if (!mir_wstrcmp(tszStatusMsg, tszMsg)) { found = true; if (msgbox_data->m_szProto) { mir_snprintf(buff2, "Last%sMsg", msgbox_data->m_szProto); - db_set_s(NULL, "SimpleStatusMsg", buff2, buff); + db_set_s(NULL, MODULENAME, buff2, buff); mir_snprintf(buff2, "%sMsg", msgbox_data->m_szProto); db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, buff2), tszMsg); } else { - db_set_s(NULL, "SimpleStatusMsg", "LastMsg", buff); + db_set_s(NULL, MODULENAME, "LastMsg", buff); for (int j = 0; j < accounts->count; j++) { auto *pa = accounts->pa[j]; if (!pa->IsEnabled()) @@ -1200,7 +1200,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA continue; mir_snprintf(buff2, "Last%sMsg", pa->szModuleName); - db_set_s(NULL, "SimpleStatusMsg", buff2, buff); + db_set_s(NULL, MODULENAME, buff2, buff); mir_snprintf(buff2, "%sMsg", pa->szModuleName); iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName); @@ -1215,7 +1215,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA } if (!found) { - int last_modified_msg = db_get_w(NULL, "SimpleStatusMsg", "LMMsg", msgbox_data->max_hist_msgs); + int last_modified_msg = db_get_w(NULL, MODULENAME, "LMMsg", msgbox_data->max_hist_msgs); if (last_modified_msg == msgbox_data->max_hist_msgs) last_modified_msg = 1; @@ -1223,17 +1223,17 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA last_modified_msg++; mir_snprintf(buff, "SMsg%d", last_modified_msg); - db_set_ws(NULL, "SimpleStatusMsg", buff, tszMsg); + db_set_ws(NULL, MODULENAME, buff, tszMsg); if (msgbox_data->m_szProto) { mir_snprintf(buff2, "Last%sMsg", msgbox_data->m_szProto); - db_set_s(NULL, "SimpleStatusMsg", buff2, buff); + db_set_s(NULL, MODULENAME, buff2, buff); mir_snprintf(buff2, "%sMsg", msgbox_data->m_szProto); db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, buff2), tszMsg); } else { - db_set_s(NULL, "SimpleStatusMsg", "LastMsg", buff); + db_set_s(NULL, MODULENAME, "LastMsg", buff); for (int j = 0; j < accounts->count; j++) { auto *pa = accounts->pa[j]; if (!pa->IsEnabled()) @@ -1249,14 +1249,14 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA continue; mir_snprintf(buff2, "Last%sMsg", pa->szModuleName); - db_set_s(NULL, "SimpleStatusMsg", buff2, buff); + db_set_s(NULL, MODULENAME, buff2, buff); mir_snprintf(buff2, "%sMsg", pa->szModuleName); iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName); db_set_ws(NULL, "SRAway", StatusModeToDbSetting(iStatus, buff2), tszMsg); } } - db_set_w(NULL, "SimpleStatusMsg", "LMMsg", (WORD)last_modified_msg); + db_set_w(NULL, MODULENAME, "LMMsg", (WORD)last_modified_msg); } if (!msgbox_data->m_szProto) @@ -1387,7 +1387,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (LOWORD(histitem.lParam) == HISTORY_MSG) { char szSetting[16]; mir_snprintf(szSetting, "SMsg%d", (int)HIWORD(histitem.lParam)); - db_set_ws(NULL, "SimpleStatusMsg", szSetting, L""); + db_set_ws(NULL, MODULENAME, szSetting, L""); SendMessage(msgbox_data->recent_cbex, CBEM_DELETEITEM, (WPARAM)msgbox_data->curr_sel_msg, 0); } if (LOWORD(histitem.lParam) == PREDEFINED_MSG) { @@ -1499,7 +1499,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (LOWORD(histitem.lParam) == HISTORY_MSG) { mir_snprintf(buff, "SMsg%d", (int)HIWORD(histitem.lParam)); - db_set_ws(NULL, "SimpleStatusMsg", buff, L""); + db_set_ws(NULL, MODULENAME, buff, L""); } else if (LOWORD(histitem.lParam) == PREDEFINED_MSG) msgbox_data->m_bPredefChanged = TRUE; @@ -1570,8 +1570,8 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA WINDOWPLACEMENT wp; wp.length = sizeof(wp); GetWindowPlacement(hwndDlg, &wp); - db_set_dw(NULL, "SimpleStatusMsg", "Winx", wp.rcNormalPosition.left); - db_set_dw(NULL, "SimpleStatusMsg", "Winy", wp.rcNormalPosition.top); + db_set_dw(NULL, MODULENAME, "Winx", wp.rcNormalPosition.left); + db_set_dw(NULL, MODULENAME, "Winy", wp.rcNormalPosition.top); if (msgbox_data->m_bPredefChanged) { int i, num_items, new_num_def_msgs = 0; @@ -1591,13 +1591,13 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA mir_snprintf(buff, "DefMsg%d", i); if (LOWORD(cbitem.lParam) == PREDEFINED_MSG) { new_num_def_msgs++; - db_set_ws(NULL, "SimpleStatusMsg", buff, text); + db_set_ws(NULL, MODULENAME, buff, text); } else - db_unset(NULL, "SimpleStatusMsg", buff); + db_unset(NULL, MODULENAME, buff); num_items--; } - db_set_w(NULL, "SimpleStatusMsg", "DefMsgCount", (WORD)new_num_def_msgs); + db_set_w(NULL, MODULENAME, "DefMsgCount", (WORD)new_num_def_msgs); } ImageList_Destroy(msgbox_data->status_icons); |