<?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[GDI+ auf Paintbox -&amp;gt; Flimmern]]></title><description><![CDATA[<p>Hi,<br />
ich benutze eine Paintbox mit GDI+. Ich will jetzt, dass wenn man die Maus mit gedrückter maustaste linien auf die Paintbox zeichnet. Dann wird PaintBox-&gt;Refresh() aufgerufen. Problem: Es ensteht ungeheures flimmern. Bildgröße: 800x600</p>
<p>Das Programm könnt ihr selber testen und von <a href="http://www.virtualuna.de/giveme/Project1.exe" rel="nofollow">http://www.virtualuna.de/giveme/Project1.exe</a> runterladen. Nur 33kb groß. Bräuchtet aber WinXP wegen der GDI+.DLL.</p>
<p>Code:</p>
<pre><code>__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
  Gdiplus::GdiplusStartup(&amp;gdiplusToken, &amp;gdiplusStartupInput, NULL);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
  delete myPen;
  delete Bmp;
  Gdiplus::GdiplusShutdown(gdiplusToken);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBox1MouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
  Gdiplus::Graphics gfx(Bmp);

  if(mdown)
  {
    //Bmp-&gt;SetPixel(X, Y, Color::Blue);
    gfx.DrawLine(myPen, X1, Y1, X, Y);
    PaintBox1-&gt;Repaint();
  }

  X1 = X;
  Y1 = Y;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBox1MouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
  mdown = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBox1MouseUp(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
  mdown = false;  
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  myPen = new Gdiplus::Pen(Color::Blue, 1);
  Bmp = new Gdiplus::Bitmap(640,480, PixelFormat32bppARGB);
  Gdiplus::Graphics gfx(Bmp);
  gfx.Clear(Color::White);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
{
  Gdiplus::Graphics gfx(PaintBox1-&gt;Canvas-&gt;Handle);
  gfx.DrawImage(Bmp, 0,0);
}
//---------------------------------------------------------------------------
</code></pre>
<p>Vielen dank schonmal</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/88442/gdi-auf-paintbox-gt-flimmern</link><generator>RSS for Node</generator><lastBuildDate>Sun, 05 Jul 2026 01:36:52 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/88442.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 09 Oct 2004 19:59:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GDI+ auf Paintbox -&amp;gt; Flimmern on Sat, 09 Oct 2004 20:01:07 GMT]]></title><description><![CDATA[<p>Hi,<br />
ich benutze eine Paintbox mit GDI+. Ich will jetzt, dass wenn man die Maus mit gedrückter maustaste linien auf die Paintbox zeichnet. Dann wird PaintBox-&gt;Refresh() aufgerufen. Problem: Es ensteht ungeheures flimmern. Bildgröße: 800x600</p>
<p>Das Programm könnt ihr selber testen und von <a href="http://www.virtualuna.de/giveme/Project1.exe" rel="nofollow">http://www.virtualuna.de/giveme/Project1.exe</a> runterladen. Nur 33kb groß. Bräuchtet aber WinXP wegen der GDI+.DLL.</p>
<p>Code:</p>
<pre><code>__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
  Gdiplus::GdiplusStartup(&amp;gdiplusToken, &amp;gdiplusStartupInput, NULL);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
  delete myPen;
  delete Bmp;
  Gdiplus::GdiplusShutdown(gdiplusToken);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBox1MouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
  Gdiplus::Graphics gfx(Bmp);

  if(mdown)
  {
    //Bmp-&gt;SetPixel(X, Y, Color::Blue);
    gfx.DrawLine(myPen, X1, Y1, X, Y);
    PaintBox1-&gt;Repaint();
  }

  X1 = X;
  Y1 = Y;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBox1MouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
  mdown = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBox1MouseUp(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
  mdown = false;  
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  myPen = new Gdiplus::Pen(Color::Blue, 1);
  Bmp = new Gdiplus::Bitmap(640,480, PixelFormat32bppARGB);
  Gdiplus::Graphics gfx(Bmp);
  gfx.Clear(Color::White);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
{
  Gdiplus::Graphics gfx(PaintBox1-&gt;Canvas-&gt;Handle);
  gfx.DrawImage(Bmp, 0,0);
}
//---------------------------------------------------------------------------
</code></pre>
<p>Vielen dank schonmal</p>
]]></description><link>https://www.c-plusplus.net/forum/post/625086</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/625086</guid><dc:creator><![CDATA[Salim]]></dc:creator><pubDate>Sat, 09 Oct 2004 20:01:07 GMT</pubDate></item></channel></rss>