Office 2000 Style Mooring, Smart Menu

zhaozj2021-02-08  241

Office 2000 Style Mooring, Smart Menu

Translator: Xu Jingzhou (original: Piero viano)

Download Demonstration Source Code (http://www.vckbase.com/vckbase/vckbase12/vc/ctrls/menu_07/1207099.htm)

Office 2000 styles, smart menu examples are shown below:

(Translator Note: Since the original author provides an example code to use RC resources, it feels not universal after use, so some source code is modified and translated in the article. Now, the example is the case for me to make a capture program for me. Interface part. Not only the Office 2000 intelligent menu! Also included the TAB page of the multi-document view, self-drawing menu, etc. For details, please refer to the instance code. My email is: jingzhou_xu@163.net ~ o ~)

Use the Office 2000 menu in your project file (Translator: Currently, only multi-document menu modification, if you want to change the document menu interface, you can modify the CMULTIDEMPLATEEX class, the CMDIFRAMEX class, and the CMDIFrameEx class in the file to adapt. Single document interface.), Please follow the steps below:

Add two strings in the string table in the resource: 1. ID_SHOWFULL, 32792, the full menu is displayed. Second, ID_INTMODE, 32794, open / prohibit smart menu mode. Each .cpp and .h file in the OffMenu folder contain a well in your project file. MAINFRM.H in the project file (main frame header file):

Statement of the original class from:

Class CMAINFRAME: PUBLIC CMDIFrameWnd is changed to:

#include "mdifrmex.h" #include "Toolbarex.h"

Class CMAINFRAME: PUBLIC CMDIFRAMEX will then change the tools in the class from ctoolbar to ctoolbarex:

CToolbar M_Wndtoolbar; becomes:

CToolBAREX M_WNDTOOLBAR;

Edit the mainfrm.cpp in the project file:

Change the message mapping from:

Implement_dynamic (cmainframe, cmdiframeWnd) begin_message_map (cmainframe, cmdiframeWnd) becomes:

Implement_dynamic (cmainframe, cmdiframeex) begin_message_map (cmainframe, cmdiframeex) then in CMAINFRAME :: OnCreate:

IF (cmdiframeWnd :: OnCreate (lpcreateStruct) == -1) becomes:

IF (cmdiframeex :: oncreate (lpcreatestruct) == -1)

Edit the myApp.h in the project file:

Classified the class declaration from:

Class Ctestmdiapp: Public CWINAPP becomes:

#include "winappex.h"

Class Ctestmdiapp: Public CWINAPPEX

Edit the myApp.cpp in the project file:

Map the message from:

Begin_MESSAGE_MAP (CTESTMDIAPP, CWINAPP) becomes:

#include "doctplex.h"

BEGIN_MESSAGE_MAP (CTestMDIApp, CWinAppEx) then CMyApp :: InitInstance () in the code below: CMultiDocTemplate * pDocTemplate; pDocTemplate = new CMultiDocTemplate (IDR_TESTMDTYPE, RUNTIME_CLASS (CTestMDIDoc), // custom MDI child frame RUNTIME_CLASS (CChildFrame), RUNTIME_CLASS (CTestMDIView )); Adddoctemplate (pdoctemplate);

// Create Main MDI Frame Window CMAINFRAME * PMAINFRAME = New CMAINFRAME; if (! PMAINFRAME-> LoadFrame (iDR_mainframe)) Return False; m_pmainwnd = PMAINFRAME; replacement:

UINT NID; NID = IDR_MAINFRAME;

// Create Main MDI Frame Window CMAINFRAME * PMAINFRAME = New CMAINFRAME; if (! pmaInframe-> loadframe (NID)) Return False; m_pmainwnd = PMAINFRAME

CMultiDocTemplateEx * pDocTemplate; pDocTemplate = new CMultiDocTemplateEx (IDR_TESTMDTYPE, RUNTIME_CLASS (CTestMDIDoc), // custom MDI child frame RUNTIME_CLASS (CChildFrame), RUNTIME_CLASS (CTestMDIView), & nID, 1); AddDocTemplate (pDocTemplate);

CWINAPPEX :: InitInstance ();

Next, you can read and run your program.

If you want to control your smart menu, you can directly overload the following categories in the cMenubar class.

Word Cmenubar :: Incmenuusage (cmenenuex * pparent,

UINT POS,

Word Curusage)

Bool Cmenubar :: Evaluateifgrayed (cmenuex * pparent,

UINT POS,

Word & Curusage,

INT IMED,

IRANGE

The first mandate is used to add a current menu strip. The second mandate determines if the current menu strip is gray display, which can also be used to modify the usage of the current menu bar. If you want to store data defined in the application in the menu, you can include CMenuex :: getExtradataPtr (uint).

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

New Post(0)