Solved

Scroll box and Canvas

Posted on 1998-01-21
6
1,462 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
ID: 1357216
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
ID: 1357217
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
ID: 1357218
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Accepted Solution

by:
mov earned 20 total points
ID: 1357219
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
ID: 1357220
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
ID: 1357221
Did you consider the metafile approach friend? Or do you solve the problem?

Sincerely,
Igor
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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