// Display File dialog in center
wndParent->CenterWindow();
// Implementation of Toolbar in file dialog is in class "ToolbarWindow32".
We get the toolbar by looping through all
// CFileDialog child controls and getting their class name.
TCHAR strClassName[255];
CWnd* wndChild = wndParent->GetWindow(GW_CHILD);
while( wndChild != NULL )
{
// Get the class name of child control
::GetClassName(wndChild->GetSafeHwnd(), strClassName, 255);
// if child control is toolbar then we add a button in it.
if( _tcscmp(_T("ToolbarWindow32"), strClassName) == 0 )
{
CToolBarCtrl* pToolbarCtrl = (CToolBarCtrl*)wndChild;
ASSERT(pToolbarCtrl != NULL);
// Get the number of buttons in existing toolbar control.
int nButCount = pToolbarCtrl->GetButtonCount();
// Add a new button in it. IDB_NEW_BUTTON is a bitmap resource
pToolbarCtrl->AddBitmap(1, IDI_ICON_NEW2);
// get the number of images in existing toolbar
int nImageCount = pToolbarCtrl->GetImageList()->GetImageCount();
// Define a new button
TBBUTTON tb;
// Index of new button image.
tb.iBitmap = nImageCount-1;
// Command associated with toolbar button
tb.idCommand = ID_ADD_BUTTON;
// Setting button state
tb.fsState = TBSTATE_ENABLED;
// Setting button style
tb.fsStyle = TBSTYLE_BUTTON;
tb.dwData = 0;
tb.iString = NULL;
// Insert it in existing toolbar control
pToolbarCtrl->InsertButton(nButCount, &tb);
break;
}
wndChild = wndChild->GetNextWindow();
}
// setup parent window procedure to capture the mouse click event of
Toolbar button//
m_wndProc
=(WNDPROC)SetWindowLong(wndParent->GetSafeHwnd(),GWL_WNDPROC,(LONG)CCustomFileDialog::WindowProcNew);
}
how do I set the tooltip for my new button ?
Thanks,
Janiv Ratson.
> tb.iString = NULL;
> how do I set the tooltip for my new button ?
Fill tb.iString
(you don't need TBN_GETINFOTIP)
and still it does not work.
Is there something else ?
Thanks,
Janiv Ratson.
"Christian ASTOR" <cast...@club-internet.fr> wrote in message
news:uYDYaHjs...@tk2msftngp13.phx.gbl...
Actually, that won't work... iString is the zero based index in a the
control's string array for the button label of the button which must have
been previously entered using AddString. You should just be able to add a
string resource using the command value of your button (ID_ADD_BUTTON) to
have the tooltip text popup.
--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.
>>Fill tb.iString
>>(you don't need TBN_GETINFOTIP)
> Actually, that won't work... iString is the zero based index in a the
> control's string array for the button label of the button which must have
> been previously entered using AddString.
I've tested in a single Win32 app before answering : it works.
(with tb.iString = "test"; and TB_ADDBUTTONS...)
Interesting, the only way I could get it to compile and work was to change
the code to this...
{
CWnd* wndParent= GetParent();
ASSERT( wndParent != NULL );
// Display File dialog in center
wndParent->CenterWindow();
// Implementation of Toolbar in file dialog is in class
// "ToolbarWindow32". We get the toolbar by looping
// through all CFileDialog child controls and getting
// their class name.
TCHAR strClassName[255];
CWnd* wndChild= wndParent->GetWindow( GW_CHILD );
while( wndChild != NULL )
{
// Get the class name of child control
::GetClassName( wndChild->GetSafeHwnd(), strClassName, 255 );
// if child control is toolbar then we add a button in it.
if ( _tcscmp( _T("ToolbarWindow32"), strClassName) == 0 )
{
CToolBarCtrl* pToolbarCtrl= static_cast< CToolBarCtrl* >(
wndChild );
// This is not needed since we would not be here if wndChild was
NULL...
// ASSERT( pToolbarCtrl != NULL );
// Get the number of buttons in existing toolbar control.
int nButCount = pToolbarCtrl->GetButtonCount();
// Add a new button in it. IDB_NEW_BUTTON is a bitmap resource
int nBmpID= pToolbarCtrl->AddBitmap(1, IDI_ICON_NEW2);
// Add the button string don't forget to terminate with 2
zeros...
// (the compiler adds one on string literals so just add one
more)
int nBtnStrID= pToolbarCtrl->AddStrings( _T("My Test
Button\0") );
// nBtnStrID == -1 is a failure...
// get the number of images in existing toolbar
int nImageCount = pToolbarCtrl->GetImageList()->GetImageCount();
// Define a new button
TBBUTTON tb;
// Index of new button image.
tb.iBitmap = nImageCount-1; // this is wrong, your setting
the id to a different button...
// Command associated with toolbar button
tb.idCommand = ID_ADD_BUTTON;
// Setting button state
tb.fsState = TBSTATE_ENABLED;
// Setting button style
tb.fsStyle = TBSTYLE_BUTTON;
tb.dwData = 0;
tb.iString= nBtnStrID;
// Insert it in existing toolbar control
pToolbarCtrl->InsertButton( nButCount, &tb );
// or
// tb.iBitmap = nBmpID;
// pToolbarCtrl->AddButtons( 1, &tb );
break;
}
wndChild = wndChild->GetNextWindow();
}
// setup parent window procedure to capture
// the mouse click event of Toolbar button
// m_wndProc= (WNDPROC)SetWindowLong(
// wndParent->GetSafeHwnd(), GWL_WNDPROC,
// (LONG)CCustomFileDialog::WindowProcNew );
Please expect few more questions regarding CFileDialog.
Thanks again,
Janiv Ratson.
"Frank Hickman [MVP]" <fhickman3_NOSP@M_noblesoft.com> wrote in message
news:%23qGBxQl...@TK2MSFTNGP14.phx.gbl...