Jump to content

aehimself

Members
  • Content Count

    1090
  • Joined

  • Last visited

  • Days Won

    23

Posts posted by aehimself


  1. 16 minutes ago, David Heffernan said:

    Actually it's a really bad idea. Cross process window parenting relationships just don't work out. Don't even think about it. 

    I respectfully disagree. I had issues with focus and modals not being true modals but otherwise it's working pretty all right. I have to admit that I docked quite simple applications (like PUTTY) until now, though.


  2. 11 minutes ago, Soji said:

    Application.ProcessMessages is not a solution I am fond of. I wanted to avoid that and came into the peekmessage option.

    Well, you are effectively - almost - doing the same 🙂

     

    12 minutes ago, Soji said:

    But it is a big overhaul and in sustain mode, it is not allowed to do that overhaul.

    This is a difference in point of views by different coders / companies. Sustain mode means only to fix critical bugs for me. Main window is frozen? Live with it; it's only visual, not critical.


  3. 5 hours ago, Rollo62 said:

    Have you considered to call several EXE files in the umbrella app ?

    They seem not be related much yet, so that could be a way to be faster.

    This is actually a really good idea. Call the .EXE's and dock their window into your application, like a new tabsheet. And until the clients are happy, you can work on the refactoring 🙂


  4. What you see is how a specific operating system is handling unresponsive windows. It's not only your program, it's all which are freezing the main thread (therefore blocks message processing).

     

    If you don't mind getting your hand dirty by writing REALLY BAD code you can get away with periodically calling Application.ProcessMessages during your long operation:

    Procedure StartLongOperaton;
    Begin
     Operation1;
     Application.ProcessMessages;
     Operation2;
     Application.ProcessMessages;
    End;

    or

    Procedure WorkWithDataSet(inDataSet: TDataSet);
    Begin
     inDataSet.First;
     While Not inDataSet.Eof Do
      Begin
       DoSomethingWithRecord;
       inDataSet.Next;
       Application.ProcessMessages;
      End;
    End;

    ...but if you don't know what you are doing, you'll quickly face more issues than just a frozen window.

     

    PeekMessage works, because it is forcing the processing of windows messages, therefore your form will APPEAR not frozen. Application.ProcessMessages does the same, it's basically a better wrapper for it.

     

    The real solution is... well, you guessed it: threads. There is no such thing as a method is "not possible to put in a thread".


  5. When I reached a point like this in the past I always went for a full refactor. It's painful, it's slow, adding no new features at all (maybe even removing some...?) but you always can reuse chunks of code to help to finish faster.

    In the end it worths the effort, trust me.

     

    I had an application I was maintaining for 10 years (7 threads plus VCL logic written in Unit1.pas, with names like Button1 or Thread1) when I decided that it was too messy. It took about 3 months to rewrite the whole thing from scratch but implementing proper class inheritance and separation of data access, business logic and UI. Adding a new feature in the past took days or weeks, now it is a matter of hours. As an addition, I cannot tell how many bugs were fixed just by cleaning the code up.

     

    It's a tremendous and scary job. But knowing the result I'd definitely do it again.


  6. Soooo... the bad thing is that without major changes the original project started to work correctly and I don't know why!!!

     

    Especially since the raw DBGrid seems to have this issue and I don't remember fixing anything in my descendant...


  7. Yes, original code was without .Lock and .Unlock but since it started to glitch out I decided to include it (and it remained). As for the Mod 2 it is no mystery, only my mistake: took the shots before changing the value - was experimenting with a lot of things before asking.
    Invalidating after a column drag will not be the solution - as this is only the sample code, and this is how I could recreate the issue. In the original project some lines are drawn correctly, some are in black (no matter that the color is set to red), some does not appear at all even without dragging involved.


  8. Hello,

     

    In Delphi 10.3.3 I have a DBGrid component with the following handler:

    procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);
    Var
     r: TRect;
    begin
     If ZQuery1.RecNo Mod 2 = 0 Then Begin
                                     r := Rect;
                                     InflateRect(r, -1, -1);
                                     DBGrid1.Canvas.Lock;
                                     Try
                                      DBGrid1.Canvas.Pen.Color := clRed;
                                      DBGrid1.Canvas.Pen.Width := 2;
                                      DBGrid1.Canvas.MoveTo(r.Left, r.Top);
                                      DBGrid1.Canvas.LineTo(r.Right, r.Top);
                                     FInally
                                      DBGrid1.Canvas.Unlock;
                                     End;
                                     End;
    end;

    Everything works fine:

     

    DBGrid_Unstyled_OK.PNG.34da0626bda8fa11700cb7925fb35fcd.PNG

     

    Until the moment when I enable VCL Styles. At first, it appears okay:

     

    DBGrid_Styled_OK.PNG.5660e2b8296fc25b3a7718acb7056ea9.PNG

     

    But if you start to click (especially try to drag and drop column headers) things start to fall apart:

     

    DBGrid_Styled_NOK.PNG.29703ad5d8e9e82e71b036ce8f668fc7.PNG

     

    This does not seem to happen when there are no Styles enabled. Anyone has an idea on what is this and how to fix it?

     

    Thanks!


  9. 3 hours ago, Mark- said:

    Am I wrong to think that some values, while using WMI to fetch the values, WMI retrieves the values from the registry?

    To be honest I am not 100% sure about it, but I think no. WMI is storing information in it's own database, which is a piece of junk. Back in the days when I was a sysadmin we had to rebuild countless corrupted WMI databases 🙂

    Wikipedia also seems to confirm that it's separate from Registry: "Windows Management Instrumentation (WMI) consists of a set of extensions to the Windows Driver Model that provides an operating system interface through which instrumented components provide information and notification."

     

    https://en.wikipedia.org/wiki/Windows_Management_Instrumentation

     


  10. Happens a lot to some of us at work, using 10.0. Sometimes a reinstall helps, sometimes it comes back... I suspect it has to do something with the size of the codebase / amount of components and addons installed, but was never able to confirm this.

    Also keep in mind that in the release notes of 10.3.3 they mentioned a bugfix of a sudden IDE crash.

     

    P.s.: turn off code insight. It's unusable anyway and can cause havoc in the IDE!

    • Thanks 1

  11. In the prehistoric times, you could download the MySQL C library from their website. Then they changed to the installer-type (download installer, select Connector-C, install 32 bit, copy file, uninstall 32 bit, install 64 bit copy file, uninstall everything).

    Now it's even worse.

     

    The installer now offers only 6.1.11, but you still can have the latest by downloading MySQL server and copying the file from the Lib folder. My 64 bit Delphi apps are using it happily; but that's only 64 bit, and there's no 32 bit version of MySQL anymore.

    The question is: is there a way to get the latest (currently 8.0.18) libmysql.dll in 32 bits?

     

    P.s.: I know that libmariadb is a drop-in replacement but I'd prefer the original if possible somehow / somewhere.


  12. Agreeing with @David Heffernan here. If the only solution is to kill and restart you are facing an endless loop, a never firing event, critical section deadlock, incorrect CoInitialize context, an unhandled exception rendering the rest of your code unusable, or thousands of other reasons, what moving to a UWP will most likely not solve.

     

    Litter your code with debugging log messages and you'll find out quickly what the culprit is.

     


  13. Indeed the question is a little bit broad. Are you looking for visual or functional updates? The "How can I modernize my app" can mean implementing cloud-based data storage and/or processing with extensive APIs or just eye candy to make end users more comfortable using it.


  14. Maybe related...?

    I'd also experiment with .BringToFront and .RestoreTopMosts but I'm almost certain that this will push it behind a modal dialog. Keep in mind that this is by design though - if there's an open modal dialog behind your visible form, no actions will be processed and your program will seem to be frozen!

     

    If you really need to achieve this, you could make your own dialog as a simple form and handle the .Enabled and .Visible properties from code. It might sound messy, but results will always be more reliable than playing around with owner and poup handles imo.

     


  15. 1 hour ago, ertank said:

    Maybe you can run two threads?

    Something like your thread-1 does the loop. Upon a variable trigger or a procedure call, thread-1 runs the possibly never ending code in thread-2.

    After that thread-1 checks if that thread-2 terminates in a given time limits.

    If there is a timeout, your main app can provide a feedback to user and maybe an option to re-start the app or something.

    This seems to be over-complication for me. Basically, this is somewhat what happens, only with thread 1 being the main (VCL) thread.

     

    Based on the comments above it seems on Linux there's a high chance (almost certain?) that the app will quit. On Windows it leaks memory and there's a slight chance of further misbehavior - although I could not induce a case like this myself. At the end of the day, if the app is most likely to stop it's better to try to kill the thread first imo. With the 25 prior confirmations, of course 🙂

×