Program exceptions on W10 system with long uptime

Are you allowed to share what the code is for the TfmMain.WMMenuSelect method?

What is happening in there (on the 8th line), that is causing a ERangeError exception?

That’s something that I added a long time ago to do with the hints.

procedure TfmMain.WMMenuSelect(var Msg: TWMMenuSelect);
var
  MenuItem: TMenuItem;
  hSubMenu: HMENU;
begin
  inherited; // from TCustomForm (ensures that Application.Hint is assigned)
  MenuItem := nil;
  if (Msg.MenuFlag <> $FFFF) or (Msg.IDItem <> 0) then
  begin
    if Msg.MenuFlag and MF_POPUP = MF_POPUP then
    begin
      hSubMenu := GetSubMenu(Msg.Menu, Msg.IDItem);
      MenuItem := Self.Menu.FindItem(hSubMenu, fkHandle);
    end
    else
    begin
      MenuItem := Self.Menu.FindItem(Msg.IDItem, fkCommand);
    end;
  end;
  FmiHint.DoActivateHint(MenuItem);
end;

Have you thought of disabling the operation when you enter it, and then enabling again when you have finished processing? Like the way we disable timers and then re-enable them when done so that the code isn’t called again while it is still running.

I have things like that littered all over my code - the trouble is without extensive comments it’s hard to remember exactly what the problem was and why that code exists… and it might cause issues when upgrading to newer delphi versions - now when I encounter them the first thing I do is disable them and see if the original issue still happens - I disabled one a while back that was added for dephi 7!

So it might just be worth disabling that method and seeing what happens.

It’s funny how you can overlook / forget about stuff written long ago. When I was looking at that error report for some reason I was thinking that line was a call to some inbuilt function, not something I’d written !

I think this is the first time a user has actually sent me a report of that exact exception. Thanks to all for taking the time to ask the questions I should have asked myself. :slight_smile: