Adding toolbar buttons at run-time
Markus Seger -- m.seger@ids-scheer.de
Friday, February 07, 1997
Environment: VC++ 4.2b, Win 95, NT 4.0
I need to add certain buttons to a toolbar at run-time. My problem: how can
I specify the texts for the tooltips and the statusbar MFC displays when I
touch the button with the mouse.
Normaly, these texts are specified in the string table resource. This can
not be done because my buttons are created at run-time.
Can someone please help me? A pointer to the MFC source which loads the
strings from the resource would also be helpfull. TIA
Markus
--------------------------------------------------------------------
Markus Seger IDS Prof. Scheer GmbH
voice: +49-681-9921-844 Altenkesseler Str. 17
fax: +49-681-9921-801 66115 Saarbruecken
mailto:m.seger@ids-scheer.de Germany
http://www.ids-scheer.de
--------------------------------------------------------------------
Alexander Grigoriev -- alegr@aha.ru
Sunday, February 09, 1997
Override CFrameWnd::GetMessageString
Quote from the doc:
virtual void GetMessageString( UINT nID, CString& rMessage ) const;
Parameters
nID Resource ID of the desired message.
rMessage CString object into which to place the message.
Remarks
Override this function to provide custom strings for command IDs. The
default implementation simply loads the string specified by nID from the
resource file. This function is called by the framework when the message
string in the status bar needs updating.
----------
> From: Markus Seger
> To: mfc-l@netcom.com
> Subject: Adding toolbar buttons at run-time
> Date: 7 ЖЕЧТБМС 1997 З. 10:41
>
> Environment: VC++ 4.2b, Win 95, NT 4.0
>
> I need to add certain buttons to a toolbar at run-time. My problem: how
can
> I specify the texts for the tooltips and the statusbar MFC displays when
I
> touch the button with the mouse.
>
> Normaly, these texts are specified in the string table resource. This can
> not be done because my buttons are created at run-time.
>
> Can someone please help me? A pointer to the MFC source which loads the
> strings from the resource would also be helpfull. TIA
>
> Markus
>
> --------------------------------------------------------------------
> Markus Seger IDS Prof. Scheer GmbH
> voice: +49-681-9921-844 Altenkesseler Str. 17
> fax: +49-681-9921-801 66115 Saarbruecken
> mailto:m.seger@ids-scheer.de Germany
> http://www.ids-scheer.de
> --------------------------------------------------------------------
>
Jim Lawson Williams -- jimlw@mail.ccur.com.au
Monday, February 10, 1997
At 08:41 AM 7/02/97 +0100, "Markus Seger"
wrote:
>Environment: VC++ 4.2b, Win 95, NT 4.0
>
>I need to add certain buttons to a toolbar at run-time. My problem: how can
>I specify the texts for the tooltips and the statusbar MFC displays when I
>touch the button with the mouse.
>
>Normaly, these texts are specified in the string table resource. This can
>not be done because my buttons are created at run-time.
>
>Can someone please help me? A pointer to the MFC source which loads the
>strings from the resource would also be helpfull. TIA
>
G'day!
This code for W95 was lifted just about straight from the CD:
CString CThingToolBar::NeedText( UINT nID, NMHDR* pNotifyStruct, LRESULT*
lResult )
{
LPTOOLTIPTEXT lpTTT = (LPTOOLTIPTEXT)pNotifyStruct ;
ASSERT(nID == lpTTT->hdr.idFrom);
CString toolTipText;
toolTipText.LoadString(nID);//<<<<<<<<<<<<<<<<<<<<<<<<<
// szText length is 80
int nLength = (toolTipText.GetLength() > 79) ? 79 :
toolTipText.GetLength();
toolTipText = toolTipText.Left(nLength);
return toolTipText;
}
Instead of the LoadString(), do your own thing with the text. Can't speak
for the status-bar: it might be worthwhile trying to jam the value here,
since you know it's needed.
Regards,
Jim LW
>From the BBC's "Barchester Chronicles":
"I know that ultimately we are not supposed to understand.
But I also know that we must try."
-- the Reverend Septimus Harding,
tax-consultant, crypt-analyst, clog-dancer, C++ programmer
Become an MFC-L member
| Вернуться в корень Архива
|