Skip to content

Commit

Permalink
fixed: missing string table handling in WeaselSetup, modify macros
Browse files Browse the repository at this point in the history
  • Loading branch information
fxliang committed Sep 8, 2023
1 parent 4b892e6 commit 1b08cd4
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 38 deletions.
21 changes: 21 additions & 0 deletions WeaselSetup/InstallOptionsDlg.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
#pragma once

#include "resource.h"
#include <atlstr.h>

#define MSG_BY_IDS(idInfo, idCap, uType) \
{\
CString info, cap;\
info.LoadStringW(idInfo);\
cap.LoadStringW(idCap);\
LANGID langID = GetThreadUILanguage();\
MessageBoxExW(NULL, info, cap, uType, langID);\
}

#define MSG_ID_CAP(info, idCap, uType) \
{\
CString cap;\
cap.LoadStringW(idCap);\
LANGID langID = GetThreadUILanguage();\
MessageBoxExW(NULL, info, cap, uType, langID);\
}

#define MSG_NOT_SILENT_BY_IDS(silent, idInfo, idCap, uType) {if(!silent) MSG_BY_IDS(idInfo, idCap, uType); }
#define MSG_NOT_SILENT_ID_CAP(silent, info, idCap, uType) {if(!silent) MSG_ID_CAP(info, idCap, uType);}

class InstallOptionsDialog : public CDialogImpl<InstallOptionsDialog>
{
Expand Down
8 changes: 4 additions & 4 deletions WeaselSetup/WeaselSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static int CustomInstall(bool installing)
0, NULL, 0, KEY_ALL_ACCESS, 0, &hKey, NULL);
if (FAILED(HRESULT_FROM_WIN32(ret)))
{
MessageBox(NULL, KEY, L"安裝失敗", MB_ICONERROR | MB_OK);
MSG_ID_CAP(KEY, IDS_STR_INSTALL_FAILED, MB_ICONERROR | MB_OK);
return 1;
}

Expand All @@ -121,15 +121,15 @@ static int CustomInstall(bool installing)
(user_dir.length() + 1) * sizeof(WCHAR));
if (FAILED(HRESULT_FROM_WIN32(ret)))
{
MessageBox(NULL, L"無法寫入 RimeUserDir", L"安裝失敗", MB_ICONERROR | MB_OK);
MSG_BY_IDS(IDS_STR_ERR_WRITE_USER_DIR, IDS_STR_INSTALL_FAILED, MB_ICONERROR | MB_OK);
return 1;
}

DWORD data = hant ? 1 : 0;
ret = RegSetValueEx(hKey, L"Hant", 0, REG_DWORD, (const BYTE*)&data, sizeof(DWORD));
if (FAILED(HRESULT_FROM_WIN32(ret)))
{
MessageBox(NULL, L"無法寫入 Hant", L"安裝失敗", MB_ICONERROR | MB_OK);
MSG_BY_IDS(IDS_STR_ERR_WRITE_HANT, IDS_STR_INSTALL_FAILED, MB_ICONERROR | MB_OK);
return 1;
}
if (_has_installed)
Expand All @@ -143,7 +143,7 @@ static int CustomInstall(bool installing)
ShellExecuteW(NULL, NULL, (dir + L"\\WeaselDeployer.exe").c_str(), L"/deploy", NULL, SW_SHOWNORMAL);
});
th.detach();
MessageBox(NULL, L"修改用戶資料夾位置成功:)", L"修改成功", MB_ICONINFORMATION | MB_OK);
MSG_BY_IDS(IDS_STR_MODIFY_SUCCESS_INFO, IDS_STR_MODIFY_SUCCESS_CAP, MB_ICONINFORMATION | MB_OK);
}

return 0;
Expand Down
Binary file modified WeaselSetup/WeaselSetup.rc
Binary file not shown.
28 changes: 7 additions & 21 deletions WeaselSetup/imesetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,7 @@
#include <WeaselCommon.h>
#include <msctf.h>
#include <strsafe.h>
#include <atlstr.h>
#include "resource.h"

#define MSG_NOT_SILENT_BY_IDS(silent, idInfo, idCap, uType) \
if(!silent) {\
CString info, cap;\
info.LoadStringW(idInfo);\
cap.LoadStringW(idCap);\
LANGID langID = GetThreadUILanguage();\
MessageBoxExW(NULL, info, cap, uType, langID);\
}

#define MSG_NOT_SILENT_ID_CAP(silent, info, idCap, uType) \
if(!silent) {\
CString cap;\
cap.LoadStringW(idCap);\
LANGID langID = GetThreadUILanguage();\
MessageBoxExW(NULL, info, cap, uType, langID);\
}
#include "InstallOptionsDlg.h"


// {A3F4CDED-B1E9-41EE-9CA6-7B4D0DE6CB0A}
Expand Down Expand Up @@ -413,8 +395,12 @@ int register_text_service(const std::wstring& tsf_path, bool register_ime, bool
else
{
WCHAR msg[100];
StringCchPrintfW(msg, _countof(msg), L"註冊輸入法錯誤 regsvr32.exe %s", params.c_str());
if (!silent) MessageBoxW(NULL, msg, L"安装/卸載失败", MB_ICONERROR | MB_OK);
CString str;
str.LoadStringW(IDS_STR_ERRREGTSF);
StringCchPrintfW(msg, _countof(msg), str, params.c_str());
//StringCchPrintfW(msg, _countof(msg), L"註冊輸入法錯誤 regsvr32.exe %s", params.c_str());
//if (!silent) MessageBoxW(NULL, msg, L"安装/卸載失败", MB_ICONERROR | MB_OK);
MSG_NOT_SILENT_ID_CAP(silent, msg, IDS_STR_INORUN_FAILED, MB_ICONERROR | MB_OK);
return 1;
}

Expand Down
28 changes: 15 additions & 13 deletions WeaselSetup/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@
#define IDR_MAINFRAME 128
#define IDS_STRING_INSTALL 129
#define IDS_STRING_MODIFY 130

#define IDS_STR_INSTALL_FAILED 131
#define IDS_STR_INSTALL_SUCCESS_CAP 132
#define IDS_STR_UNINSTALL_SUCCESS_CAP 133
#define IDS_STR_UNINSTALL_FAILED 134
#define IDS_STR_ERRCANCELFSREDIRECT 135
#define IDS_STR_ERRRECOVERFSREDIRECT 136
#define IDS_STR_ERRREGIME 137
#define IDS_STR_ERRREGTSF 138
#define IDS_STR_ERRREGIMEWRITESVREXE 139
#define IDS_STR_INORUN_FAILED 140
#define IDS_STR_ERRWRITEWEASELROOT 141
#define IDS_STR_INSTALL_FAILED 131
#define IDS_STR_INSTALL_SUCCESS_CAP 132
#define IDS_STR_UNINSTALL_SUCCESS_CAP 133
#define IDS_STR_UNINSTALL_FAILED 134
#define IDS_STR_ERRCANCELFSREDIRECT 135
#define IDS_STR_ERRRECOVERFSREDIRECT 136
#define IDS_STR_ERRREGIME 137
#define IDS_STR_ERRREGTSF 138
#define IDS_STR_ERRREGIMEWRITESVREXE 139
#define IDS_STR_INORUN_FAILED 140
#define IDS_STR_ERRWRITEWEASELROOT 141
#define IDS_STR_INSTALL_SUCCESS_INFO 142
#define IDS_STR_UNINSTALL_SUCCESS_INFO 143

#define IDS_STR_ERR_WRITE_USER_DIR 144
#define IDS_STR_ERR_WRITE_HANT 145
#define IDS_STR_MODIFY_SUCCESS_INFO 146
#define IDS_STR_MODIFY_SUCCESS_CAP 147
#define IDD_INSTALL_OPTIONS 201
#define IDD_DIALOG1 203
#define IDC_RADIO_CN 1000
Expand Down

0 comments on commit 1b08cd4

Please sign in to comment.