Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 01/18/25 in all areas

  1. Paul Dardeau

    Vcl text box that user can move/resize at runtime?

    Giving up? Au contraire! I'm just getting started! 😀 I suspect that my initial post may have agitated you since you thought I was giving up without trying. Sorry for that (if that's the case). I did try playing with various snippets of code I had found and had the 'move' functionality done in a matter of minutes. As you say, the resizing is more involved. I started with the question because I'd like to leverage best practices and not waste time going down a rabbit hole unnecessarily. I'm not opposed to doing that when required (and I do like the learning aspects of doing that).
  2. Hi, if your goal is to be able to "take control" of the project, modify it and implement it with new features, I must warn you that it is an operation that even a senior programmer generates some anxiety. Pascal, and DELPHI in particular, helps you in this and therefore your work will certainly be "lighter". To be able to do this, in the absence of any information about you, there is a series of activities to be carried out preliminarily (what you call a roadmap): 1) Know the basics of Pascal, and by basics I mean the structure of a Pascal program, in particular how it is implemented in Delphi, and its composition; 2) Definitions, variables, constants; 3) Operators (logical, mathematical); 4) Assignments and comparisons; 5) Numbers, characters, variants; 6) Vectors and matrices; 7) Structured data, sets; 8 ) Procedures and functions; 9) Pointers; To then move on to OOP: 10) Basic OOP concepts (encapsulation, abstraction, inheritance, polymorphism); 11) Classes, constructors and destructors; 12) Exceptions; 13) Properties and events; 14) Multithreading; 15) Life and purpose of "variables" or object instances; 16) Memory management; 17) Files, streams; 18) RTL and RTTI; xx) Generics and collections; and lastly (so to speak) to the VCL, if you want to stay in the classic Windows application or in FMX if you want to go towards the environment more dedicated to the Mac, Linux and mobile worlds (Android and IOS), also functional for Windows: 19) Basic VCL classes (TObject, TPersistent, TComponent, TControl); 20) Ownership and parentship; 21) Graphics: TCanvas and handles; 22) Generics and collections; Another topic, really expanded and I would say almost a world in itself are databases ... Delphi has a good library (FireDac) that allows very easy access to most modern and not modern databases. Within all this there should also be a smattering of how the IDE works, already as a "ZERO" chapter as it will be needed to be able to carry out all these points. In conclusion I do not know if there is a specific publication that allows you to do all this, if not it will be necessary to read various publications to allow you to operate safely in the project. This is as far as I think it is necessary, maybe someone else certainly has some additional information or a different path in mind. If the forum members want to provide you with some links on this ... Bye
  3. in a dynamic 2D array ( a type like TMyArray = array of array of integer) you can set the number of rows with a SetLength call on the array variable and, for each row, set the number of columns with a SetLength(arrayvar, rowindex) call. That should cover your requirements. To reduce memory fragmentation you should avoid multiple SetLength calls on the same array row or the array itself, though. Determine the number of rows/elements beforehand, if possible.
  4. david berneda

    Making both vertical axis visible at all times in TeeChart

    We're adding a new property to axes to achieve this functionality: Chart1.Axes.Left.AutoHide := False; By default AutoHide is True, meaning the axis will be automatically made invisible when all of its associated series are also invisible. Setting it to False will always paint the axis as if all of its series were visible. If the axis min and max are set to be automatic, they will be calculated using all associated series. If you wish to beta test I'll be glad to email you the latest sources, just email me at david@steema.com This new property will also allow adding multiple custom axes anywhere, without the need of creating series, among other things. regards ! david
  5. This "Delphi Programming for Beginners" could also help you how Delphi and Pascal language work : https://www.dropbox.com/scl/fi/kh9qih54jgfbohejfmmww/Delphi-Programming-for-beginners-Yuriy-Kalmykov.pdf?rlkey=nv258b6gu7eufb674itnl4h39&dl=1
  6. Ok, let's check this two guides redacted for new Delphi&Pascal developers : - Programming with Delphi : https://docwiki.embarcadero.com/RADStudio/en/Programming_with_Delphi_Index - Developing Database Applications : https://docwiki.embarcadero.com/RADStudio/en/Developing_Database_Applications_Index They are old, but still up to date except for the database part where you are invited to use FireDAC, but if your project is old, you should have this deprecated knowledge in mind. (if you look on the Internet you should find the PDF release of them from Delphi 7 of after)
  7. Remy Lebeau

    Getting of dynamic array from Variant

    By default, an array inside a Variant is stored as (a pointer to) a COM SAFEARRAY: https://docs.microsoft.com/en-us/archive/msdn-magazine/2017/march/introducing-the-safearray-data-structure https://docs.microsoft.com/en-us/windows/win32/api/oaidl/ns-oaidl-safearray Which is completely different than a Delphi-style dynamic array. The two are not compatible with each other. The only way to store a Delphi-style dynamic array AS-A dynamic array in a Variant is to use a custom Variant type: https://docwiki.embarcadero.com/RADStudio/en/Defining_Custom_Variants That being said, Delphi 10.2 and later are more strict about NOT letting you assign a raw Pointer to a dynamic array, as you are trying to do: So, you would have to type-cast the raw Pointer in order to get the old Delphi 6 behavior, eg: type TDoubleArray = array of double; var Value: Variant; //this variable is assigned to a dynamic array somewhere in the code ... procedure DoSomething; var rv: TDoubleArray; begin rv := TDoubleArray(TVarData(Value).VArray.Data); // note, no @ used here. Why would you want to assign a PPointer to a dynamic array??? ... end; But, it never made sense to me why anyone would ever want to do this, since this makes the dynamic array point at something that is not a valid dynamic array, and can't be accessed as a dynamic array. The structure of a SAFEARRAY and a dynamic array are completely different. In any case, to safely access the raw data of a SAFEARRAY, you MUST use the SafeArrayAccessData() function, which Delphi's RTL has wrapped in the VarArrayLock() function, eg: var Value: Variant; //this variable is assigned to a dynamic array somewhere in the code ... procedure DoSomething; var rv: PDouble; begin rv := PDouble(VarArrayLock(Value)); try // use rv as needed... finally VarArrayUnlock(Value); end; end;
  8. Ehm! That Exit call will only exit procedure gotoTrue, but not function BlankControl. Funny, that such a suggested improvement perfectly qualifies for the reason of this thread
  9. try ... except on E: Exception do ... raise E; end Gives scary and mystic AV somewhat later after the problematic line in OS callstack. Real PITA to find and fix.
  10. My forever favorite stays this: Function GetUserID(APageIndex: Integer): Integer; Begin Case APageIndex Of 0: Result := -1; 1: Result := -1; 2: Result := -1; 3: Result := -1; [...] 50: Result := -1; Else Result := -1; End; Probably it had functionality a long time ago, but this method was still called from a live part of the code when I found it...! There were also some fancy fails (mainly memory leaks), including but not limited to: TMyClass = Class(TObject) private FOwner: TComponent; public Constructor Create(AOwner: TComponent); ReIntroduce; End; Constructor TMyClass.Create(AOwner: TComponent); Begin FOwner := AOwner; End; Or the other, which was probably a typo but took me a while to finally realize the issue: TMyClass = Class(TComponent) public Constructor Create(AOwner: TComponent); Override; End; Constructor TMyClass.Create(AOwner: TComponent); Begin inherited Create(Owner); End;
  11. Even though TList<T> uses a dynamic array internally, accessing its elements is very different than accessing the elements of TArray<T>. In your case, accessing vArray[n] is direct access to your record items, but vList[n] uses the TList<T>.Items property, which returns a copy of your record items, and you can't modify a copy inline the way you are trying to. You would have to manually save that copy to a variable and reassign it back to the TList<T> after modifying it, eg: procedure TForm1.FormCreate(Sender: TObject); var vArray: TArray<TRecLine>; vList: TList<TRecLine>; vNode: PVirtualNode; vRec: TRecLine; begin ... vArray[0].VirtualNode := vNode; // OK //vList[0].VirtualNode := vNode; // NOT OK! vRec := vList[0]; vRec.VirtualNode := vNode; vList[0] := vRec; ... end;
×