<?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[Grafische Komponenente]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte eine grafische Komponente mit zunächst einer property IMColor erstellen.</p>
<pre><code class="language-cpp">static inline void ValidCtrCheck(TComponent1 *)
{
	new TComponent1(NULL);
}
//---------------------------------------------------------------------------
__fastcall TComponent1::TComponent1(TComponent* Owner)
	: TComponent(Owner)
{
	Image = new TImage(Owner);
     Image-&gt;Parent 	= ((TWinControl*)Owner)-&gt;Parent;
     Image-&gt;Height 	= 100;
     Image-&gt;Width  	= 100;
     Image-&gt;Visible	= true;
	IMColor		= clRed;
     DrawGrafValue();
}
//---------------------------------------------------------------------------
namespace Component1
{
	void __fastcall PACKAGE Register()
	{
		TComponentClass classes[1] = {__classid(TComponent1)};
		RegisterComponents(&quot;Standard&quot;, classes, 0);
	}
}
//---------------------------------------------------------------------------
//
//---------------------------------------------------------------------------
void TComponent1::DrawGrafValue(void)
{
	Image-&gt;Canvas-&gt;Brush-&gt;Color = IMColor;
     Image-&gt;Canvas-&gt;FillRect(Rect(0,0,Image-&gt;Width,Image-&gt;Height));
}
</code></pre>
<p>Wie muss ich nun vorgehen, das die Komponente immer wieder neu<br />
gezeichnet wird. (Paint?)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/125606/grafische-komponenente</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Jul 2026 22:03:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/125606.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 07 Nov 2005 21:49:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Grafische Komponenente on Mon, 07 Nov 2005 21:49:31 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte eine grafische Komponente mit zunächst einer property IMColor erstellen.</p>
<pre><code class="language-cpp">static inline void ValidCtrCheck(TComponent1 *)
{
	new TComponent1(NULL);
}
//---------------------------------------------------------------------------
__fastcall TComponent1::TComponent1(TComponent* Owner)
	: TComponent(Owner)
{
	Image = new TImage(Owner);
     Image-&gt;Parent 	= ((TWinControl*)Owner)-&gt;Parent;
     Image-&gt;Height 	= 100;
     Image-&gt;Width  	= 100;
     Image-&gt;Visible	= true;
	IMColor		= clRed;
     DrawGrafValue();
}
//---------------------------------------------------------------------------
namespace Component1
{
	void __fastcall PACKAGE Register()
	{
		TComponentClass classes[1] = {__classid(TComponent1)};
		RegisterComponents(&quot;Standard&quot;, classes, 0);
	}
}
//---------------------------------------------------------------------------
//
//---------------------------------------------------------------------------
void TComponent1::DrawGrafValue(void)
{
	Image-&gt;Canvas-&gt;Brush-&gt;Color = IMColor;
     Image-&gt;Canvas-&gt;FillRect(Rect(0,0,Image-&gt;Width,Image-&gt;Height));
}
</code></pre>
<p>Wie muss ich nun vorgehen, das die Komponente immer wieder neu<br />
gezeichnet wird. (Paint?)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/911202</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/911202</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Mon, 07 Nov 2005 21:49:31 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Tue, 08 Nov 2005 07:27:29 GMT]]></title><description><![CDATA[<p>die komponenten von <strong>TGrapicControl</strong> ableiten und nicht von <strong>TComponent</strong> und die methode</p>
<pre><code class="language-cpp">virtual void  __fastcall Paint(void);
</code></pre>
<p>ueberschreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/911366</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/911366</guid><dc:creator><![CDATA[Sunday]]></dc:creator><pubDate>Tue, 08 Nov 2005 07:27:29 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Tue, 08 Nov 2005 21:30:58 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">//---------------------------------------------------------------------------
__fastcall TGraphicControl1::TGraphicControl1(TComponent* Owner)
	: TGraphicControl(Owner)
{
	Image = new TImage(Owner);
     Image-&gt;Parent 	= ((TWinControl*)Owner)-&gt;Parent;
     Image-&gt;Height 	= 100;
     Image-&gt;Width  	= 100;
     Image-&gt;Visible	= true;
	IMColor		= clRed;
}
//---------------------------------------------------------------------------
void __fastcall TGraphicControl1::Paint(void)
{
	DrawGrafValue();
}
//---------------------------------------------------------------------------
// Zeichnet eine Balckengrafig
//---------------------------------------------------------------------------
void TGraphicControl1::DrawGrafValue(void)
{
	Image-&gt;Canvas-&gt;Brush-&gt;Color = IMColor;
     Image-&gt;Canvas-&gt;FillRect(Rect(0,0,Image-&gt;Width,Image-&gt;Height));
}
</code></pre>
<p>Habe das ganze nun von TGraphicControl abgeleitet sowie die virtuelle Funktion<br />
Paint überschrieben, ändere ich nun die Eigenschaft Farbe der Componente tu sich aber nichts.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/912263</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/912263</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Tue, 08 Nov 2005 21:30:58 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Wed, 09 Nov 2005 08:10:10 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Du mußt dafür sorgen, dass Paint nach Ändern der Frabe auch aufgerufen wird. Wenn die Änderung von IMColor über eine set-Methode erfolgt (evtl. in einer Property) dann ruftst du einfach dort Repaint() auf. Wenn IMColor einfach nur eine Membervariable ist, mach eine Property draus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/912438</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/912438</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Wed, 09 Nov 2005 08:10:10 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Wed, 09 Nov 2005 10:38:20 GMT]]></title><description><![CDATA[<blockquote>
<p>Du mußt dafür sorgen, dass Paint nach Ändern der Frabe auch aufgerufen wird. Wenn die Änderung von IMColor über eine set-Methode erfolgt (evtl. in einer Property) dann ruftst du einfach dort Repaint() auf. Wenn IMColor einfach nur eine Membervariable ist, mach eine Property draus.</p>
</blockquote>
<p>Jo alles klar.</p>
<p>Wie kann ich nun noch dafür sorgen das die Komponenete schon zur Entwurfszeit<br />
auf dem Formular sichtbar wird und bei Änderung einer Property im<br />
Objektinspektor neu gezeichznet wird?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/912580</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/912580</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Wed, 09 Nov 2005 10:38:20 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Wed, 09 Nov 2005 12:33:53 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>das passiert automatisch, wenn du wie beschrieben ableitest und Paint() benutzt.<br />
Und wenn du bei den Settern der Eigenscvhaften, die du im OI anzeigen läßt, auch entsprechend die Repaint-Methode aufrufst.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/912687</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/912687</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Wed, 09 Nov 2005 12:33:53 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Wed, 09 Nov 2005 22:55:40 GMT]]></title><description><![CDATA[<p>Mit einem Setter lässt sich nun die Eigenschaft Color auch zur Entwurfszeit<br />
ändern.</p>
<p>Habe nun ein anderes Problem, beim plazieren der Komponente existieren nun<br />
zwei Komponenten. Einmal die von mir erstellte mit der entsprechenden<br />
Eigenschaft Color, sowie eine weitere ohne Namen die alle Eigenschaften von<br />
einem Image hat. Bei dieser Komponente ändert sich dann auch die Farbe.<br />
Meine eigentliche Komponente bleibt dabei unsichtbar.</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------
class PACKAGE TGraphicControl1 : public TGraphicControl
{
private:
TImage *Image;
TColor IMColor;
void __fastcall Paint(void);
void __fastcall SetIMColor(TColor NewColor);
void DrawGrafValue(void);
__published:
	__property TColor Color = {read=IMColor,write=SetIMColor};
protected:
public:
	__fastcall TGraphicControl1(TComponent* Owner);

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
__fastcall TGraphicControl1::TGraphicControl1(TComponent* Owner)
	: TGraphicControl(Owner)
{
	Image = new TImage(Owner);
     Image-&gt;Parent 	= ((TWinControl*)Owner);
     Image-&gt;Height 	= 100;
     Image-&gt;Width  	= 100;
     Image-&gt;Visible	= true;
	IMColor		= clRed;
}
//---------------------------------------------------------------------------
void __fastcall TGraphicControl1::SetIMColor(TColor NewColor)
{
	if(Image) IMColor = NewColor;
     Repaint();
}
//---------------------------------------------------------------------------
void __fastcall TGraphicControl1::Paint(void)
{
	DrawGrafValue();
}
//---------------------------------------------------------------------------
// Zeichnet eine Balckengrafig
//---------------------------------------------------------------------------
void TGraphicControl1::DrawGrafValue(void)
{
	Image-&gt;Canvas-&gt;Brush-&gt;Color = IMColor;
     Image-&gt;Canvas-&gt;FillRect(Rect(0,0,Image-&gt;Width,Image-&gt;Height));
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/913452</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913452</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Wed, 09 Nov 2005 22:55:40 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Wed, 09 Nov 2005 22:53:44 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>und wo ist jetzt das Problem? Ich sehe keine Frage.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913455</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913455</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Wed, 09 Nov 2005 22:53:44 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Wed, 09 Nov 2005 23:00:09 GMT]]></title><description><![CDATA[<p>Meine Frage über dem Source Code.</p>
<p>Habe nun ein anderes Problem, beim plazieren der Komponente existieren nun<br />
zwei Komponenten. Einmal die von mir erstellte mit der entsprechenden<br />
Eigenschaft Color, sowie eine weitere ohne Namen die alle Eigenschaften von<br />
einem Image hat. Bei dieser Komponente ändert sich dann auch die Farbe.<br />
Meine eigentliche Komponente bleibt dabei unsichtbar.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913458</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913458</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Wed, 09 Nov 2005 23:00:09 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Wed, 09 Nov 2005 23:04:15 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>ich sehe immer noch nicht, was du nun von uns wissen willst. Was stört dich an den beschriebenen Fakten? Wie soll es werden?</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913459</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Wed, 09 Nov 2005 23:04:15 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Thu, 10 Nov 2005 07:37:59 GMT]]></title><description><![CDATA[<p>mal ein paar anmerkungen...</p>
<p>das Paint sollte wie bereits von mir geschrieben <strong>virtual</strong> sein, denn sonst kannst du mal später nicht von deiner komponente ableiten und das Paint in der abgeleiteten Version verwenden. (bin grad nicht sicher... oder hiess einmal virtual immer virtual?)</p>
<p>wieso bekommt das TImage den selben Owner wie deine komponente und nicht die komponente selbst?</p>
<pre><code class="language-cpp">Image         = new TImage(this);
Image-&gt;Parent = this;
</code></pre>
<p>ausserdem ist ein name wie <strong>TGraphicControl1</strong> ziemlich blöd gewählt, führt schnell dazu sich zu verlesen, da auch die 1 (eins) kaum von l (L) zu unterscheiden ist...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913559</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913559</guid><dc:creator><![CDATA[Sunday]]></dc:creator><pubDate>Thu, 10 Nov 2005 07:37:59 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Thu, 10 Nov 2005 09:00:01 GMT]]></title><description><![CDATA[<p>Sunday schrieb:</p>
<blockquote>
<p>(bin grad nicht sicher... oder hiess einmal virtual immer virtual?)</p>
</blockquote>
<p>Genau so ist es.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913641</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913641</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 10 Nov 2005 09:00:01 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Thu, 10 Nov 2005 10:10:34 GMT]]></title><description><![CDATA[<p>Noch mal zur Sicherheit der Standard: Kapitel 10.3 2</p>
<blockquote>
<p>If a virtual member function vf is declared in a class Base and in a class Derived, derived directly or indirectly from Base, a member function vf with the same name and same parameter list as Base::vf is declared, then Derived::vf is also virtual (whether or not it is so declared) and it overrides Base::vf.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/913699</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913699</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 10 Nov 2005 10:10:34 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Thu, 10 Nov 2005 14:25:53 GMT]]></title><description><![CDATA[<blockquote>
<p>Image = new TImage(this);<br />
Image-&gt;Parent = this;</p>
</blockquote>
<p>Ok, Owner von Image sollte natürlich meine Komponenete sein, ebenfalls<br />
das Parent von Image.</p>
<p>Image-&gt;Parent = this; //Parent ist meine Komponente</p>
<p>gibt eine Fehlermeldung &quot;... TTemp *const nach TWinControl* nicht möglich.</p>
<p>Caste ich den Pointer this auf TWinControl<br />
Image-&gt;Parent = ((TWinControl*)Owner)this;<br />
kommt der Fehler zwar nicht mehr, dafür gibt es beim benutzen der Komponenete<br />
eine Zugrifsverletzung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913963</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913963</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Thu, 10 Nov 2005 14:25:53 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Thu, 10 Nov 2005 14:47:53 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>das liegt ja auch daran, das TGraphicControl nicht von TWinControl abgeleitet ist, und damit auch nicht dein TGraphicControl1. Damit kannst du zwar diesen harten C-Style Cast machen, aber das Ergbnis ist in jedenfall fehlerhaft. Mit einem static_cast stattdessen hätte dich der Compiler davor gewarnt.</p>
<p>Du must als Parent in deinem Fall den Parent von dem TGraphicControl1 übergeben</p>
<pre><code class="language-cpp">Image-&gt;Parent = Parent;
</code></pre>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/914009</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/914009</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Thu, 10 Nov 2005 14:47:53 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Thu, 10 Nov 2005 15:18:32 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<blockquote>
<p>das liegt ja auch daran, das TGraphicControl nicht von TWinControl abgeleitet ist, und damit auch nicht dein TGraphicControl1. Damit kannst du zwar diesen harten C-Style Cast machen, aber das Ergbnis ist in jedenfall fehlerhaft. Mit einem static_cast stattdessen hätte dich der Compiler davor gewarnt.</p>
</blockquote>
<p>Ok, da TGraphicControl nicht von TWinControl abgeleitet ist darf ich den Pointer natürlich nicht auf TWinControl casten.</p>
<p>Mein Code sieht nun folgendermassen aus.</p>
<pre><code class="language-cpp">class PACKAGE TTemp : public TGraphicControl
{
private:
TImage *Image;
TColor IMColor;
void __fastcall Paint(void);
void __fastcall SetIMColor(TColor NewColor);
void DrawGrafValue(void);
__published:
    __property TColor Color = {read=IMColor,write=SetIMColor};
protected:
public:
	__fastcall TTemp(TComponent* Owner);
};

//---------------------------------------------------------------------------
__fastcall TTemp::TTemp(TComponent* Owner)
	: TGraphicControl(Owner)
{
    Image = new TImage(this);
    Image-&gt;Parent = Parent;    //Parent des erstellten Objects
    Image-&gt;Height     = 100;
    Image-&gt;Width      = 100;
    Image-&gt;Visible    = true;
    SetIMColor(clRed);
}
//---------------------------------------------------------------------------
void __fastcall TTemp::SetIMColor(TColor NewColor)
{
    if(Image) IMColor = NewColor;
     Repaint();
}
//---------------------------------------------------------------------------
void __fastcall TTemp::Paint(void)
{
    DrawGrafValue();
}
//---------------------------------------------------------------------------
// Zeichnet eine Balckengrafig
//---------------------------------------------------------------------------
void TTemp::DrawGrafValue(void)
{
    Image-&gt;Canvas-&gt;Brush-&gt;Color = IMColor;
     Image-&gt;Canvas-&gt;FillRect(Rect(0,0,Image-&gt;Width,Image-&gt;Height));
}
</code></pre>
<p>Nun wird die Komponenete trotz Repaint nicht mehr gezeichnet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/914052</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/914052</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Thu, 10 Nov 2005 15:18:32 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Thu, 10 Nov 2005 15:34:59 GMT]]></title><description><![CDATA[<p>probiere mal statt <strong>Repaint</strong> ein <strong>Invalidate();</strong>...</p>
<p><em>Repaint</em> bzw. <em>Invalidate</em> brauchst du auch nur aufrufen, wenn sich eine eigenschaft auch wirklich geändert hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/914069</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/914069</guid><dc:creator><![CDATA[Sunday]]></dc:creator><pubDate>Thu, 10 Nov 2005 15:34:59 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Thu, 10 Nov 2005 15:49:23 GMT]]></title><description><![CDATA[<p>Invalidate() funktioniert auch nicht.</p>
<p>Selbst nach dem Progstart und Änderung der Eigenschaft Color durch Button1Click<br />
taucht die Grafig nicht auf, obwohl der Setter SetIMColor ausgeführt wird (mit Break getestet).</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
	Temp1-&gt;Color = clBlue;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/914082</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/914082</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Thu, 10 Nov 2005 15:49:23 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Thu, 10 Nov 2005 15:51:10 GMT]]></title><description><![CDATA[<p>Wenn der Parent des Image der Parent der Komponente ist, wird das Image doch eigentlich auch da gezeichnet. Im Objektinspektor also garnicht.<br />
Warum eigentlich das Image? Eine von TGraphicControl abgeleitete Komponente hat doch ein eigens Canvas auf dem man zeichnen kann. Das könnte man doch einfach nehmen. Genau dafür ist TGraphicControl doch da.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/914083</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/914083</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 10 Nov 2005 15:51:10 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Thu, 10 Nov 2005 16:38:32 GMT]]></title><description><![CDATA[<blockquote>
<p>Warum eigentlich das Image? Eine von TGraphicControl abgeleitete Komponente hat doch ein eigens Canvas auf dem man zeichnen kann. Das könnte man doch einfach nehmen. Genau dafür ist TGraphicControl doch da.</p>
</blockquote>
<p>Stimmt, das mit dem Image kann ich mir sparen.</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------
__fastcall TTemp::TTemp(TComponent* Owner)
	: TGraphicControl(Owner)
{
    Height     = 100;
    Width      = 100;
    SetIMColor(clRed);
}
//---------------------------------------------------------------------------
void __fastcall TTemp::SetIMColor(TColor NewColor)
{
        IMColor = NewColor;
	Repaint();
}
//---------------------------------------------------------------------------
void __fastcall TTemp::Paint(void)
{
    DrawGrafValue();
}
//---------------------------------------------------------------------------
// Zeichnet eine Balckengrafig
//---------------------------------------------------------------------------
void TTemp::DrawGrafValue(void)
{
    Canvas-&gt;Brush-&gt;Color = IMColor;
     Canvas-&gt;FillRect(Rect(0,0,Width,Height));
}
</code></pre>
<p>So gehts.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/914109</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/914109</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Thu, 10 Nov 2005 16:38:32 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Thu, 10 Nov 2005 17:24:47 GMT]]></title><description><![CDATA[<p>Hi,<br />
ich würd das so machen:</p>
<pre><code class="language-cpp">void __fastcall TTemp::SetIMColor(TColor NewColor)
{
      if (IMColor != NewColor) {
            IMColor = NewColor;
      	Repaint();
      }
}
</code></pre>
<p>Dann wirds nur beim tatsächlichen Ändern neugezeichnet.</p>
<p>MfG</p>
<p>Alexander Sulfrian</p>
]]></description><link>https://www.c-plusplus.net/forum/post/914155</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/914155</guid><dc:creator><![CDATA[Alexander Sulfrian]]></dc:creator><pubDate>Thu, 10 Nov 2005 17:24:47 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Thu, 10 Nov 2005 17:50:08 GMT]]></title><description><![CDATA[<blockquote>
<pre><code class="language-cpp">void __fastcall TTemp::SetIMColor(TColor NewColor)
{
      if (IMColor != NewColor) {
            IMColor = NewColor;
          Repaint();
      }
}
</code></pre>
</blockquote>
<p>Gute Idee.</p>
<p>Ich habe nun noch die Eigenschaften PosValue, ErrorValue, NoErrorColor, ErrorColor.<br />
Ist ErrorValue &gt; PosValue wird die Farbe ErrorColor benutzt, sonst NoErrorColor.<br />
Sollte man da so vorgehen oder anders.</p>
<pre><code class="language-cpp">class PACKAGE TTemp : public TGraphicControl
{
private:
TColor Color;
TColor IMNoErrorColor;
TColor IMErrorColor;
int IMErrorValue;
int IMPosValue;
void __fastcall Paint(void);
void __fastcall SetIMNoErrorColor(TColor NewColor);
void __fastcall SetIMErrorColor(TColor NewColor);
void __fastcall SetIMErrorValue(int NewErrorValue);
void __fastcall SetIMPosValue(int NewPosValue);
void DrawGrafValue(void);
__published:
    __property TColor NoErrorColor = {read=IMNoErrorColor,write=SetIMNoErrorColor};
    __property TColor ErrorColor = {read=IMErrorColor,write=SetIMErrorColor};
    __property int  ErrorValue = {read=IMErrorValue,write=SetIMErrorValue};

protected:
public:
    __fastcall TTemp(TComponent* Owner);
    __property int  PosValue = {read=IMPosValue,write=SetIMPosValue};
};

//---------------------------------------------------------------------------
__fastcall TTemp::TTemp(TComponent* Owner)
	: TGraphicControl(Owner)
{
    Height     = 100;
    Width      = 100;
}
//---------------------------------------------------------------------------
void __fastcall TTemp::SetIMNoErrorColor(TColor NewColor)
{
     IMNoErrorColor = NewColor;
}
//---------------------------------------------------------------------------
void __fastcall TTemp::SetIMErrorColor(TColor NewColor)
{
     IMErrorColor = NewColor;
}
//---------------------------------------------------------------------------
void __fastcall TTemp::SetIMErrorValue(int NewErrorValue)
{
     IMErrorValue = NewErrorValue;
}
//---------------------------------------------------------------------------
void __fastcall TTemp::SetIMPosValue(int NewPosValue)
{
     IMPosValue = NewPosValue;
     if(IMPosValue &gt; IMErrorValue)
     {
		Color	= IMErrorColor;
     }
     else
     {
		Color	= IMNoErrorColor;
     }
     Repaint();
}
//---------------------------------------------------------------------------
void __fastcall TTemp::Paint(void)
{
    DrawGrafValue();
}
//---------------------------------------------------------------------------
// Zeichnet eine Balckengrafig
//---------------------------------------------------------------------------
void TTemp::DrawGrafValue()
{
    Canvas-&gt;Brush-&gt;Color = Color;
     Canvas-&gt;FillRect(Rect(0,0,Width,Height));
}
</code></pre>
<p>Und kann man ohne Probleme eine Timer Instanz erzeugen, die dann das ganze<br />
noch blinken lässt, oder besser nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/914164</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/914164</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Thu, 10 Nov 2005 17:50:08 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Sat, 12 Nov 2005 12:45:43 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>die Eigenschaften Width sowie Height werden ja von TGraphicControl als Publisched<br />
geerbt.</p>
<p>Wie kann ich diese Eigenschaften nun als private überschreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/915848</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/915848</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Sat, 12 Nov 2005 12:45:43 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Sat, 12 Nov 2005 12:54:09 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>indem du</p>
<pre><code class="language-cpp">__property int Width;
__property int Height;
</code></pre>
<p>in den private-Teil deiner Klasse schreibst.<br />
Allerdings kann das zu unschönen Fehlern führen.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/915854</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/915854</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sat, 12 Nov 2005 12:54:09 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Sat, 12 Nov 2005 13:04:02 GMT]]></title><description><![CDATA[<p>Dann kommt die Fehlermeldung _property-Variable muss initialisiert sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/915862</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/915862</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Sat, 12 Nov 2005 13:04:02 GMT</pubDate></item><item><title><![CDATA[Reply to Grafische Komponenente on Sat, 12 Nov 2005 13:07:47 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>sorry, int muß da weg</p>
<pre><code class="language-cpp">__property Width;
__property Height;
</code></pre>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/915867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/915867</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sat, 12 Nov 2005 13:07:47 GMT</pubDate></item></channel></rss>