Page 1 of 1

画图,图像显示有抖动,更新后才能看见

PostPosted: Sun Sep 25, 2011 3:16 am
by liqi98136
画图,图像显示有抖动,更新后才能看见
为什么?
Code: Select all

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
import "ecere"
 
class Form1 : Window
{
   text = "Form1";
   background = activeBorder;
   borderStyle = sizable;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   size = { 576, 432 };

   void OnRedraw(Surface surface)
   {
         
          HDC hdc;
          //PAINTSTRUCT ps;
          const POINT polygon[10] = { 30, 145, 85, 165, 105, 110, 65, 125, 30, 105 };
          const POINT bezier[4] = {280, 160, 320, 160, 325, 110, 350, 110};
         
         
         
          hdc =GetDC(surface.GetDisplay().systemWindow);
          //hdc=BeginPaint(surface.GetDisplay(), &ps);
          Ellipse(hdc, 50, 50, 120, 90);
       
          RoundRect(hdc, 150, 30, 240, 90, 15, 20);
          Chord(hdc, 270, 30, 360, 90, 270, 45, 360, 45);
          Polygon(hdc, polygon, 5);
          Rectangle(hdc, 150, 110, 230, 160);
          PolyBezier(hdc, bezier, 4);
          //EndPaint(surface.GetDisplay(), &ps);
   }
}

Form1 form1 {};

Re: 画图,图像显示有抖动,更新后才能看见

PostPosted: Sun Sep 25, 2011 3:35 am
by jerome
liqi,

Ecere is meant for writing cross-platform software, that will run as well on Linux as on Windows.

It doesn't support using the GDI.

Ecere has its own display buffer that it will copy to the screen and overwrite whatever you draw to the window.

If you really wanted to do this, you would need to know about the internal of the Ecere GDI driver implementation:
Code: Select all
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
import "ecere"
 
class GDISurface : LFBSurface { HDC hdc; }
 
class Form1 : Window
{
   text = "Form1";
   background = activeBorder;
   borderStyle = sizable;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   size = { 576, 432 };
 
   void OnRedraw(Surface surface)
   {
       const POINT polygon[10] = { { 30, 145 }, { 85, 165 }, { 105, 110 }, { 65, 125 }, { 30, 105 } };
       const POINT bezier[4] = { { 280, 160 }, { 320, 160 }, { 325, 110 }, { 350, 110 } };
       GDISurface gdiSurface = (GDISurface)surface.driverData;
       HDC hdc = gdiSurface.hdc;
       Ellipse(hdc, 50, 50, 120, 90);
       RoundRect(hdc, 150, 30, 240, 90, 15, 20);
       Chord(hdc, 270, 30, 360, 90, 270, 45, 360, 45);
       Polygon(hdc, polygon, 5);
       Rectangle(hdc, 150, 110, 230, 160);
       PolyBezier(hdc, bezier, 4);
   }
}
 
Form1 form1 {};


Cheers,

Jerome