Replace system menu popup on windows - c++

I want to replace the default sys menu(Restore, Move, Size etc.) with my custom entries. The menu I'm talking about can be opened either by clicking left button on window icon or by clicking right button on window title.
I can remove all the items and populate this menu with my own entries. But if I remove all entries then minimize, maximize and close buttons become inactive. So they depend on those menu items.
I want to have min, max, close buttons working as usual but system menu which contains my own items(like it is done in Windows Media Player).
I'm using Qt, but I'm almost sure it can't be done with it so any solution would be appreciated.

Do not remove Min/Max/Close items from system menu. It's much better to process WM_SYSCOMMAND message instead (SC_MINIMIZE, SC_MAXIMIZE, SC_RESTORE, SC_CLOSE).

Related

How do I use Spy++ on this menu that keeps disappearing if I click outside of it?

I want to log the messages of this menu using Spy++.
Usually, if I want to log the messages of a window, I would use Spy++ and drag the "Find Window" tool over it. But in this case, if I drag the tool over this menu, the menu disappears because I clicked outside it.
Is there any workaround to this?
A little more information:
What I want to achieve is finding out what messages are sent when I click the menu's items (they are buttons).
That particular menu in the first picture is created only when I click the button, and it has a different HWND every time I click it.
If I can't accomplish this in Spy++, can I do this using some other application similar to Spy++?
Actually I figured it out myself.
You can just log messages of the parent window with the logging options set to also log messages of child windows.

C++ Windows add option to menu

In windows, when you click the small icon in the upper left of the window, you get a menu with Move, Minimize, Maximize, and Close options.
Is there anyway I can add my own options to that menu?
Absolutely.
GetSystemMenu(hWindow, FALSE) gets you menu handle and you are free to modify it.
A nice way is to add a separator and append your additional items like "About...". ATL code snippet is here: http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/FilterGraphSpy/GraphBuilderCallbackPropertySheet.h#ln1392 lines 1392-1396.

"Sticky" MFC popup menu

I currently have some toolbar buttons with a small arrow on the side (TBSTYLE_EX_DRAWDDARROWS) that, when clicked, result in a popup context menu being displayed under the button. This is done by constructing a custom popup menu and calling TrackPopupMenu.
The client now wants to be able to select multiple options from the menu before it closes, so that multiple options can be be modified without the need to re-open the menu and wait for an intermediate redraw between each change.
For example:
User clicks dropdown button
Dropdown menu appears (modal, waits indefinitely for user action)
User clicks some item (e.g., toggle a checkmark)
Timer (e.g., 500ms) starts
If timer expires, the menu is closed and all selected actions are executed.
User clicks another item before the timer expires, go back to 4.
The best I can come up with is to redisplay the menu by calling TrackPopupMenu multiple times. This makes the menu "flicker" when you select an item, and will probably require me to start a thread in order to do the timeouts, which I would rather avoid.
Rather than a menu, put up a dialog box with the options on it. A dialog can easily do all that is required.
A menu that doesn't close when you click it will just seem wrong. A dialog that closes by itself will seem wrong too, but it's probably the least of two evils.
Edit: If there's anything I've learned with Microsoft, it's don't try to fight the default behavior. You're asking for trouble if you do.
If you're building your menu dynamically I can see how automatic sizing can be handy, but it's not hard to do in a dialog either - make the dialog really big and before it becomes visible, enumerate the children and take a union of all their rectangles, then resize to that. Checking the boundaries to make sure they're on-screen is just a few if statements with OffsetRect. Checkboxes are trivial; icons less so, but still not bad.
One additional enhancement that would be easy to add is to dismiss the dialog immediately on a double-click.
Following #Mark Ransom's answer, you should put up a dialog box. But you can make the dialog modeless and make it close itself when you click outside of it (i.e., the dialog loses focus). That way it could behave more like a menu.
Notice that normal menus never go away by themselves, you always have to click somewhere outside the menu (or one of its options) to make it disappear.

Keyboard Tabbing Stops working on Windows GUI

I have a windows gui built in Microsoft Visual C++ and when the user performs a certain set of actions the keyboard tabbing to move from widget to widget stops working.
Simply put, there are two list boxes with an add and a remove buttons. Selecting a row in listbox #1 and pressing the add button removes the object from list box #1 and moves it to list box #2. The problem I am seeing is that the keyboard tabbing functionality goes away since the tab focus was on the add button which become desensitized when the add callback is completed (since no row in list box #1 is selected currently).
I want to be able to re-set the tab focus to listbox #1 (but not the selection of a particular row). Any ways to do this? I believe I am running as a standard modal dialog.
If I understand correctly, you just want to set the focus back to one of the listboxes. Since this is in a dialog, instead of calling SetFocus, The Old New Thing recommends you send a message to the listbox's hWnd to do this:
void SetDialogFocus(HWND hdlg, HWND hwndControl)
{
SendMessage(hdlg, WM_NEXTDLGCTL, (WPARAM)hwndControl, TRUE);
}

Making a groupbox button win32 C++

i have a button that is a rectangle how would i put words in it i want to make so ican click the word and it starts the progrma i know ShellExecute the style is BS_GROUPBOX
If you have more than one program you want to start, you need a button per program you want to start.
To start you external progrma, in the button parent window, you need to process the WM_COMMAND message with the BN_CLICKED notification.
To set the text of the button, you need to send WM_SETTEXT message to the button with the text you want shown.
Btw, BS_GROUPBOX is used for creating the rectangle around radio buttons. This style is not going to work for your scenario.
If you want an alternative to using multiple Button controls, you can use a Toolbar. In fact, it seems to me that a toolbar would be a better control for you. You can read more about creating a toolbar.