Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 11/13/19 in all areas

  1. Anders Melander

    Saving registry keys

    Additionally, RegSaveKey doesn't save in .reg format but in registry hive format. There is no API for saving in .reg format.
  2. Remy Lebeau

    Sending Email via GMail Using OAuth 2.0 via Indy

    2FA is a good thing. And no, you don't actually need to authenticate every login. An app-specific password is meant to be used in only 1 location and shouldn't be passed around. You can set Google to remember where the password is being used from so you don't have to re-authenticate every time it is used from that location. I use app-specific passwords when testing Indy with GMail (POP3, SMTP, and IMAP) and don't have to re-authenticate each time.
  3. Fr0sT.Brutal

    How to manage defined list values

    Sure he could but pre-defined enums and consts benefit from compiler-controlled item names and CodeInsight showing const values in code editor
  4. Dmitry Arefiev

    FDQuery, threads and CmdExecMode

    Leave it amBlocking.
  5. Fr0sT.Brutal

    How to manage defined list values

    Well, you can define lots of overloaded functions like EnumDefValue, EnumCaption etc for now and implement them in any form. Later, if you find a structure you like more, you won't have to change the interface, only the internal implementation. Or, if you decide to switch to enum helpers, perform replace in files with regexp-s ( EnumDefValue\((.+?)\) => \1.DefValue )
  6. Geoffrey Smith

    Sending Email via GMail Using OAuth 2.0 via Indy

    I have now updated my demo to use an TIdSASL derived component that I created. I must admit that it does use the Delphi TOAuth2Authenticator component as well which is not a Indy component... but it has been in Delphi going back quite a few versions.
  7. Lars Fosdal

    How to manage defined list values

    There is no definitive answer to that as YMMV. We do literally have 100+ types of enums, and we implemented record helpers for each one, simply to ensure that all enums had the same capabilities. AsString, FromString, Name, and in some cases more texts, or biz.logic associated with the enum. We actually did the last push for this model this autumn, to get rid of the last couple of dozens of standalone TypeNameToStr functions. We also introduced app wide translations (Norwegian, Swedish, English) using Sisulizer. It turned out that using attributes for naming was a bit of a challenge, since you can't use a resourcestring as an argument to an attribute - go figure. resourcestring sName = 'Name'; type AttrNameAttribute = class(TCustomAttribute) constructor Create(const aName: String); end; type TSomeType = class private FaName: string; procedure SetaName(const Value: string); public [AttrName(sName)] // <-- [dcc32 Error] : E2026 Constant expression expected property aName: string read FaName write SetaName; end; We ended up setting names explicitly in code instead.
  8. Yeeah, when you move from English-only to multi-language, these 100 lines will turn into 100 files xD
  9. I think that depends a lot on what languages you are targeting. See i18n for howto handle different pluralities in other languages well, this can get very scaring.
  10. Remy Lebeau

    TThread issue

    TThread holds an internal reference to itself (in the TThread.CurrentThread property), which under ARC ensures the thread stays alive and continues to run as expected even if all other references to the TThread object get cleared. That internal reference gets cleared when the thread stops running. However, that internal reference does not get assigned until the thread is actually running, which is why you need the extra delay on ARC systems, otherwise if ARC calls the TThread destructor, it will terminate the newly-created thread before it begins to run. Rather than using an arbitrary sleep, you should instead use a waitable event, like TEvent. Have the code that creates the TThread object wait on that event before continuing. Signal the event at the beginning of your thread's Execute(). For example: type TMyThread = class(TThread) private procedure aaaa; FStarted: TEvent; protected procedure Execute; override; public constructor Create; reintroduce; destructor Destroy; override; procedure WaitForStart; end; constructor TMyThread.Create; begin inherited Create(False); FStarted := TEvent.Create; end; destructor TMyThread.Destroy; begin FStarted.Free; inherited; end; procedure TMyThread.Execute; begin FStarted.SetEvent; ... end; procedure TMyThread.WaitForStart; begin FStarted.WaitFor(Infinite); end; procedure TForm1.Button1Click(Sender: TObject); var T: TMyThread; begin T := TMyThread.Create; T.WaitForStart; end;
  11. David Heffernan

    How to manage defined list values

    [Names('foo', 'bar')] TMyEnum = (foo, bar); It's kinda flaky of course because of the limitations on attribute constructor arguments being true constants. Later on I can write Enum.Name(someEnum)
  12. Dalija Prasnikar

    TThread issue

    Actually, there is no race condition because thread is actually started in AfterConstruction. So you can put just about anything you need in thread constructor and create thread in non suspended state.
  13. Anders Melander

    New TForm - Defaults

    In the project file (the DPR file) I do this before the first form is created: if (CheckWin32Version(6, 0)) then begin // Application.DefaultFont is the font used when TForm.ParentFont=True. // It is Tahoma by default but should be Segoe UI on Vista and later (according to MS UI guide lines). // See InitDefFontData() in graphics.pas Application.DefaultFont.Assign(Screen.MessageFont); // DefFontData.Name specifies the default font for everything that doesn't specify a specific font. // For now we leave it as is (Tahoma). At some point it should follow the system default like above: // DefFontData.Name := Screen.MessageFont.Name; end; And then I just make sure to set all forms ParentFont=True at design time.
  14. Allen@Grijjy

    Linux Platform target - problem with linking

    Actually it seems it cannot find librtlhelper_PIC.a. Make sure that C:\Program Files (x86)\Embarcadero\Studio\19.0\lib\linux64\debug or release is in your path.
×