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

 *   If you move the scrollbar, go and update the Paintbox
procedure TViewBitMapForm.ScrollbarMove(Sender : TObject);
    DisplayBitmap(xScrollBar.Position, yScrollBar.Position);
 *  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);
   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,
                     Xpixel  ,
                     Ypixel  , SRCCOPY) then
                     ViewBitMapForm.Caption  := 'Error BitBlt!!';
   // MyPaintBox.refresh;

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You should draw bitmap in PaintBox OnPaint event.
Why don't You use ScrollBox?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BdLmAuthor Commented:
add this code

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

solved my trouble, your answer is fine  :-)
 but I don't understand the sequence of painting components ....
Any hint ?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.