Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BGRAGraphicControl turns transparent onredraw #39

Closed
MaartenJB opened this issue Jan 31, 2019 · 4 comments
Closed

BGRAGraphicControl turns transparent onredraw #39

MaartenJB opened this issue Jan 31, 2019 · 4 comments

Comments

@MaartenJB
Copy link

Hi,

I've got an issue with the with the TBGRAGraphicControl component. When I reposition for example a button on the form from within the onredraw, the canvas turns transparent for a moment, before painting it. This does not happen with the TBGRAVirtualScreen. This is the test code I use:

procedure TForm1.FormCreate(Sender: TObject);
begin
  with BGRAGraphicControl1
  do begin
    Align:=alLeft;
    BevelOuter := bvNone;
    Color := clYellow;
    ColorOpacity:=255;
    Caption := '';
  end;

  with BGRAVirtualScreen1
  do begin
    Align:=alRight;
    Caption := '';
  end;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
  BGRAGraphicControl1.Width := (Form1.Width div 2);
  BGRAVirtualScreen1.Width := Form1.Width - BGRAGraphicControl1.Width-10;
end;
procedure TForm1.BGRAGraphicControl1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
begin
  Bitmap.FillRect(0, 0, Bitmap.Width, Bitmap.Height, clLime);
  sleep(10); // To make it a little bit more visible
  Button1.Left := (Form1.Width div 2); // <--- enable this and the screen flickers
end;
procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
begin
  Bitmap.FillRect(0, 0, Bitmap.Width, Bitmap.Height, clRed);
  sleep(10); // To make it a little bit more visible
  //Button1.Left := (Form1.Width div 2); // <--- enable this and the screen won't flicker  (and disable the above)
end; 

Is this fixable? I've looked into the onredraw source, but can't find a problem there.

Best regards, Maarten

@circular17
Copy link
Contributor

Hi

That's kind of normal. The thing is you need to decide where the button is before redrawing the content. What is supposed to trigger the button to move? Surely not the update of the graphic control.

@MaartenJB
Copy link
Author

Hi, ah ok, that makes sense. I have a grid menu of buttons that need to be center on the graphic control. (even if you resize the application)

I've moved the positioning of the buttons to the onresize of the form, and that works fine.

Thanks for the fast response.

Maarten

@MaartenJB
Copy link
Author

user error corrected ;-)

@circular17
Copy link
Contributor

Happy you found your way :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants