Create或者CreateEx参数怎么带
我的toolbar不是在父窗体,是在子窗体
创建toolbar时的第一个参数应该怎么带
Create(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP, AFX_IDW_TOOLBAR);
这儿第一个this,不可能还是this吧。我试过。不行的
[解决办法]
MSND:
This member function creates a Windows toolbar (a child window) and associates it with the CToolBar object.
virtual BOOL Create(
CWnd* pParentWnd,
DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP,
UINT nID = AFX_IDW_TOOLBAR
);
Parameters
pParentWnd
Pointer to the window that is the toolbar's parent.
dwStyle
The toolbar style. Additional toolbar styles supported are:
CBRS_TOP Control bar is at top of the frame window.
CBRS_BOTTOM Control bar is at bottom of the frame window.
CBRS_NOALIGN Control bar is not repositioned when the parent is resized.
CBRS_TOOLTIPS Control bar displays tool tips.
CBRS_SIZE_DYNAMIC Control bar is dynamic.
CBRS_SIZE_FIXED Control bar is fixed.
CBRS_FLOATING Control bar is floating.
CBRS_FLYBY Status bar displays information about the button.
CBRS_HIDE_INPLACE Control bar is not displayed to the user.
nID
The toolbar's child-window ID.
Return Value
Nonzero if successful; otherwise 0.
Remarks
It also sets the toolbar height to a default value.
Example
Visual C++ Copy Code
// This code fragment is taken from CMainFrame::OnCreate
// CMainFrame is derived from CMDIFrameWnd.
//This example creates a dockable toolbar.
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
//Make the toolbar dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
[解决办法]
哦,是Cwnd指针,晕死,CWnd::FromHandle(frame.m_hWnd);