Solved

resize window to image size

Posted on 2004-08-11
10
291 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
Comment Utility
Instead of Width and Height use ClientWidth and ClientHeight
0
 
LVL 16

Expert Comment

by:xDamox
Comment Utility
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
Comment Utility
erm I think the I made an aerror it shoould be

(image1.clientheight + statusBar.width);

plus not minus :S
0
 
LVL 12

Expert Comment

by:Ivanov_G
Comment Utility
"image1.clientheight + statusBar.width"

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

Expert Comment

by:esoftbg
Comment Utility
download working examples from:
page:        http://www.geocities.com/esoftbg/
  link:        Q_20951029.zip
  link:        Q_21046446.zip
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 17

Expert Comment

by:Wim ten Brink
Comment Utility
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
Comment Utility
Oh, TImage is of course your image object. Don't use the class!!! Use your TImage variable. :-)
0
 
LVL 2

Expert Comment

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

Author Comment

by:hibbidiji
Comment Utility
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
Comment Utility
thanks everyone for your suggestions.   Ivanov_G's was just what I needed
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now