<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[toolBar-buttons zur laufzeit ändern]]></title><description><![CDATA[<p>HI IHR.</p>
<p>ich wollte gerne das bitmap einer meiner buttons während der laufzeit ändern. d.h., wenn ich auf den button drücke, wechselt das bitmap, wird erneut gedrückt, kommt das ursprüngliche bild. ich habe zwei versionen probiert, klappt aber beides nicht.<br />
hier mein code dazu:<br />
version 1:</p>
<pre><code class="language-cpp">CToolBar::SetButtonInfo(ID_ANI,ID_8,TBBS_BUTTON,IDB_REP);
</code></pre>
<p>mit der meldung:</p>
<blockquote>
<p>error C2352: 'CToolBar::SetButtonInfo' : illegal call of non-static member function</p>
</blockquote>
<p>und version 2:</p>
<pre><code class="language-cpp">CBitmap MyBMP;
	CButton myButton;

	MyBMP.DeleteObject();
	MyBMP.LoadBitmap(IDB_REP);
	myButton.SetBitmap(MyBMP);
</code></pre>
<p>da stürzt das programm aber mit 'Debug Assertion Failed' ab, wahrscheinlich, weil überhaupt nicht klar ist, welcher button hier das neue bitmap erhalten soll.</p>
<p>DANKE für eure hinweise!<br />
STICK.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/172861/toolbar-buttons-zur-laufzeit-ändern</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 04:00:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/172861.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 09 Feb 2007 05:29:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to toolBar-buttons zur laufzeit ändern on Fri, 09 Feb 2007 05:29:41 GMT]]></title><description><![CDATA[<p>HI IHR.</p>
<p>ich wollte gerne das bitmap einer meiner buttons während der laufzeit ändern. d.h., wenn ich auf den button drücke, wechselt das bitmap, wird erneut gedrückt, kommt das ursprüngliche bild. ich habe zwei versionen probiert, klappt aber beides nicht.<br />
hier mein code dazu:<br />
version 1:</p>
<pre><code class="language-cpp">CToolBar::SetButtonInfo(ID_ANI,ID_8,TBBS_BUTTON,IDB_REP);
</code></pre>
<p>mit der meldung:</p>
<blockquote>
<p>error C2352: 'CToolBar::SetButtonInfo' : illegal call of non-static member function</p>
</blockquote>
<p>und version 2:</p>
<pre><code class="language-cpp">CBitmap MyBMP;
	CButton myButton;

	MyBMP.DeleteObject();
	MyBMP.LoadBitmap(IDB_REP);
	myButton.SetBitmap(MyBMP);
</code></pre>
<p>da stürzt das programm aber mit 'Debug Assertion Failed' ab, wahrscheinlich, weil überhaupt nicht klar ist, welcher button hier das neue bitmap erhalten soll.</p>
<p>DANKE für eure hinweise!<br />
STICK.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1225425</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1225425</guid><dc:creator><![CDATA[stick_thai]]></dc:creator><pubDate>Fri, 09 Feb 2007 05:29:41 GMT</pubDate></item><item><title><![CDATA[Reply to toolBar-buttons zur laufzeit ändern on Fri, 09 Feb 2007 08:26:57 GMT]]></title><description><![CDATA[<p>SetButtonInfo() ist schon die richtige Methode dafür - allerdings benötigst du dort den Toolbar, dessen Buttons du ändern willst.<br />
(ein Fenster kann mehrere Toolbars haben ;))</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1225475</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1225475</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 09 Feb 2007 08:26:57 GMT</pubDate></item><item><title><![CDATA[Reply to toolBar-buttons zur laufzeit ändern on Fri, 09 Feb 2007 09:01:43 GMT]]></title><description><![CDATA[<p>an CStoll:</p>
<p>und was mache ich mit der fehlerwarnung, die ich angezeigt bekomme? wie bekomme ich diese weg?</p>
<p>STICK.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1225497</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1225497</guid><dc:creator><![CDATA[stick_thai]]></dc:creator><pubDate>Fri, 09 Feb 2007 09:01:43 GMT</pubDate></item><item><title><![CDATA[Reply to toolBar-buttons zur laufzeit ändern on Fri, 09 Feb 2007 09:13:20 GMT]]></title><description><![CDATA[<p>Ich bin mir nicht ganz sicher, wo, aber irgendwo in deinem CWnd-Objekt solltest du eine CToolBar-Variable haben - und die mußt du angeben als <code>m_toolbar.SetButtonInfo(...);</code> , wenn du die Buttons ändern willst.</p>
<p>(die Fehlermeldung sagt ganz einfach aus, daß du für nicht-statische Methoden ein Objekt benötigst, das als this übergeben werden kann)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1225507</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1225507</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 09 Feb 2007 09:13:20 GMT</pubDate></item><item><title><![CDATA[Reply to toolBar-buttons zur laufzeit ändern on Fri, 09 Feb 2007 09:49:01 GMT]]></title><description><![CDATA[<p>okay. ich versuche es mal.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1225529</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1225529</guid><dc:creator><![CDATA[stick_thai]]></dc:creator><pubDate>Fri, 09 Feb 2007 09:49:01 GMT</pubDate></item><item><title><![CDATA[Reply to toolBar-buttons zur laufzeit ändern on Fri, 09 Feb 2007 09:58:35 GMT]]></title><description><![CDATA[<p>okay.</p>
<p>ich habe jetzt in CMainFrame.cpp folgenden code eingefügt:</p>
<pre><code class="language-cpp">BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	ON_WM_CREATE()
	ON_COMMAND(ID_REMOVE,	RemoveButton)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//...
void CMainFrame::RemoveButton()
{
	m_wndToolBar.SetButtonInfo(ID_ANI,ID_8,TBBS_BUTTON,IDB_REP);
}
</code></pre>
<p>jetzt gibts aber auch hier einen 'Debug Assertion Failed' <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> was nun?<br />
DANKE!</p>
<p><strong>EDIT:</strong> irgendwie kann es auch nicht in CMainFrame.cpp sein, denn dann ist der button schon 'highlighted', wenn noch gar kein childwindow geöffnet wurde <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1225531</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1225531</guid><dc:creator><![CDATA[stick_thai]]></dc:creator><pubDate>Fri, 09 Feb 2007 09:58:35 GMT</pubDate></item><item><title><![CDATA[Reply to toolBar-buttons zur laufzeit ändern on Fri, 09 Feb 2007 12:53:29 GMT]]></title><description><![CDATA[<p>Und wo ist der Assert?<br />
Kann es sein das m_wndToolBar gar nur eine von Dir erzeugte Variable ist aber nichts mit dem eigentlichen Toolbar zu tun hat?</p>
<blockquote>
<p>EDIT: irgendwie kann es auch nicht in CMainFrame.cpp sein, denn dann ist der button schon 'highlighted', wenn noch gar kein childwindow geöffnet wurde</p>
</blockquote>
<p>Was meinst Du damit?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1225667</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1225667</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Fri, 09 Feb 2007 12:53:29 GMT</pubDate></item><item><title><![CDATA[Reply to toolBar-buttons zur laufzeit ändern on Sat, 10 Feb 2007 05:23:05 GMT]]></title><description><![CDATA[<p>okay. ich bin's nochmal. ich denke, in dieser klasse möchte ich die methode einbauen, die das BITMAP meines button verändern kann, wenn ich auf den entsprechenden button drücke.</p>
<pre><code class="language-cpp">class CTestGLView : public CGLEnabledView, public cGlobDat
{
protected: // create from serialization only
	CTestGLView();
	DECLARE_DYNCREATE(CTestGLView)

// Attributes
public:
	CTestGLDoc* GetDocument();
//....

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CTestGLView)
	//}}AFX_VIRTUAL

// Implementation
public:
	void OnCreateGL();
	void OnDrawGL();
	virtual ~CTestGLView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext&amp; dc) const;
#endif

protected:

// Generated message map functions
protected:
	void OnSizeGL(int cx, int cy);
	void VideoMode(ColorsNumber &amp;c,ZAccuracy &amp;z,BOOL &amp;dbuf);
	//{{AFX_MSG(CTestGLView)
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnButton();

	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
private:
	CPoint MouseDownPoint;
	CBallController trackball;
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnTimer(UINT_PTR nIDEvent);
};
</code></pre>
<p>und die source datei dazu:</p>
<pre><code class="language-cpp">BEGIN_MESSAGE_MAP(CTestGLView, CGLEnabledView)
	//{{AFX_MSG_MAP(CTestGLView)
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_MOUSEMOVE()
	ON_COMMAND(ID_BUTTON,	OnButton)

	//}}AFX_MSG_MAP
	ON_WM_RBUTTONDOWN()
	ON_WM_RBUTTONUP()
	ON_WM_TIMER()
END_MESSAGE_MAP()

//...

void CTestGLView::OnButton()
{
	CToolBar::SetButtonInfo(ID_ANI,ID_8,TBBS_BUTTON,IDB_REP);
}
</code></pre>
<blockquote>
<p>Was meinst Du damit?</p>
</blockquote>
<p>wenn ich den code für OnButton in CMainFrame.cpp einfüge, dann ist der Button bereits aktiv, wenn noch kein Childwindow geöffnet wurde. dies soll aber nicht der fall sein. erst wenn ein childwindow zur verfügung steht, soll man diesen button drücken können.</p>
<p>DANKE!!!<br />
STICK.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1226042</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1226042</guid><dc:creator><![CDATA[stick_thai]]></dc:creator><pubDate>Sat, 10 Feb 2007 05:23:05 GMT</pubDate></item><item><title><![CDATA[Reply to toolBar-buttons zur laufzeit ändern on Sat, 10 Feb 2007 05:32:13 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>die Fehlermeldung sagt ganz einfach aus, daß du für nicht-statische Methoden ein Objekt benötigst, das als this übergeben werden kann</p>
</blockquote>
<p>meinst du das so:</p>
<pre><code class="language-cpp">CToolBar obj;
obj.SetButtonInfo(ID_ANI,ID_8,TBBS_BUTTON,IDB_REP);
</code></pre>
<p>ich habe das ausprobiert, aber es kommt wieder 'Debug Assertion Failed' <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>ich weis auch nicht, aber irgendwie kann ich nicht verstehen, warum eine so kleine aufgabe so kompliziert sein kann <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1226043</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1226043</guid><dc:creator><![CDATA[stick_thai]]></dc:creator><pubDate>Sat, 10 Feb 2007 05:32:13 GMT</pubDate></item><item><title><![CDATA[Reply to toolBar-buttons zur laufzeit ändern on Sat, 10 Feb 2007 08:50:13 GMT]]></title><description><![CDATA[<p>stick_thai schrieb:</p>
<blockquote>
<p>ich weis auch nicht, aber irgendwie kann ich nicht verstehen, warum eine so kleine aufgabe so kompliziert sein kann <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
</blockquote>
<p>Du hast das Prinzip hinter Klassen und Objekten immer noch nicht verstanden, sonst wüsstest du, warum das so nicht funktionieren kann.</p>
<p>Du legst ein neues CToolBar-Objekt an, und glaubst, dieses Objekt hätte irgendetwas mit der Toolbar deines Programms zu tun.</p>
<p>Wenn du etwas aus einem Schrank holen willst, hilft es dir nicht, wenn du einen neuen, baugleichen Schrank kaufst. Was du suchst, wird in dem neuen Schrank nicht drin sein.</p>
<p>Deine Mainframe-Klasse hat mit ziemlich hoher Wahrscheinlichkeit einen CToolBar-Member namens m_wndToolBar. Das ist das Objekt, das du suchst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1226065</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1226065</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Sat, 10 Feb 2007 08:50:13 GMT</pubDate></item><item><title><![CDATA[Reply to toolBar-buttons zur laufzeit ändern on Mon, 12 Feb 2007 02:23:27 GMT]]></title><description><![CDATA[<p>Hi MFK,</p>
<p>vielen dank für deinen nützlichen hinweis! damit ist mir auf jeden fall ein bisschen weitergeholfen. ich habe jetzt erstmal meine 'application class' wie folgt modifiziert:</p>
<p>Test.h:</p>
<pre><code class="language-cpp">class CTestApp : public CWinApp
{
public:
	CTestGLApp();

// Implementation

	afx_msg void OnButton();

private:
	CMainFrame* pMainFrame;
};
</code></pre>
<p>Test.cpp:</p>
<pre><code class="language-cpp">BEGIN_MESSAGE_MAP(CTestApp, CWinApp)
	//{{AFX_MSG_MAP(CTestApp)
	ON_COMMAND(ID_ANI,		OnButton)
END_MESSAGE_MAP()

void CTestApp::OnButton	()
{
	pMainFrame-&gt;GToolbar()-&gt;SetButtonInfo(11,ID_ANI,TBBS_BUTTON,0);
}
</code></pre>
<p>nun habe ich dazu folgende 2 probleme:<br />
1.) in diesem code wird jetzt einfach button 11 mit dem bild von button 0 ersetzt. ich will aber einen völlig anderes bitmap laden, was ich als bitmap-ressource (IDB_BUTTON) in meinem project gespeichert habe. was muss ich dafür verändern?</p>
<p>2.) wenn ich diesen code für den button bereits in meiner 'applikationsklasse' implementiere, dann wird ist der button bereits aktiv, wenn ich nur einfach mein programm starte. wie kann ich aber von der 'CTestView class' auf das objekt m_wndToolBar zugreifen, ohne dass ich dieses global definieren muss?</p>
<p>VIELEN DANK!<br />
STICK.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1227142</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1227142</guid><dc:creator><![CDATA[stick_thai]]></dc:creator><pubDate>Mon, 12 Feb 2007 02:23:27 GMT</pubDate></item></channel></rss>