• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

resize window to image size

I have an app that allows users to edit an image.   I want to resize the window to be the same size as the image.   I have tried editing just the width and height of the form, but it always cuts off the bottom (I assume its not taking into account the wise of the bar.

What is the BEST way of doing what I am doing?
0
hibbidiji
Asked:
hibbidiji
  • 2
  • 2
  • 2
  • +3
1 Solution
 
Ivanov_GCommented:
Instead of Width and Height use ClientWidth and ClientHeight
0
 
xDamoxCommented:
ok,

if you have a bar at the bottom of your window try

form1.clientwidth := image1.clientwidth;
form1.clientheight := (image1.clientheight - statusBar.width);
0
 
xDamoxCommented:
erm I think the I made an aerror it shoould be

(image1.clientheight + statusBar.width);

plus not minus :S
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Ivanov_GCommented:
"image1.clientheight + statusBar.width"

xDamox, how come you combine ClientHeight and Width ???
0
 
esoftbgCommented:
download working examples from:
page:        http://www.geocities.com/esoftbg/
  link:        Q_20951029.zip
  link:        Q_21046446.zip
0
 
Wim ten BrinkSelf-employed developerCommented:
Well, there should be an interesting trick here that takes into account all the toolbars on the left, top, right and bottom by setting the Align property of the image to alClient. Then you use the difference between the TImage.Width/Height and the TImage.Picture.Bitmap.Width/Height. Like this:

Width := Width + TImage.Picture.Bitmap.Width - TImage.Width;
Height := Height + TImage.Picture.Bitmap.Height - TImage.Height;

This just modifies width and height with the difference between the image width and the real bitmap width.
0
 
Wim ten BrinkSelf-employed developerCommented:
Oh, TImage is of course your image object. Don't use the class!!! Use your TImage variable. :-)
0
 
-Karamja-Commented:
Image1.Top:= 0;
Image1.Left:= 0;
Image1.AutoSize:= True;
Form1.AutoSize:= True;
0
 
hibbidijiAuthor Commented:
I will be trying these soon,   one thing to karamja, I dont want to use autosize because i have a draggable object on the canvas and I t will increase the window size when moved at runtime
0
 
hibbidijiAuthor Commented:
thanks everyone for your suggestions.   Ivanov_G's was just what I needed
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now