Discussion:
GetControlBar
(too old to reply)
Z.K.
2007-11-05 18:31:59 UTC
Permalink
I am trying to get access to my toolbar with this command form my ViewForm,
but I keep getting the error that it is not a member of CWnd. What am I
doing wrong?

CControlBar *pMyControlBar = (CControlBar
*)::AfxGetMainWnd()->GetControlBar(IDR_MAINFRAME);

Z.K.
Mark Salsbery [MVP]
2007-11-05 23:01:31 UTC
Permalink
GetControlBar() is a CFrameWnd member but AfxGetMainWnd() returns a CWnd
pointer.

You would need to (down)cast the pointer returned from AfxGetMainWnd() to at
least a CFrameWnd* to make the call to GetControlBar().

Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
Post by Z.K.
I am trying to get access to my toolbar with this command form my ViewForm,
but I keep getting the error that it is not a member of CWnd. What am I
doing wrong?
CControlBar *pMyControlBar = (CControlBar
*)::AfxGetMainWnd()->GetControlBar(IDR_MAINFRAME);
Z.K.
Z.K.
2007-11-06 16:32:13 UTC
Permalink
Thanks for the info. Actually I kind of already discovered it. So, I used
a pointer to mainframe to access the toolbar and then wrote a few helper
functions to access the protected data.

Z.K.
Post by Mark Salsbery [MVP]
GetControlBar() is a CFrameWnd member but AfxGetMainWnd() returns a CWnd
pointer.
You would need to (down)cast the pointer returned from AfxGetMainWnd() to
at least a CFrameWnd* to make the call to GetControlBar().
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
Post by Z.K.
I am trying to get access to my toolbar with this command form my
ViewForm, but I keep getting the error that it is not a member of CWnd.
What am I doing wrong?
CControlBar *pMyControlBar = (CControlBar
*)::AfxGetMainWnd()->GetControlBar(IDR_MAINFRAME);
Z.K.
Loading...