.net - How to open window system menu on right click? -
Text after "
I show the progress of the unmanned splash screen form and minimize / Strong> and Close button (similar to the screen that appears in Office 2013). I would also like to provide a system menu of window which opens at right click anywhere in the form. Currently I use Alt + Space . SystemVindows.Forms.SendKeys.SendWait ("%") 'To Send Alt + Space With this approach, the window system menu Always open in the top-left corner of the window. Is there a way to open the program menu in the program menu, such as the window's user right-click title bar? / Strong> An API call or message that opens the menu? I would like to keep the available system menu in the app because I also added "about it" items I and "settings" there (This app serves as an independent launcher and updater of the main app.) The platform included Windows Forms with the platform WPF Use After displaying a baked-in WinAPI system menu, you can display it by using Pinovok GetSystemMenu () function to display a system to the system menu, you display it by using TrackPopupMenu (), you send the WM_SYSCOMMAND to execute the selected command by calling SendMessage. Some sample codes show how to do this and include the necessary announcements: Note that wherever you can display a menu, I have selected the upper-left corner of the window. Be careful that the position values are in pixels.
SendWait () ) for that solution Feel free to select VB or C # in case of some code posting.
System. Using Runtime.InteropServices; ... Private Zero Window_MouseDown (Object Sender, MouseButtonEventArgs E) {if (e.ChangedButton == MouseButton.Right) {IntPtr hWnd = New System.Windows.Interop.WindowInteropHelper (this) .Handle; RECT Pause; GetWindowRect (hWnd, outside position); IntPtr hMenu = GetSystemMenu (hWnd, incorrect); Int CMD = Trackpopup menu (hmnu, 0x100, pause. Left, pause .top, 0, hwnd, interpitter, zero); If (CMD> 0) Send Message (HWND, 0x112, (Interpet) CMD, InterPTOR Zorro); }} [DllImport ("user32.dll")] static extern IntPtr SendMessage (IntPtr hWnd, int msg, IntPtr WP, IntPtr lp); [DllImport ("user32.dll")] static extern IntPtr GetSystemMenu (IntPtr hWnd, bool bRevert); [DllImport ("user32.dll")] Fixed extern int TrackPopupMenu (IntPtr hMenu, uintlags, int x, int y, nReserved, intPtr hWnd, IntPtr prcRect int); [DllImport ("user32.dll")] Static Extra Bool GetWondroct (Interpreter HRWD, RECT Racket); Structure RECT {public int left, top, right, bottom; }
Comments
Post a Comment