Menu Window from .Net

How to display the general window menu from the .Net code that appears when Alt + Space is pressed?

+4
source share
2 answers

How to disable the Close button in the title bar of a console application using Visual Basic 2005 or Visual Basic.NET.

Insert from http://support.microsoft.com/kb/818361

If wParam is SC_KEYMENU, lParam contains the key character code, which is used with the ALT key to display a pop-up menu. For example, pressing ALT + F to display the File pop-up will cause WM_SYSCOMMAND with wParam to be equal to SC_KEYMENU and lParam to be equal to "f".

Insert from http://msdn.microsoft.com/en-us/library/ms646360.aspx

Menu items in the window menu can be changed using the GetSystemMenu, AppendMenu, InsertMenu, ModifyMenu, InsertMenuItem, and SetMenuItemInfo functions. Applications that change the window menu should process WM_SYSCOMMAND messages.

Insert from http://msdn.microsoft.com/en-us/library/ms646360.aspx

+1
source

You can use SendKeys in C # to send keys to your application. As in your case, you want to send ALT + Space keys to your application to display the System menu, for this you need to do what you need to shift focus to your form, where you want to display the system menu and use SendKeys.SendWait ( )

Note. Without moving the focus to the form in which you want to display the system menu, the command does not work properly.

Try the following code to send ALT + Space to display the system menu

this.Focus(); // Transfering focus to form SendKeys.SendWait("% "); // Sending Keys 

Here,% represents ALT, and white space displays space keys, respectively.

0
source

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


All Articles