MFC program is designed to have some basic skills

xiaoxiao2021-03-06  89

1. The title of the modification program adds two lines in the PrecreateWindow function of CMAINFRAME.

CS.Style & = ~ (ws_thickframe | ws_maximizebox | fws_addtotitle); // fws_addtotitle must be added, otherw in the title cs.lpszname = "The title to display";

2. Add a toolbar (Toolbar) assumption, the toolbar ID is IDR_TOOLBAR1

if (! m_wndToolBar.CreateEx (this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || m_wndToolBar.LoadToolBar (IDR_TOOLBAR1)!) {TRACE0 ( "Failed to create toolbarn"); return -1; // fail to create}

Where m_wndtoolbar must be defined in the header file because the toolbar will disappear when M_WndToolbar is over.

When you add a toolbar button, you can open the toolbar in the resource editor, hold down Ctrl, then double-click the mouse on your button, you will appear ClassWizard = ^ _ ^ =

3. Change the size of the window // get the size of the frame

CRECT REWINDOW;

GetParentFrame () -> getWindowRect (shutindow);

Rewindow.right = 50;

// change the frame size

GetParentFrame () -> MoveWindow (Rewindow, True);

Change the size of the view:

// Get the size of the view

CRECT REWINDOW;

GetWindowRect (shutindow);

Rewindow.right = 50;

// change the size

MoveWindow (ReWindow.Left, Rewindow.top, Rewindow.right, Rewindow.bottom, true);

// Need to note that you can only change the view in the framework, that is, the size of the framework will not change. If you change it, you can cover the toolbar and status bar.

4. The Binding Control (Spin) and Edit Box (Edit) Binds in a dialog first adds an edit box, then add an up and down control, must be in this order, otherwise it is likely to be bound (if not This order is not to be tight about how to solve it. Double-click the upper and lower controls, modify its properties, tick the Auto Buddy and Set Buddy Integer, Alignment, is the upper and lower controls stick to the edit box, while selecting Right and sets it in OnInitDialog (). The value can be used, and if the scope may not be used, because the default value is (100, 0), it will be subtracted when pressing, and the GG, which is interested, can try it.

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

New Post(0)