|
@@ -30,9 +30,12 @@ implementation
|
|
|
|
|
|
uses
|
|
|
Classes, SysUtils, Win32Int, WSLCLClasses, Forms, Windows, Win32Proc,
|
|
|
- Controls, LCLType, fMain, Win32WSControls, uImport;
|
|
|
+ Controls, LCLType, fMain, Win32WSControls, uImport
|
|
|
+{$IF DEFINED(DARKWIN)}
|
|
|
+ , uDarkStyle
|
|
|
+{$ENDIF}
|
|
|
+ ;
|
|
|
|
|
|
-{$IF NOT DEFINED(DARKWIN)}
|
|
|
const
|
|
|
ClassNameW: PWideChar = 'TTOTAL_CMD'; // for compatibility with plugins
|
|
|
|
|
@@ -54,14 +57,11 @@ begin
|
|
|
end;
|
|
|
Result := Windows.RegisterClassW(@WindowClassW) <> 0;
|
|
|
end;
|
|
|
-{$ENDIF}
|
|
|
|
|
|
var
|
|
|
__GetProp: function(hWnd: HWND; lpString: LPCSTR): HANDLE; stdcall;
|
|
|
__SetProp: function(hWnd: HWND; lpString: LPCSTR; hData: HANDLE): WINBOOL; stdcall;
|
|
|
-{$IF NOT DEFINED(DARKWIN)}
|
|
|
__CreateWindowExW: function(dwExStyle: DWORD; lpClassName: LPCWSTR; lpWindowName: LPCWSTR; dwStyle: DWORD; X: longint; Y: longint; nWidth: longint; nHeight: longint; hWndParent: HWND; hMenu: HMENU; hInstance: HINST; lpParam: LPVOID): HWND; stdcall;
|
|
|
-{$ENDIF}
|
|
|
|
|
|
function _GetProp(hWnd: HWND; lpString: LPCSTR): HANDLE; stdcall;
|
|
|
var
|
|
@@ -83,7 +83,6 @@ begin
|
|
|
Result:= __SetProp(hWnd, lpString, hData);
|
|
|
end;
|
|
|
|
|
|
-{$IF NOT DEFINED(DARKWIN)}
|
|
|
function _CreateWindowExW(dwExStyle: DWORD; lpClassName: LPCWSTR; lpWindowName: LPCWSTR; dwStyle: DWORD; X: longint; Y: longint; nWidth: longint; nHeight: longint; hWndParent: HWND; hMenu: HMENU; hInstance: HINST; lpParam: LPVOID): HWND; stdcall;
|
|
|
var
|
|
|
AParams: PNCCreateParams absolute lpParam;
|
|
@@ -91,7 +90,6 @@ begin
|
|
|
if (hWndParent = 0) and Assigned(AParams) and (AParams^.WinControl is TfrmMain) then lpClassName:= ClassNameW;
|
|
|
Result:= __CreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
|
|
|
end;
|
|
|
-{$ENDIF}
|
|
|
|
|
|
procedure Initialize;
|
|
|
var
|
|
@@ -103,14 +101,17 @@ begin
|
|
|
begin
|
|
|
hModule:= GetModuleHandle(user32);
|
|
|
|
|
|
-{$IF NOT DEFINED(DARKWIN)}
|
|
|
- pFunction:= FindImportFunction(pLibrary, GetProcAddress(hModule, 'CreateWindowExW'));
|
|
|
- if Assigned(pFunction) then
|
|
|
+{$IF DEFINED(DARKWIN)}
|
|
|
+ if not g_darkModeEnabled then
|
|
|
+{$ENDIF}
|
|
|
begin
|
|
|
- WinRegister;
|
|
|
- Pointer(__CreateWindowExW):= ReplaceImportFunction(pFunction, @_CreateWindowExW);
|
|
|
+ pFunction:= FindImportFunction(pLibrary, GetProcAddress(hModule, 'CreateWindowExW'));
|
|
|
+ if Assigned(pFunction) then
|
|
|
+ begin
|
|
|
+ WinRegister;
|
|
|
+ Pointer(__CreateWindowExW):= ReplaceImportFunction(pFunction, @_CreateWindowExW);
|
|
|
+ end;
|
|
|
end;
|
|
|
-{$ENDIF}
|
|
|
|
|
|
// Prevent plugins written in Lazarus from crashing by changing the name for
|
|
|
// GetProp/SetProp to store control data from 'WinControl' to 'WinControlDC'
|
|
@@ -134,10 +135,10 @@ end;
|
|
|
initialization
|
|
|
Initialize;
|
|
|
|
|
|
-{$IF NOT DEFINED(DARKWIN)}
|
|
|
finalization
|
|
|
- Windows.UnregisterClassW(PWideChar(ClassNameW), System.HInstance);
|
|
|
+{$IF DEFINED(DARKWIN)}
|
|
|
+ if not g_darkModeEnabled then
|
|
|
{$ENDIF}
|
|
|
+ Windows.UnregisterClassW(PWideChar(ClassNameW), System.HInstance);
|
|
|
|
|
|
end.
|
|
|
-
|