[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 373
  • Last Modified:

what is the order to paint/refresh components on my form ...

I have a form to display a bitmap with scrollbars on each side and a panel (color blue) on which a put a Paintbox.

a) If I move the scrollbars the Bitmap is displayed in the paintbox correctly

b) If a add the command  MyPaintBox.refresh in the .DisplayBitmap function,
   I see only the blue panel behind the paintbox

c) If I call the ScrollbarMove function eg. after the resize function I also see only the
   blue panel and not my bitmap

Any Input is highly welcome

best
BDLM
{******************************************************************************
 *   If you move the scrollbar, go and update the Paintbox
 ******************************************************************************}
 
procedure TViewBitMapForm.ScrollbarMove(Sender : TObject);
begin
 
    DisplayBitmap(xScrollBar.Position, yScrollBar.Position);
 
end;
 
 
{******************************************************************************
 *  Function:  Copy the Bitmap to the PaintBox
 *  Input :  xpixel :  x postition of the scrollbar
 *           ypixel :  y position of the scrollbar
 *
 * OutPut:  -----  (show the Bitmap)
 ******************************************************************************}
 
procedure TViewBitMapForm.DisplayBitmap(xpixel, ypixel : Integer);
begin
 
 
   {************************************************************************
   BOOL BitBlt(
      HDC hdcDest, // handle to destination DC
      int nXDest,  // x-coord of destination upper-left corner
      int nYDest,  // y-coord of destination upper-left corner
      int nWidth,  // width of destination rectangle
      int nHeight, // height of destination rectangle
      HDC hdcSrc,  // handle to source DC
      int nXSrc,   // x-coordinate of source upper-left corner
      int nYSrc,   // y-coordinate of source upper-left corner
      DWORD dwRop  // raster operation code
    );
    ************************************************************************}
 
 
   if FBitMap <> nil then
 
             if  not BitBlt(MyPaintBox.Canvas.Handle,0,0,
                     MyPaintBox.ClientWidth,
                     MyPaintBox.ClientHeight,
                     FBitMap.Canvas.Handle,
                     Xpixel  ,
                     Ypixel  , SRCCOPY) then
 
                     ViewBitMapForm.Caption  := 'Error BitBlt!!';
 
 
   // MyPaintBox.refresh;
 
end;

Open in new window

ee-repaint.jpg
0
BdLm
Asked:
BdLm
1 Solution
 
mokuleCommented:
You should draw bitmap in PaintBox OnPaint event.
Why don't You use ScrollBox?
0
 
BdLmAuthor Commented:
add this code

procedure TViewBitMapForm.MyPaintBoxPaint(Sender: TObject);
begin
     DisplayBitmap(xScrollBar.Position, yScrollBar.Position);
end;

solved my trouble, your answer is fine  :-)
 but I don't understand the sequence of painting components ....
Any hint ?
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now