Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 03-19-2002, 06:46 PM
IBM IBM is offline
Senior Member
 
Join Date: Feb 2002
Posts: 178
Default !Form Objects Positoning!

Hmm...
I'm frustrated to no end.
I have a form, on this form I have a panel, 2 buttons, and a label.

When I run it, it starts up fine, it has a set width and height in the OnFormCreate procedure, as well as objects initial position.


begin
//Dynamically sets objects positions
GlyphlblWallpaper.Left:=280;
GlyphlblWallpaper.Top:=1;
frmPanel.Top:=25;
frmPanel.Left:=320;
btnChangeWallpaper.Top:=232;
btnChangeWallpaper.Left:=290;
btnUndoWallpaper.Top:=272;
btnUndoWallpaper.Left:=290;

//form height and width
frmMain.ClientHeight:=432;
frmMain.ClientWidth:=370;
end;


During runtime, I have a toolmenu(View/Filemanager) that when checked makes the filemanager Visible, increases the form width and height, and moves all the objects(panel,buttons,label etc..) to the right side, for asthetic pruposes. It works great.

But If I then ucheck the view/filemanager, the form is supposed to return to the previous size, and the objects to a set location,I add the .Top and .Left to the filemanager Uncheck procedure.
However what happens is that the form resizes to a different size than specified...it's too wide, and a little bit shorter...I Can tell visually.

Below is my Filemanager Code,


begin
mnuFileManager.Checked:= not mnuFileManager.Checked;
if mnuFileManager.Checked then
begin
frmMain.Width:=625;
frmMain.Height:=440;
frmLsDirTree.Visible:=True;
frmLsFilelistView.Visible:=True;
GlyphlblWallpaper.Left:=354;
GlyphlblWallpaper.Top:=1;
frmPanel.Top:=25;
frmPanel.Left:=413;
btnChangeWallpaper.Top:=232;
btnChangeWallpaper.Left:=415;
btnUndoWallpaper.Top:=272;
btnUndoWallpaper.Left:=415;
end
else
begin
frmMain.Width:=432;
frmMain.Height:=370;
frmLsDirTree.Visible:=False;
frmLsFilelistView.Visible:=False;
GlyphlblWallpaper.Left:=150;
GlyphlblWallpaper.Top:=1;
frmPanel.Top:=25;
frmPanel.Left:=180;
btnChangeWallpaper.Top:=232;
btnChangeWallpaper.Left:=180;
btnUndoWallpaper.Top:=272;
btnUndoWallpaper.Left:=180;
end;


end;



Do you see a flaw in the code...
I was thinking of removing the OnFormCreate Positiong and size, and just using the Filemanager code to define width and sizes.

But ...I'm just not sure.

Thank you
Reply With Quote
  #2  
Old 03-19-2002, 06:57 PM
Ted On The NeT Ted On The NeT is offline
Senior Member
 
Join Date: Apr 2001
Posts: 2,182
Default RE: !Form Objects Positoning!

this is your problem:
frmMain.ClientHeight:=432;
frmMain.ClientWidth:=370;
is different then this size:
frmMain.Width:=432;
frmMain.Height:=370;

clientheight/width is not height/width!


Greetz,
::TeD On The NeT::

=[ QUESTIONS ]=========================================
don't forget to accept this reply if it helped you!
================================================== =====

=[ EXTRA INFO ]========================================
Location : Netherlands (GMT +01.00)
Languages : English, Dutch, German
Age : 25
ICQ : Be smart and figure out what my UIN is...
================================================== =====
Reply With Quote
  #3  
Old 03-19-2002, 06:57 PM
Ted On The NeT Ted On The NeT is offline
Senior Member
 
Join Date: Apr 2001
Posts: 2,182
Default RE: !Form Objects Positoning!

this is your problem:
frmMain.ClientHeight:=432;
frmMain.ClientWidth:=370;
is different then this size:
frmMain.Width:=432;
frmMain.Height:=370;

clientheight/width is not height/width!


Greetz,
::TeD On The NeT::

=[ QUESTIONS ]=========================================
don't forget to accept this reply if it helped you!
================================================== =====

=[ EXTRA INFO ]========================================
Location : Netherlands (GMT +01.00)
Languages : English, Dutch, German
Age : 25
ICQ : Be smart and figure out what my UIN is...
================================================== =====
Reply With Quote
  #4  
Old 03-19-2002, 06:59 PM
Ted On The NeT Ted On The NeT is offline
Senior Member
 
Join Date: Apr 2001
Posts: 2,182
Default RE: !Form Objects Positoning!

Use ClientWidth to determine the width (in pixels) of the formís client area. The client area is the usable area inside the form's border. Set ClientWidth to change the width of the formís window based on the desired client area. To change the width of the formís window based on the total size of the window (including the border, status bar and so on), use the Width property instead.


Use ClientHeight to determine the height (in pixels) of the formís client area. The client area is the usable area inside the form's border, excluding the title bar, scroll bars, and so on.

Set ClientHeight to change the height of the formís window based on the desired client area. To change the height of the formís window based on the total size of the window (including the border, menu, status bar and so on), use the Height property instead.


Greetz,
::TeD On The NeT::

=[ QUESTIONS ]=========================================
don't forget to accept this reply if it helped you!
================================================== =====

=[ EXTRA INFO ]========================================
Location : Netherlands (GMT +01.00)
Languages : English, Dutch, German
Age : 25
ICQ : Be smart and figure out what my UIN is...
================================================== =====
Reply With Quote
  #5  
Old 03-19-2002, 07:11 PM
IBM IBM is offline
Senior Member
 
Join Date: Feb 2002
Posts: 178
Default RE: !Form Objects Positoning!

Hi, thanks.
I've already tried that...and i still got a form too big after unchecking the filemanager.
So I changed my code to clientheight,clientwidth etc..

However, I have changed back to Wifth/Height.
When Filemanager is unchecked, I still get a oversized Form.
It's like the code is ignored..?

In my properties of every object, I've set the anchored to left and top property to false...Could this have anything to do with it...

I'm going to try to enable the anchors, see what happens.

Thank you
Reply With Quote
  #6  
Old 03-19-2002, 07:26 PM
IBM IBM is offline
Senior Member
 
Join Date: Feb 2002
Posts: 178
Default RE: !Form Objects Positoning!

Anchoring the objects to the left and top had no effect.
I still get a wider, form when Unchecking the filemanager menu button.

It's like the code is being ignored..but why?

Thank you
Reply With Quote
  #7  
Old 03-19-2002, 08:25 PM
GoodFun GoodFun is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,645
Default RE: !Form Objects Positoning!

Hi there,

if you anchor the objects correctly you shouldn't have to do anything in the OnResize event... what version of Delphi are you using?

Hope this helps,

Marcel

Please click on Accept if this helped...
Reply With Quote
  #8  
Old 03-19-2002, 08:32 PM
GoodFun GoodFun is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,645
Default RE: !Form Objects Positoning!

Have you tried putting things on panels? Then when you hide the additional part make that panel visible otherwise hide it. In addition you have to set the clientwidth and the clientheight to the size of the panel that remains.

For example, you have Panel1 that holds everything but your file manager and is right aligned. You also have a Panel2 to the left of that that is client aligned and visible set to false by default. In the OnCreate you set the form's client width and client height to the width and height of Panel2. Once you set the Panel1 visible, you first resize the form's client width to Panel1.width + Panel2.width, then you set the Panel2.Visible = True. Once you hide it again, you set the Panel2.Visible = False and then set the clientwidth of the form to Panel1.Width.

Hope this helps,

Marcel

Please click on Accept if this helped...
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 10:06 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.