×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Drag and drop on VCL components

Drag and drop on VCL components

Drag and drop on VCL components

(OP)
I want to build an application that shows images like a flow chart. Which component would be the best choice to draw the pictures.
I mean a TImage has a canvas on which I can draw, but it does not have scroll bars. A TScrollBox does have the bars but no canvas.
Does anybody know of a VCL component which has horizontal and vertical scroll bars, a canvas, and drag&drop events?  

RE: Drag and drop on VCL components

You can place a TImage on a TScrollBox and set the Top and Left properties of the TImage to zero.  I like to remove all trace of the border of the TScrollBox so the TScrollBox 'blends' into the background.  That way the TImage appears to have the scroll bars.

Steve.

RE: Drag and drop on VCL components

(OP)
I tried tis code:

CODE

    TGraphic *g = Image1->Picture->Graphic;
    Image2->AutoSize = true;
    Image2->Canvas->Draw(100,100,g);
    Image2->Canvas->Draw(10000,10000,g);

I expected Image2 to expand to the size needed to fit the expanded image. Image2, width 700, height 500, fits snug inside the ScrollBox.
No Scrollbars appear.

RE: Drag and drop on VCL components

Perhaps you need to size at run-time Image2 to be big enough to hold the two copies of Image1.  From what I see in your code, two copies of Image1 should be placed at 100, 100 and 10000, 10000.

If you are wanting to place two copies of Image1 on Image2 at different X - Y locations, consider the following code:

CODE

    int iTopMost = 1000, iLeftMost = 1000;

    Image2->Height = iTopMost + Image1->Height;
    Image2->Width = iLeftMost + Image1->Width;
    Image2->Canvas->Draw(iLeftMost, iTopMost, Image1->Picture->Graphic);
    Image2->Canvas->Draw(100, 100, Image1->Picture->Graphic);

This code will place both images at the correct spots on your Image1 and scroll bars will appear on the TScrollBox.  Since you are drawing Image1 onto the TCanvas of Image2, I don't think AutoSize is what you want.

I hope this helps.

Steve.

RE: Drag and drop on VCL components

(OP)
I hoped that I could do the job without calculating the size of Image2 and expected that AutoSize would do this for me.
So I have to create a new control. A descendant of TScrollBox and TImage.
If you might find another control that's more suitable, please let me know before I finish my own smile

thanks for your help.

RE: Drag and drop on VCL components

(OP)
Your code does not always work. Once you have written a small inmage in the top-left corner, you cannot resize the image anymore.
Please try this:

CODE

    int iTopMost = 1000, iLeftMost = 1000;

    Image2->Canvas->Draw(100, 100, Image1->Picture->Graphic);
    //Once you have written to the canvas
    //Resizing is no longer pssible

    Image2->Height = iTopMost + Image1->Height;
    Image2->Width = iLeftMost + Image1->Width;

    Image2->Canvas->Draw(100, 100, Image1->Picture->Graphic);
    Image2->Canvas->Draw(iLeftMost, iTopMost, Image1->Picture->Graphic);

RE: Drag and drop on VCL components

Hello Hennep,

 Don't you need to resize the bitmap as well.

   int iTopMost = 1000, iLeftMost = 1000;

    Image2->Canvas->Draw(100, 100, Image1->Picture->Graphic);

    // Extra code to change bitmap size.
    Image2->Picture->Bitmap->Width= iLeftMost + Image1->Width;
    Image2->Picture->Bitmap->Height= iTopMost + Image1->Height;

    Image2->Height = iTopMost + Image1->Height;
    Image2->Width = iLeftMost + Image1->Width;

    Image2->Canvas->Draw(100, 100, Image1->Picture->Graphic);
    Image2->Canvas->Draw(iLeftMost, iTopMost, Image1->Picture->Graphic);

Hope that helps you friend.

Regards
Blue.

RE: Drag and drop on VCL components

(OP)
You've solved it, thanks alot.
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close