---- When there is a large-scale application program in VC5.0, the tools are often unpleasant in the program, and the closing position of the entire window is especially the key, which directly affects the outer view of the program interface. This article introduces all kinds of tool bars to control the control skills, for reference.
---- This, you can use the menu item to control the top stop of the custom tool strip.
---- Stop-controlled system of standard tools
---- VC5.0 should be used in the frame code of the procedure of the procedure. Under normal circumstances, the tool class CToolbar is the derived class of the CControlbar, which is determined by calling inherited functions ccontrolbar :: enabledocking (dWord dwstyle), and its parameter DWStyle is used to specify the specific location of the dock The format related to this article is as follows (the rest, please refer to the online documentation of the VC5.0):
---- CBRS -Align -Top stops at the top of the frame window window;
---- CBRS -Align -Bottom stops at the bottom of the cabinet window;
---- CBRS -Align -Left stops on the left side of the frame window window;
---- CBRS -Align -right darkens on the right side of the cabinet area;
---- CBRS -ALIGN-YY stops in the cabinet window home area.
---- In the application programming of the Application Program Wizard AppWizard, the control code default stop is set to CBRS -Align -any, which is allowed to stop on any edge of the frame window cake. The toolbar docked at the top of the window customer area when normal display, the control command is enabledocking (cbrs_align_any) or m_wndtoolbar. Enabledocking (CBRS_ALIGN_ANY), Note that the former must be in front of all other control code when actual program control, otherwise the floating tool bar or Some of the code such as special tool bars may not work. In the case of a physical control method, please refer to the function on the functional ().
---- The single document of the application and the multi-document window frame class is implemented by cframeWnd :: EnableDocking (DWORD DWDOCKS TYLE), and the optional parameter has increased the five kinds of CBRS float. MULTI parameters, this parameter is mainly increasing to design a floating tool bar, which is used to determine that there is a plurality of floating tool bars in a frame window. Also utilize the application wizard AppWizard generated application, the default docking position is also cbrs -align -a ny, that is, the toolbar is allowed to stop on any edge of the frame window, and its default initial position is the top of the frame window, ie EN Abledocking (CBRS_ALIGN_ANY) or M_WNDTOOLBAR.EnableDocking (CBRS_ALIGN_ANY). ---- Stop-controlled system of floating tools
---- When there are multiple standard or floating tools in a frame window, you need to use the function void dockcontrolbar (cc ontrolbar * pbar, uint ndockbarid = 0, lpcRect LPRECT = null) to determine the toolbar to control the position of the docking position. It is also a member function of the CFrameWnd class. The parameter PBAR is used to point to the controlled stop-enclosed tool pair, the parameter ndockbarid is used to determine which side of the tool stop on the frame window, and the specific value of the control is:
---- AFX -IDW -Dockbar -top darkends on the top of the frame window;
---- Afx -idw -dockbar -bottom dysfuncts at the bottom of the frame window;
---- Afx -idw -dockbar -left stops on the left side of the frame window;
---- Afx -idw -dockbar -right stopped on the right side of the frame window.
---- When the value of the parameter ndockbarid is 0, the tool strip can stop on any one of the stable edges in the frame window, and its default initial position is set to the top of the window.
---- Stop-controlled control system in parallel
---- Many large-scale applications are stored in a certain side of a certain side of a certain window in the same time. This kind of stop method can be used to realize the LPRECT parameters of the above tools control function DockControlbar. The real function is as follows:
---- 1. Increment in real documents, MAINFRM.H, adding as the following member function:
---- Void DockControlbarleftof (CToolbar * Bar, CToolbar * Leftof); ---- 2. Increment in real documents Mainfrm.cpp, adding as the following member function:
---- Void CMAINFRAME :: DockControlbarleftof (ctoolbar * bar, ctooibar * leftof)
---- {// Set the tool strip to stop on the same edge
---- CRECT RECT; // Rectangular area definition
---- DWORD DW;
---- uint n = 0;
---- RECALCLAYOUT (); // Renew new display
---- Leftof -> getWindowRect (& Re);
---- Rect.offset (1,0); // Setting the offset plants to stop on the same side
---- dw = leftof -> getbarstyle ();
---- n = (DW & CBRS_ALIGN_TOP)? AFX_IDW_DOCKBAR_TOP: N;
---- n = (DW & CBRS_ALIGN_BOTTOM & & N == 0)? AFX_IDW_DOCKBAR_BOTTOM: N;
---- n = (DW & CBRS_ALIGN_LEFT & & N == 0)? AFX_IDW_DOCKBAR_LEFT: N;
---- n = (DW & CBRS_ALIGN_RIGHT & & N == 0)? AFX_IDW_DOCKBAR_RIGHT: N;
---- DockControlbar (Bar, N, & Re);
----}
---- In this function, pay attention to the call to the recalclayout () function and the OffestRect () function, the former is used to reset the adjusted client area and toolbar, which is used to re-determine the rectangular area, which is equivalent to utilization The mouse dragged the second toolbar window to the previous toolbar and release it.
---- 3. Recovery Application Junction The Phase DockControlbar () function in the ONCREATE () function is the DockControlbarof () function, and it is determined to set the pointer of the tool object. The control code in the current order is as follows:
---- Enabledocking (CBRS_ALIGN_ANY); // Stopping must be in the front
---- / / Working with a function
---- m_wndtoolbar.enabledocking (CBRS_ALIGN_ANY);
---- m_wndtesttoolbar.enabledocking (CBRS_ALIGN_ANY);
---- DockControlbar (& M_WNDTOOLBAR, AFX_IDW_DOCKBAR_TOP);
---- / / make two tools to parallel
---- DockControlbarleftof (& M_WndtestToolbar, & M_WndToolbar);
---- Top of the tool stopped control
---- 1. Open the menu resource to add top position control menu item IDD_dlgbartop; ---- 2. Add members in real documents Mainfrm.h to add members control variables m_bdialogtop:
---- BOOL M_BDIALOGTOP;
---- and set the initial value in the configuration function;
---- 3. Using the class wizard classwizard to set the response function for the menu item;
---- 4. In the real literary document, MAINFRM.CPP, through the baked use of setwindowpos () members to complete the message mapping function.
Void cmainframe :: onbuttondigbartop ()
{// custom tool top position control function
IF (m_bdialogtop)
M_WnddigBar.SetWindowPos (& M_WndStatusbar, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE);
// The top tool stops on the side of the window, the left right tool stops
Else
M_WnddigBar.SetWindowPOS (& Wndtop, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE); // Stop in the top
RecalcLayout (); // Re-explicit window
m_bdialogtop =! m_bdialogtop; // change variable mark
}
Void CMAINFRAME :: OnUpdateButtonDigbartop (ccmdui * pcmdui)
{// Setup menu item check-state update function
PCMDUI -SETCHECK (m_bdialogtop);
}