WTL architecture
view
The view window looks very simple:
class CMyView: public CWindowImpl
class CMyView: public CScrollWindowImpl
The splitter window is like a view, the frame window as its parent window. In this code, I passed the actual size of the frame window client area to the splitter window. I can use RCDefault here, because once the frame window creates completion The frame window will forward the WM_SIZE message to splitter. Such splitter can change its own size to fill the frame. However, when I am ready to use a parameter-free setSplitterpos (), the split bar is set to the window midline, there is a problem. The splitter window uses its size to determine the center of the center, because rcdefault tells the window its size is 0 (therefore the center line is also 0), which means that the split strip will appear in Z left edge, hide the left window. Create Once the splitter window, you need to create the window you want to split. They will be created as the sub-window for the Splitter window. Finally, you will be added to the SPLitter window via setsplitterpanes () and determine the splice strip. The location. TheUI Update menu item can be set to be valid or invalid, you can take the check mark or like a Radio button, in a set of menu items, only one can be CHECK. In addition, the menu item can also with icon and Text. All of these states can be changed according to a value in the program at runtime. The toolbar can see some degree of easy-to-see menu because their buttons can be individually, or as a group Part of the part is set effective or invalid, pushing. UI Update mechanism allows you to specify which UI Element can change at runtime. WTL uses the following Update mapping to implement this feature: Begin_UPDATE_UI_MAP (CMAINFRAME ) UPDATE_ELEMENT (ID_FILE_SAVERESULTS, UPDUI_MENUPOPUP | UPDUI_TOOLBAR) UPDATE_ELEMENT (ID_VIEW_TOOLBAR, UPDUI_MENUPOPUP) UPDATE_ELEMENT (ID_VIEW_STATUS_BAR, UPDUI_MENUPOPUP) END_UPDATE_UI_MAP () this example points out three menu items have a state needs to display at runtime, one, ID_FILE_SAVERESULTS, as well as a tool The strip button is associated with it. WTL saves this information by establishing an array. To this end, you need to complete two works:
The first is the status of the UI component. If it is a menu item, you can use uieNable () enable the menu item, uisetcheck () set the check mark, uiSettext () change the text of the menu. If it is the toolbar button, then you use uienable. Enable the button, uisetcheck () or uiSetradio () decision button is put into or launched. The following code is selected according to whether there is text, to enable the CUT menu item and the toolbar button: BOOL bselected = getSelected (); uieNable (Id_edit_cut, bselected); You can put this code into the corresponding processing function (such as a menu item depending on the action of another menu item, put it into the latter's processing function), or put onIdle () Method, by checking a certain type variable to determine the status of the component. Second, it is to determine if each UI component is updated, and for this, you need to call a certain method of CupdateUi <> to add the UI component to the list. Main menu Has been automatically added, but other menus and all the toolbars must be joined manually by calling uiaddmenubar () and uiaddtoolbar (). At other, there is also a bunch of things to pay attention. First, use UiupDateToolbar after setting the toolbar. ) So that the tool strip status is updated. For menus, you don't need this, because the submenu is dynamically generated .uiupdateMenubar () method also exists, but its role is to restore the menu to the initial state, if you change some The text of the item, the result of calling UiupdateMenubar () may not be what you expect (because the text of the menu item will become old). Although there is still a method uiTradio (), but there is no one menu item or toolbar The button is as a Radio button group (that is, there is one and only one selected) mechanism. If you want to get this effect, you must encode yourself, but it is not difficult. (Untrained)