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
LVL 8
BdLmAsked:
Who is Participating?
 
mokuleConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.