Dynamically add a menu bar in the dialog

xiaoxiao2021-03-05  23

// Add Icon and Toolbar // This code Add OnInitDialog () message response function in the dialog box // set icon m_pimagelist = new cimagelist (); m_pimagelist-> create (16, 16, ILC_mask, 2, 2); m_pimagelist-> add (AFXGetApp () -> Loadicon (Idi_Backward)); m_pimagelist-> add (AFXGetApp () -> loadicon (idi_upward)); // Sets the size of the toolbar CRECT RECT; Rect.Left = 0; Bottom = 200; Rect.right = Rect.Left 200; Rect.top = 0; // Defines the control tbutton arrtbbutton [2] of the toolbar; m_upback.addstring (IDS_UP); m_upback.addstring (IDS_BACK); Arrtbbutton [0 ] .iString = NULL; arrTbButton [0] .iBitmap = 0; arrTbButton [0] .fsStyle = TBSTYLE_BUTTON; arrTbButton [0] .fsState = TBSTATE_ENABLED; arrTbButton [0] .idCommand = ID_BACK; arrTbButton [1] .idCommand = ID_UP Arrtbbutton [1] .IBitmap = 1; ArrtbButton [1] .ITBB / NULL; Arrtbbutton [1] .fsStyle = TBStyle_Button; arrtbbutton [1] .fsState = TBSTATE_DETERMINATE; / / Create a toolbar in the container, so that in arbitrary location create a toolbar m_UpBack.Create (WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_FLAT, rect, (CStatic *) (GetDlgItem (IDC_TB_CONTAINER)), 0); m_UpBack.AddButtons (2, arrTbButton); m_UpBack.SetImageList (m_pImageList);

m_UpBack.SetStyle (TBSTYLE_FLAT | TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE); // set height, which will hide the toolbar above the horizontal line int iButtonHeight = HIWORD (m_UpBack.GetButtonSize ()); CRect CombRect; ((CComboBox *) GetDlgItem (IDC_COM_FOLDER)) -> getWindowRect (& CombRect); setWindowPos ((cstatic *) getdlgitem, 0, CombRect.top, iButtonHeight, 200, SWP_Nomove;

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

New Post(0)