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?

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

x
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.

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

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);
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
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
Delphi

From novice to tech pro — start learning today.