Discussion:
CToolBar buttons are disabled
(too old to reply)
vaclav
2004-02-27 08:11:08 UTC
Permalink
After building a bitmap for CToolBar ( in resource editor) and creating it in my MFC MDI application I cannot click on the buttons because they are disabled.
Here is a code snippet

// create views frames tool bar
if (!m_wndToolBar.Create(this) |
!m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))//MAINFRAME)

TRACE0("Failed to create toolbar\n")
return -1; // fail to creat


if (!m_wndStatusBar.Create(this) |
!m_wndStatusBar.SetIndicators(indicators
sizeof(indicators)/sizeof(UINT))

TRACE0("Failed to create status bar\n")
return -1; // fail to creat


// set tool bar style include tooltips
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle()
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC)


// enable docking
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY)
EnableDocking(CBRS_ALIGN_ANY)
DockControlBar(&m_wndToolBar)

What am I missing
Thanks for your help
Vacla
Karsten Kirchner
2004-02-27 08:46:58 UTC
Permalink
Hello vaclav !

Perhaps you have forgotten to implement the handler functions for the
disabled toolbar buttons.
You should set the right resource-ID to each toolbar button.
Post by vaclav
After building a bitmap for CToolBar ( in resource editor) and creating it
in my MFC MDI application I cannot click on the buttons because they are
disabled.
Post by vaclav
Here is a code snippet
// create views frames tool bar
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))//MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// set tool bar style include tooltips
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// enable docking
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
What am I missing?
Thanks for your help.
Vaclav
R. Selvam
2004-02-27 09:41:06 UTC
Permalink
----- vaclav wrote: ----

After building a bitmap for CToolBar ( in resource editor) and creating it in my MFC MDI application I cannot click on the buttons because they are disabled.
Here is a code snippet

// create views frames tool bar
if (!m_wndToolBar.Create(this) |
!m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))//MAINFRAME)

TRACE0("Failed to create toolbar\n")
return -1; // fail to creat



if (!m_wndStatusBar.Create(this) |
!m_wndStatusBar.SetIndicators(indicators
sizeof(indicators)/sizeof(UINT))

TRACE0("Failed to create status bar\n")
return -1; // fail to creat



// set tool bar style include tooltips
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle()
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC)


// enable docking
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY)
EnableDocking(CBRS_ALIGN_ANY)
DockControlBar(&m_wndToolBar)

What am I missing
Thanks for your help
Vacla

Hello

you add the message handlers in that functions

With Regards
R.Selva
Ajay Kalra
2004-02-27 09:52:56 UTC
Permalink
Provide ON_COMMAND/ON_UPDATE_COMMAND_UI handlers for each of the buttons you
want enabled.

--
Ajay Kalra [MVP - VC++]
Post by vaclav
After building a bitmap for CToolBar ( in resource editor) and creating it
in my MFC MDI application I cannot click on the buttons because they are
disabled.
Post by vaclav
Here is a code snippet
// create views frames tool bar
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))//MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// set tool bar style include tooltips
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// enable docking
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
What am I missing?
Thanks for your help.
Vaclav
Vaclav
2004-02-27 19:41:05 UTC
Permalink
Thanks for responses, however, I should clarify this.
I started by adding new button to existing toolbar and it showed up "grayed out" - disabled.
I process the existing toolbar buttons "messages" by using OnCmdMsg - so I do not need individual ON_COMMAND etc. stuff.

My basic questions are:
1. After adding a new button - how and where do I add this button ID?
2. If I add new whole tollbar their butons are also disabled and the individual buttons are nowhere to be found.
I am obviusly missing a step somwhere.

What I am asking is - how do I add toolbar and its corresponding button ID's?
Karsten Kirchner
2004-03-01 09:17:06 UTC
Permalink
Hello Vaclav !
Post by Vaclav
Thanks for responses, however, I should clarify this.
I started by adding new button to existing toolbar and it showed up "grayed out" - disabled.
I process the existing toolbar buttons "messages" by using OnCmdMsg - so
I do not need individual ON_COMMAND etc. stuff.
Post by Vaclav
1. After adding a new button - how and where do I add this button ID?
2. If I add new whole tollbar their butons are also disabled and the
individual buttons are nowhere to be found.
Post by Vaclav
I am obviusly missing a step somwhere.
What I am asking is - how do I add toolbar and its corresponding button ID's?
Open your Toolbar in the resource editor, and make any double click on your
toolbar button.
The properties dialog of this button opens. You should select the ID for the
function which you will process it. In the normal case it is an ID
(function) where you have implemented for the menue.

Greetings
Karsten

Loading...