开发者

Window's menu from .Net

开发者 https://www.devze.com 2022-12-30 01:10 出处:网络
How do Idisplay a common window\'s menu from .Net code, the one that a开发者_运维技巧ppears when Alt+Space is pressed?How to disable the Close button on the title bar of a console application by using

How do I display a common window's menu from .Net code, the one that a开发者_运维技巧ppears when Alt+Space is pressed?


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

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

If the wParam is SC_KEYMENU, lParam contains the character code of the key that is used with the ALT key to display the popup menu. For example, pressing ALT+F to display the File popup will cause a WM_SYSCOMMAND with wParam equal to SC_KEYMENU and lParam equal to 'f'.

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

The menu items in a window menu can be modified by using the GetSystemMenu, AppendMenu, InsertMenu, ModifyMenu, InsertMenuItem, and SetMenuItemInfo functions. Applications that modify the window menu must process WM_SYSCOMMAND messages.

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


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 System menu for this first thing you have to do is that you have to transfer the focus to your form where you want to display the system menu and the use SendKeys.SendWait() method.

Note : Without transfering focus to the form where you want to display the system menu the command don't work properly.

Try the following code for sending ALT + Space to display the system menu

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

Here % represents ALT and empty space represnts spacebar keys respectively.

0

精彩评论

暂无评论...
验证码 换一张
取 消