Solved

resize window to image size

Posted on 2004-08-11
10
295 Views
Last Modified: 2010-04-05
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
Comment
Question by:hibbidiji
  • 2
  • 2
  • 2
  • +3
10 Comments
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 250 total points
ID: 11770474
Instead of Width and Height use ClientWidth and ClientHeight
0
 
LVL 16

Expert Comment

by:xDamox
ID: 11771478
ok,

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

form1.clientwidth := image1.clientwidth;
form1.clientheight := (image1.clientheight - statusBar.width);
0
 
LVL 16

Expert Comment

by:xDamox
ID: 11771492
erm I think the I made an aerror it shoould be

(image1.clientheight + statusBar.width);

plus not minus :S
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11771555
"image1.clientheight + statusBar.width"

xDamox, how come you combine ClientHeight and Width ???
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11771755
download working examples from:
page:        http://www.geocities.com/esoftbg/
  link:        Q_20951029.zip
  link:        Q_21046446.zip
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 11772648
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
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 11772657
Oh, TImage is of course your image object. Don't use the class!!! Use your TImage variable. :-)
0
 
LVL 2

Expert Comment

by:-Karamja-
ID: 11773902
Image1.Top:= 0;
Image1.Left:= 0;
Image1.AutoSize:= True;
Form1.AutoSize:= True;
0
 
LVL 1

Author Comment

by:hibbidiji
ID: 11774940
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
 
LVL 1

Author Comment

by:hibbidiji
ID: 11776756
thanks everyone for your suggestions.   Ivanov_G's was just what I needed
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

828 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