Skip to content

Commit a26be57

Browse files
authored
Merge pull request #10 from yener90/master
Add v21.07 & 64bit support
2 parents 0d4ad49 + 0c1fde5 commit a26be57

7 files changed

Lines changed: 201 additions & 107 deletions

File tree

huans7z/7zip/UI/FileManager/EditorUIDarkMode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ namespace EditorUIDarkMode
637637
{ pRect->right - 2, pRect->bottom - 2 + i },
638638
}};
639639

640-
PolyPolyline(hdc, verts.data(), counts.data(), counts.size());
640+
PolyPolyline(hdc, verts.data(), counts.data(), (DWORD)counts.size());
641641
}
642642

643643
// Fill background on hover (1px padding for border shadow)

huans7z/7zip/UI/FileManager/FM.cpp

Lines changed: 59 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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;
4040
using namespace NFile;
4141
using 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;
4747
bool 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

5152
static bool g_Maximized = false;
5253

54+
extern
55+
UInt64 g_RAM_Size;
5356
UInt64 g_RAM_Size;
5457

5558
#ifdef _WIN32
59+
extern
60+
HINSTANCE g_hInstance;
5661
HINSTANCE g_hInstance;
5762
#endif
5863

@@ -66,6 +71,8 @@ void FreeGlobalCodecs();
6671

6772
#ifndef UNDER_CE
6873

74+
extern
75+
DWORD g_ComCtl32Version;
6976
DWORD g_ComCtl32Version;
7077

7178
static 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

94101
bool g_IsSmallScreen = false;
95102

103+
extern
104+
bool g_LVN_ITEMACTIVATE_Support;
96105
bool 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

110117
class 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);
348355
static 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();
364372
bool 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;
401411
bool g_SymLink_Supported = false;
402412

403413
static 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

460475
static 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

786800
LRESULT 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
{

huans7z/7zip/UI/FileManager/FM.mak

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LIBS = $(LIBS) ceshell.lib Commctrl.lib
77
!ELSE
88
LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib
99
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -DSUPPORT_DEVICE_FILE
10-
LFLAGS = $(LFLAGS) /DELAYLOAD:mpr.dll
11-
LIBS = $(LIBS) delayimp.lib
10+
LFLAGS = $(LFLAGS) /DELAYLOAD:mpr.dll
11+
LIBS = $(LIBS) delayimp.lib
1212
!ENDIF
1313

1414
FM_OBJS = \
@@ -73,7 +73,8 @@ FM_OBJS = \
7373
$O\Darkmode.obj \
7474
$O\IatHook.obj \
7575
$O\EditorUIDarkMode.obj \
76-
76+
$O\VerCtrl.obj \
77+
7778
!IFNDEF UNDER_CE
7879

7980
FM_OBJS = $(FM_OBJS) \

0 commit comments

Comments
 (0)