|
when i create some toolbars whith this class and dock any of them on the left side of other , some toolbar drop to next line . i use DockControlBarLeftOf function . this function is in DockTool Sample in MS Visual Studio . Can Help me ?
|
|
|
|
|
the old stuff needs an update
|
|
|
|
|
how can i add text to this toolbar?
in the example of one of the threads using
<br />
int l_ButtonIndex = m_MainToolBar.CommandToIndex(IDB_EMPFORM);<br />
m_wndToolBar.SetButtonText(l_ButtonIndex, "ciccio");<br />
i get excetion...
do u have any idea?
|
|
|
|
|
hi ,
i have a dialog based application and want to use this for my toolbar.... how do i go about it.
Satadru
|
|
|
|
|
Hi,
I have a question about a resource leak when the CTrueColorToolbar is destroyed.
Modifying a bit the sample project in order to have a CTrueColorToolbar pointer instead of a CTrueColorToolbar data member and creating and destroying the toolbar i found a gdi leak every time a new instance of the toolbar is created.
any help would be appreciated
thanks
manero.
here is the code:
h:
...
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
CTrueColorToolBar* m_ToolBarDrawLeft;
CTrueColorToolBar m_ToolBarDrawRight;
...
cpp:
...
BOOL CMainFrame::CreateToolbarDrawLeft()
{
ASSERT(!m_ToolBarDrawLeft);
m_ToolBarDrawLeft = new CTrueColorToolBar;
m_ToolBarDrawLeft->SetBorders(1, 1, 1, 1);
if (!m_ToolBarDrawLeft->Create(this, WS_CHILD | WS_VISIBLE | CBRS_LEFT
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_ToolBarDrawLeft->LoadToolBar(IDR_TOOLBAR_DRAW))
{
TRACE0("Failed to create toolbar\n");
return FALSE; // fail to create
}
m_ToolBarDrawLeft->ModifyStyle(0, TBSTYLE_FLAT);
m_ToolBarDrawLeft->LoadTrueColorToolBar(TOOLBAR_DRAW_BUTTON_WIDTH,
IDB_TOOLBAR_DRAW,
IDB_TOOLBAR_DRAW_HOT,
IDB_TOOLBAR_DRAW_DISABLED);
m_ToolBarDrawLeft->EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(m_ToolBarDrawLeft);
return TRUE;
}
void CMainFrame::OnEditToggleToolbar()
{
if(m_ToolBarDrawLeft)
{
delete m_ToolBarDrawLeft;
m_ToolBarDrawLeft = NULL;
}
else
CreateToolbarDrawLeft();
}
...
|
|
|
|
|
i have a problem to add text to the toolbar, using "SetButtonText" method, no text is displayed, anyone has an answer??
Ahmad Fadlallah
|
|
|
|
|
I think the problem is the toolbar height (too small). The text is present but if you want to see it the toolbar height must be more wider than the icon height.
try to call SetSizes() to enlarge it.
ex:
p_ToolBar.SetSizes(CSize(l_MaxButtonWidth, p_ToolbarHeight), CSize(p_ImageWidth, p_ImageHeight));
with
p_ToolbarHeight > p_ImageHeight;
hope this help
luca
|
|
|
|
|
Your trick Don't work!!!
Eric
|
|
|
|
|
Go to the CMainFrame::OnCreate(...) method
in the sample project and after the
m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT);
add the followings lines
int l_ButtonIndex = m_wndToolBar.CommandToIndex(ID_FILE_NEW);
m_wndToolBar.SetButtonText(l_ButtonIndex, "ciccio");
m_wndToolBar.SetSizes(CSize(24, 52), CSize(16,16));
52 is the toolbar height
24 the button width
16x16 the icon size.
ciao,
luca.
|
|
|
|
|
I want to set a text on some of the buttons(how the iexplorer looks) with the following function:
m_ToolBarDrawLeft.SetButtonText(0, "Start");
Thats work just fine except I get all the buttons in the same width even if I set the TBSTYLE_AUTOSIZE in the the Create function
m_ToolBarDrawLeft.SetBorders(1, 1, 1, 1);
if (!m_ToolBarDrawLeft.CreateEx(this,TBSTYLE_LIST, TBSTYLE_AUTOSIZE | WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_ToolBarDrawLeft.LoadToolBar(IDR_TOOLBAR_DRAW))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_ToolBarDrawLeft.ModifyStyle(0, TBSTYLE_FLAT);
m_ToolBarDrawLeft.LoadTrueColorToolBar(TOOLBAR_DRAW_BUTTON_WIDTH, IDB_TOOLBAR_DRAW, IDB_TOOLBAR_DRAW_HOT, IDB_TOOLBAR_DRAW_DISABLED);
Can anyone help me out with this one?
Thx Anders
|
|
|
|
|
Nm, I found the problem. I needed to set the button style.
m_ToolBarDrawLeft.SetButtonStyle(0, TBSTYLE_AUTOSIZE );
/Anders
|
|
|
|
|
I modified this slightly to work in my ATL app. When I create the image lists and attach, it works fine except for the buttons which have a checked state of true (on). Any ideas? Here's a snippet of the code that loads my bmps and attaches to image lists:
CImageList m_cImageList;
CImageList m_cImageListHot;
CImageList m_cImageListDisabled;
HBITMAP bmNormal = AtlLoadBitmapImage(bmpNormal, LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS);
HBITMAP bmHot = AtlLoadBitmapImage(bmpHot, LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS);
HBITMAP bmDisabled = AtlLoadBitmapImage(bmpDisabled, LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS);
// Create normal image list and add to toolbar
if (!m_cImageList.m_hImageList)
{
if (m_cImageList.Create(width, height, ILC_COLOR24, 4, 4))
{
m_cImageList.Add(bmNormal);
wndColorToolBar.SetImageList(m_cImageList.m_hImageList);
}
}
Thanks for any help..
|
|
|
|
|
Since I can't update my article because is appear to be closed, I will post new article soon with added code for DropDown Button, DLL and your problem.
->L'enfer est pavé de bonnes intentions! :-S
->The road to hell is paved with good intentions! :-S
|
|
|
|
|
Great. Let me know when you get the new article posted.
|
|
|
|
|
i am using XP and VC6.0 with your truecolorbar ..
but I never found the flat style shown.
code behind:
m_wndToolBar.SetBorders(1, 1, 1, 1);
if (!m_wndToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT);
Gozhhu
|
|
|
|
|
Good work! Just what I want. However, when I add drop arrow to some toolbar button, it just cannot show up. any help with that? Thanks!
Come on! Decode me.
|
|
|
|
|
Look at http://www.codeproject.com/docking/toolbar_droparrow.asp
work fine!!!
->L'enfer est pavé de bonnes intentions! :-S
->The road to hell is paved with good intentions! :-S
|
|
|
|
|
Great job! Just what I needed!
But I have a question: Shouldn't you use a "AfxGetResourceHandle" in place of "AfxGetInstanceHandle"?
Because if you use an external DLL to load the resource, you will not find the bitmaps.
|
|
|
|
|
This is not directly related to this article but I thought you would know how to help me. I am trying to disable a toolbar button in a CTreeView MFC generated program. In MainFraim.cpp in the OnCreate function, I do the following:
CToolBarCtrl& tools = m_wndToolBar.GetToolBarCtrl();<br />
tools.EnableButton(ID_ADD_PAGE,false);
The EnableButton function does nothing! Other functions like DeleteButton and Indeterminate work fine, but EnableButton doesn't work. Do I have to do something else to make this change go into effect?
Much Appreciated
Anthony
|
|
|
|
|
In general way you need to trap command button with OnUpdate event and an BOOL member like this.
void CXXX::OnUpdateButton1(CCmdUI* pCmdUI)
{
pCmdUI->Enable(m_bEnable);
pCmdUI->SetCheck(m_bSetCheck);
...
}
- The hell is paved good intentions.
|
|
|
|
|
Thank You So much!!! I have wondered how to do that for a LONG time. I NEVER would have figured that out on my own. Thanks again.
Much thanks
|
|
|
|
|
Thank You So much!!! I have wondered how to do that for a LONG time. I NEVER would have figured that out on my own. Thanks again. Do you happen to know how to change the tree style (i.e. show +/- buttons, lines etc) in a CTreeView? The help said to use SetWindowLong, but that doesn't seem to do anything.
Much Much thanks
|
|
|
|
|
Take a look to this article http://www.codeproject.com/treectrl/ColorTreeCtrl.asp#xx191980xx very simple!
- The hell is paved good intentions.
|
|
|
|
|
Why we have to change the toolbar's style to flat?
|
|
|
|
|
Because under WindowsXP if you use CreateEx with flag TBSTYLE_FLAT the toolbar not repaint correcly (Bug from MS). You need to use Create and use ModifyStyle TBSTYLE_FLAT;
That it!
- The hell is paved good intentions.
|
|
|
|