Skip to content

Commit ff4f68c

Browse files
authored
Merge pull request #2 from jet2jet/feature/implement_mui
Add MUI for localization and English translation
2 parents f828cd9 + 68235c7 commit ff4f68c

36 files changed

Lines changed: 700 additions & 114 deletions

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ indent_style = tab
66
indent_size = 4
77
root = true
88

9+
[{*.rc}]
10+
charset = utf-16le
11+
12+
[{resource.h}]
13+
charset = utf-8-bom
14+
15+
[{*.vcxproj}]
16+
charset = utf-8-bom
17+
indent_style = space
18+
indent_size = 2
19+
920
[{*.yml}]
1021
end_of_line = lf
1122
indent_style = space

.github/workflows/build-and-release.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,28 @@ jobs:
7777
msbuild EasySFTP.sln /p:Configuration=Release /p:Platform=x64
7878
7979
- name: Prepare artifacts directory
80+
shell: pwsh
8081
run: |
8182
mkdir dist
8283
mkdir dist\x64
84+
$PSNativeCommandUseErrorActionPreference = $true
8385
8486
copy bin\Win32\Release\*.exe dist\
8587
copy bin\Win32\Release\*.dll dist\
88+
$PSNativeCommandUseErrorActionPreference = $false
89+
robocopy bin\Win32\Release dist /S /E /IF *.mui
90+
if ($global:LASTEXITCODE -le 7) { $global:LASTEXITCODE = 0 } else { throw "Robocopy error: $global:LASTEXITCODE" }
91+
$PSNativeCommandUseErrorActionPreference = $true
8692
copy EasySFTP.txt dist\
8793
copy license.txt dist\
8894
copy README.md dist\
8995
copy CHANGELOG.md dist\
9096
9197
copy bin\x64\Release\*.exe dist\x64\
9298
copy bin\x64\Release\*.dll dist\x64\
99+
$PSNativeCommandUseErrorActionPreference = $false
100+
robocopy bin\x64\Release dist\x64 /S /E /IF *.mui
101+
if ($global:LASTEXITCODE -le 7) { $global:LASTEXITCODE = 0 } else { throw "Robocopy error: $global:LASTEXITCODE" }
93102
94103
- name: Upload artifacts
95104
uses: actions/upload-artifact@v4

Common/AppClass.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ EXTERN_C int APIENTRY MyWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
2727
s_app.pMainApp->m_dwThreadID = ::GetCurrentThreadId();
2828
s_app.pMainApp->m_hThread = ::GetCurrentThread();
2929
s_app.pMainApp->m_hInstance = hInstance;
30+
s_app.pMainApp->m_hResInstance = hInstance;
3031
s_app.pMainApp->m_lpCmdLine = lpCmdLine;
3132
s_app.pMainApp->m_nCmdShow = nCmdShow;
3233
if (!s_app.pMainApp->InitInstance())
@@ -45,6 +46,7 @@ EXTERN_C BOOL APIENTRY MyDllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpR
4546
if (!s_app.pDLLApp)
4647
return FALSE;
4748
s_app.pDLLApp->m_hInstance = hInstance;
49+
s_app.pDLLApp->m_hResInstance = hInstance;
4850
if (!s_app.pDLLApp->InitInstance())
4951
{
5052
s_app.pDLLApp->ExitInstance();
@@ -89,6 +91,16 @@ EXTERN_C HINSTANCE WINAPI MyGetCurrentInstance()
8991
return NULL;
9092
}
9193

94+
EXTERN_C HINSTANCE WINAPI MyGetCurrentResourceInstance()
95+
{
96+
if (s_app.pMainApp)
97+
return s_app.pMainApp->GetResourceInstance();
98+
else if (s_app.pDLLApp)
99+
return s_app.pDLLApp->GetResourceInstance();
100+
else
101+
return NULL;
102+
}
103+
92104
////////////////////////////////////////////////////////////////////////////////
93105

94106
CMyThread::CMyThread()
@@ -270,6 +282,10 @@ bool CMyWinThread::PumpMessage()
270282
////////////////////////////////////////////////////////////////////////////////
271283

272284
CMyApplication::CMyApplication()
285+
: m_hInstance(nullptr)
286+
, m_hResInstance(nullptr)
287+
, m_lpCmdLine(nullptr)
288+
, m_nCmdShow(SW_SHOWNORMAL)
273289
{
274290
if (!s_app.pMainApp)
275291
s_app.pMainApp = this;
@@ -283,6 +299,8 @@ CMyApplication::~CMyApplication()
283299
////////////////////////////////////////////////////////////////////////////////
284300

285301
CMyDLLApplication::CMyDLLApplication()
302+
: m_hInstance(nullptr)
303+
, m_hResInstance(nullptr)
286304
{
287305
if (!s_app.pDLLApp)
288306
s_app.pDLLApp = this;

Common/AppClass.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,15 @@ class DECLSPEC_NOVTABLE CMyApplication : public CMyWinThread
6262
virtual ~CMyApplication();
6363

6464
HINSTANCE m_hInstance;
65+
HINSTANCE m_hResInstance;
6566
LPTSTR m_lpCmdLine;
6667
int m_nCmdShow;
6768

69+
inline HINSTANCE GetResourceInstance() const
70+
{
71+
return m_hResInstance ? m_hResInstance : m_hInstance;
72+
}
73+
6874
public:
6975
//virtual bool InitInstance() = 0;
7076
};
@@ -76,6 +82,12 @@ class DECLSPEC_NOVTABLE CMyDLLApplication : public CMyThread
7682
virtual ~CMyDLLApplication();
7783

7884
HINSTANCE m_hInstance;
85+
HINSTANCE m_hResInstance;
86+
87+
inline HINSTANCE GetResourceInstance() const
88+
{
89+
return m_hResInstance ? m_hResInstance : m_hInstance;
90+
}
7991

8092
public:
8193
virtual bool InitInstance() = 0;
@@ -86,6 +98,7 @@ CMyThread* WINAPI GetCurThread();
8698
CMyApplication* WINAPI GetCurApp();
8799
CMyDLLApplication* WINAPI GetCurDLLApp();
88100
EXTERN_C HINSTANCE WINAPI MyGetCurrentInstance();
101+
EXTERN_C HINSTANCE WINAPI MyGetCurrentResourceInstance();
89102

90103
EXTERN_C int APIENTRY MyWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
91104
LPTSTR lpCmdLine, int nCmdShow);

Common/Common.vcxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,13 @@
197197
</ItemGroup>
198198
<ItemGroup>
199199
<None Include="..\.gitignore" />
200+
<None Include="..\MuiResourceCompile.props" />
201+
<None Include="..\MuiResourceCompile.targets" />
200202
<None Include="ReadMe.txt" />
201203
</ItemGroup>
204+
<ItemGroup>
205+
<Xml Include="..\MuiResourceCompile.xml" />
206+
</ItemGroup>
202207
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
203208
<ImportGroup Label="ExtensionTargets">
204209
</ImportGroup>

Common/Common.vcxproj.filters

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,10 @@
150150
<ItemGroup>
151151
<None Include="ReadMe.txt" />
152152
<None Include="..\.gitignore" />
153+
<None Include="..\MuiResourceCompile.targets" />
154+
<None Include="..\MuiResourceCompile.props" />
155+
</ItemGroup>
156+
<ItemGroup>
157+
<Xml Include="..\MuiResourceCompile.xml" />
153158
</ItemGroup>
154159
</Project>

Common/MyDialog.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ INT_PTR CMyDialog::ModalDialogA(HWND hWndParent)
461461
return (INT_PTR) -1;
462462
HGLOBAL hGlobal;
463463
INT_PTR nRet;
464-
HINSTANCE hInst = MyGetCurrentInstance();
464+
HINSTANCE hInst = MyGetCurrentResourceInstance();
465465

466466
hGlobal = _DuplicateDialogTemplate(hInst, MAKEINTRESOURCE(m_uID));
467467
if (hGlobal == NULL)
@@ -491,7 +491,7 @@ INT_PTR CMyDialog::ModalDialogW(HWND hWndParent)
491491
return (INT_PTR) -1;
492492
HGLOBAL hGlobal;
493493
INT_PTR nRet;
494-
HINSTANCE hInst = MyGetCurrentInstance();
494+
HINSTANCE hInst = MyGetCurrentResourceInstance();
495495

496496
hGlobal = _DuplicateDialogTemplate(hInst, MAKEINTRESOURCE(m_uID));
497497
if (hGlobal == NULL)
@@ -527,7 +527,7 @@ HWND CMyDialog::CreateA(HWND hWndParent)
527527
return NULL;
528528
HGLOBAL hGlobal;
529529
HWND hRet;
530-
HINSTANCE hInst = MyGetCurrentInstance();
530+
HINSTANCE hInst = MyGetCurrentResourceInstance();
531531

532532
hGlobal = _DuplicateDialogTemplate(hInst, MAKEINTRESOURCE(m_uID));
533533
if (hGlobal == NULL)
@@ -557,7 +557,7 @@ HWND CMyDialog::CreateW(HWND hWndParent)
557557
return NULL;
558558
HGLOBAL hGlobal;
559559
HWND hRet;
560-
HINSTANCE hInst = MyGetCurrentInstance();
560+
HINSTANCE hInst = MyGetCurrentResourceInstance();
561561

562562
hGlobal = _DuplicateDialogTemplate(hInst, MAKEINTRESOURCE(m_uID));
563563
if (hGlobal == NULL)

Common/MyProp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ LPCWSTR CMyPropertyPage::GetPageTitle()
170170

171171
HGLOBAL CMyPropertyPage::GetDialogResource()
172172
{
173-
HINSTANCE hInst = MyGetCurrentInstance();
173+
HINSTANCE hInst = MyGetCurrentResourceInstance();
174174

175175
if (m_hGlobal)
176176
GlobalFree(m_hGlobal);

Common/unicode.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ static LPSTR __stdcall _MyLoadStringA(HINSTANCE hInstance, UINT uID)
3232
LPSTR szTemp, szRet;
3333
int nSize, nLen;
3434
if (!hInstance)
35-
hInstance = ::GetModuleHandle(NULL);
35+
{
36+
hInstance = MyGetCurrentResourceInstance();
37+
if (!hInstance)
38+
hInstance = ::GetModuleHandle(NULL);
39+
}
3640
szTemp = (LPSTR) malloc(sizeof(CHAR) * 256);
3741
szTemp[0] = 0;
3842
nSize = 256;
@@ -71,7 +75,7 @@ LPWSTR __stdcall UniLoadStringW(HINSTANCE hInstance, UINT uID)
7175
int nSize, nLen;
7276
if (!hInstance)
7377
{
74-
hInstance = MyGetCurrentInstance();
78+
hInstance = MyGetCurrentResourceInstance();
7579
if (!hInstance)
7680
hInstance = ::GetModuleHandle(NULL);
7781
}

EasySFTP/EasySFTP.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -727,26 +727,26 @@ HRESULT CMainApplication::InitGraphics()
727727
if (!m_hImageListFileIcon)
728728
return E_OUTOFMEMORY;
729729

730-
//m_hImageListToolBar = ::ImageList_LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_TOOLBAR),
730+
//m_hImageListToolBar = ::ImageList_LoadImage(GetResourceInstance(), MAKEINTRESOURCE(IDB_TOOLBAR),
731731
// 16, 0, CLR_NONE, IMAGE_BITMAP, LR_LOADTRANSPARENT);
732732
//if (!m_hImageListToolBar)
733733
// return false;
734734
m_hImageListToolBar = ::ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0);
735735
if (!m_hImageListToolBar)
736736
return E_OUTOFMEMORY;
737-
::ImageList_Add(m_hImageListToolBar, ::LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDB_TOOLBAR)), NULL);
737+
::ImageList_Add(m_hImageListToolBar, ::LoadBitmap(GetResourceInstance(), MAKEINTRESOURCE(IDB_TOOLBAR)), NULL);
738738
m_hImageListToolBarL = ::ImageList_Create(32, 32, ILC_COLOR32 | ILC_MASK, 0, 0);
739739
if (!m_hImageListToolBarL)
740740
return E_OUTOFMEMORY;
741-
::ImageList_Add(m_hImageListToolBarL, ::LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDB_TOOLBAR_L)), NULL);
741+
::ImageList_Add(m_hImageListToolBarL, ::LoadBitmap(GetResourceInstance(), MAKEINTRESOURCE(IDB_TOOLBAR_L)), NULL);
742742
m_hImageListAddrButtons = ::ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0);
743743
if (!m_hImageListAddrButtons)
744744
return E_OUTOFMEMORY;
745-
::ImageList_Add(m_hImageListAddrButtons, ::LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDB_ADDRESS_BUTTONS)), NULL);
745+
::ImageList_Add(m_hImageListAddrButtons, ::LoadBitmap(GetResourceInstance(), MAKEINTRESOURCE(IDB_ADDRESS_BUTTONS)), NULL);
746746
m_hImageListAddrButtonsL = ::ImageList_Create(32, 32, ILC_COLOR32 | ILC_MASK, 0, 0);
747747
if (!m_hImageListAddrButtonsL)
748748
return E_OUTOFMEMORY;
749-
::ImageList_Add(m_hImageListAddrButtonsL, ::LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDB_ADDRESS_BUTTONS_L)), NULL);
749+
::ImageList_Add(m_hImageListAddrButtonsL, ::LoadBitmap(GetResourceInstance(), MAKEINTRESOURCE(IDB_ADDRESS_BUTTONS_L)), NULL);
750750

751751
return S_OK;
752752
}
@@ -771,13 +771,13 @@ HRESULT CMainApplication::InitWindowClasses()
771771
wcex.cbClsExtra = 0;
772772
wcex.cbWndExtra = 0;
773773
wcex.hInstance = m_hInstance;
774-
wcex.hIcon = LoadIcon(m_hInstance, MAKEINTRESOURCE(IDI_EASYFTP));
774+
wcex.hIcon = LoadIcon(GetResourceInstance(), MAKEINTRESOURCE(IDI_EASYFTP));
775775
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
776776
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
777777
//wcex.hbrBackground = NULL;
778778
wcex.lpszMenuName = NULL;
779779
wcex.lpszClassName = strC;
780-
wcex.hIconSm = (HICON) LoadImage(wcex.hInstance, MAKEINTRESOURCE(IDI_EASYFTP),
780+
wcex.hIconSm = (HICON) LoadImage(GetResourceInstance(), MAKEINTRESOURCE(IDI_EASYFTP),
781781
IMAGE_ICON, 16, 16, 0);
782782

783783
if (!::RegisterClassExW(&wcex))
@@ -887,7 +887,7 @@ HRESULT CMainApplication::InitAppData()
887887
m_strTempPath += L'\\';
888888
}
889889

890-
m_hMenuPopup = MyLoadMenuW(m_hInstance, MAKEINTRESOURCEW(IDR_POPUP));
890+
m_hMenuPopup = MyLoadMenuW(GetResourceInstance(), MAKEINTRESOURCEW(IDR_POPUP));
891891

892892
m_strTitle.LoadString(IDS_APP_TITLE);
893893

0 commit comments

Comments
 (0)