<?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[Ereigniss für dynamische Komponente]]></title><description><![CDATA[<p>Hallo,</p>
<p>habe jetzt die halbe Nacht das FAQ und hier das Forum durchgeackert, bekomme es aber einfach nicht hin: Ich brauche für ein TStringGrid das Ereigniss DrawCell:</p>
<p>Ich erzeuge in einer Schleife x TStringGrids; das funktioniert auch. Nur die Zuweisung eines Ereignisses klappt nicht. Bekomme entweder Konvertierungs oder TypeDef Fehler.</p>
<p>IM CPP:</p>
<p>Erzeugen:</p>
<pre><code class="language-cpp">Grid[i1]=new TStringGrid(this);                                               // neues Control entwerfen
  Grid[i1]-&gt;Parent=frm22_scr1_Box;                                              // Parent zuordnen
  Grid[i1]-&gt;Left=iX;                                                            // Rand einstellen
  Grid[i1]-&gt;ColCount=25;                                                        // Anzahl Spalten
  Grid[i1]-&gt;RowCount=10;                                                        // Anzahl Zeilen
  Grid[i1]-&gt;DefaultDrawing=true;                                                // selbst zeichnen ja
  Grid[i1]-&gt;DefaultRowHeight=15;                                                // Standardhöhe
  Grid[i1]-&gt;FixedCols=1;                                                        // 1 feste Spalte
  Grid[i1]-&gt;FixedRows=1;                                                        // 1 feste Zeile
  Grid[i1]-&gt;FixedColor=clCream;                                                 // feste Zellen in hellgelb
  Grid[i1]-&gt;Options &lt;&lt; goRangeSelect &lt;&lt; goThumbTracking;                        // Optionen setzen
  Grid[i1]-&gt;Options &gt;&gt; goFixedVertLine &gt;&gt; goFixedHorzLine &gt;&gt; goVertLine &gt;&gt; goHorzLine; // Optionen löschen
  Grid[i1]-&gt;ScrollBars=ssBoth;                                                  // beide Slider
  Grid[i1]-&gt;Name=&quot;frm22_grd1_Schrank&quot;+IntToStr(i1);                             // Komponentenname geben
  //Grid[i1]-&gt;OnClick=...;                                                       // bei Anklicken wie reagieren
  Grid[i1]-&gt;Top=25;                                                             // Oben
  Grid[i1]-&gt;Width=iBreite;                                                      // Breite
  Grid[i1]-&gt;Height=iH-220;                                                      // Höhe
  Grid[i1]-&gt;Visible=true;                                                       // sichtbar ja
  Grid[i1]-&gt;Show();                                                             // und jetzt zeigen
  Grid[i1]-&gt;OnDrawCell=GridDrawCell; // FEHLER Konvertierung E2034 ????
  //Grid[i1]-&gt;OnDrawCell(TObject *Sender, int ACol, int ARow, TRect &amp;Rect, TGridDrawState State);
</code></pre>
<pre><code class="language-cpp">void __fastcall TForm22::GridDrawCell(TObject *Sender, int ACol, int ARow, TRect &amp;Rect, TGridDrawState State)
{TStringGrid  *Grid  = dynamic_cast&lt;TStringGrid  *&gt; (Sender);                   // Versuchen, Sender als StringGrid  anzusprechen
 if(Grid) { GridZeichnen(1,ACol,ARow,Rect,State,Grid); }                        // und dann zeichnen
}
</code></pre>
<p>IM HEADER:</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#ifndef SkylineH
#define SkylineH
//---------------------------------------------------------------------------
#include &lt;Classes.hpp&gt;
#include &lt;Controls.hpp&gt;
#include &lt;StdCtrls.hpp&gt;
#include &lt;Forms.hpp&gt;
#include &lt;ComCtrls.hpp&gt;
#include &lt;Grids.hpp&gt;
#include &lt;Buttons.hpp&gt;

// ?????
typedef  void __fastcall (__closure *GridDrawCell)(TObject *Sender, int ACol, int ARow, TRect &amp;Rect, TGridDrawState State);

//---------------------------------------------------------------------------
class TForm22 : public TForm
{
__published:	                                                                // Von der IDE verwaltete Komponenten
        TButton *frm22_btnDrucken;
        TButton *frm22_btnHilfe;
        TButton *frm22_btnBeenden;
        TLabel *frm22_lbl1;
        TLabel *frm22_lblGeraet;
        TStatusBar *frm22_stbStatus;
        TPageControl *frm22_tabReiter;
        TTabSheet *frm22_tabSchrank;
        TTabSheet *frm22_tabKomp;
        TScrollBox *frm22_scr1_Box;
        TBitBtn *frm22_btnOptionen;
        TButton *frm22_btnAktuell;
        void __fastcall frm22_btnBeendenClick(TObject *Sender);
        void __fastcall FormResize(TObject *Sender);
        void __fastcall FormShow(TObject *Sender);
        void __fastcall FormClose(TObject *Sender, TCloseAction &amp;Action);
        void __fastcall frm22_btnAktuellClick(TObject *Sender);
private:	                                                                // Anwender-Deklarationen
public:		                                                                // Anwender-Deklarationen
 Integer     iBreite;                                                           // definieren
 TStringGrid *Grid[50];                                                         // vorbereiten
 TLabel      *Label[50];                                                        // vorbereiten

// Boolean frm22_GridDrawCell(TObject *Sender);                                   // Funktion definieren

        __fastcall TForm22(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm22 *Form22;
//---------------------------------------------------------------------------
#endif
</code></pre>
<p>Ich denke mal der Fehler ist im Header; anhand dieses Beispiels<br />
komme ich aber nicht weiter:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39204.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-39204.html</a></p>
<p>Bin für jeden Tip dankbar...<br />
Gruss, Stefan</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/158394/ereigniss-für-dynamische-komponente</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 15:40:09 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/158394.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 05 Sep 2006 03:57:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ereigniss für dynamische Komponente on Tue, 05 Sep 2006 03:57:48 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>habe jetzt die halbe Nacht das FAQ und hier das Forum durchgeackert, bekomme es aber einfach nicht hin: Ich brauche für ein TStringGrid das Ereigniss DrawCell:</p>
<p>Ich erzeuge in einer Schleife x TStringGrids; das funktioniert auch. Nur die Zuweisung eines Ereignisses klappt nicht. Bekomme entweder Konvertierungs oder TypeDef Fehler.</p>
<p>IM CPP:</p>
<p>Erzeugen:</p>
<pre><code class="language-cpp">Grid[i1]=new TStringGrid(this);                                               // neues Control entwerfen
  Grid[i1]-&gt;Parent=frm22_scr1_Box;                                              // Parent zuordnen
  Grid[i1]-&gt;Left=iX;                                                            // Rand einstellen
  Grid[i1]-&gt;ColCount=25;                                                        // Anzahl Spalten
  Grid[i1]-&gt;RowCount=10;                                                        // Anzahl Zeilen
  Grid[i1]-&gt;DefaultDrawing=true;                                                // selbst zeichnen ja
  Grid[i1]-&gt;DefaultRowHeight=15;                                                // Standardhöhe
  Grid[i1]-&gt;FixedCols=1;                                                        // 1 feste Spalte
  Grid[i1]-&gt;FixedRows=1;                                                        // 1 feste Zeile
  Grid[i1]-&gt;FixedColor=clCream;                                                 // feste Zellen in hellgelb
  Grid[i1]-&gt;Options &lt;&lt; goRangeSelect &lt;&lt; goThumbTracking;                        // Optionen setzen
  Grid[i1]-&gt;Options &gt;&gt; goFixedVertLine &gt;&gt; goFixedHorzLine &gt;&gt; goVertLine &gt;&gt; goHorzLine; // Optionen löschen
  Grid[i1]-&gt;ScrollBars=ssBoth;                                                  // beide Slider
  Grid[i1]-&gt;Name=&quot;frm22_grd1_Schrank&quot;+IntToStr(i1);                             // Komponentenname geben
  //Grid[i1]-&gt;OnClick=...;                                                       // bei Anklicken wie reagieren
  Grid[i1]-&gt;Top=25;                                                             // Oben
  Grid[i1]-&gt;Width=iBreite;                                                      // Breite
  Grid[i1]-&gt;Height=iH-220;                                                      // Höhe
  Grid[i1]-&gt;Visible=true;                                                       // sichtbar ja
  Grid[i1]-&gt;Show();                                                             // und jetzt zeigen
  Grid[i1]-&gt;OnDrawCell=GridDrawCell; // FEHLER Konvertierung E2034 ????
  //Grid[i1]-&gt;OnDrawCell(TObject *Sender, int ACol, int ARow, TRect &amp;Rect, TGridDrawState State);
</code></pre>
<pre><code class="language-cpp">void __fastcall TForm22::GridDrawCell(TObject *Sender, int ACol, int ARow, TRect &amp;Rect, TGridDrawState State)
{TStringGrid  *Grid  = dynamic_cast&lt;TStringGrid  *&gt; (Sender);                   // Versuchen, Sender als StringGrid  anzusprechen
 if(Grid) { GridZeichnen(1,ACol,ARow,Rect,State,Grid); }                        // und dann zeichnen
}
</code></pre>
<p>IM HEADER:</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#ifndef SkylineH
#define SkylineH
//---------------------------------------------------------------------------
#include &lt;Classes.hpp&gt;
#include &lt;Controls.hpp&gt;
#include &lt;StdCtrls.hpp&gt;
#include &lt;Forms.hpp&gt;
#include &lt;ComCtrls.hpp&gt;
#include &lt;Grids.hpp&gt;
#include &lt;Buttons.hpp&gt;

// ?????
typedef  void __fastcall (__closure *GridDrawCell)(TObject *Sender, int ACol, int ARow, TRect &amp;Rect, TGridDrawState State);

//---------------------------------------------------------------------------
class TForm22 : public TForm
{
__published:	                                                                // Von der IDE verwaltete Komponenten
        TButton *frm22_btnDrucken;
        TButton *frm22_btnHilfe;
        TButton *frm22_btnBeenden;
        TLabel *frm22_lbl1;
        TLabel *frm22_lblGeraet;
        TStatusBar *frm22_stbStatus;
        TPageControl *frm22_tabReiter;
        TTabSheet *frm22_tabSchrank;
        TTabSheet *frm22_tabKomp;
        TScrollBox *frm22_scr1_Box;
        TBitBtn *frm22_btnOptionen;
        TButton *frm22_btnAktuell;
        void __fastcall frm22_btnBeendenClick(TObject *Sender);
        void __fastcall FormResize(TObject *Sender);
        void __fastcall FormShow(TObject *Sender);
        void __fastcall FormClose(TObject *Sender, TCloseAction &amp;Action);
        void __fastcall frm22_btnAktuellClick(TObject *Sender);
private:	                                                                // Anwender-Deklarationen
public:		                                                                // Anwender-Deklarationen
 Integer     iBreite;                                                           // definieren
 TStringGrid *Grid[50];                                                         // vorbereiten
 TLabel      *Label[50];                                                        // vorbereiten

// Boolean frm22_GridDrawCell(TObject *Sender);                                   // Funktion definieren

        __fastcall TForm22(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm22 *Form22;
//---------------------------------------------------------------------------
#endif
</code></pre>
<p>Ich denke mal der Fehler ist im Header; anhand dieses Beispiels<br />
komme ich aber nicht weiter:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39204.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-39204.html</a></p>
<p>Bin für jeden Tip dankbar...<br />
Gruss, Stefan</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1131219</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1131219</guid><dc:creator><![CDATA[Stefan71242]]></dc:creator><pubDate>Tue, 05 Sep 2006 03:57:48 GMT</pubDate></item><item><title><![CDATA[Reply to Ereigniss für dynamische Komponente on Tue, 05 Sep 2006 05:16:01 GMT]]></title><description><![CDATA[<p>die einfachste Methode so ein Problem zu lösen ist: ein StringGrid auf dem Form platzieren, dort das Ereignis OnDrawCell erstellen (im Objektinspektor) und dann einfach sehen was in der CPP und im Header passiert.<br />
Einziger Unterschied beim dynamischen Zuweisen zur Laufzeit ist das const vor dem TRect</p>
<p>in der CPP</p>
<pre><code class="language-cpp">void __fastcall TForm1::GridDrawCell(TObject *Sender, int ACol,
      int ARow, const TRect &amp;Rect, TGridDrawState State)
{

}
</code></pre>
<p>im Header</p>
<pre><code class="language-cpp">class TForm1 : public TForm
{
...
private:	// Anwender-Deklarationen
	void __fastcall GridDrawCell(TObject *Sender, int ACol, int ARow,
         const TRect &amp;Rect, TGridDrawState State);
...
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1131221</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1131221</guid><dc:creator><![CDATA[Linnea]]></dc:creator><pubDate>Tue, 05 Sep 2006 05:16:01 GMT</pubDate></item><item><title><![CDATA[Reply to Ereigniss für dynamische Komponente on Tue, 05 Sep 2006 07:05:20 GMT]]></title><description><![CDATA[<p>Hallo, Linnea</p>
<p>vielen Dank! Es funktioniert, aber wieso muss<br />
denn das Const rein... ?</p>
<p>Na ja, zumindest war ich dicht dran <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";-)"
      alt="😉"
    /></p>
<p>Gruss, Stefan</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1131249</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1131249</guid><dc:creator><![CDATA[Stefan71242]]></dc:creator><pubDate>Tue, 05 Sep 2006 07:05:20 GMT</pubDate></item><item><title><![CDATA[Reply to Ereigniss für dynamische Komponente on Tue, 05 Sep 2006 07:17:52 GMT]]></title><description><![CDATA[<p>Das Const steht da drin, damit das Rechteck für die Zellengröße nicht verändert werden kann. Wenn du es dennoch versucht, bekommst du einen compilerfehler.<br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1131253</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1131253</guid><dc:creator><![CDATA[Burkhi]]></dc:creator><pubDate>Tue, 05 Sep 2006 07:17:52 GMT</pubDate></item></channel></rss>