How to add a custom item to the system menu in C ++?

I need to list all running applications. In particular, all the upper windows. And for each window I need to add my custom element to the system menu of this window.

How can I do this in C ++?

Refresh.

I would be more than happy to have a solution for Windows, MacOS and Ubuntu (although, I'm not sure if MacOS and Ubuntu have such a thing as a "system menu").

+5
source share
4 answers

For Windows, another way to get top-level windows (besides EnumWindows, which uses a callback) is to get the first child of the desktop and then retrieve all its siblings:

HWND wnd = GetWindow(GetDesktopWindow(), GW_CHILD);
while (wnd) {
    // handle 'wnd' here
    // ...
    wnd = GetNextWindow(wnd, GW_HWNDNEXT);
}

, GetSystemMenu, FALSE - . GetMenu, , .

, , , . - , , (, WH_GETMESSAGE WH_CBT) WM_SYSCOMMAND.

+8

, , GetMenu() Window, , :

HMENU hMenu = GetMenu(hwndNext);
+1

EnumWindows() Windows.

, , , .

: , : GetMenu()

0

Re: - , Microsoft Windows , sytem. GetMenu() 0. , .

In addition, what you offer is quite intrusive for other applications. How are you going to guarantee that they will not break when you change their menu? And how are you going to provide message suppression? In particular, how do you ensure they are intercepted before anyone else sees them? To quote Raymond Chen, imagine what would happen if two programs tried to do this.

0
source

All Articles