Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Change width on my components form

Posted on 1999-09-12
12
Medium Priority
?
134 Views
Last Modified: 2010-08-05
Why can't I change the width on the form on which my component is placed, with this code

TForm(Parent).Width:= 500;
0
Comment
Question by:koger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2040195
? maybe its not the parent
0
 

Expert Comment

by:Gamba
ID: 2040364
Maybe  WindowState=wsMaximized
or BorderStyle = bsDialog ,
then the width also won't be changeble.
0
 

Expert Comment

by:haehnen
ID: 2040449
This is Code from my Component TGetFolder, I do this to get the Main Form:

var
 MainForm: TForm;

implementation

constructor TGetFolder.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
 MainForm := TForm(AOwner);
end;

destructor TGetFolder.Destroy;
begin
 inherited Destroy;
end;

Now you can use the Main Form.
bye
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 10

Expert Comment

by:ptmcomp
ID: 2040517
If your component is derrived from TControl you can use (GetParentForm(Self) as TCustomForm).Widht:=500; if it's derrived from TComponent (not a Control) you can write (Owner as TCustomForm).Width:=500; (Normally the owner of a TComponent is the Form)
Regards, ptm.
0
 
LVL 3

Expert Comment

by:bryan7
ID: 2040667
try Application.ProcessMessages   after changing the size
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2040880
I'm with ptmcomp...

Cheers,

Raymond.
0
 
LVL 1

Expert Comment

by:WiseGuy
ID: 2047672
Do you have the autosize property of your form set to 'true'?
0
 

Author Comment

by:koger
ID: 2049080
ptmcomp
It works just fine.
The component is a tstringgrid, so wouldn't both methods work?
0
 
LVL 6

Accepted Solution

by:
Jaymol earned 300 total points
ID: 2087864
Hey, how about this code....

procedure ComponentName.Loaded;
var
  MainForm : TForm;
begin
  MainForm:=TForm(Owner);
  MainForm.Width:=500;
end;
0
 
LVL 6

Expert Comment

by:Jaymol
ID: 2087884
Have a look at...

   Http://SecretDelphi.cjb.net

On the components page is a component called TPaintForm.  It uses the above code to reference the form so that it can draw on it's canvas.  (Also, see TBorderForm for similar and TClearForm for an example of a component handling it's ownerform's windows messages.)

Ta.
0
 
LVL 10

Expert Comment

by:ptmcomp
ID: 2093676
Hi koger
Normally for controls (like TStringGrid) both methods will work. But the first is better (GetParentForm(Self) as TCustomForm).Widht:=500). Because it where possible that the owner is not the form (if the component is created dynamicly).
Regards, ptm.
0
 
LVL 10

Expert Comment

by:ptmcomp
ID: 2116824
What's about your question? Is it answered? Then you should accept the answer otherwise reject it.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

705 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