Add menu, status bar, toolbar, and window full screen in VC ++

Source: Internet
Author: User

1. Add a menu bar

1. You can add the Dialog attribute directly. Property-> Menu ID.

2. Add code:

CMenu m_menu;
M_menu.LoadMenu (IDR_MENU1); // IDR_MENU1 menu ID
// Set the current menu
SetMenu (& m_menu );

 

2. Add the status bar

CStatusBarCtrl * m_StatBar = new CStatusBarCtrl;
RECT m_Rect;
GetClientRect (& m_Rect); // obtain the rectangular area of the dialog box.
M_rect.top = m_Rect.bottom-20; // set the rectangular area of the status bar
M_statbar-> Create (ws_border | ws_visible | cbrs_bottom, m_rect, this, 3 );

Int nparts [3] = {0.2 * m_rect.right, 0.8 * m_rect.right, m_rect.right}; // split size
M_statbar-> setparts (3, nparts); // split the status bar
M_statbar-> settext (L "status: distributing items",); // Add "This is the first indicator" to the first column"
M_statbar-> settext (L "this is the second indicator",); // The following is similar

M_statbar-> settext (L "this is the third indicator", 2, 0); // The following is similar
M_statbar-> showwindow (sw_show );

 

3. Add a toolbar

Ctoolbar m_wndtoolbar;
If (! M_wndtoolbar.createex (this, tbstyle_flat, ws_child | ws_visible | cbrs_align_top | cbrs_gripper | cbrs_tooltips,
Crect (,) |! M_wndtoolbar.loadtoolbar (idr_toolbar1) // toolbar ID
{
Trace0 ("failed to create toolbar/N ");
Return false;
}
M_wndtoolbar.showwindow (sw_show );
Repositionbars (afx_idw_controlbar_first, afx_idw_controlbar_last, 0 );

 

4. Full Screen

Int nheight, nwidth;

Nheight = getsystemmetrics (sm_cyscreen );
// NHeight = GetSystemMetrics (SM_CYSCREEN)-GetSystemMetrics (SM_CYSIZE); // The height is lower than the full screen height.
NWidth = GetSystemMetrics (SM_CXSCREEN );
MoveWindow (, nWidth, nHeight); // sets the position and size of the Dialog display.

Note: To pre-display full screen, set the Dialog attribute: Border-> None, Style-> Popup.

Additional: Dialog determines the control position

CWnd * pWnd = NULL;
// Set the location of the log Group
PWnd = GetDlgItem (IDC_LIST_TEAM); // Control ID: IDC_LIST_TEAM
ASSERT (pWnd! = NULL );
PWnd-> MoveWindow (10, 10, 200,680); // sets the display position of the control.

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.