Solved

Scroll box and Canvas

Posted on 1998-01-21
6
1,458 Views
Last Modified: 2013-01-10
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
0
Comment
Question by:Matvey
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:inter
Comment Utility
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
0
 
LVL 3

Author Comment

by:Matvey
Comment Utility
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?
0
 
LVL 5

Expert Comment

by:inter
Comment Utility
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
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.

 

Accepted Solution

by:
mov earned 20 total points
Comment Utility
scrollbox1.HorzScrollBar.Position.. and use onClick event.. and then just look from that scrollbox1.HorzScrollBar.Position for position.. there is own for vertical too.

And that bitmap rotation question.. make two images... and copy from other to other..like:

image1 have 12mb picture sized 3000x3000.. and image2 is that area you can see.. like 200x200.. and now you only copy some area from image1 to image2.

0
 
LVL 3

Author Comment

by:Matvey
Comment Utility
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
0
 
LVL 5

Expert Comment

by:inter
Comment Utility
Did you consider the metafile approach friend? Or do you solve the problem?

Sincerely,
Igor
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

11 Experts available now in Live!

Get 1:1 Help Now