<?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[Komponeten ... Vererbung ...]]></title><description><![CDATA[<p>Hallo ... tja der Titel is wenig sagend ... aber mir is nichts besseres eingefallen ...</p>
<p>So ich möchte folgendes.<br />
Ich habe eine Komponente von TEdit abgeleitet.</p>
<pre><code class="language-cpp">class PACKAGE TIntEdit : public TEdit
{
private:
   bool IVUseMinMax;
   int  IVMin;
   int  IVMax;
   int  IVValue;

   void __fastcall SetValue(int Val)
   {
      try {
         if (IVUseMinMax)
            if (Val &lt; IVMin)
               IVValue = IVMin;
            else
            if (Val &gt; IVMax)
               IVValue = IVMax;
            else
               IVValue = Val;
         else
            IVValue = Val;

      } catch(...) {}
      Text = IVValue;
   }
   void __fastcall SetMinValue(int MinVal)
   {
      if (MinVal &gt; IVMax)
         IVMax = MinVal;
      IVMin = MinVal;
   }
   void __fastcall SetMaxValue(int MaxVal)
   {
      if (MaxVal &lt; IVMin)
         IVMin = MaxVal;
      IVMax = MaxVal;
   }
protected:
public:
   __fastcall TIntEdit(TComponent* Owner);
__published:
   __property bool UseMinMax   = {read=IVUseMinMax, write=IVUseMinMax, default=0};
   __property int  MinValue    = {read=IVMin,       write=SetMinValue, default=0};
   __property int  MaxValue    = {read=IVMax,       write=SetMaxValue, default=0};
   __property int  Value       = {read=IVValue,     write=SetValue,    default=0};
};
</code></pre>
<p>Soweit funktioniert das auch ganz gut.</p>
<p>Jetzt möchte ich wenn die Eigenschaft Text geändert wird, dass die Funktion SetValue aufgerufen wird.</p>
<pre><code class="language-cpp">void __fastcall SetValue(int Val)
   {
      try {
         if (IVUseMinMax)
            if (Val &lt; IVMin)
               IVValue = IVMin;
            else
            if (Val &gt; IVMax)
               IVValue = IVMax;
            else
               IVValue = Val;
         else
            IVValue = Val;

      } catch(...) {}
      Text = IVValue;
   }
</code></pre>
<p>Aber die Eigenschaft Text gibt es ja schon in TEdit.</p>
<p>Wie kann man das Problem lösen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/189357/komponeten-vererbung</link><generator>RSS for Node</generator><lastBuildDate>Mon, 17 Aug 2026 04:23:59 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/189357.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 11 Aug 2007 19:38:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Komponeten ... Vererbung ... on Sat, 11 Aug 2007 19:38:56 GMT]]></title><description><![CDATA[<p>Hallo ... tja der Titel is wenig sagend ... aber mir is nichts besseres eingefallen ...</p>
<p>So ich möchte folgendes.<br />
Ich habe eine Komponente von TEdit abgeleitet.</p>
<pre><code class="language-cpp">class PACKAGE TIntEdit : public TEdit
{
private:
   bool IVUseMinMax;
   int  IVMin;
   int  IVMax;
   int  IVValue;

   void __fastcall SetValue(int Val)
   {
      try {
         if (IVUseMinMax)
            if (Val &lt; IVMin)
               IVValue = IVMin;
            else
            if (Val &gt; IVMax)
               IVValue = IVMax;
            else
               IVValue = Val;
         else
            IVValue = Val;

      } catch(...) {}
      Text = IVValue;
   }
   void __fastcall SetMinValue(int MinVal)
   {
      if (MinVal &gt; IVMax)
         IVMax = MinVal;
      IVMin = MinVal;
   }
   void __fastcall SetMaxValue(int MaxVal)
   {
      if (MaxVal &lt; IVMin)
         IVMin = MaxVal;
      IVMax = MaxVal;
   }
protected:
public:
   __fastcall TIntEdit(TComponent* Owner);
__published:
   __property bool UseMinMax   = {read=IVUseMinMax, write=IVUseMinMax, default=0};
   __property int  MinValue    = {read=IVMin,       write=SetMinValue, default=0};
   __property int  MaxValue    = {read=IVMax,       write=SetMaxValue, default=0};
   __property int  Value       = {read=IVValue,     write=SetValue,    default=0};
};
</code></pre>
<p>Soweit funktioniert das auch ganz gut.</p>
<p>Jetzt möchte ich wenn die Eigenschaft Text geändert wird, dass die Funktion SetValue aufgerufen wird.</p>
<pre><code class="language-cpp">void __fastcall SetValue(int Val)
   {
      try {
         if (IVUseMinMax)
            if (Val &lt; IVMin)
               IVValue = IVMin;
            else
            if (Val &gt; IVMax)
               IVValue = IVMax;
            else
               IVValue = Val;
         else
            IVValue = Val;

      } catch(...) {}
      Text = IVValue;
   }
</code></pre>
<p>Aber die Eigenschaft Text gibt es ja schon in TEdit.</p>
<p>Wie kann man das Problem lösen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1342923</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342923</guid><dc:creator><![CDATA[Boto]]></dc:creator><pubDate>Sat, 11 Aug 2007 19:38:56 GMT</pubDate></item><item><title><![CDATA[Reply to Komponeten ... Vererbung ... on Sat, 11 Aug 2007 19:49:02 GMT]]></title><description><![CDATA[<p>meine, dass die Funktion aufgerufen werden soll ... habe mich oben vertan.</p>
<pre><code class="language-cpp">void __fastcall SetValue(String Val)
   {
      try {
         if (IVUseMinMax)
            if (StrToInt(Val) &lt; IVMin)
               IVValue = IVMin;
            else
            if (StrToInt(Val) &gt; IVMax)
               IVValue = IVMax;
            else
               IVValue = StrToInt(Val);
         else
            IVValue = StrToInt(Val);
      } catch(...) {Text = IVValue;}
   }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1342929</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342929</guid><dc:creator><![CDATA[Boto]]></dc:creator><pubDate>Sat, 11 Aug 2007 19:49:02 GMT</pubDate></item><item><title><![CDATA[Reply to Komponeten ... Vererbung ... on Sat, 11 Aug 2007 20:36:23 GMT]]></title><description><![CDATA[<p>OnChange ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1342939</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342939</guid><dc:creator><![CDATA[onchanger]]></dc:creator><pubDate>Sat, 11 Aug 2007 20:36:23 GMT</pubDate></item><item><title><![CDATA[Reply to Komponeten ... Vererbung ... on Sat, 11 Aug 2007 21:16:38 GMT]]></title><description><![CDATA[<p>Das war auch mein erster Gedanke ... aber so geht es dann doch nicht im Objektinspektor ... oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1342951</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342951</guid><dc:creator><![CDATA[Boto]]></dc:creator><pubDate>Sat, 11 Aug 2007 21:16:38 GMT</pubDate></item><item><title><![CDATA[Reply to Komponeten ... Vererbung ... on Sat, 11 Aug 2007 21:36:13 GMT]]></title><description><![CDATA[<p>Das Property überladen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1342959</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342959</guid><dc:creator><![CDATA[audacia]]></dc:creator><pubDate>Sat, 11 Aug 2007 21:36:13 GMT</pubDate></item><item><title><![CDATA[Reply to Komponeten ... Vererbung ... on Sat, 11 Aug 2007 22:40:20 GMT]]></title><description><![CDATA[<p>typedef void __fastcall (__closure *ValueChange)(TObject *Sender);</p>
<p>class PACKAGE TIntEdit : public TEdit<br />
{<br />
private:<br />
ValueChange IVValueChange;<br />
protected:<br />
public:<br />
void __fastcall ValueChanged();</p>
<p>void __fastcall WndProc(Messages::TMessage &amp;Message)<br />
{<br />
Dispatch(&amp;Message);</p>
<p>switch(Message.Msg)<br />
{<br />
case WM_KEYFIRST:<br />
if (LOWORD(Message.WParam) == 13)<br />
ValueChanged();<br />
break;<br />
}<br />
}</p>
<p>__fastcall TIntEdit(TComponent* Owner);</p>
<p>__published:<br />
__property ValueChange OnValueChange {read=IVValueChange,write=IVValueChange};<br />
};<br />
[/cpp]Danke!</p>
<p>Funktioniert!</p>
<p>Noch nen kleines Progblem.</p>
<p>Ich habe so eine Komponente entwickelt:<br />
[cpp]</p>
<p>Wenn ich jetzt so eine Komponete auf meiner Form zur Disignzeit - also nicht zur Laufzeit - draufziehe, kann ich meine Komponente verwenden, als würde das Programm laufen .... also den Focus geben und Zahlen eingeben etc.</p>
<p>Wie kann man das verhindern?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1342990</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342990</guid><dc:creator><![CDATA[Boto]]></dc:creator><pubDate>Sat, 11 Aug 2007 22:40:20 GMT</pubDate></item></channel></rss>