<?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[&amp;quot;Bug&amp;quot; &amp;lt; ? Im Canvas?]]></title><description><![CDATA[<p>Also hab hier ein projekt erstellt, es ging einfach darum mal nen gezeichnetes objekt zu haben das man rumziehen kann.</p>
<p><a href="http://uploaded.to/?id=bl2rg3" rel="nofollow">http://uploaded.to/?id=bl2rg3</a></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
#pragma resource &quot;blau.res&quot;
#define BallGroesse 50
TForm1 *Form1;
Graphics::TBitmap *Bitmap1 = new Graphics::TBitmap();
int CurrXLeft, CurrYTop, CurrXRight, CurrYBottom;
bool MousePressed;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
CurrXLeft=Form1-&gt;Width-BallGroesse/2;
CurrYTop=Form1-&gt;Height-BallGroesse/2;
CurrXRight=Form1-&gt;Width+BallGroesse/2;
CurrYBottom=Form1-&gt;Height+BallGroesse/2;
Timer1-&gt;Interval = 15;
Timer1-&gt;Enabled = true;
Bitmap1-&gt;LoadFromResourceName((int)HInstance,&quot;Blau&quot;);
Form1-&gt;Canvas-&gt;StretchDraw(Rect(CurrXLeft,CurrYTop,CurrXRight,CurrYBottom),Bitmap1);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
CurrYTop++;
CurrYBottom++;
Form1-&gt;Canvas-&gt;FillRect(Rect(0,0,Form1-&gt;Width,Form1-&gt;Height));
Form1-&gt;Canvas-&gt;StretchDraw(Rect(CurrXLeft,CurrYTop,CurrXRight,CurrYBottom),Bitmap1);
if ( CurrYBottom &gt;= Form1-&gt;Height )Timer1-&gt;Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y)
{
if (  (( X &gt;= CurrXLeft )&amp;&amp;( X &lt;= CurrXRight ))&amp;&amp;(( Y &gt;= CurrYTop )&amp;&amp;( Y &lt;= CurrYBottom )) )MousePressed = true;
Timer1-&gt;Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
if ( MousePressed ){
        if (( X &lt; Form1-&gt;Width-100 ) &amp;&amp; ( X &gt; 0 ) &amp;&amp; ( Y &lt; Form1-&gt;Height-100 ) &amp;&amp; ( Y &gt; 0 ) ){
        Form1-&gt;Canvas-&gt;Brush-&gt;Color = clWhite;
        Form1-&gt;Canvas-&gt;FillRect(Rect(0,0,Form1-&gt;Width,Form1-&gt;Height));
        Form1-&gt;Canvas-&gt;StretchDraw(Rect(X,Y,X+BallGroesse,Y+BallGroesse),Bitmap1);
        CurrXLeft = X;
        CurrYTop  = Y;
        CurrXRight  = X+BallGroesse;
        CurrYBottom = Y+BallGroesse;
        }
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y)
{
MousePressed = false;
Timer1-&gt;Enabled = true;
}
//---------------------------------------------------------------------------
</code></pre>
<p>so soweit ist ja alles okay. aber sagen wir mal ich lasse die kugel fallen, ja?</p>
<p>dann fällt sie ja leicht verzögert. auch noch alles okay.</p>
<p>jetzt fahre ich aber mit der maus über die kugel und taddaah sie fällt flüssig.</p>
<p>wieso?</p>
<p>PS: Das kompillierte projekt mit alt - f4 beenden</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/206076/quot-bug-quot-lt-im-canvas</link><generator>RSS for Node</generator><lastBuildDate>Thu, 20 Aug 2026 01:26:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/206076.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 20 Feb 2008 23:11:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to &amp;quot;Bug&amp;quot; &amp;lt; ? Im Canvas? on Wed, 20 Feb 2008 23:12:09 GMT]]></title><description><![CDATA[<p>Also hab hier ein projekt erstellt, es ging einfach darum mal nen gezeichnetes objekt zu haben das man rumziehen kann.</p>
<p><a href="http://uploaded.to/?id=bl2rg3" rel="nofollow">http://uploaded.to/?id=bl2rg3</a></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
#pragma resource &quot;blau.res&quot;
#define BallGroesse 50
TForm1 *Form1;
Graphics::TBitmap *Bitmap1 = new Graphics::TBitmap();
int CurrXLeft, CurrYTop, CurrXRight, CurrYBottom;
bool MousePressed;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
CurrXLeft=Form1-&gt;Width-BallGroesse/2;
CurrYTop=Form1-&gt;Height-BallGroesse/2;
CurrXRight=Form1-&gt;Width+BallGroesse/2;
CurrYBottom=Form1-&gt;Height+BallGroesse/2;
Timer1-&gt;Interval = 15;
Timer1-&gt;Enabled = true;
Bitmap1-&gt;LoadFromResourceName((int)HInstance,&quot;Blau&quot;);
Form1-&gt;Canvas-&gt;StretchDraw(Rect(CurrXLeft,CurrYTop,CurrXRight,CurrYBottom),Bitmap1);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
CurrYTop++;
CurrYBottom++;
Form1-&gt;Canvas-&gt;FillRect(Rect(0,0,Form1-&gt;Width,Form1-&gt;Height));
Form1-&gt;Canvas-&gt;StretchDraw(Rect(CurrXLeft,CurrYTop,CurrXRight,CurrYBottom),Bitmap1);
if ( CurrYBottom &gt;= Form1-&gt;Height )Timer1-&gt;Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y)
{
if (  (( X &gt;= CurrXLeft )&amp;&amp;( X &lt;= CurrXRight ))&amp;&amp;(( Y &gt;= CurrYTop )&amp;&amp;( Y &lt;= CurrYBottom )) )MousePressed = true;
Timer1-&gt;Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
if ( MousePressed ){
        if (( X &lt; Form1-&gt;Width-100 ) &amp;&amp; ( X &gt; 0 ) &amp;&amp; ( Y &lt; Form1-&gt;Height-100 ) &amp;&amp; ( Y &gt; 0 ) ){
        Form1-&gt;Canvas-&gt;Brush-&gt;Color = clWhite;
        Form1-&gt;Canvas-&gt;FillRect(Rect(0,0,Form1-&gt;Width,Form1-&gt;Height));
        Form1-&gt;Canvas-&gt;StretchDraw(Rect(X,Y,X+BallGroesse,Y+BallGroesse),Bitmap1);
        CurrXLeft = X;
        CurrYTop  = Y;
        CurrXRight  = X+BallGroesse;
        CurrYBottom = Y+BallGroesse;
        }
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y)
{
MousePressed = false;
Timer1-&gt;Enabled = true;
}
//---------------------------------------------------------------------------
</code></pre>
<p>so soweit ist ja alles okay. aber sagen wir mal ich lasse die kugel fallen, ja?</p>
<p>dann fällt sie ja leicht verzögert. auch noch alles okay.</p>
<p>jetzt fahre ich aber mit der maus über die kugel und taddaah sie fällt flüssig.</p>
<p>wieso?</p>
<p>PS: Das kompillierte projekt mit alt - f4 beenden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1459869</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1459869</guid><dc:creator><![CDATA[Schurke]]></dc:creator><pubDate>Wed, 20 Feb 2008 23:12:09 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Bug&amp;quot; &amp;lt; ? Im Canvas? on Thu, 21 Feb 2008 17:27:39 GMT]]></title><description><![CDATA[<p>Pack das was du im Timer stehen hast in eine Schleife und füge ein Application-&gt;ProcessMessages hinzu. Ist zwar nicht der schönste Programmierstil aber das sollte den gewünschten Effekt haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1460425</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1460425</guid><dc:creator><![CDATA[rean]]></dc:creator><pubDate>Thu, 21 Feb 2008 17:27:39 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Bug&amp;quot; &amp;lt; ? Im Canvas? on Fri, 22 Feb 2008 14:38:07 GMT]]></title><description><![CDATA[<p>und wieso geht es dann?<br />
und was wäre schönerer programmierstyl?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1460997</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1460997</guid><dc:creator><![CDATA[Schurke]]></dc:creator><pubDate>Fri, 22 Feb 2008 14:38:07 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Bug&amp;quot; &amp;lt; ? Im Canvas? on Fri, 22 Feb 2008 14:45:47 GMT]]></title><description><![CDATA[<p>Schurke schrieb:</p>
<blockquote>
<p>und was wäre schönerer programmierstyl?</p>
</blockquote>
<p>Vermutlich wäre es schöner, die ganzen Canvas-Ausgaben in das OnPaint-Ereignis zu packen und diese einfach mittels Invalidate() das Neuzeichnen auszulösen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1461003</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461003</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Fri, 22 Feb 2008 14:45:47 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Bug&amp;quot; &amp;lt; ? Im Canvas? on Fri, 22 Feb 2008 15:16:11 GMT]]></title><description><![CDATA[<p>Uiuiui das is doch mal ne tolle antwort ^^ danke werd ich gleich mal probieren <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Das erste mal das ich von Invaliddate() höre aber der hilfe nach hörts sich gut an <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Aber mal zur hauptfrage, warum läufst denn mit dem timer flüssig wenn die maus auf eines der objekte geht? ( habs mittlerweile in ne klasse gepackt )</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1461023</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461023</guid><dc:creator><![CDATA[Schurke]]></dc:creator><pubDate>Fri, 22 Feb 2008 15:16:11 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Bug&amp;quot; &amp;lt; ? Im Canvas? on Sat, 23 Feb 2008 10:29:34 GMT]]></title><description><![CDATA[<p>Gute Frage. Müsste man mal mit dem Debugger nachsehen, wo der Unterschied liegt... Vermutlich wird durch das Bewegen der Maus über dem Ball, irgendein Ereignis öfter aufgerufen und in Folge dessen das Fenster öfter neu gezeichnet. Das könnte dann zu einem flüssigerem Ablauf führen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1461363</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461363</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 23 Feb 2008 10:29:34 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Bug&amp;quot; &amp;lt; ? Im Canvas? on Sat, 23 Feb 2008 13:37:41 GMT]]></title><description><![CDATA[<p>Danke nochmal Joe. ich hab jetzt die zeichnung in den OnPaint, mit nem 1 Millisekunden zeiger immer Invalidate und dann noch Form1-&gt;DoubleBuffered = true; und jetzt zeichnet er auch noch bei 1000 objekten flüssig <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/1461495</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461495</guid><dc:creator><![CDATA[Schurke]]></dc:creator><pubDate>Sat, 23 Feb 2008 13:37:41 GMT</pubDate></item></channel></rss>