Use BCB to change the window system menu

zhaozj2021-02-16  69

Two years ago, I took it out of the firing.

----------------------

Use BCB to change the window system menu

(Author: mikespook | Published: 2002-12-8 | Views: 133)

Keywords: BCB, System menu, message mapping table We will find some software that the system menus of these software is not standard, maybe few items, maybe more, maybe the default system menu has become unrecognizable . Figure 1 is a standard system menu. Figure 2 is a modified system menu. Below I will use this example to briefly introduce the modification method of the system menu. Figure 1 Figure 2 New Application. Name the main form "frm_main". Add the following code Tfrm_main :: FormCreate () function: void __fastcall Tfrm_main :: FormCreate (TObject * Sender) {HMENU system_menu = GetSystemMenu (Handle, false); // Handle to obtain the Form menu system DeleteMenu (system_menu, 4, MF_BYPOSITION); // Delete the first appendmenu (System_Menu, MF_String, ID_ABout_Menu, "About (& A)); // Add a" About "menu MODIFYMENU (System_Menu, 0, MF_String, ID_NULL_MENU," NULL "); // Modify the menu item, change the separator to" NULL "} to use GetSystemMenu (), deletemenu (), appendmenu (), modifyMenu (), these four API functions, please refer to MSDN or Win32SDK. HLP Help File (there is a BCB installation disk). Ok, let's take a look now. Press the F9 Run the program and call out the system menu. As we expect, the system menu has been modified successfully. This is it? You click on our new menu item to try and nothing happens. This is because we don't have processed this message in the menu item. Fortunately, the powerful BCB has left us a back door, allowing us to intercept the Windows message. Let's continue our surgery. Add a message mapping table in the end of the TFRM_MAIN class definition in the main window body header filefrmmain.h: begin_MESSAGE_MAPMESSAGE_HANDLER (WM_SYSCOMMAND, TMESSAGE, SYSMENUONCLICK) End_Message_map (TFORM) where WM_SYSCOMMAND is the message we want to intercept the process. When we intercepted the WM_SYSCOMMAND message, it will be handled by the sysmenuonclick () function.

转载请注明原文地址:https://www.9cbs.com/read-20343.html

New Post(0)