Link to home
Start Free TrialLog in
Avatar of Matvey
Matvey

asked on

Scroll box and Canvas

To my surprise I found out that a Delphi scroll box has no OnScrool event or ANYTHING that will tell me when the user scrools it!!! How will I solve this problem?!

And another thing that really drives me crazy is that when I draw on the canvas of a Paintbox or a form, all the graphics disappears when this area becomes hidden somehow, I mean by another window or scrolled away, AND I CAN'T RESTORE IT anyhow unless I draw it again!!!
Smth about that, PLEASE?

Thankful for any comment!
Matvey
Avatar of inter
inter
Flag of Türkiye image

Dear Matvey,

Regarding First Question of yours:
(These are two methods that I can imagine rightnow)

- Do you want a clean or dirty way(I mean clean way is to override TScrollBox we introduce one new event OnScrolled and override two methods)
- Dirty way, try to capture scroll events in applications.onmessage

Regarding Second Question of yours:

- As far as I know TPaintBox is just a cliping rectangle, so you can not draw persistent images(as far as I know) on it unless every time you paint it in OnPaint, so another method is to use TImage and create a bitmap for its Picture property. If you use the Canvas of the Image.Picture.Bitmap.Canvas to draw the things they do persists overlapping, hiding, showing etc...

Waiting for your comment,
Igor
Avatar of Matvey
Matvey

ASKER

Hi Igor,

You see, if a have a good solution for my seccond question, I don't need one for my first question!

What I really need is some good Canvas object to draw things on it so I won't need to refresh them anytime someone scrolls the drawing surface.
What I actually have is a huge Image (13MB), that I can't open as 16 color image because it seemes I don't have enough resources, so I do open it as just BW image as it is. What for do I need it to be opened as 16 colors at least? -to draw colorful lines on it that will seem to the user as roads - the image is actually a scaned map. So I thought that if I can't draw colorful things on the image, why not to put some transperent drawing surface above it to draw on it.
And so I did. But now I have the problems I've described above.
To REDRAEW all the roads of Alabama and Florida everytime doesn't seemes to me like a good solution. And I've tried to put an Image instead of PaintBox above it, but then I also run out of resources, because it has to be the same size as the Image.
I understand that I can make it NORMALLY (you know what I mean - to calculate which lines will be seen, which won't; to reduce the sizes of the images to fit only the screen, to load only the rectangle that needes to be visible, etc...), but time, long brain activity and patience are needed for that task, which are, I must admit, limited resources for me right now :)

Anything on your mind?
Are you from Russia too?
Dear Matvey,

I guess, we can solve your problem with meta-files. So when we want draw a thing on canvas we put it into the metafile and in our TPaintBox.OnPaint just tell metafile to draw everything it contains by PlayMetafile api function (or using TMetaFile objects methods). Thats what in my mind currently.

About the country, I am very close Russia, the Igor is my nickname assigned by my friend decades ago.(I am from Turkey)

So, please consider this solution and notify me, I am here about an hour.

Sincerely,
Igor
ASKER CERTIFIED SOLUTION
Avatar of mov
mov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Matvey

ASKER

Hi mov!

Of course I had the idea of copying image parts...but if it's the only way, then I guess I'll have to play with it for a while..

C U
Matvey
Did you consider the metafile approach friend? Or do you solve the problem?

Sincerely,
Igor