Jump to content

Steve Maughan

Members
  • Content Count

    135
  • Joined

  • Last visited

Posts posted by Steve Maughan


  1. The way Delphi handles application icons seems to be terrible.

     

    Here's what happened. We have a new icon for our application. I managed to delete the old icon and all *.res file and update it with a new icon. Then suddenly the application is using the wrong icon in the main form. I've repeated the icon update process once again and now I seem to have messed things up. I now have the default icon as the application icon.

     

    OK - rant over, now for my questions:

     

    1. Is there an approved step-by-step process for changing a Delphi application's icon?
    2. How do I determine which size icon is used for the main form. Is it the 16x16 or 24x24 version of the main icon?

     

    Thanks,

     

    Steve


  2. Looks like I haven't figured it out at all. It seems much more complex.

     

    Here's the order of events:

    1. OnMouseDown (processed with no problem)
    2. OnMouseUp (processed with no problem)
    3. OnDblClick - I'm showing a form for the user at this point. The GUI is recording the mousemove actions and generating OnMouseMove messages
    4. OnMouseDown - the second OnMouseDown of the double click, which can be ignored using a flag
    5. OnMouseUp - the second OnMouseUp of the double click, which can be ignored using a flag, and the fag can be reset
    6. Multiple OnMouseMove - then all of the OnMouseMove messages that were generated while the form was showing are now processed

    How do I either ensure the OnMouseMove messages aren't generated when the form is shown, or how do I remove them from the message queue?

     

    Here's a short video that shows the behavior:

     

     

    All help appreciate! Thanks,

     

    Steve

     


  3. I have a TPaintBox where I normally process OnMouseDown, OnMouseMove and OnMouseUp events. I'd like to perform an action using the DoubleClick even. It seems that when the user double clicks the order of events is as follows:

    1. OnMouseDown
    2. OnMouseUp
    3. OnDblClick
    4. OnMouseDown
    5. OnMouseUp

    I'd like to cancel / "eat" the second OnMouseDown and OnMouseUp events. How can I do this? Setting them to "nil" doesn't seem to work.

     

    Thanks - Steve


  4. On 12/14/2018 at 7:24 AM, Fritzew said:

    If it is the distance you are looking for, I don't think presorting are really faster as calculate the
    distance direct.
    from my experience presorting is in the most cases slower.
    But it depends. If the Data is more or less static then maybe presorting will win.


    in other cases

    Use Hypot to calculate the distance.

    
    for point in Pointlist do
      begin
        dist := Hypot(checkx-point.x, checky-point.y);
        if dist <  checkdist then .....
      end;

    Hypot is very fast 
    You can also use a parallel Loop in this case


     

    I didn't know about "Hypot": thanks for sharing!!

     

    Steve


  5. I do this all the time in AlignMix, our mapping package. Here's our super-fast algorithm:

     

    1. Have a sorted list along one dimension (I normally do longitude)

    2. Do a binary search to find the point with the closest longitude (let's call this P:0 ) and record the distance between this point and the search point

    3. Start a loop: look at the next sequential point from P:0 in the sorted list; record the distance and update if smaller than previous; exit the loop if the difference in the longitude is now greater than the shortest distance found, otherwise move on to next point

    4. Start a loop: look at the previous sequential point from P:0 in the sorted list: record the distance and update if smaller than previous; exit the loop if the difference in the longitude is now greater than the shortest distance found, otherwise move on to next point

     

    In practice I combine steps 3 & 4 so it alternates searching for the next above and the next below P:0.

     

    Hope that helps. In my tests this is extremely fast and scales the same as a binary search (log(n))

     

    Steve

    • Like 1
    • Thanks 2
×