MFC Architecture (2)

Source: Internet
Author: User
Tags prepare

First, Cwind class

1. Tools/Tips Support

Provide short help to users

A.enabletooltips Open Prompt function

OnToolHitTest determines which word control to display the ToolTip

b.updatedata (DDV dialog box data exchange) Exchange The value of an MFC member variable to a control, or the value of a control to a member variable

C.updatedialogcontrols such as dialog box change Size Refresh dialog box control

D. center window

E.runmodalloop Continuemodal Endmodalloop

Temporarily take over the thread of the message loop, you can do message filtering, such as you manually implement modal dialog box

You open the dialog box, you only have to deal with the message of this window, all the others are filtered out.



Second, CFrameWnd class frame window

1. Active Frame View document support

A.getactivedocument () Gets the active document

GetActiveView () Get Activity active view SetActiveView () Set Active active view

GetActiveFrame () get the active frame

B.gettitle () Settitle () set frame title

C.setmessagetext () sets the caption of the message prompt box

D.beginmodalstate () endmodalstate () inmodalstate ()

Auxiliary dialog modal State, modal dialog box pop out, frame window is inactive

However, do not activate when you click on him will flash, prompting the user I am not active,

All require the above API to control these states.


2. Relationship of frame windows and views

A. The outermost layer is the frame window object, which displays the entire frame window.

B.view object is a child window, which is actually the client area, assigned by the View view class,

A DC with a frame window is shared, and the frame window is wrapped with a view. Views can have a variety of content displayed.

The C.view view is responsible for communicating with document, which is a typical documentation view

Application framework.


3. There is more support in the derived classes, especially CMDIFrameWnd

He's talking about his client division, some customer areas can be toolbars, to the panel,

Some have to give to the sub-framework, there are some customer areas to be assigned to the status bar, menu bar.



Third, Cviwe Class View class

1. Derived classes must overload methods

a.virtual void OnDraw (cdc* PDC) = 0;

OnPaint the sub-method called in the OnPaint, before the DC to do a preprocessing

Distinguish whether you are a print environment, a print preview, or a screen display, OnDraw inside

You will not have to distinguish between the print status and what I am going to wait for the tender.

OnDraw is to concentrate on drawing, drawing, information display.

Draw the required parameters, do the marking, all in the OnPrint to complete

The OnPaint () method requires a lot of preparation before calling the OnDraw method to output to the monitor.

One of them is to prepare a DC object associated with the monitor and pass this object to the OnDraw method, which is used to output the object to the monitor.

The OnPrint () method also makes a lot of preparations before calling the OnDraw method to output the printer.

One of them is to prepare a DC object associated with the printer and pass this object to the OnDraw method, which is used to output the object to the printer.


b.virtual void OnUpdate (cview* psender,lparam lHint, cobject* phint);

When the content of the document changes, he informs the view to change your display, which is often used in

Multiple views of a document. There's a view in which a user operates a thing in this view,

That will receive OnUpdate messages,Psender who initiated the change, if NULL is the change

All views, if a view finds Psender and its own this is equal, represents itself,

If you have already updated it, you do not need to update it again. Frequent calls are less efficient.



2. Other important methods

A.getdocument () get the document corresponding to the view

B.onactivateview () When view is active

C.onactivateframe () View when the frame is active

D. In fact, either of these two activations can be selected, without having to write the code in both

Because view actually represents the client area of the frame window, you activate the frame window,

Your client area must also be activated, and your client area Activation frame window is also activated



3.View kinds of features and uses (available derived classes)

A.ceditview simple text editing view Notepad

B.cfromview Class Dialog View database application with rich controls

C.chtmleditviw HTML edit display view HTML editor

D.chtmlview HTML display View e-mail app. browser

E.clistview Simple List view class spreadsheet application (need to be improved)

F.cricheditview RTF Text Edit view WordPad, etc.

G.cscrollview simple view with scroll bar drawing He, CAD artboard

H.ctreeview Tree control view shows the application of the tree-shaped information




MFC Architecture (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.