Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Scroll box and Canvas

Posted on 1998-01-21
6
Medium Priority
?
1,482 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Accepted Solution

by:
mov earned 40 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Screencast - Getting to Know the Pipeline
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

877 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