Question:

Is it possible to add a toolbar to a c++ dialog based application?

by  |  earlier

0 LIKES UnLike

I'm trying to do this using Microsoft Visual C++ 6.0 but cant get it to show up.

Here is what I am trying:

int CTL1DatabaseProgrammerDlg::OnCreate(LPCR... lpCreateStruct)

{

if (CDialog::OnCreate(lpCreateStruct) == -1)

return -1;

if (!mybar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP

| CBRS_TOOLTIPS) ||

!mybar.LoadToolBar(IDR_TOOLBAR1))

{

TRACE0("Failed to create toolbar\n");

return -1; // fail to create

}

return 0;

}

Everything compiles just fine, and the app starts, just no toolbar!

Are toolbars only available for SDI, and MDI apps?

 Tags:

   Report

2 ANSWERS


  1. Tool bars are available in dialog applications also.

    You have done everything fine.. just try RepositionBars() on your parent dialog for repositioning/showing the tool bar.


  2. I do it all the time.

    Create your menu in the Visual Studio resource editor.

    Then add it in your main dialog's OnInitDialog() like this:

    CMenu mMenu;

    mMenu.LoadMenu(IDR_MENU1);

    SetMenu(&mMenu);

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.