Jump to content

Leaderboard


Popular Content

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

  1. You are wrong, the design makes eminent sense for a message/event driven environment like Windows. A modal form has its own internal message loop and that needs a way to figure out that it should exit the loop. Modalresult <> mrNone is that condition.
  2. Alexander Sviridenkov

    TListView - manually adding items faster at runtime

    Use virtual mode (OwnerData) https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.ComCtrls.TListView.OwnerData
  3. Anders Melander

    Event handler in thread

    I agree. One of the things that have helped me tremendously over the years as a software developer is my (hobby) background in first analog electronics and then digital, hardware and then software. It gives one a deep understanding of how things work and why. There was also an early phase where I ventured into chemistry but, although I got really good at blowing shit up, I don't think that particular skill set has helped me much 🙂 (and thanks 😘 )
  4. The next release of ICS is finished, in SVN and the overnight zip. Once documentation is finished, it will be release next week. Meanwhile, testing of this version would be appreciated, so any serious problems can be found and fixed before the release. I'd particularly like C++ users to try and install it, it's okay for Win32, but getting some missing symbols for Win64, despite adding them. Angus
  5. Not that again! Just remove the f*ck*** call to Close and be done with it.
  6. I definitely don't "get" that. I think it's very unlikely. You're one of those people who assumes every gap in their knowledge is due to someone else's error. It's a waste of time to try to help people like that learn something.
  7. Remy Lebeau

    TListView - manually adding items faster at runtime

    That is correct.
  8. DelphiUdIT

    Event handler in thread

    Don't worry, when you feel the need just ask. Someone will help you. You'll find that Delphi (Pascal) will help you on the way. Also try to have a quick read about the various topics in the various manuals available, there are several available even for free. You can also do a search on the forum and you will find several links about this. Embarcadero's online wiki can also help you. Enjoy and good works.
  9. Jesus Christ, that is awful design. It's amazing, everytime I encounter a situation where I ask myself "how am I meant to [thing] with this framework", the answer is always "we implemented it, just in the most non-sensical way possible lol".
  10. PeaShooter_OMO

    Event handler in thread

    @ErikT I can assure you it still is pretty much the same. The Main application loop has been created for you by Delphi and that is inside the Application instance of TApplication and its setup you will find inside the DPR file (Project Source file). It is similar to what you will find in the Arduino ecosystem where the "Sketch" file is basicaly abstracted from the actual Main loop. The guys from Arduino thought it best to provide newbies two procedures; "setup" and "loop" in a sketch but there is another piece of code that has a Main loop that calls Setup and then just loops the Loop procedure. Delphi's Main loop receives Windows Messages from the underlying OS. Almost like interrupts they inform the application what is happening in repect to hardware and OS related events. The Delphi Application instance will then act upon some of those messages or will send the rest on to all corners of its fiefdom and any object, window or control that wants to can have those messages and react. For instance a Mouse Move event in the OS will cause the OS to send a correlating message to the Application instance if need be. The Application instance will check who should get the messages and then pass it on. A Button might receive the message if it is found that the mouse moved over the button's area and then the button can redraw with a highlighted display to show that the mouse is over it. All these happen the whole time, in a loop the same as your Main loop checking and waiting for interrupts. Below is Arduino's main.cpp. You don't see this when you use the Arduino IDE. Just like Delphi. Threading is just an extension of this whole process that allows you to do mutiple actions that seems to be happening at the same time. In the old days of mono-core CPUs it was done in a way where the OS will give each thread a time slice which will make it look as if the threads did their thing at the same time but it was still a sequential process. Nowadays with multi-core CPUs each core will be doing that which means that a single core will be giving its own threads each a time slice but across cores many threads might really be running at the same time. In an environment like Delphi you can be totally unaware of most of this and still create a great application and never even encounter any of the behind-the-scenes code. But it is good to know how these things work because it broadens your ability to figure out why a bug is doing what it is doing. If your Delphi edition has the source code for the VCL and FMX then go into that code and check it out. #include <Arduino.h> // Declared weak in Arduino.h to allow user redefinitions. int atexit(void (* /*func*/ )()) { return 0; } // Weak empty variant initialization function. // May be redefined by variant files. void initVariant() __attribute__((weak)); void initVariant() { } void setupUSB() __attribute__((weak)); void setupUSB() { } int main(void) { init(); initVariant(); #if defined(USBCON) USBDevice.attach(); #endif setup(); for (;;) { loop(); if (serialEventRun) serialEventRun(); } return 0; }
  11. Remy Lebeau

    TListView - manually adding items faster at runtime

    For a non-trivial number of items, it is best to use the TListView in virtual mode. Set the OwnerData property to true, assign an OnData event handler, and then set the TListView.Items.Count property instead of using the TListView.Items.Add() method, eg: type TItemData = record LN: Integer; ItemNo: string; Desc: string; end; private lvItems: array of TItemData; procedure TForm1.btnAddClick(Sender: TObject); var Col : TListColumn; SW : TStopwatch; s : string; i : Integer; begin Col := lv1.Columns.Add; Col.Caption := 'LN'; Col.Alignment := taLeftJustify; Col.Width := 30; Col := lv1.Columns.Add; Col.Caption := 'ItemNo'; Col.Alignment := taLeftJustify; Col.Width := 60; Col := lv1.Columns.Add; Col.Caption := 'Desc'; Col.Alignment := taLeftJustify; Col.Width := 160; SetLength(lvItems, 25000); SetLength(ary,10); // create the array length (1,2,3,4,5,6,7,8,9,0) chars beep; SW := TStopWatch.StartNew; // start timing it for i := Low(lvItems) to High(lvItems) do begin ary := genRandValues; // generate random numbers ie (2,9,8,4,7,5,6,0,1,3) s := ListToStr(ary); // convert array list into a string var ie ('2984756013') lvItems[i].LN := i; lvItems[i].ItemNo := s; lvItems[i].Desc := s; end; lv1.Items.Count := Length(lvItems); SW.Stop; // finish timing eb1.Text := IntToStr(SW.ElapsedTicks) + ' ticks / ' + IntToStr(SW.ElapsedMilliseconds) + ' ms'; beep; end; procedure TForm1.lv1Data(Sender: TObject; Item: TListItem); begin Item.Caption := lvItems[Item.Index].LN.ToString(); // add the major field, ie 'LN', thus the populate with the index as line numbers Item.SubItems.Add(lvItems[Item.Index].ItemNo); // itemno ie '2984756013', and so on. Item.SubItems.Add(lvItems[Item.Index].Desc); // desc ie same, ... end;
  12. PeaShooter_OMO

    Event handler in thread

    It really is not that much different. I personally think Delphi can be much more alike to microcontroller programming than some other languages. You allocate memory, you remember to deallocate it. A good microcontroller programmer probably has that ingrained. You most probably have an advantage to those starting their programming career on multi-core, mega-memory, full fledged operating system computers; you are conscious about space and performance. Just like on microcontrollers there are ways of doing things in Delphi that might work but most of the time there are the correct ways to do things. You learn as you go. Threading is so cool once you get the hang of it, just like pointers. The main rule is; if it is not an atomic operation when accessing/changing some memory then you must be conscious about which thread is accessing what and when and whether changing it can cause another thread some issues. Read up on thread-safety if you have not already. Ask questions here as there are brilliant and very knowledgeable Delphi experts on this forum. Anders Melander being one of them.
  13. What you are trying to do is reverse engineer the application - you start with a working app and you figure out how it does what it does. Reverse engineering happens everyday, but it is done by very experienced software developers.
  14. That is 100% correct! Either intentionally or unintentionally that is the situation.
  15. DelphiUdIT

    Very large h file to pas

    You need a wrapper in pascal from "HCNetSDK.h" and some dlls: - HCNetSDK.dll - ssleay.dll - libeay.dll - zlib.dll - libssl-1_1-x64.dll for new SDK I think - libcrypto-1_1-x64.dll for new SDK I think Depends on video machine you want to connect you need other dll too, but all of them are in the SDK (may be, in the old sdk they were inside). And of course, all the samples are in C or C# but I think you can copy how they do the things and replicate in Delphi. Of course there is some work to do. EDIT ... or I understand bad and you are talking about CHET ?
  16. DelphiUdIT

    Very large h file to pas

    The last that I had from HikVision was in pure C (and with comments in Chinese ....). They had a C# wrapper for demo project.
  17. Die Holländer

    Very large h file to pas

    Isn't the headerfile for C#?
  18. pyscripter

    Very large h file to pas

    @Erik@Grijjy's neslib/Chet: C Header Translator for Delphi may be worth giving it a try.
×