• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • 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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

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