Solved

Painting on TScrollBox

Posted on 1998-07-12
8
910 Views
Last Modified: 2010-04-04
How can I draw something on TScrollBox (it has no Canvas property). I tried to put TImage on it, but I need something like a background, and when I make TImage's Align alClient and draw on its canvas, and then I have to scroll it, only that part which was visible from the beginning remains painted, and it doesn#t paint to the rest of Canvas. Waht can I do here?

And one more problem: how can I refresh the TImage's canvas? (when I have to change the image, it is painted over the old one, and the problem is that I have to draw on the canvas (I can't use LoadFromFile and so on)).
0
Comment
Question by:Stern
  • 4
  • 3
8 Comments
 

Expert Comment

by:jm verdi
ID: 1357745
Hi stern,

I would say: you don't need scrollbox to scroll a bitmap.
Just put a TImage and 2 scrollbar on your form.
Load bitmap and display it on the canvas of the Timage, then
modify the maxvalue of these scrollbars to match the size of the bitmap, then attach a function for scrollbars OnChange like:
Bitmap.Canvas.Draw(Hscroll.Position,VScroll.Position,Bitmap)

The bitmap will scroll smothly when you click on your scrollbars.

But if you need scrollbox for another usage, than i have no suggestion :-(

Jean marie
0
 

Author Comment

by:Stern
ID: 1357746
Well, sorry, it's not what I need. Let it be not a scroll box, but a simple panel, or it doesn't mean. The problem is that it doesn't paint on the rest of the canvas, when the TImage becomes larger than it was first. So when I resize a form to the larger size (or scroll, it's not a problem), only the first visible part becomes painted.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1357747
Hello Stern,
First you need to remove the content of the TImage comp and then draw on it. It can be done like this:

Image1.Canvas.Brush.Color := ClBtnFace;//Set the color
//the color has to be same as your form's color or it's parent}
Image1.Canvas.FillRect(Canvas.ClipRect);//Clean up the canvas of the Image
//then draw whatever you want
Image.Draw(0,0,MyBitmap);

Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1357748
Oooopppssss....
I've got a mistake over there......
Image.Canvas.Draw(0,0,MyBitmap);
Sorry.....
Viktor Ivanov
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Stern
ID: 1357749
Thank you very much! I see, I could do it myself, but you know, there are always these small simple things which make us crazy.
0
 

Author Comment

by:Stern
ID: 1357750
I've really forgotten how should I accept the answer.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1357751
I'll make it an answer and then you can accept it if you want to..ok?

Viktor Ivanov
0
 
LVL 10

Accepted Solution

by:
viktornet earned 50 total points
ID: 1357752
Hello Stern,
  Here is the answer...  
   First you need to remove the content of the TImage comp and then draw on
     it. It can be done like this:

     Image1.Canvas.Brush.Color := ClBtnFace;//Set the color
     //the color has to be same as your form's color or it's parent}
     Image1.Canvas.FillRect(Canvas.ClipRect);//Clean up the canvas of the
     Image
     //then draw whatever you want
     Image1.Canvas.Draw(0,0,MyBitmap);

     Viktor Ivanov
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now