Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2010 编写代码将工具栏添加到基于对话框的mfc后,该对话框不会';跑不动_Visual Studio 2010_Visual C++_Mfc_Modal Dialog_Toolbar - Fatal编程技术网

Visual studio 2010 编写代码将工具栏添加到基于对话框的mfc后,该对话框不会';跑不动

Visual studio 2010 编写代码将工具栏添加到基于对话框的mfc后,该对话框不会';跑不动,visual-studio-2010,visual-c++,mfc,modal-dialog,toolbar,Visual Studio 2010,Visual C++,Mfc,Modal Dialog,Toolbar,我用来在对话框上创建工具栏的代码,我在本教程的早期阶段刚刚将这些代码添加到我的程序中: InitialJobProject2Dlg.h CToolBar m_FirstToolBar; BOOL CInitialJobProject2Dlg::OnInitDialog() { CDialogEx::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the syst

我用来在对话框上创建工具栏的代码,我在本教程的早期阶段刚刚将这些代码添加到我的程序中:

InitialJobProject2Dlg.h

CToolBar m_FirstToolBar;  
BOOL CInitialJobProject2Dlg::OnInitDialog()
{
CDialogEx::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
    BOOL bNameValid;
    CString strAboutMenu;
    bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
    ASSERT(bNameValid);
    if (!strAboutMenu.IsEmpty())
    {
        pSysMenu->AppendMenu(MF_SEPARATOR);
        pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
    }
}

// Set the icon for this dialog.  The framework does this automatically
//  when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE);         // Set big icon
SetIcon(m_hIcon, FALSE);        // Set small icon

// TODO: Add extra initialization here
GDALAllRegister();

bool bAnchored = false;
bAnchored = m_resizer.Hook(this);
assert(bAnchored);
bAnchored = m_resizer.SetAnchor(IDC_TXTDataFile,ANCHOR_LEFT | ANCHOR_TOP);
assert(bAnchored);
bAnchored = m_resizer.SetAnchor(IDC_EDTDataPath,ANCHOR_LEFT | ANCHOR_TOP);
assert(bAnchored);
bAnchored = m_resizer.SetAnchor(IDC_BTNBrowse,ANCHOR_LEFT | ANCHOR_TOP);
assert(bAnchored);
bAnchored = m_resizer.SetAnchor(IDC_RICHEDTHeader,ANCHOR_HORIZONTALLY);
assert(bAnchored);
bAnchored = m_resizer.SetAnchor(IDC_OPENGL,ANCHOR_ALL);
assert(bAnchored);
bAnchored = m_resizer.InvokeOnResized();
assert(bAnchored);

if(!m_FirstToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | 
    WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | 
    CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || 
    !m_FirstToolBar.LoadToolBar(IDR_TOOLBAR1))
{
    EndDialog(IDCANCEL);
}

RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST,0);
m_FirstToolBar.MoveWindow( 50, 0,100, 100, 1 );

m_oglWindow = new COpenGLControl();

CRect rect;

// Get size and position of the picture control
GetDlgItem(IDC_OPENGL)->GetWindowRect(rect);

// Convert screen coordinates to client coordinates
ScreenToClient(rect);

// Create OpenGL Control window
m_oglWindow -> oglCreate(rect, this);

// Setup the OpenGL Window's timer to render
//m_oglWindow -> m_unpTimer = m_oglWindow -> SetTimer(1, 1, 0);

return TRUE;  // return TRUE  unless you set the focus to a control
}  
InitialJobProject2.cpp

CToolBar m_FirstToolBar;  
BOOL CInitialJobProject2Dlg::OnInitDialog()
{
CDialogEx::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
    BOOL bNameValid;
    CString strAboutMenu;
    bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
    ASSERT(bNameValid);
    if (!strAboutMenu.IsEmpty())
    {
        pSysMenu->AppendMenu(MF_SEPARATOR);
        pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
    }
}

// Set the icon for this dialog.  The framework does this automatically
//  when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE);         // Set big icon
SetIcon(m_hIcon, FALSE);        // Set small icon

// TODO: Add extra initialization here
GDALAllRegister();

bool bAnchored = false;
bAnchored = m_resizer.Hook(this);
assert(bAnchored);
bAnchored = m_resizer.SetAnchor(IDC_TXTDataFile,ANCHOR_LEFT | ANCHOR_TOP);
assert(bAnchored);
bAnchored = m_resizer.SetAnchor(IDC_EDTDataPath,ANCHOR_LEFT | ANCHOR_TOP);
assert(bAnchored);
bAnchored = m_resizer.SetAnchor(IDC_BTNBrowse,ANCHOR_LEFT | ANCHOR_TOP);
assert(bAnchored);
bAnchored = m_resizer.SetAnchor(IDC_RICHEDTHeader,ANCHOR_HORIZONTALLY);
assert(bAnchored);
bAnchored = m_resizer.SetAnchor(IDC_OPENGL,ANCHOR_ALL);
assert(bAnchored);
bAnchored = m_resizer.InvokeOnResized();
assert(bAnchored);

if(!m_FirstToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | 
    WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | 
    CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || 
    !m_FirstToolBar.LoadToolBar(IDR_TOOLBAR1))
{
    EndDialog(IDCANCEL);
}

RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST,0);
m_FirstToolBar.MoveWindow( 50, 0,100, 100, 1 );

m_oglWindow = new COpenGLControl();

CRect rect;

// Get size and position of the picture control
GetDlgItem(IDC_OPENGL)->GetWindowRect(rect);

// Convert screen coordinates to client coordinates
ScreenToClient(rect);

// Create OpenGL Control window
m_oglWindow -> oglCreate(rect, this);

// Setup the OpenGL Window's timer to render
//m_oglWindow -> m_unpTimer = m_oglWindow -> SetTimer(1, 1, 0);

return TRUE;  // return TRUE  unless you set the focus to a control
}  
在这个阶段,当我运行代码时,没有错误,但是对话框窗口没有显示。我有,但在网上搜索工具栏的情况下没有结果

您能帮我解决问题吗?我该怎么办?

MSDN中的DLGCBR32示例演示了如何将工具栏添加到MFC对话框: