Przeglądaj źródła

Removing redundant Windows XP-compatibility code (BCB11 does not support XP)

Source commit: 6442ebecf7dd5c6f45ffa9ef4ea34b82cf7ac95a
Martin Prikryl 10 miesięcy temu
rodzic
commit
9345fadc52

+ 5 - 79
source/core/Common.cpp

@@ -1079,17 +1079,6 @@ static int __fastcall PathRootLength(UnicodeString Path)
   return (Buffer != NULL) ? (Buffer - Result.c_str()) : -1;
 }
 //---------------------------------------------------------------------------
-static bool __fastcall PathIsRelative_CorrectedForMicrosoftStupidity(UnicodeString Path)
-{
-  // Correction for PathIsRelative API
-
-  // Replace all /'s with \'s because PathIsRelative can't handle /'s
-  UnicodeString Result = ReplaceChar(Path, L'/', L'\\');
-
-  //Now call the API
-  return PathIsRelative(Result.c_str());
-}
-//---------------------------------------------------------------------------
 static int __fastcall GetOffsetAfterPathRoot(UnicodeString Path, PATH_PREFIX_TYPE & PrefixType)
 {
   // Checks if 'pPath' begins with the drive, share, prefix, etc
@@ -1112,17 +1101,11 @@ static int __fastcall GetOffsetAfterPathRoot(UnicodeString Path, PATH_PREFIX_TYP
   {
     int Len = Path.Length();
 
-    bool WinXPOnly = !IsWinVista();
-
-    // The PathSkipRoot() API doesn't work correctly on Windows XP
-    if (!WinXPOnly)
+    // Works since Vista and up, but still needs correction :)
+    int RootLength = PathRootLength(Path);
+    if (RootLength >= 0)
     {
-      // Works since Vista and up, but still needs correction :)
-      int RootLength = PathRootLength(Path);
-      if (RootLength >= 0)
-      {
-        Result = RootLength + 1;
-      }
+      Result = RootLength + 1;
     }
 
     // Now determine the type of prefix
@@ -1141,12 +1124,6 @@ static int __fastcall GetOffsetAfterPathRoot(UnicodeString Path, PATH_PREFIX_TYP
       // Found \\?\UNC\ prefix
       PrefixType = PPT_LONG_UNICODE_UNC;
 
-      if (WinXPOnly)
-      {
-          //For older OS
-          Result += 8;
-      }
-
       //Check for UNC share later
       IndCheckUNC = 8;
     }
@@ -1158,12 +1135,6 @@ static int __fastcall GetOffsetAfterPathRoot(UnicodeString Path, PATH_PREFIX_TYP
     {
       // Found \\?\ prefix
       PrefixType = PPT_LONG_UNICODE;
-
-      if (WinXPOnly)
-      {
-          //For older OS
-          Result += 4;
-      }
     }
     else if ((Len >= 2) &&
         (Path[1] == L'\\' || Path[1] == L'/') &&
@@ -1191,12 +1162,6 @@ static int __fastcall GetOffsetAfterPathRoot(UnicodeString Path, PATH_PREFIX_TYP
               {
                 PrefixType = PPT_UNC;
               }
-
-              if (WinXPOnly)
-              {
-                  //For older OS
-                  Result = Index;
-              }
             }
 
             break;
@@ -1204,36 +1169,6 @@ static int __fastcall GetOffsetAfterPathRoot(UnicodeString Path, PATH_PREFIX_TYP
         }
       }
     }
-
-    if (WinXPOnly)
-    {
-      // Only if we didn't determine any other type
-      if (PrefixType == PPT_UNKNOWN)
-      {
-        if (!PathIsRelative_CorrectedForMicrosoftStupidity(Path.SubString(Result, Path.Length() - Result + 1)))
-        {
-          PrefixType = PPT_ABSOLUTE;
-        }
-      }
-
-      // For older OS only
-      int RootLength = PathRootLength(Path.SubString(Result, Path.Length() - Result + 1));
-      if (RootLength >= 0)
-      {
-        Result = RootLength + 1;
-      }
-    }
-    else
-    {
-      // Only if we didn't determine any other type
-      if (PrefixType == PPT_UNKNOWN)
-      {
-        if (!PathIsRelative_CorrectedForMicrosoftStupidity(Path))
-        {
-          PrefixType = PPT_ABSOLUTE;
-        }
-      }
-    }
   }
 
   return Result;
@@ -1666,7 +1601,7 @@ int __fastcall FileGetAttrFix(const UnicodeString & FileName)
     // FileGetAttr when called for link with FollowLink set (default) will always fail on pre-Vista
     // as it calls InternalGetFileNameFromSymLink, which test for CheckWin32Version(6, 0)
     Result = GetFileAttributes(FileName.c_str());
-    if ((Result >= 0) && FLAGSET(Result, faSymLink) && IsWinVista())
+    if ((Result >= 0) && FLAGSET(Result, faSymLink))
     {
       try
       {
@@ -3075,15 +3010,6 @@ void AddToShellFileListCommandLine(UnicodeString & List, const UnicodeString & V
   AddToList(List, Arg, L" ");
 }
 //---------------------------------------------------------------------------
-bool __fastcall IsWinVista()
-{
-  // Vista is 6.0
-  // Win XP is 5.1
-  // There also 5.2, what is Windows 2003 or Windows XP 64bit
-  // (we consider it WinXP for now)
-  return CheckWin32Version(6, 0);
-}
-//---------------------------------------------------------------------------
 bool __fastcall IsWin7()
 {
   return CheckWin32Version(6, 1);

+ 0 - 1
source/core/Common.h

@@ -145,7 +145,6 @@ bool __fastcall CutTokenEx(UnicodeString & Str, UnicodeString & Token,
   UnicodeString * RawToken = NULL, UnicodeString * Separator = NULL);
 void __fastcall AddToList(UnicodeString & List, const UnicodeString & Value, const UnicodeString & Delimiter);
 void AddToShellFileListCommandLine(UnicodeString & List, const UnicodeString & Value);
-bool __fastcall IsWinVista();
 bool __fastcall IsWin7();
 bool __fastcall IsWin8();
 bool __fastcall IsWin10();

+ 1 - 9
source/forms/Copy.cpp

@@ -128,7 +128,6 @@ __fastcall TCopyDialog::TCopyDialog(
   FPresetsMenu = new TPopupMenu(this);
 
   HotTrackLabel(CopyParamLabel);
-  CopyParamListButton(TransferSettingsButton);
   HotTrackLabel(ShortCutHintLabel);
 
   if (FLAGSET(FOptions, coBrowse))
@@ -501,14 +500,7 @@ void __fastcall TCopyDialog::ControlChange(TObject * /*Sender*/)
 //---------------------------------------------------------------------------
 void __fastcall TCopyDialog::TransferSettingsButtonClick(TObject * /*Sender*/)
 {
-  if (!SupportsSplitButton())
-  {
-    CopyParamListPopup(CalculatePopupRect(TransferSettingsButton), 0);
-  }
-  else
-  {
-    CopyParamGroupClick(NULL);
-  }
+  CopyParamGroupClick(NULL);
 }
 //---------------------------------------------------------------------------
 void __fastcall TCopyDialog::GenerateCode()

+ 1 - 9
source/forms/FullSynchronize.cpp

@@ -74,7 +74,6 @@ __fastcall TFullSynchronizeDialog::TFullSynchronizeDialog(TComponent* Owner)
   FPresetsMenu = new TPopupMenu(this);
   FSynchronizeBySizeCaption = SynchronizeBySizeCheck->Caption;
   HotTrackLabel(CopyParamLabel);
-  CopyParamListButton(TransferSettingsButton);
   LoadDialogImage(Image, L"Synchronize directories");
 }
 //---------------------------------------------------------------------------
@@ -344,14 +343,7 @@ void __fastcall TFullSynchronizeDialog::CopyParamListPopup(TRect R, int Addition
 void __fastcall TFullSynchronizeDialog::TransferSettingsButtonClick(
   TObject * /*Sender*/)
 {
-  if (FLAGCLEAR(FOptions, fsoDoNotUsePresets) && !SupportsSplitButton())
-  {
-    CopyParamListPopup(CalculatePopupRect(TransferSettingsButton), 0);
-  }
-  else
-  {
-    CopyParamGroupClick(NULL);
-  }
+  CopyParamGroupClick(NULL);
 }
 //---------------------------------------------------------------------------
 void __fastcall TFullSynchronizeDialog::CopyParamClick(TObject * Sender)

+ 2 - 3
source/forms/MessageDlg.cpp

@@ -498,7 +498,7 @@ TButton * __fastcall TMessageForm::CreateButton(
     &TextRect, DT_CALCRECT | DT_LEFT | DT_SINGLELINE |
     DrawTextBiDiModeFlagsReadingOnly());
   int CurButtonWidth = TextRect.Right - TextRect.Left + ScaleByTextHeightRunTime(this, 16);
-  if (ElevationRequired && IsVista())
+  if (ElevationRequired)
   {
     // Elevation icon
     CurButtonWidth += ScaleByTextHeightRunTime(this, 16);
@@ -510,8 +510,7 @@ TButton * __fastcall TMessageForm::CreateButton(
 
   TButton * Button = NULL;
 
-  if (SupportsSplitButton() &&
-      (GroupWith >= 0) &&
+  if ((GroupWith >= 0) &&
       DebugAlwaysTrue(AnswerButtons.find(GroupWith) != AnswerButtons.end()))
   {
     TButton * GroupWithButton = AnswerButtons[GroupWith];

+ 0 - 1
source/forms/Preferences.cpp

@@ -1501,7 +1501,6 @@ void __fastcall TPreferencesDialog::UpdateControls()
 
     // integration
     EnableControl(ShellIconsGroup, !IsUWP());
-    MakeDefaultHandlerItem->Visible = IsWinVista();
 
     // languages
     LanguageChangeLabel->Visible =

+ 1 - 9
source/forms/Synchronize.cpp

@@ -89,7 +89,6 @@ __fastcall TSynchronizeDialog::TSynchronizeDialog(TComponent * Owner)
   FSynchronizeOptions = NULL;
 
   HotTrackLabel(CopyParamLabel);
-  CopyParamListButton(TransferSettingsButton);
   LoadDialogImage(Image, L"Keep remote directory up to date");
 
   SetGlobalMinimizeHandler(this, GlobalMinimize);
@@ -309,14 +308,7 @@ void __fastcall TSynchronizeDialog::CopyParamListPopup(TRect R, int AdditionalOp
 void __fastcall TSynchronizeDialog::TransferSettingsButtonClick(
   TObject * /*Sender*/)
 {
-  if (FLAGCLEAR(FOptions, soDoNotUsePresets) && !SupportsSplitButton())
-  {
-    CopyParamListPopup(CalculatePopupRect(TransferSettingsButton), 0);
-  }
-  else
-  {
-    CopyParamGroupClick(NULL);
-  }
+  CopyParamGroupClick(NULL);
 }
 //---------------------------------------------------------------------------
 void __fastcall TSynchronizeDialog::DoStartStop(bool Start, bool Synchronize)

+ 0 - 26
source/packages/filemng/CustomDirView.pas

@@ -175,7 +175,6 @@ type
     FDarkMode: Boolean;
     FScrollOnDragOver: TListViewScrollOnDragOver;
     FStatusFileInfo: TStatusFileInfo;
-    FDoubleBufferedScrollingWorkaround: Boolean;
     FOnBusy: TDirViewBusy;
     FOnChangeFocus: TDirViewChangeFocusEvent;
     FFallbackThumbnail: array[Boolean] of TBitmap;
@@ -184,7 +183,6 @@ type
 
     procedure CNNotify(var Message: TWMNotify); message CN_NOTIFY;
     procedure WMNotify(var Msg: TWMNotify); message WM_NOTIFY;
-    procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN;
     procedure WMLButtonDblClk(var Message: TWMLButtonDblClk); message WM_LBUTTONDBLCLK;
     procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP;
     procedure WMContextMenu(var Message: TWMContextMenu); message WM_CONTEXTMENU;
@@ -889,7 +887,6 @@ begin
   FNaturalOrderNumericalSorting := True;
   FAlwaysSortDirectoriesByName := False;
   FDarkMode := False;
-  FDoubleBufferedScrollingWorkaround := not IsVistaHard();
 
   FOnHistoryChange := nil;
   FOnPathChange := nil;
@@ -1663,29 +1660,6 @@ begin
     OnGetOverlay(Self, Item, Result);
 end;
 
-procedure TCustomDirView.WMKeyDown(var Message: TWMKeyDown);
-begin
-  if DoubleBuffered and (Message.CharCode in [VK_PRIOR, VK_NEXT]) and
-     FDoubleBufferedScrollingWorkaround then
-  begin
-    // WORKAROUND
-    // When scrolling with double-buffering enabled, ugly artefacts
-    // are shown temporarily.
-    // LVS_EX_TRANSPARENTBKGND fixes it on Vista and newer
-    LockDrawing;
-    try
-      inherited;
-    finally
-      UnlockDrawing;
-    end;
-    Repaint;
-  end
-    else
-  begin
-    inherited;
-  end;
-end;
-
 procedure TCustomDirView.DoDisplayPropertiesMenu;
 begin
   if not IsBusy then

+ 1 - 1
source/packages/filemng/DirView.pas

@@ -2511,7 +2511,7 @@ begin
       Assert(Assigned(Item.Data));
       ItemData := PFileRec(Item.Data);
 
-      Invisible := IsVista and (not IsItemVisible(Item));
+      Invisible := not IsItemVisible(Item);
 
       if (Invisible or (not FThumbnail)) and
          (not Assigned(ItemData.Thumbnail)) then

+ 5 - 5
source/packages/my/NortonLikeListView.pas

@@ -129,12 +129,12 @@ begin
   FUpdatingSelection := 0;
   FFocusingItem := False;
   FLastSelectMethod := smNoneYet;
-  // On Windows Vista, native GetNextItem for selection stops working once we
-  // disallow deselecting any item (see ExCanChange).
+  // Since Windows Vista, native GetNextItem for selection stops working
+  // once we disallow deselecting any item (see ExCanChange).
   // So we need to manage selection state ourselves
-  // cannot use Win32MajorVersion as it is affected by compatibility mode and
-  // the bug is present even in compatibility mode
-  FManageSelection := IsVistaHard;
+  // All supported Windows versions have the bug (last time tested on Windows 11 23H2 22631),
+  // keeping the variable only as a way to tag all related code
+  FManageSelection := True;
   FFocused := 0;
   FIgnoreSetFocusFrom := INVALID_HANDLE_VALUE;
   // On Windows 7 we have to force item update when it looses focus,

+ 0 - 16
source/packages/my/PasTools.pas

@@ -9,10 +9,6 @@ uses
 
 function Construct(ComponentClass: TComponentClass; Owner: TComponent): TComponent;
 
-function IsVistaHard: Boolean;
-
-function IsVista: Boolean;
-
 {$EXTERNALSYM IsWin7}
 function IsWin7: Boolean;
 
@@ -173,18 +169,6 @@ begin
   Result := ComponentClass.Create(Owner);
 end;
 
-// detects vista, even in compatibility mode
-// (GetLocaleInfoEx is available since Vista only)
-function IsVistaHard: Boolean;
-begin
-  Result := (GetProcAddress(GetModuleHandle(Kernel32), 'GetLocaleInfoEx') <> nil);
-end;
-
-function IsVista: Boolean;
-begin
-  Result := CheckWin32Version(6, 0);
-end;
-
 function IsWin7: Boolean;
 begin
   Result := CheckWin32Version(6, 1);

+ 3 - 15
source/windows/Setup.cpp

@@ -681,16 +681,8 @@ static void __fastcall NotifyChangedAssociations()
 void __fastcall RegisterForDefaultProtocols()
 {
   AppLog(L"Registering to handle protocol URL addresses");
-  if (IsWinVista())
-  {
-    AppLog(L"Registering as default program");
-    RegisterForDefaultPrograms();
-  }
-  else
-  {
-    AppLog(L"Registering for non-browser protocols");
-    RegisterAsNonBrowserUrlHandler(UnicodeString());
-  }
+  AppLog(L"Registering as default program");
+  RegisterForDefaultPrograms();
 
   AppLog(L"Registering for non-browser protocols with prefix");
   RegisterAsNonBrowserUrlHandler(WinSCPProtocolPrefix);
@@ -729,8 +721,6 @@ void __fastcall UnregisterForProtocols()
 //---------------------------------------------------------------------------
 void __fastcall LaunchAdvancedAssociationUI()
 {
-  DebugAssert(IsWinVista());
-
   RegisterForDefaultPrograms();
   NotifyChangedAssociations();
   // sleep recommended by https://learn.microsoft.com/en-us/windows/win32/shell/default-programs#becoming-the-default-browser
@@ -1818,9 +1808,7 @@ bool __fastcall CheckForUpdates(bool CachedResults)
 
   if (New)
   {
-    // Internet Explorer on Windows XP cannot talk to CDN77, where we host Store Get button.
-    // As a simple solution, we just do not display the donation panel on Windows XP.
-    if (Updates.Results.DownloadUrl.IsEmpty() && IsInstalled() && IsWinVista())
+    if (Updates.Results.DownloadUrl.IsEmpty() && IsInstalled())
     {
       DebugAssert(Dialog->OnShow == NULL);
       // InsertDonateLink need to be called only after MessageBrowser is created

+ 0 - 5
source/windows/VCLCommon.cpp

@@ -2383,11 +2383,6 @@ TForm * __fastcall _SafeFormCreate(TMetaClass * FormClass, TComponent * Owner)
   return Form;
 }
 //---------------------------------------------------------------------------
-bool __fastcall SupportsSplitButton()
-{
-  return (Win32MajorVersion() >= 6);
-}
-//---------------------------------------------------------------------------
 static TButton * __fastcall FindStandardButton(TWinControl * Control, bool Default)
 {
   TButton * Result = NULL;

+ 0 - 1
source/windows/VCLCommon.h

@@ -71,7 +71,6 @@ FormType * __fastcall SafeFormCreate(TComponent * Owner = NULL)
 {
   return dynamic_cast<FormType *>(_SafeFormCreate(__classid(FormType), Owner));
 }
-bool __fastcall SupportsSplitButton();
 TModalResult __fastcall DefaultResult(TCustomForm * Form, TButton * DefaultButton = NULL);
 void __fastcall DefaultButton(TButton * Button, bool Default);
 void __fastcall MemoKeyDown(TObject * Sender, WORD & Key, TShiftState Shift);

+ 0 - 8
source/windows/WinInterface.cpp

@@ -763,14 +763,6 @@ bool __fastcall ProcessGUI(bool Force)
   return Result;
 }
 //---------------------------------------------------------------------------
-void __fastcall CopyParamListButton(TButton * Button)
-{
-  if (!SupportsSplitButton())
-  {
-    MenuButton(Button);
-  }
-}
-//---------------------------------------------------------------------------
 const int cpiDefault = -1;
 const int cpiConfigure = -2;
 const int cpiCustom = -3;

+ 0 - 1
source/windows/WinInterface.h

@@ -489,7 +489,6 @@ void __fastcall DoGenerateTransferCodeDialog(
   bool ToRemote, bool Move, int CopyParamAttrs, TSessionData * Data, TFilesSelected FilesSelected,
   TStrings * FileList, const UnicodeString & Path, const TCopyParamType & CopyParam);
 
-void __fastcall CopyParamListButton(TButton * Button);
 const int cplNone =             0x00;
 const int cplCustomizeDefault = 0x02;
 const int cplSaveSettings =     0x04;