Recent

Author Topic: [SOLVED] BGRAGraphic Control - Redraw - Disappearing Bitmap and or SIG Error  (Read 1055 times)

pixelink

  • Hero Member
  • *****
  • Posts: 1260
I seem to be stuck on an issue.

After assigning a bitmap to a BGRAGraphicControl2

My bimap disappears when I try to resize the form. (I don't get a black screen)

I assigned an image to two controls on startup.
It's the second BGRAGraphicControl2 that is disappearing
I have narrowed down that the issue is with my resize code.

I have resize code that tries to get away from the SIG error because if the control isn't visible it generates the SIG error.

What is the secret in dealing with Redraws when resizing a form??

Here is what I have in FormResize to redraw the control.

Code: Pascal  [Select][+][-]
  1. [code=pascal]//eval flag to see if startup, else we get an SIG error
  2. procedure TForm1.FormResize(Sender: TObject);
  3. begin
  4.   if StartUp = False Then
  5.     if (nb.PageIndex = 1) Or (nb.PageIndex = 2) Then //we do this or we get SIG error. The controls have to be visible
  6.        begin
  7.           BGRAGraphicControl1.Bitmap.Assign(theBMP.Bitmap);
  8.           BGRAGraphicControl2.Bitmap.Assign(newBMP.Bitmap);
  9.           startUp:=False;
  10.        end
  11.   else
  12.      startUp:=False;
  13.  
  14. end;
« Last Edit: August 11, 2019, 09:35:20 pm by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 2.2.0 •  VSSTUDIO(.Net) 2022 • Win10 • 16G RAM • Nvida GForce RTX 2060

lainz

  • Hero Member
  • *****
  • Posts: 4462
    • https://lainz.github.io/
Re: BGRAGraphic Control - Redraw - Disappearing Bitmap and or SIG Error
« Reply #1 on: August 11, 2019, 05:23:28 pm »
BGRAGraphicControl and BGRAVirtualScreen both has a resize code that frees the previous drawing and then call OnRedraw event.

For the code you provided in other posts you-re using OnPaint event, is not the correct event to use.

When you draw OnRedraw event, everything will work fine, try that. Try drawing only in that OnRedraw event and never outside to prevent this kind of problems.

pixelink

  • Hero Member
  • *****
  • Posts: 1260
Re: BGRAGraphic Control - Redraw - Disappearing Bitmap and or SIG Error
« Reply #2 on: August 11, 2019, 05:26:05 pm »
BGRAGraphicControl and BGRAVirtualScreen both has a resize code that frees the previous drawing and then call OnRedraw event.

For the code you provided in other posts you-re using OnPaint event, is not the correct event to use.

When you draw OnRedraw event, everything will work fine, try that. Try drawing only in that OnRedraw event and never outside to prevent this kind of problems.

Okay... I also discovered that my "startup boolean flag is not being changed from True to false after the initial startup. Why?
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 2.2.0 •  VSSTUDIO(.Net) 2022 • Win10 • 16G RAM • Nvida GForce RTX 2060

lainz

  • Hero Member
  • *****
  • Posts: 4462
    • https://lainz.github.io/
Re: BGRAGraphic Control - Redraw - Disappearing Bitmap and or SIG Error
« Reply #3 on: August 11, 2019, 05:27:24 pm »
Because you must do something like:

if Startup then
begin
  your code
  Startup := False;
end;

pixelink

  • Hero Member
  • *****
  • Posts: 1260
Re: BGRAGraphic Control - Redraw - Disappearing Bitmap and or SIG Error
« Reply #4 on: August 11, 2019, 05:31:58 pm »
Because you must do something like:

if Startup then
begin
  your code
  Startup := False;
end;

I did that... see above.

I fixed it... I put "startUp:=False;" in the Show even after the resize has fired.

Thanks
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 2.2.0 •  VSSTUDIO(.Net) 2022 • Win10 • 16G RAM • Nvida GForce RTX 2060

pixelink

  • Hero Member
  • *****
  • Posts: 1260
Re: BGRAGraphic Control - Redraw - Disappearing Bitmap and or SIG Error
« Reply #5 on: August 11, 2019, 05:38:56 pm »
Okay... moved routine to the redraw.
Now that the startup flag is fixed... it still does it.

How do I call the redraw from the resize code.?
I get these this error.
Wrong number of parameters specified for call to "BGRAGraphicControl2Redraw"

procedure TForm1.FormResize(Sender: TObject);
begin
   //showmessage(BoolToStr(startUp));
  if StartUp = False Then
    if (nb.PageIndex = 1) Or (nb.PageIndex = 2) Then
       begin
          BGRAGraphicControl1.Bitmap.Assign(theBMP.Bitmap);
          BGRAGraphicControl2.Bitmap.Assign(newBMP.Bitmap);
          BGRAGraphicControl2Redraw(Sender);  //<-- ERROR
       end
end; 
« Last Edit: August 11, 2019, 05:46:14 pm by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 2.2.0 •  VSSTUDIO(.Net) 2022 • Win10 • 16G RAM • Nvida GForce RTX 2060

pixelink

  • Hero Member
  • *****
  • Posts: 1260
Re: BGRAGraphic Control - Redraw - Disappearing Bitmap and or SIG Error
« Reply #6 on: August 11, 2019, 05:48:20 pm »
Nevermind... I figured it out...

Code: Pascal  [Select][+][-]
  1. BGRAGraphicControl2Redraw(Sender,newBMP);


I needed the second arg... I was trying Bitmap and not newBMP (which is the actual bitmap image)


Thanks
« Last Edit: August 11, 2019, 07:36:27 pm by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 2.2.0 •  VSSTUDIO(.Net) 2022 • Win10 • 16G RAM • Nvida GForce RTX 2060

lainz

  • Hero Member
  • *****
  • Posts: 4462
    • https://lainz.github.io/
Re: BGRAGraphic Control - Redraw - Disappearing Bitmap and or SIG Error
« Reply #7 on: August 11, 2019, 05:54:11 pm »
Code: Pascal  [Select][+][-]
  1. BGRAGraphicControl2.DiscardBitmap;

 

TinyPortal © 2005-2018