Jump to content

Fr0sT.Brutal

Members
  • Content Count

    1457
  • Joined

  • Last visited

  • Days Won

    35

Fr0sT.Brutal last won the day on May 21

Fr0sT.Brutal had the most liked content!

Community Reputation

634 Excellent

2 Followers

Technical Information

  • Delphi-Version
    Delphi XE2

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Fr0sT.Brutal

    MessageBox is hidden by a modal form

    Sure but if the modal form is not focused and OS-topmost (hangs in the background) bad things happen. That's what I advised too and what I use widely in my projects. However I found the App's method contains additional stuff dealing with multi-monitor setup and RTL which could be useful. OTOH, it ridiculously still uses PChar's for caption and text forcing a user to add excess casts.
  2. You can also press "Like" on the post to increase my rep 🙂 Addition: as you develop generic wrapper, adding record's size check would save you from mysterious bugs in the future.
  3. Fr0sT.Brutal

    TChromeTabs for Delphi 11?

    General approach: grab a full repository and open the highest project available. RAD is pretty good in upgrading project files from older versions
  4. I don't realize the problem at all. FaN pro's - it could help find bugs and is useful for lazy init. Con's - procedure use instead of a method? Duh. Insignificant for me. I see no reasons to not use FaN everywhere,
  5. One additional function call and nested condition is nothing even in time-critical parts compared to heap area disposal. I know but I've seen plenty of those checks in 3rd party code
  6. Often you can find code if obj <> nil then begin obj.Free; obj := nil; end; that's what FaN is for
  7. Fr0sT.Brutal

    MessageBox is hidden by a modal form

    You can ensure MessageBox is shown on top of calling window by specifying that window's handle. Application's method tries its best but can fail. If you look at its source, the 1st line is "ActiveWindow := ActiveFormHandle;" which leads to "GetActiveFormHandle" method which turns out to call FOnGetActiveFormHandle event which you can handle manually.
  8. Okay I dove a little bit deeper (never touched RTTI before). It seems strictly tied to types so free pointer casting won't help. However I likely managed to get correct results program foo; {$APPTYPE CONSOLE} uses System.SysUtils, System.Classes, System.rtti, System.TypInfo; type // enlarge record to be always passed by ref TDateRec = record Year: Integer; Dummy: Double; end; TExample = class public function Calc(const dateRec: TDateRec): Integer; end; function TExample.Calc(const dateRec: TDateRec): Integer; begin result := dateRec.Year + round(daterec.Dummy); // use 2nd field end; var ex: TExample; dateRec: TDateRec; intResult: Integer; function executeInstanceMethod(Reference: NativeUInt; const AName: string; const Args: array of TValue): TValue; var context: TRttiContext; instType: TRttiInstanceType; params: TArray<TRttiParameter>; obj: TObject; Arg: TValue; p: Pointer; begin context := TRttiContext.Create; try try obj := TObject(Reference); instType := (context.GetType(obj.ClassType) as TRttiInstanceType); // get the actual pointer - didn't find another way to TValue.GetAsPointer Args[0].ExtractRawData(@p); // learn method's parameters params := instType.GetMethod(AName).GetParameters; // make new TValue with proper type TValue.Make(p, params[0].ParamType.Handle, Arg); result := instType.GetMethod(AName).Invoke(obj, [Arg]); except on E: Exception do writeln(E.ClassName + ' error raised, with message : ' + E.Message); end; finally context.Free; end; end; function executeInstanceMethodReturnIntArgsStruct(Reference: NativeUInt; const AName: PAnsiChar; Reference2: Pointer): Integer; begin result := executeInstanceMethod(Reference, string(AName), [Reference2]) .AsInteger; end; begin try ex := TExample.Create; dateRec.Year := 2022; dateRec.Dummy := 1; writeln( executeInstanceMethodReturnIntArgsStruct(NativeUInt(ex), 'Calc', @dateRec) ); except on E: Exception do writeln(E.ClassName, ': ', E.Message); end; Readln; end. Works on my XE2, prints "2023"
  9. Hmm, seems I remembered wrong. No declaration => value always Var/out => reference always Const => value if size <= pointer size (4 bytes on all platforms since Rio), reference if larger
  10. Where the error occurs and what it is? I repeat: don't cast pointers to Integer! It's incorrect on x64
  11. Fr0sT.Brutal

    Split String

    Edit3.Text:=String.Join('.',S); ?
  12. When record argument is declared as const, Delphi always passes it by reference (pointer). So you should try to feed the function with pointers. BTW, if you use Reference as pointer, don't declare it as Integer.
  13. So as a very experienced Delphi developer I should be getting $200k? Plz hire me 😄
  14. Fr0sT.Brutal

    Do you need an ARM64 compiler for Windows?

    Sure thing. However, backdoor holes left for spying could be revealed by someone else and used with all possible harmful purposes. Contrary, I've never heard of any Russian developers that are "angry at everybody else" and do any harm with their software. They seem to know the difference between business and politics while others seem not. I know several cases when other developers were so angry to put some destructive code into their products to be executed when being run in Russia. Not mentioning numerous companies leaving the market screwing up all their contract liabilities. Back to the topic, the quote you gave shows that rules of the game are maintained. Formalities are valid, nothing to worry about things you don't know 😉
  15. Fr0sT.Brutal

    Do you need an ARM64 compiler for Windows?

    That's why the CB development is SOOOO slow 😄 Well, then you should be also frightening of USA developers that you don't know personally because CIA/DOD has long story of injecting backdoors into well-known tools. Not talking about Chinese developers that obey to communist party (goddamn commies want to eat the whole world!)
×