Minimize Delphi app with Live Popup Menu

I try to run this in a timer:

Application.Minimize;
ShowWindow( Application.handle, SW_HIDE );

It was in the code forever, and we just found that it does not work, when you have popupmenu active, it does not minimize the MDI parent window.

I believe that if I close the popup menu before running this code, then everything will be fine. The problem is that this code is in MDI Parent, and I have no idea where the current popup menu is. It does not matter if it is part of another form toolbar, it creates a toolbar, a right-click product or a seemingly meaningless key next to a space.

So, is there a way to hide the active popup menu in my entire program?

Also, if there is a better piece of code than what I use to minimize what will circumvent this problem, this will also be awesome information.

+3
source share
1 answer

To close the popup menu you can use

  if GetCapture <> 0 then
    SendMessage(GetCapture, WM_CANCELMODE, 0, 0);

in your code before trying to minimize form.

+7
source

Source: https://habr.com/ru/post/1724992/


All Articles