<?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[Subdialogaufruf kackt ab, weiss net warum]]></title><description><![CDATA[<p>folgende situation<br />
ich habe einen dialog A. Dieser hat als member einen zeiger auf einen weiteren dialog B, welcher im Konstruktor des dialogs A initialisiert wird. Also ungefaehr:</p>
<pre><code>// ...
A::A(){
 m_pDlgB = new B();
}
// ...
</code></pre>
<p>ein Button in dem Dialog A soll nun bei druecken den Dialog B anzeigen:</p>
<pre><code>void OnButton(){
   if(m_pDlgB-&gt;DoModal()==IDOK){
      // hier irgendwas machen ..
   }
}
</code></pre>
<p>meine probleme sind folgende:</p>
<ol>
<li>
<p>der dialog b wird nicht angezeigt. die anwendung kackt einfach ab (assertion failed error)</p>
</li>
<li>
<p>was muss ich machen um beispielsweise dialog-elemente von dialog B VOR DEM ANZEIGEN zu modifizieren. Das geht meines erachtens nicht (glaube ich)!?<br />
Also ungefaehr:</p>
</li>
</ol>
<pre><code>void OnButton(){
   // Baum-Element aktualisieren (fuellen) ...
   mpDlgB-&gt;treeElement.InsertItem(&quot;Hallo&quot;, TVI_ROOT);

   if(m_pDlgB-&gt;DoModal()==IDOK){
      // hier irgendwas machen ..
   }
}
</code></pre>
<p>erbitte code-schnippsel, URL oder tips</p>
<p>danke, gruss</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/76083/subdialogaufruf-kackt-ab-weiss-net-warum</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Apr 2026 02:44:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/76083.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 07 Jun 2004 16:34:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Mon, 07 Jun 2004 16:34:40 GMT]]></title><description><![CDATA[<p>folgende situation<br />
ich habe einen dialog A. Dieser hat als member einen zeiger auf einen weiteren dialog B, welcher im Konstruktor des dialogs A initialisiert wird. Also ungefaehr:</p>
<pre><code>// ...
A::A(){
 m_pDlgB = new B();
}
// ...
</code></pre>
<p>ein Button in dem Dialog A soll nun bei druecken den Dialog B anzeigen:</p>
<pre><code>void OnButton(){
   if(m_pDlgB-&gt;DoModal()==IDOK){
      // hier irgendwas machen ..
   }
}
</code></pre>
<p>meine probleme sind folgende:</p>
<ol>
<li>
<p>der dialog b wird nicht angezeigt. die anwendung kackt einfach ab (assertion failed error)</p>
</li>
<li>
<p>was muss ich machen um beispielsweise dialog-elemente von dialog B VOR DEM ANZEIGEN zu modifizieren. Das geht meines erachtens nicht (glaube ich)!?<br />
Also ungefaehr:</p>
</li>
</ol>
<pre><code>void OnButton(){
   // Baum-Element aktualisieren (fuellen) ...
   mpDlgB-&gt;treeElement.InsertItem(&quot;Hallo&quot;, TVI_ROOT);

   if(m_pDlgB-&gt;DoModal()==IDOK){
      // hier irgendwas machen ..
   }
}
</code></pre>
<p>erbitte code-schnippsel, URL oder tips</p>
<p>danke, gruss</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535283</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535283</guid><dc:creator><![CDATA[peperonee]]></dc:creator><pubDate>Mon, 07 Jun 2004 16:34:40 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 06:36:35 GMT]]></title><description><![CDATA[<p>mal den debugger anwerfen und gucken, ob dein B-Dlg wirklich initialisiert wird.<br />
Um Dialogelemente vor dem anzeigen des B-Dialogs zu modifizieren, im OnInitDialog des B-Dialogs modifikationen vornehmen, bzw. vor dem aufruf von DoModal Werte richtig setzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535678</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535678</guid><dc:creator><![CDATA[ü]]></dc:creator><pubDate>Tue, 08 Jun 2004 06:36:35 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 06:55:00 GMT]]></title><description><![CDATA[<p>logisch ! der zeiger ist nur innerhalb des konstruktors gültig. musst den zeiger da anlegen wo du ihn benötigst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535688</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535688</guid><dc:creator><![CDATA[rene04]]></dc:creator><pubDate>Tue, 08 Jun 2004 06:55:00 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 06:58:05 GMT]]></title><description><![CDATA[<p>Also meiner Meinung nach musst du deinen Dialog B noch &quot;createn&quot; im Konstruktor von A, sonst kackt´s ab...</p>
<pre><code class="language-cpp">A::A()
{
   m_pDlgB = new B();
   m_pDlgB-&gt;Create(IDD_DEINES_DIALOGS, NULL);
}
</code></pre>
<p>Dachte ich mir so... (is aber noch früh am Morgen...)</p>
<p>Greez <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/535691</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535691</guid><dc:creator><![CDATA[muhkuh_dd]]></dc:creator><pubDate>Tue, 08 Jun 2004 06:58:05 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 07:29:55 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6494">@rene04</a><br />
wenn der zeiger ein member der klasse ist, ist er NICHT nur im Konstruktor gültig !<br />
Dass es ein Member is erkennt man an m_, also sollte er auch im OnButton gültig sein.</p>
<p>@muhkuh<br />
Create wird doch nur für einen modless dialog benötigt !</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535713</guid><dc:creator><![CDATA[ü]]></dc:creator><pubDate>Tue, 08 Jun 2004 07:29:55 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 07:39:01 GMT]]></title><description><![CDATA[<p>@ Ü Jepp... (Sorry) -&gt; ich sollte so früh noch nichts posten... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>erstmal Kaffee holen... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Greez</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535721</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535721</guid><dc:creator><![CDATA[muhkuh_dd]]></dc:creator><pubDate>Tue, 08 Jun 2004 07:39:01 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 07:41:56 GMT]]></title><description><![CDATA[<p>@peperone</p>
<p>mach mal das da - nur so zum testen.</p>
<pre><code class="language-cpp">if(!m_pDlgB)
   AfxMessageBox(&quot;BLA&quot;);
else
   m_pDlgB-&gt;DoModal();
</code></pre>
<p>ähh, prüf mal, ob deine B Klasse schön brav den Basisklassenkontruktor von CDialog aufrufen tun tut ! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/535722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535722</guid><dc:creator><![CDATA[ü]]></dc:creator><pubDate>Tue, 08 Jun 2004 07:41:56 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 07:48:50 GMT]]></title><description><![CDATA[<p>also damit klar ist, was ich ueberhaupt hier versuche nochmal ein kleines resumee meines codes (eure tipps haben leider nicht geholfen <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 habe eine &quot;Hauptdialog&quot;-Klasse A. Diese hat eine member-Var. vom Typ &quot;Zeiger auf Dialogklasse B&quot; also in etwa:</p>
<pre><code>class A : CDialog{
public:
  A(CWnd *parent){m_dlgB = new B();}

  void OnButton();

  // member vars ...
  B *m_dlgB;
};

void A::OnButton(){
   m_dlgB-&gt;m_Tree.InsertItem(&quot;Hallo&quot;, TVI_ROOT);
   if(m_dlgB-&gt;DoModal()==IDOK){
      MessageBox(&quot;Hast auf OK gedrueckt&quot;,&quot;&quot;,MB_OK);
   }
}
</code></pre>
<p>Ferner sieht meine Unterdialog-Klasse B in etwa so aus:</p>
<pre><code>class B : CDialog{
public:

   BOOL OnInitDialog();
   // member vars ..
   CTreeCtrl m_Tree;
   CImageList m_TreeImg;
};

B::OnInitDialog(){

   m_TreeImg.Create(IDB_BITMAP, 16, 2, RGB (255, 255, 255));
   m_Tree.SetImageList(&amp;m_TreeImg, TVSIL_NORMAL);

   return CDialog::OnInitDialog();
}
</code></pre>
<p>Leider verstehe ich momentan nicht warum die member-var m_dlgB nicht korrekt initialisiert sein sollte. Mein Programm kackt genau an der Stelle in A::OnButton() ab, wo ich auf die member-var m_Tree zugreife.</p>
<p>Hat jemand vielleicht ne idee wieso???? <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="😕"
    /></p>
<p>Vielen dank vorab.</p>
<p>grussle</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535730</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535730</guid><dc:creator><![CDATA[peperonee]]></dc:creator><pubDate>Tue, 08 Jun 2004 07:48:50 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 07:52:14 GMT]]></title><description><![CDATA[<p>ok gut, ich sehs mir mal an, aber das mit der TreeControl haste ja vorher nicht geschrieben, daher konnte ich das nicht wissen ! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/535733</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535733</guid><dc:creator><![CDATA[ü]]></dc:creator><pubDate>Tue, 08 Jun 2004 07:52:14 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 07:55:18 GMT]]></title><description><![CDATA[<p>Ev. Solltest Du im Konstrutor Der B-Klasse das TreeControl &quot;Createn&quot;.</p>
<p><strong>MSDN:</strong></p>
<p><strong>CTreeCtrl::Create</strong></p>
<p>BOOL Create( DWORD dwStyle, const RECT&amp; rect, CWnd* pParentWnd, UINT nID );</p>
<p>Return Value</p>
<p>Nonzero if initialization was successful; otherwise 0.</p>
<p>Parameters</p>
<p>dwStyle</p>
<p>Specifies the tree view control’s style. Apply any combination of tree view control styles to the control.</p>
<p>rect</p>
<p>Specifies the tree view control’s size and position. It can be either a CRect object or aRECT structure.</p>
<p>pParentWnd</p>
<p>Specifies the tree view control’s parent window, usually a CDialog. It must not be NULL.</p>
<p>nID</p>
<p>Specifies the tree view control’s ID.</p>
<p>Remarks</p>
<p>If you specify the tree control in a dialog box template, or if you are using CTreeView, your tree control is created automatically when the dialog box or view is created. If you want to create the tree control as a child window of some other window, use the Create member function. If you create the tree control using Create, you must pass it WS_VISIBLE, in addition to other tree view styles.</p>
<p>You construct a CTreeCtrl in two steps. First call the constructor, then call Create, which creates the tree view control and attaches it to the CTreeCtrl object.</p>
<p>The following styles can be applied to a tree view control:</p>
<p>TVS_HASLINES The tree view control has lines linking child items to their corresponding parent items.</p>
<p>TVS_LINESATROOT The tree view control has lines linking child items to the root of the hierarchy.</p>
<p>TVS_HASBUTTONS The tree view control adds a button to the left of each parent item.</p>
<p>TVS_EDITLABELS The tree view control allows the user to edit the labels of tree view items.</p>
<p>TVS_SHOWSELALWAYS Causes a selected item to remain selected when the tree-view control loses focus.</p>
<p>TVS_DISABLEDRAGDROP The tree-view control is prevented from sending TVN_BEGINDRAG notification messages.</p>
<p>TVS_NOTOOLTIPS The tree view control uses no tooltips.</p>
<p>TVS_SINGLEEXPAND When this style is enabled, changing the selection in the tree view will automatically cause the item being selected to expand and the item being unselected to collapse. If the mouse is used to single-click the selected item and that item is closed, it will be expanded. If the selected item is single-clicked when it is open, it will be collapsed.<br />
Example</p>
<p>// Assuming your window has a CTreeCtrl member named m_TreeCtrl,<br />
// you can create the tree control window with a child ID of 0x1005<br />
// using a call like this:</p>
<p>m_TreeCtrl-&gt;Create(WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_BORDER<br />
| TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES<br />
| TVS_DISABLEDRAGDROP,<br />
CRect(10, 10, 300, 100), this, 0x1005);</p>
<p>// The control will have the appropiate window styles, and the tree<br />
// control styles specified are those most commonly used.</p>
<p>CTreeCtrl Overview | Class Members | Hierarchy Chart</p>
<p>See Also CTreeCtrl::CTreeCtrl,Tree View Control Window Styles in the Platform SDK</p>
<p>--------------------------------------------------------------------------------<br />
Send feedback to MSDN.Look here for MSDN Online resources.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535735</guid><dc:creator><![CDATA[Maroni]]></dc:creator><pubDate>Tue, 08 Jun 2004 07:55:18 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 08:00:32 GMT]]></title><description><![CDATA[<p>also den von benutzer &quot;ü&quot; geposteten tipp habe ich probiert (ueberprufung ob zeiger vielleicht null ist) --&gt; er ist es nicht <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="😕"
    /></p>
<p>noch eine kleine zusatzinfo:<br />
ich habe in der klasse A noch eine weitere member-variable die auch ein zeiger auf einen Dialog vom Typ C ist (also ein weiterer unterdialog). Das anzeigen dieses dialogs laeuft einwandfrei. nur klasse B macht schwierigkeiten.</p>
<p>sone scheisse.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535737</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535737</guid><dc:creator><![CDATA[peperonee]]></dc:creator><pubDate>Tue, 08 Jun 2004 08:00:32 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 08:07:06 GMT]]></title><description><![CDATA[<p>das mit dem createn des CTreeCtrl elements im Konstruktor der Klasse B habe ich probiert. Mal davon abgesehen das diese member m_Tree bei mir kein Zeiger ist, habe ich durch</p>
<pre><code>m_Tree.Create(WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_BORDER 
		| TVS_HASBUTTONS | VS_LINESATROOT | TVS_HASLINES 
		| TVS_DISABLEDRAGDROP, 
		CRect(10, 10, 300, 100), this, IDC_WATREE);
</code></pre>
<p>das CTreeCtrl element &quot;created&quot;. Aber es funzt trotzdem nocht nicht !!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535743</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535743</guid><dc:creator><![CDATA[peperonee]]></dc:creator><pubDate>Tue, 08 Jun 2004 08:07:06 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 08:21:23 GMT]]></title><description><![CDATA[<p>ich habe die methode BOOL B::OnInitDialog() manuell in meinen Code so eingefuegt. Sie sieht so aus:</p>
<pre><code>BOOL CScopeSelectDlg::OnInitDialog(){

	m_TreeImg.Create(IDB_BITMAP, 16, 2, RGB (255, 255, 255));
	m_Tree.SetImageList(&amp;m_TreeImg, TVSIL_NORMAL);

	MessageBox(&quot;Oninitdialog&quot;,&quot;&quot;,MB_OK);

	return CDialog::OnInitDialog();
}
</code></pre>
<p>Nur ich sehe die obige MessageBox garnicht. Wann wird eigentlich OnInitDialog()aufgerufen? VOR meinem Versuch von m_dlgB-&gt;DoModal() oder DANACH ?</p>
<p>danke, grussle.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535751</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535751</guid><dc:creator><![CDATA[peperonee]]></dc:creator><pubDate>Tue, 08 Jun 2004 08:21:23 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 08:22:51 GMT]]></title><description><![CDATA[<p>Zeig mal genau die Zeile wo dein Programm eine exeption hat.<br />
Wie kommst du dahin ? Debug !!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535752</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535752</guid><dc:creator><![CDATA[Unix-Tom]]></dc:creator><pubDate>Tue, 08 Jun 2004 08:22:51 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 08:35:35 GMT]]></title><description><![CDATA[<p>vielleicht hilft dir das weiter:</p>
<p>[url]<br />
<a href="http://www.devmentor.ch/teaching/additional/00I/Semester6/Abend8/TreeCtrl.pdf" rel="nofollow">http://www.devmentor.ch/teaching/additional/00I/Semester6/Abend8/TreeCtrl.pdf</a><br />
[/url]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535761</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535761</guid><dc:creator><![CDATA[ü]]></dc:creator><pubDate>Tue, 08 Jun 2004 08:35:35 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 08:38:47 GMT]]></title><description><![CDATA[<p>also, soweit ich das jetzt analysiert habe, zerwurschtelt es ihn, weil er das m_Tree dort noch nicht intitialisiert hat.<br />
ich habe testweise die zeile mit Insert vor dem DoModal weggenommen und in die Klasse B OnInitDialog gepackt - funzt einwandfrei.<br />
Mal sehen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535766</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535766</guid><dc:creator><![CDATA[ü]]></dc:creator><pubDate>Tue, 08 Jun 2004 08:38:47 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 08:43:15 GMT]]></title><description><![CDATA[<p>geh den umgekehrten weg:<br />
gib nicht von A nach B, sondern hole mit B von A die Daten !</p>
<p>probier mal folgendes:</p>
<pre><code class="language-cpp">class A : public CDialog
{
public:
    CString strBla;
    void OnButton()
    {
        B dlg(this);
        dlg.DoModal();
    }
}
class B : public CDialog
{
  private:
  A *a;
  public:
  B(A &amp;a)
  {
    this-&gt;a=a;
  }
  BOOL OnInitDialog()
  {
        m_Tree-&gt;InsertItem(a-&gt;m_strBla,TVI_LAST);
        return TRUE;
  }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/535770</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535770</guid><dc:creator><![CDATA[ü]]></dc:creator><pubDate>Tue, 08 Jun 2004 08:43:15 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 08:48:32 GMT]]></title><description><![CDATA[<p>Unix-Tom schrieb:</p>
<blockquote>
<p>Zeig mal genau die Zeile wo dein Programm eine exeption hat.<br />
Wie kommst du dahin ? Debug !!!</p>
</blockquote>
<p>also ich poste mal nochmal ein paar kleine code-schnippsel und sage dann an welcher stelle es abschmiert:</p>
<pre><code>void A::OnButton(){

if(!m_pScopeSelectDlg) 
	AfxMessageBox(&quot;Pointer ist NULL!!&quot;); 
else{ 
	AfxMessageBox(&quot;Hurra&quot;);
	if(m_pScopeSelectDlg-&gt;DoModal()==IDOK){
	}	
}
}
</code></pre>
<p>Ferner habe ich folgende zwei Methoden der Klasse B (Unterdialogsklasse) ueberschrieben:</p>
<pre><code>BOOL B::OnInitDialog(){

   CDialog::OnInitDialog();

   m_Tree.Create(WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_BORDER 
        | TVS_HASBUTTONS | TVS_HASLINES | TVS_DISABLEDRAGDROP, CRect(10, 10,   300, 100), this, IDC_WATREE); 

   m_TreeImg.Create(IDB_BITMAP, 16, 2, RGB (255, 255, 255));
   m_Tree.SetImageList(&amp;m_TreeImg, TVSIL_NORMAL);

   MessageBox(&quot;OnInit&quot;,&quot;&quot;,MB_OK);

   return TRUE;
}

int B::DoModal(){
   MessageBox(&quot;DoModal&quot;,&quot;&quot;,MB_OK);
   return CDialog::DoModal();
}
</code></pre>
<p>Es werden folgende MessageBoxen fuer obigen programm-ablauf gezeigt:</p>
<p>&quot;Hurra&quot;<br />
&quot;DoModal&quot;</p>
<p>Danach kackt es ab mit der Meldung:<br />
&quot;Debug Assertion Failed&quot; [irgendwo in wincore.cpp]<br />
Das heisst die MessageBox &quot;OnInitDialog&quot; wird NICHT angezeigt! <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="😕"
    /><br />
Verlege ich den Inhalt der Methode B::OnInitDialog() in den Konstruktor von B,<br />
schmiert das Programm gleich beim starten ab. <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/535777</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535777</guid><dc:creator><![CDATA[peperonee]]></dc:creator><pubDate>Tue, 08 Jun 2004 08:48:32 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 09:18:39 GMT]]></title><description><![CDATA[<p>Das Problem ist, dass</p>
<pre><code class="language-cpp">mpDlgB-&gt;treeElement.InsertItem(&quot;Hallo&quot;, TVI_ROOT);
</code></pre>
<p>VOR dem DoModal &amp; OnInitDialog aufgerufen wird.<br />
Daher kommt die Assertation !<br />
Du kommst gar nicht mehr zu DoModal bzw. OnInitDialog !<br />
Richtigerweise solltest du das Frühestens im OnInitDialog füllen.</p>
<p>Zuerst wird</p>
<pre><code class="language-cpp">DoModal()
</code></pre>
<p>aufgerufen, anschliessend</p>
<pre><code class="language-cpp">OnInitDialog()
</code></pre>
<pre><code class="language-cpp">BOOL B::OnInitDialog(){ 

   CDialog::OnInitDialog(); 

   m_Tree.Create(WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_BORDER 
        | TVS_HASBUTTONS | TVS_HASLINES | TVS_DISABLEDRAGDROP, CRect(10, 10,   300, 100), this, IDC_WATREE); 

   m_TreeImg.Create(IDB_BITMAP, 16, 2, RGB (255, 255, 255)); 
   m_Tree.SetImageList(&amp;m_TreeImg, TVSIL_NORMAL); 

   MessageBox(&quot;OnInit&quot;,&quot;&quot;,MB_OK); 

   m_Tree.InsertItem(((A*)GetParent())-&gt;GetTextString(),......);

   return TRUE; 
} 

int B::DoModal(){ 
   MessageBox(&quot;DoModal&quot;,&quot;&quot;,MB_OK); 
   return CDialog::DoModal(); 
}
</code></pre>
<pre><code class="language-cpp">[cpp]
void OnButton(){ 
   B pDlg(this);
   if(pDlgB.DoModal()==IDOK){ 
      // hier irgendwas machen .. 
   } 
}
</code></pre>
<p>ich will nun keinen blödsinn schreiben, aber ich denke das es daran liegt, dass</p>
<pre><code class="language-cpp">void B::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(B)
	DDX_Control(pDX, IDC_IDC_WATREE, m_Tree);
	//}}AFX_DATA_MAP
}
</code></pre>
<p>Erst vom OnInitDialog der BASISKLASSE aufgerufen wird !<br />
Daher kennt das Ding das Control nicht und macht einen auf Servus !</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535778</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535778</guid><dc:creator><![CDATA[Ernsti]]></dc:creator><pubDate>Tue, 08 Jun 2004 09:18:39 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 09:00:04 GMT]]></title><description><![CDATA[<p>ü schrieb:</p>
<blockquote>
<p>geh den umgekehrten weg:<br />
gib nicht von A nach B, sondern hole mit B von A die Daten !</p>
</blockquote>
<p>ich glaube das entspricht nicht ganz dem, was ich so in manchem buch gesehen habe :). Da sind die Subdialoge als member des hauptdialogs zu sehen und nicht umgekehrt (ich vermute mal das ist geschmackssache !?).</p>
<p>Darueber hinaus noch zu Ernsti:</p>
<p>Ja das was du sagtest entspricht dem programm-verhalten. Nur mich wunderts warum B::OnInitDialog() bei mir ueberhaupt nicht aufgerufen wird!?</p>
<p>Gibt es eigentlich fuer solch einen Fall, wie ich ihn hier habe keinen standard-loesungsweg !?!?!??<br />
Mein problem ist doch nur dass zunaechst das CTreeCtrl im subdialog mit daten gefuellt werden soll und danach vom hauptdialog aus angezeigt werden soll.</p>
<p>das &quot;createn&quot; des CTreeCtrl geschieht bei mir in B::OnInitDialog() (siehe code oben). Der zeiger auf das B-Objekt wird in A::A() initialisiert (siehe auch oben). Warum funzt der scheiss also net <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/535795</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535795</guid><dc:creator><![CDATA[peperonee]]></dc:creator><pubDate>Tue, 08 Jun 2004 09:00:04 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 09:13:07 GMT]]></title><description><![CDATA[<p>OnInitDialog von B wird nicht mehr aufgerufen, weil es ihn bereits VOR dem DoModal weghängt.<br />
Bei von mir o.a. Lösung gibst du bei Erstellen von Dialog B einen Zeiger auf A mit. Dann hast du von B über GetParent() Zugriff auf A und kannst im OnInitDialog dein Control füllen und ANSCHLIESSEND anzeigen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535798</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535798</guid><dc:creator><![CDATA[Ernsti]]></dc:creator><pubDate>Tue, 08 Jun 2004 09:13:07 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 09:12:44 GMT]]></title><description><![CDATA[<p>ich habe folgendes herausgefunden:<br />
ich habe den bereits geposteten code von BOOL B::OnInitDialog()<br />
wie folgt erweiter:</p>
<pre><code>BOOL CScopeSelectDlg::OnInitDialog(){

  CDialog::OnInitDialog();

  MessageBox(&quot;1&quot;,&quot;&quot;,MB_OK);
  m_Tree.Create(	WS_VISIBLE | WS_TABSTOP | 
		WS_CHILD | WS_BORDER |
		TVS_HASBUTTONS | TVS_HASLINES | 
		TVS_DISABLEDRAGDROP, CRect(10, 10, 300, 100), 
		this, IDC_WATREE); 

  MessageBox(&quot;2&quot;,&quot;&quot;,MB_OK);
  m_TreeImg.Create(IDB_BITMAP, 16, 2, RGB (255, 255, 255));

  MessageBox(&quot;3&quot;,&quot;&quot;,MB_OK);
  m_Tree.SetImageList(&amp;m_TreeImg, TVSIL_NORMAL);

  MessageBox(&quot;4&quot;,&quot;&quot;,MB_OK);
  return TRUE;
}
</code></pre>
<p>Ich weiss das sind nicht gerade die besten debug-vorgehen :)) aber eine weiter hilfreiche info waere vielleicht, dass ich nur die MessageBox &quot;1&quot; des obigen Aufrufs zu sehen bekomme. D.h. das mit dem m_Tree.Create(...) kackt ab.</p>
<p>woran kann das liegen?</p>
<p>grussle</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535811</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535811</guid><dc:creator><![CDATA[peperonee]]></dc:creator><pubDate>Tue, 08 Jun 2004 09:12:44 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 09:16:50 GMT]]></title><description><![CDATA[<p>Ist m_Tree vielleicht NULL ?</p>
<p>Hast du das da:</p>
<pre><code class="language-cpp">void B::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(B)
	DDX_Control(pDX, IDC_IDC_WATREE, m_Tree);
	//}}AFX_DATA_MAP
}
</code></pre>
<p>und ein Control auf deinem Dialog damit verbunden (mit Resourceneditor gemacht)</p>
<p>dann kannst du dir das Create sparen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535814</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535814</guid><dc:creator><![CDATA[Ernsti]]></dc:creator><pubDate>Tue, 08 Jun 2004 09:16:50 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 09:43:40 GMT]]></title><description><![CDATA[<p>So, ich hab dir ein Beispiel gebastelt, was bei wunderbar funzt.</p>
<pre><code class="language-cpp">//*******************************************************************
// A Dialog Headerfile
//*******************************************************************
#ifndef _A_H_
#define _A_H_

//*******************************************************************

//*******************************************************************

class A : public CDialog
{
public:
	A(CWnd* pParent = NULL);	
	CString	m_strHomer;
	CString	m_strMarge;
	CString	m_strBart;
	CString	m_strLisa;
	CString	m_strMaggie;
	enum { IDD = IDD_DLG_DIALOG };
protected:
	afx_msg void OnButton1();
	DECLARE_MESSAGE_MAP()
};

//*******************************************************************

#endif 

//*******************************************************************
//*******************************************************************
//*******************************************************************
</code></pre>
<pre><code class="language-cpp">//*******************************************************************
// A Dialog cppfile
//*******************************************************************
#include &quot;stdafx.h&quot;
#include &quot;B.h&quot;
#include &quot;A.h&quot;

//*******************************************************************
// konstruktor
//*******************************************************************
A::A(CWnd* pParent) CDialog(A::IDD, pParent)
{
	m_strHomer =&quot;Homer&quot;;
	m_strMarge =&quot;Marge&quot;;
	m_strBart  =&quot;Bart&quot;;
	m_strLisa  =&quot;Lisa&quot;;
	m_strMaggie=&quot;Maggie&quot;;
}

//*******************************************************************
// messagemap
//*******************************************************************
BEGIN_MESSAGE_MAP(A, CDialog)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
END_MESSAGE_MAP()

//*******************************************************************
// button gedrückt
//*******************************************************************
void A::OnButton1() 
{
	B dlg;
	dlg.DoModal();	
}

//*******************************************************************
//*******************************************************************
//*******************************************************************
</code></pre>
<pre><code class="language-cpp">//*******************************************************************
// B Dialog Header file
//*******************************************************************
#ifndef _B_H_
#define _B_H_

//*******************************************************************

//*******************************************************************

class B : public CDialog
{
public:
	CTreeCtrl m_Tree; 
	B(CWnd* pParent = NULL);
	enum { IDD = IDD_DIALOG1 };
protected:
	virtual void DoDataExchange(CDataExchange* pDX);    
	afx_msg void OnButton1();
	virtual BOOL OnInitDialog();
};

//*******************************************************************

#endif 

//*******************************************************************
//*******************************************************************
//*******************************************************************
</code></pre>
<pre><code class="language-cpp">//*******************************************************************
// B - Dialog cpp file
//*******************************************************************
#include &quot;stdafx.h&quot;
#include &quot;A.h&quot;
#include &quot;B.h&quot;

//*******************************************************************
// konstruktor
//*******************************************************************
B::B(CWnd* pParent) : CDialog(B::IDD, pParent)
{
}

//*******************************************************************
// ddx
//*******************************************************************
void B::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_TREE1, m_Tree);
}

//*******************************************************************
// initialisiert den dialog
//*******************************************************************
BOOL B::OnInitDialog() 
{
	CDialog::OnInitDialog();

	m_Tree.InsertItem(((A*)GetParent())-&gt;m_strHomer, NULL,TVI_LAST);
	m_Tree.InsertItem(((A*)GetParent())-&gt;m_strMarge, NULL,TVI_LAST);
	m_Tree.InsertItem(((A*)GetParent())-&gt;m_strBart,  NULL,TVI_LAST);
	m_Tree.InsertItem(((A*)GetParent())-&gt;m_strLisa,  NULL,TVI_LAST);
	m_Tree.InsertItem(((A*)GetParent())-&gt;m_strMaggie,NULL,TVI_LAST);

	return TRUE;  
}

//*******************************************************************
//*******************************************************************
//*******************************************************************
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/535840</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535840</guid><dc:creator><![CDATA[Ernsti]]></dc:creator><pubDate>Tue, 08 Jun 2004 09:43:40 GMT</pubDate></item><item><title><![CDATA[Reply to Subdialogaufruf kackt ab, weiss net warum on Tue, 08 Jun 2004 09:52:53 GMT]]></title><description><![CDATA[<p>vielen vieleeen dank :))</p>
<p>ich habe wie von euch vorgeschlagen das fuellen des CTreeCtrl Elements in die OnInitDialog von Klasse B verschoben. Das Create kann ich mir in der Tat sparen, da ich das Tree-Element mit Ressourcen-Editor erstellt hatte (Warum ein zweites Create dann gleich abkackt ist mir nicht ganz geheuer).</p>
<p>Nun funzt alles wunderbar.</p>
<p>Ich danke allen vielmals <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>grussle</p>
]]></description><link>https://www.c-plusplus.net/forum/post/535850</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/535850</guid><dc:creator><![CDATA[peperonee]]></dc:creator><pubDate>Tue, 08 Jun 2004 09:52:53 GMT</pubDate></item></channel></rss>