- 2 Talk
-
Alternatives to Deprecated Methods
In recent versions of Delphi, you can use the deprecated directive to flag obsolete methods which should not be used anymore. This allows code which calls them to compile, but the compiler will emit a warning. For example, look at the following declaration from SysUtils:
procedure RaiseLastWin32Error; deprecated; // use RaiseLastOSError
If you call this method in your code, the compiler will emit a warning like this:
[Warning] Unit1.pas[28]: Symbol 'RaiseLastWin32Error' is deprecated
We can see from the comment in SysUtils that RaiseLastOSError is the intended replacement. But not all deprecated methods have such comments, so the list below is intended to help find good replacements.
Contents |
Methods Deprecated in Delphi for .NET
Edit
- AnsiStartsText
- For the WideString overload, use System.String.StartsWith()
Methods Deprecated due to Platform Compatibility
Edit
- RaiseLastWin32Error
- Use RaiseLastOSError
- IncludeTrailingBackslash/ExcludeTrailingBackslash
- Use IncludeTrailingPathDelimiter/ExcludeTrailingPathDelimiter
List of Deprecated elements in Delphi 2005
Edit
ActnMenus Unit
Edit
TCustomActionMenuBar.GetDefaultSounds;
var MenuItemControlClass: TMenuItemControlClass deprecated; MenuAddRemoveItemClass: TAddRemoveItemClass deprecated; MenuButtonControlClass: TMenuButtonControlClass deprecated; MenuPopupClass: TCustomPopupClass deprecated; MenuCustomizePopupClass: TCustomizeActionToolBarClass deprecated;
ComCtrls Unit
Edit
- CheckToolMenuDropdown
- Use TToolButton.CheckMenuDropDown
Forms Unit
Edit
- MakeObjectInstance
- Use Classes.pas version instead.
- FreeObjectInstance
- Use Classes.pas version instead.
- AllocateHWnd
- Use Classes.pas version instead.
- DeallocateHWnd
Obsolete (in Forms.pas)
Edit
- Subclass3DWnd
- Subclass3DDlg
- SetAutoSubClass
- DoneCtl3D
- InitCtl3D
StdActnMenus Unit
Edit
- RegisterStandardMenus
Deprecated Units
Edit
- OleAuto.pas
- Outline.pas
List of Deprecated elements in Delphi 7
Edit
Classes Unit
Edit
- TCollection.Added
- TCollection.Deleting
- Overwrite TCollection.Notify instead
RTLConsts Unit
Edit
Resource Strings
Edit
- SConvUnknownDescription
- No longer used
- SInvalidDate
- Moved to SysConst unit
- SInvalidDateTime
- Moved to SysConst unit
- SInvalidInteger
- Moved to SysConst unit
- SInvalidTime
- Moved to SysConst unit
- STimeEncodeError
- Moved to SysConst unit
SysConst Unit
Edit
Resource Strings
Edit
- SVarNotArray
- Use SVarInvalid instead
- SWin32Error
- Use SOSError
- SUnkWin32Error
- Use SUnkOSError
- SVarTypeUnknown
- Not used anymore
- SVarTypeOutOfRange
- Not used anymore
- SVarTypeAlreadyUsed
- Not used anymore
- SVarTypeNotUsable
- Not used anymore
- SInvalidVarOpWithHResult
- Not used anymore
System Unit (Default)
Edit
Const
Edit
- vmtAfterConstruction
- Use VMTOFFSET in asm code instead
- RaiseList
- Use AcquireExceptionObject instead
- SetRaiseList
- Use AcquireExceptionObject instead
- HPrevInst
- Cannot be tested for multiple instances in Win32
- UnicodeToUtf8
- Use overloaded alternative
- Utf8ToUnicode
- Use overloaded alternative
- TVariantManager
- See Variants unit
- GetVariantManager
- See Variants unit
- SetVariantManager
- See Variants unit
- IsVariantManagerSet
- See Variants unit
Don't use:
- vmtSafeCallException
- vmtBeforeDestruction
- vmtDispatch
- vmtDefaultHandler
- vmtNewInstance
- vmtFreeInstance
- vmtDestroy
- vmtQueryInterface
- vmtAddRef
- vmtRelease
- vmtCreateObject
Unknown:
- Mark
- Release
- TextStart
SysUtils Unit
Edit
- EStackOverflow
- EWin32Error -> use EOSError (ancestor class of EWin32Error)
- NewStr
- DisposeStr
- AssignStr
- AppendStr
- RaiseLastWin32Error
- Use RaiseLastOSError