Modify the window class name

xiaoxiao2021-03-05  20

In the application of the Doc / View structure, you want to modify the class name of the main window (CMAINFRAME), you can utilize superiochemical technology. About superclasses can also refer to the implementation of superclassics in MFC. However, hyperlying technology is no effect on dialog-based applications. How to modify it? Let's take a look at the form of Doc / View in a superclass. Ultra-category technology generally has the following steps: 1. Get information of window classes you want to perform hyperstructure by calling getClassInfoEx. The function getClassInfoEx needs a pointer to the WNDCLASSEX structure to fill in the window class when successfully returns. 2. Press the member of the WNDCLASSEX structure, two members must modify: The instance of the Hinstance Storage program points LPSZClassName points to a new class name that does not have to modify members lpfnWndProc, but most cases still need. But remember if you want to use a function CallWindowProc to call the old window, you must save the original value of the member lpfnwndproc. 3. Register the modified WndClassex structure to get a new window class with some features of the old window class. 4. Create a window with a new window class

This modifies that the main window class name can be made: BOOL CMAINFRAME :: PrecreateWindow (CreateStruct & Cs) {if (! CframeWnd :: PrecreateWindow ") Return false; // Modify the main window class name WNDClass WNDClass; // getClassInfo Return Register window information :: getClassInfo (AFXGetInstanceHandle (), cs.lpszclass, & wndclass; // Reset window class class name wNDClass.lpszclassName = "new classname"; // Re-register new window class Verify (AfXRegisterClass (& Wndclass )))); // Use the newly registered class name to modify the main window class name cs.lpszclass = wndclass.lpszclassname; return true;}

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

New Post(0)