Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 04/04/22 in all areas

  1. Methods are just routines with implicit 1st argument set to Self. If you're not using Self inside them, they will work. Try to add some internal string field and show it inside Ghost, then you'll get what you expect
  2. Executing method on nil reference is actually a language feature. But such method must be static and you must not access any instance fields if instance is nil. One such method is TObject.Free that can be safely called on nil reference, because it checks whether object is nil before calling other code, in this case virtual destructor that cannot be executed on nil instance. procedure TObject.Free; begin if Self <> nil then Destroy; end; Additional explanation how static method dispatching works can be found here https://dalijap.blogspot.com/2021/07/virtual-methods-in-delphi.html
  3. Delphi does not do caller site checks such as Java or .NET do.
  4. Languages that use manual memory management requires from the developers to take care about pointers. You have manually to initialize and also to free them. A bit more interesting result is with local variable: program Project1; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; type TDoSomething = class Danger: string; constructor create; function Ghost: boolean; end; var DoSomething2: TDoSomething; procedure MainProc; var DoSomething: TDoSomething; begin WriteLn('DoSomething = ',NativeInt(DoSomething)); if Assigned(DoSomething) then WriteLn('DoSomething is not nil'); WriteLn('DoSomething2 = ',NativeInt(DoSomething2)); DoSomething.Ghost; end; { TDoSomething } constructor TDoSomething.create; begin //FROM HERE I NEVER GO THERE .... AND IF I GO THERE BY WRONG, CLOSE THE PROGRAM !!! writeLn('TDoSomething.create'); end; function TDoSomething.Ghost: boolean; begin try result := true; WriteLn('Here I am, I am a ghost'); except result := false; end; end; begin try { TODO -oUser -cConsole Main : Insert code here } MainProc; ReadLn; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. DoSomething = 4318856 DoSomething is not nil DoSomething2 = 0 Here I am, I am a ghost
  5. vfbb

    ANN: Skia4Delphi v3.3.0

    v3.3.1 Fixed TSkLabel click in Vcl; Fixed bitmaps starting with garbage when using Skia4Delphi Canvas; Fixed AV in TSkLabel and TSkTextLayout in specific cases involving $13 char; Fixed AV drawing uninitialized bitmaps when using Skia4Delphi Canvas;
  6. HeikoG

    HTTPS problem

    Hello again, just for information, by now Depatisnet probably did notice that they have a problem, and did update their site once more. And now ICS works as expected, without any problem. Thanks again for your support. Heiko
  7. Angus Robertson

    Cloud storage

    I added the TSslHttpRest REST component four years ago, to speed up application development by combining several other ICS components needed for HTTPS applications together and building parameters in various ways. It is used for OAuth2 authentication, TIcsTwitter, TIcsRestEmail (Gmail and Outlook), TDnsQueryHttps, TIcsSMS, TIcsInetAlive and SSL/TLS certificate ordering TSslX509Certs. The last ICS TSslHttpRest release added various file downloading strategies, including resuming failed partial transfers, the next TSslHttpRest release will add various file uploading strategies using POST including multipart MIME with metadata content. Ideally, there will be new components to simplify access to various cloud services, ie TIcsMsAzure, TIcsGoogleCloud, TIcsAmazonCloud, TIcsOSSwift (Open Stack), TIcsMsDrive, TIcsDropbox, perhaps TIcsWebDAV if still used. I'm old-fashioned, I don't use any cloud facilities, I just have hosted Windows servers in a rack running the ICS FTP server for all my own upload and download needs. So supporting these various cloud protocols needs research and accounts, and a lot of reading and testing, and decisions of which specific APIs need support from a component. But I guess various ICS users are already using one or more of these cloud providers with their own applications, perhaps also with non-ICS components. Ideally I'd like such users to take ownership for developing and testing the component for a specific cloud service, based on a common template, while I update TSslHttpRest to support the extra features like multipart MIME needed, So is anyone using ICS for cloud storage? Angus
  8. You may use the following trick which I recently invented and applied to all my projects: 1) TEnumNullable = (enNone, enFoo, enBar); 2) TEnum = enFoo..enBar; // or Succ(Low(TEnumNullable))..High(TEnumNullable) this has following benefits: - RTTI features - "Null" value that won't cause range check errors in FPC like usual TEnum(-1) - "Null" value that is NULL (zero) actually - ZeroMemory, Default(), Class.Create init fields with this value - two types so you can differentiate where null is expected and where not - simple and obvious DB_Value_Of_Enum = Ord()
  9. My approach to these types of problems is to add a record helper for the enumeration that handles the conversion from and to Integer. type TDDArrangementId = (daOutstanding, daWeeklyGap, daAmount, daGapAmount); TDDArrangementIdHelper = record helper for TDDArrangementId private function GetAsInteger: Integer; procedure SetAsInteger(const Value: Integer); public property AsInteger: Integer read GetAsInteger write SetAsInteger; end; function TDDArrangementIdHelper.GetAsInteger: Integer; begin Result := Ord(Succ(Self)); end; procedure TDDArrangementIdHelper.SetAsInteger(const Value: Integer); begin Self := TDDArrangementId(Pred(Value)); end; The usage would then look like this: var myVar: TDDArrangementId; begin myVar.AsInteger := 1; Assert(myVar = daOutstanding); Inc(myVar); Assert(myVar = daWeeklyGap); Assert(myVar.AsInteger = 2); end.
  10. vfbb

    Skia4Delphi v3.0.0

    It is with great pleasure that we announce the new version of the Skia4Delphi library. The library has been completely rewritten in this major update and it looks amazing. v3.0.0 · Skia library version has been updated from Milestone 88 to 98; · New Skia based Canvas for FMX with GPU rendering support (optionally registered as default) accompanied by the following benefits a) Draw with anti-aliasing on any platform; (currently platforms that use TGPUCanvas like mobiles, and Mac computers when Metal is enabled do not use it) b) Increase the overall graphics performance of your application by up to 50%; (even drawing with higher quality) c) Resize images with better quality; (also based on Form.Quality) d) Support Right-To-Left rendering; e) Fix dozens of inconsistencies in drawings, especially in corners and strokes, such as dashes, and in texts with special emojis; f) Increase the performance of the library in general (controls, drawings, among others...). · Fully featured demo, with many more fantastic examples; · Added TSkLabel control with support for: multiple text styles (colors, sizes, fonts), justify alignment, font weight, families fallback, auto-size of width and height, limit number of lines, right-to-left texts, and more; · Added TSkAnimatedImage (replacing TSkLottieAnimation), with support for Lottie, Telegram Sticker, Animated GIF and Animated WebP files. · Added WrapMode property to TSkSvg; · Added full unicode support: grapheme iterators, BiDi regions, among others; · Added new features to SkParagraph; · Added SkTypefaceProvider; (custom fonts support in SkParagraph) · New codecs registered: a) VCL: svg, wbmp, webp and raw images (arw, cr2, dng, nef, nrw, orf, raf, rw2, pef and srw) b) FMX: bmp, gif, ico, wbmp, webp e raw images (arw, cr2, dng, nef, nrw, orf, raf, rw2, pef and srw) · Added support for SVG creation with the SkSVGCanvas class; · Exposed SkParticles (provides a way to quickly generate large numbers of drawing primitives with dynamic, animated behavior) · Added support for creating XPS documents (Windows-only); · Added Cross-Platform unit tests for console, VCL and FMX, with more over then 250 tests; · Added Android support for Delphi 10.3 Rio; · Added installation support via Chocolatey; · Improved the performance of Lottie animations; · Improved the performance of OverrideColor in TSkSvg; · Improved installation process; · Simplified Skia build with a simple native script; · Fixed library loading crash that occurred on some 32-bit Androids; · Fixed support for Android 32 bits in Android App Bundle (.aab) format; · Fixed iterators; (including path elements iterator) · Fixed image decoding issue; · Fixed Lottie files with static images embedded; · Fixed SVG locale-dependent (couldn't render when default decimal separator was not dot); · Fixed wrong draw of TSkCustomControl and descendents in FMX, when the property Angle was different than 0; · Fixed TSkPaintBox draw without clear the surface; · Fixed installation issue in RAD Studio Trial, Community Edition and Started versions; · Fixed installation issue in RAD Studio with very large Library Path (especially those that have the ACBr library installed); · Fixed many others minor issues; · And much more.. Compatibility break: We are in continuous development, so some updates will bring compatibility breaks. So pay attention to version numbers, we use semantic versions (for major versions there is some compatibility break). See some breaking changes in this version: a) Removed support to iOS, MacOS and Linux in RAD Studio 10.4 Sydney; b) Removed support to RAD Studio XE6; c) Removed the TSkLottieAnimation control, use the TSkAnimatedImage control instead; d) Several changes in API; Supported platforms: · RAD Studio 11.0 Alexandria: all platforms · RAD Studio 10.3 Rio or newer: windows and android · RAD Studio XE7 or newer: windows Demo: Github: github.com/skia4delphi/skia4delphi Website: skia4delphi.org
  11. enesgeven

    Delphi iOS Metal Api Comparison (Video)

    Hi, I recorded this video for see Metal Api difference, my suggestion is use Metal Api (60 FPS) on iOS projects. It is much more smooth. GlobalUseMetal:=True; GlobalEventDrivenDisplayUpdates:=False; GlobalPreferredFramesPerSecond:=60; Delphi Metal Api: http://docwiki.embarcadero.com/RADStudio/Sydney/en/FireMonkey_New_Features_and_Enhancements
  12. enesgeven

    iOS Metal Api form doesn't fit on screen

    Thank you. Yes I am doing like that on .dpr before Application.Initialize; also I tried on main form .pas initialization but both same result. I did this for temporary, when device Display Zoom setting is Zoomed not activating metal api, this will reduce performance but at least application will work. if TUIScreen.Wrap(TUIScreen.OCClass.mainScreen).nativeScale=TUIScreen.Wrap(TUIScreen.OCClass.mainScreen).Scale then begin GlobalUseMetal:=true; GlobalEventDrivenDisplayUpdates:=False; GlobalPreferredFramesPerSecond:=60; end;
  13. I've just tried your suggestion, and it works perfectly. I don't think I would ever have thought to look under .Model for a SelectText method. It even scrolls the line into view, and it works when the memo is ReadOnly too. Thank you Lajos!
×