44
55#include " ../../../Common/MyWindows.h"
66
7- #include < shlwapi .h>
7+ #include < Shlwapi .h>
88
99#include " ../../../../C/Alloc.h"
1010#ifdef _WIN32
@@ -40,19 +40,24 @@ using namespace NWindows;
4040using namespace NFile ;
4141using namespace NFind ;
4242
43- #define MAX_LOADSTRING 100
44-
45- #define MENU_HEIGHT 26
43+ // #define MAX_LOADSTRING 100
4644
45+ extern
46+ bool g_RAM_Size_Defined;
4747bool g_RAM_Size_Defined;
48- bool g_LargePagesMode = false ;
49- bool g_OpenArchive = false ;
48+
49+ static bool g_LargePagesMode = false ;
50+ // static bool g_OpenArchive = false;
5051
5152static bool g_Maximized = false ;
5253
54+ extern
55+ UInt64 g_RAM_Size;
5356UInt64 g_RAM_Size;
5457
5558#ifdef _WIN32
59+ extern
60+ HINSTANCE g_hInstance;
5661HINSTANCE g_hInstance;
5762#endif
5863
@@ -66,6 +71,8 @@ void FreeGlobalCodecs();
6671
6772#ifndef UNDER_CE
6873
74+ extern
75+ DWORD g_ComCtl32Version;
6976DWORD g_ComCtl32Version;
7077
7178static DWORD GetDllVersion (LPCTSTR dllName)
@@ -74,7 +81,7 @@ static DWORD GetDllVersion(LPCTSTR dllName)
7481 HINSTANCE hinstDll = LoadLibrary (dllName);
7582 if (hinstDll)
7683 {
77- DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress (hinstDll, " DllGetVersion" );
84+ DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)( void *) GetProcAddress (hinstDll, " DllGetVersion" );
7885 if (pDllGetVersion)
7986 {
8087 DLLVERSIONINFO dvi;
@@ -93,19 +100,19 @@ static DWORD GetDllVersion(LPCTSTR dllName)
93100
94101bool g_IsSmallScreen = false ;
95102
103+ extern
104+ bool g_LVN_ITEMACTIVATE_Support;
96105bool g_LVN_ITEMACTIVATE_Support = true ;
97106// LVN_ITEMACTIVATE replaces both NM_DBLCLK & NM_RETURN
98107// Windows 2000
99108// NT/98 + IE 3 (g_ComCtl32Version >= 4.70)
100109
101110
102- const int kNumDefaultPanels = 1 ;
111+ static const int kNumDefaultPanels = 1 ;
112+ static const int kSplitterWidth = 4 ;
113+ static const int kSplitterRateMax = 1 << 16 ;
114+ static const int kPanelSizeMin = 120 ;
103115
104- const int kSplitterWidth = 4 ;
105- int kSplitterRateMax = 1 << 16 ;
106- int kPanelSizeMin = 120 ;
107-
108- // bool OnMenuCommand(HWND hWnd, int id);
109116
110117class CSplitterPos
111118{
@@ -218,7 +225,7 @@ static BOOL InitInstance(int nCmdShow)
218225
219226 // wc.hCursor = LoadCursor (NULL, IDC_ARROW);
220227 wc.hCursor = ::LoadCursor (0 , IDC_SIZEWE);
221-
228+
222229 if (_ShouldAppsUseDarkMode ())
223230 wc.hbrBackground =greybrush;
224231 else
@@ -348,7 +355,7 @@ typedef BOOL (WINAPI *Func_IsWow64Process)(HANDLE, PBOOL);
348355static void Set_Wow64 ()
349356{
350357 g_Is_Wow64 = false ;
351- Func_IsWow64Process fnIsWow64Process = (Func_IsWow64Process)GetProcAddress (
358+ Func_IsWow64Process fnIsWow64Process = (Func_IsWow64Process)( void *) GetProcAddress (
352359 GetModuleHandleA (" kernel32.dll" ), " IsWow64Process" );
353360 if (fnIsWow64Process)
354361 {
@@ -361,6 +368,7 @@ static void Set_Wow64()
361368#endif
362369
363370
371+ bool IsLargePageSupported ();
364372bool IsLargePageSupported ()
365373{
366374 #ifdef _WIN64
@@ -388,7 +396,7 @@ static void SetMemoryLock()
388396 if (!IsLargePageSupported ())
389397 return ;
390398 // if (ReadLockMemoryAdd())
391- NSecurity::AddLockMemoryPrivilege ();
399+ NSecurity::AddLockMemoryPrivilege ();
392400
393401 if (ReadLockMemoryEnable ())
394402 if (NSecurity::Get_LargePages_RiskLevel () == 0 )
@@ -398,6 +406,8 @@ static void SetMemoryLock()
398406 }
399407}
400408
409+ extern
410+ bool g_SymLink_Supported;
401411bool g_SymLink_Supported = false ;
402412
403413static void Set_SymLink_Supported ()
@@ -448,14 +458,19 @@ static void ErrorMessage(const char *s)
448458}
449459
450460
461+ #if defined(_UNICODE) && !defined(_WIN64) && !defined(UNDER_CE)
451462#define NT_CHECK_FAIL_ACTION ErrorMessage (" Unsupported Windows version" ); return 1 ;
463+ #endif
452464
453465#include " Detours.h"
454466#include < assert.h>
455467#include " EditorUIDarkMode.h"
456468
469+ #if _WIN64
470+ #pragma comment(lib, "detours64.lib")
471+ #else
457472#pragma comment(lib, "detours.lib")
458-
473+ # endif
459474
460475static int WINAPI WinMain2 (int nCmdShow)
461476{
@@ -487,7 +502,6 @@ static int WINAPI WinMain2(int nCmdShow)
487502 #endif
488503 */
489504
490-
491505 NT_CHECK
492506 SetLargePageSize ();
493507
@@ -499,9 +513,9 @@ static int WINAPI WinMain2(int nCmdShow)
499513 EditorUIDarkMode::InitializeThread (); // for black background
500514
501515 auto comDll = (uintptr_t )GetModuleHandle (L" comctl32.dll" );
502- assert (comDll);
516+ assert (comDll);
503517
504- // these two lines are for background color
518+ // these two lines are for background color
505519 Detours::IATHook (comDll, " USER32.dll" , " GetSysColor" , (uintptr_t )&EditorUIDarkMode::Comctl32GetSysColor);
506520 Detours::IATHook (comDll, " USER32.dll" , " GetSysColorBrush" , (uintptr_t )&EditorUIDarkMode::Comctl32GetSysColorBrush);
507521
@@ -785,12 +799,12 @@ static void ExecuteCommand(UINT commandID)
785799
786800LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
787801{
788- int wmId, wmEvent;
789802 switch (message)
790803 {
791804 case WM_COMMAND:
792- wmId = LOWORD (wParam);
793- wmEvent = HIWORD (wParam);
805+ {
806+ unsigned wmId = LOWORD (wParam);
807+ unsigned wmEvent = HIWORD (wParam);
794808 if ((HWND) lParam != NULL && wmEvent != 0 )
795809 break ;
796810 if (wmId >= kMenuCmdID_Toolbar_Start && wmId < kMenuCmdID_Toolbar_End )
@@ -801,6 +815,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
801815 if (OnMenuCommand (hWnd, wmId))
802816 return 0 ;
803817 break ;
818+ }
804819 case WM_INITMENUPOPUP:
805820 OnMenuActivating (hWnd, HMENU (wParam), LOWORD (lParam));
806821 break ;
@@ -820,12 +835,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
820835 case WM_CREATE:
821836 {
822837 g_HWND = hWnd;
823-
824- if (g_darkModeSupported)
838+
839+ if (g_darkModeSupported)
825840 {
826841 _AllowDarkModeForWindow (hWnd, true );
827842 RefreshTitleBarThemeColor (hWnd);
828843 }
844+
829845 /*
830846 INITCOMMONCONTROLSEX icex;
831847 icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
@@ -872,9 +888,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
872888
873889 g_App.CreateDragTarget ();
874890
875- bool archiveIsOpened;
876- bool encrypted;
877- bool needOpenFile = false ;
891+ COpenResult openRes;
892+ bool needOpenArc = false ;
878893
879894 UString fullPath = g_MainPath;
880895 if (!fullPath.IsEmpty () /* && g_OpenArchive */ )
@@ -885,29 +900,34 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
885900 if (NFile::NName::GetFullPath (us2fs (fullPath), fullPathF))
886901 fullPath = fs2us (fullPathF);
887902 }
888- if (NFile::NFind::DoesFileExist (us2fs (fullPath)))
889- needOpenFile = true ;
903+ if (NFile::NFind::DoesFileExist_FollowLink (us2fs (fullPath)))
904+ needOpenArc = true ;
890905 }
891906
892907 HRESULT res = g_App.Create (hWnd, fullPath, g_ArcFormat, xSizes,
893- needOpenFile ,
894- archiveIsOpened, encrypted );
908+ needOpenArc ,
909+ openRes );
895910
896911 if (res == E_ABORT)
897912 return -1 ;
898913
899- if (needOpenFile && !archiveIsOpened || res != S_OK)
914+ if ((needOpenArc && !openRes. ArchiveIsOpened ) || res != S_OK)
900915 {
901916 UString m (" Error" );
902917 if (res == S_FALSE || res == S_OK)
903918 {
904- m = MyFormatNew (encrypted ?
919+ m = MyFormatNew (openRes. Encrypted ?
905920 IDS_CANT_OPEN_ENCRYPTED_ARCHIVE :
906921 IDS_CANT_OPEN_ARCHIVE,
907922 fullPath);
908923 }
909924 else if (res != S_OK)
910925 m = HResultToMessage (res);
926+ if (!openRes.ErrorMessage .IsEmpty ())
927+ {
928+ m.Add_LF ();
929+ m += openRes.ErrorMessage ;
930+ }
911931 ErrorMessage (m);
912932 return -1 ;
913933 }
@@ -989,7 +1009,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
9891009 g_Panel[1]._listView.MoveWindow(xSize - xWidth, 0, xWidth, ySize);
9901010 */
9911011 return 0 ;
992- break ;
1012+ // break;
9931013 }
9941014
9951015 case WM_SETFOCUS:
@@ -1020,9 +1040,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
10201040 return 0;
10211041 */
10221042
1023-
1024-
1025-
1043+ /*
1044+ case WM_SETTINGCHANGE:
1045+ break;
1046+ */
10261047
10271048 case WM_NOTIFY:
10281049 {
0 commit comments