Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Docked Window Size...

Status
Not open for further replies.

SnyAc

Programmer
Jul 25, 2001
272
US
When I dock a window on the top or bottom the window height doesn't seem to be controllable.... left and right work correctly. This window (form) has buttons that I rearrange in the before dock method (shown below). I want the docked window size to be the height of the buttons+4 (like a toolbar) but it seems to default to 1/2 of the screen.

Code:
LPARAMETERS nLocation
WITH THISFORM
  LOCAL nBtnSize,nLocation,nButtons
  nButtons=IIF(.dunnage.visible,9,8)
  DO CASE
  CASE nLocation=1 .OR. nLocation=2 && left or right
    .height=_screen.height
    nBtnSize=(_screen.height-.imglogo.height-nButtons*2-20)/nButtons
    .Specification.Height=nBtnSize
    .command2.height=nBtnSize
    .dunnage.height=nBtnSize
    .command9.height=nBtnSize
    .command5.height=nBtnSize
    .statusinquiry.height=nBtnSize
    .inventory.height=nBtnSize
    .itemanalysis.height=nBtnSize
    .plantview.height=nBtnSize
    .Specification.LEFT=2
    .Specification.top=2
    .command2.LEFT=2
    .command2.TOP=.Specification.TOP+.Specification.HEIGHT+2
    .Dunnage.LEFT=2
    .Dunnage.TOP=.command2.TOP+.command2.HEIGHT+2
    .command9.LEFT=2
    .command9.TOP=IIF(.Dunnage.VISIBLE,.Dunnage.TOP+.Dunnage.HEIGHT+2,.Dunnage.TOP)
    .command5.LEFT=2
    .command5.TOP=.command9.TOP+.command9.HEIGHT+2
    .imglogo.visible=.T.
    .imglogo.height=nBtnSize
    .imglogo.width=nBtnSize
    .imglogo.LEFT=.WIDTH/2-.imglogo.WIDTH/2
    .imglogo.TOP=.command5.TOP+.command5.HEIGHT+2
    .statusinquiry.LEFT=2
    .statusinquiry.TOP=.imglogo.TOP+.imglogo.HEIGHT+2
    .inventory.LEFT=2
    .inventory.TOP=.statusinquiry.TOP+.statusinquiry.HEIGHT+2
    .itemanalysis.LEFT=2
    .itemanalysis.TOP=.inventory.TOP+.inventory.HEIGHT+2
    .plantview.LEFT=2
    .plantview.TOP=.itemanalysis.TOP+.itemanalysis.HEIGHT+2
    .Specification.WIDTH=.WIDTH-4
    .command2.WIDTH=.WIDTH-4
    .Dunnage.WIDTH=.command2.WIDTH
    .command9.WIDTH=.command2.WIDTH
    .command5.WIDTH=.command2.WIDTH
    .statusinquiry.WIDTH=.command2.WIDTH
    .inventory.WIDTH=.command2.WIDTH
    .itemanalysis.WIDTH=.command2.WIDTH
    .plantview.WIDTH=.command2.WIDTH
  OTHERWISE && top or bottom
    nBtnSize=40
    .height=nBtnsize+4
    .width=_screen.width
    .Specification.Height=nBtnSize
    .command2.height=nBtnSize
    .dunnage.height=nBtnSize
    .command9.height=nBtnSize
    .command5.height=nBtnSize
    .statusinquiry.height=nBtnSize
    .inventory.height=nBtnSize
    .itemanalysis.height=nBtnSize
    .plantview.height=nBtnSize
    nBtnSize=(_screen.width-nButtons*4)/nButtons
    .command2.WIDTH=nBtnSize
    .Specification.WIDTH=.command2.WIDTH
    .Dunnage.WIDTH=.command2.WIDTH
    .command9.WIDTH=.command2.WIDTH
    .command5.WIDTH=.command2.WIDTH
    .statusinquiry.WIDTH=.command2.WIDTH
    .inventory.WIDTH=.command2.WIDTH
    .itemanalysis.WIDTH=.command2.WIDTH
    .plantview.WIDTH=.command2.WIDTH
    .Specification.LEFT=2
    .Specification.top=2
    .command2.top=2
    .command2.left=.Specification.left+.Specification.width+4
    .Dunnage.top=2
    .Dunnage.left=.command2.left+.command2.width+4
    .command9.top=2
    .command9.left=IIF(.Dunnage.VISIBLE,.Dunnage.left+.Dunnage.width+4,.Dunnage.left)
    .command5.top=2
    .command5.left=.command9.left+.command9.width+4
    .imglogo.visible=.F.
    .statusinquiry.top=2
    .statusinquiry.left=.command5.left+.command5.width+4
    .inventory.top=2
    .inventory.left=.statusinquiry.left+.statusinquiry.width+4
    .itemanalysis.top=2
    .itemanalysis.left=.inventory.left+.inventory.width+4
    .plantview.top=2
    .plantview.left=.itemanalysis.left+.itemanalysis.width+4
  ENDCASE
ENDWITH


Any ideas are always appreciated...


Andy Snyder
SnyAc Software Services
 
Andy,

The user can change the height interactively, using the mouse. You have no control over that.

If you want the form to be the height of its contained buttons, you should use a toolbar, not a form. A toolbar automatically sizes itself according to the height or width of its contained controls, and the user can't change that.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Well I was beginning to come to that conclusion myself... however I do find it interesting that my resizing works fine for left or right docking....

Since the app looks better in the left or right docked position anyway I'll just limit the user to those options.

Thanks for your thoughts....

Andy Snyder
SnyAc Software Services
 
Why bother with Docking, when you can set the position, height width etc of the form in code... You have more control.
I am sure you know how to position the form based upon _screen.height & _screen.width {s}
 
Just the look of a docked window.... no other reason in particular.... I like to user to be able to position windows where they are comfortable with them.

Andy Snyder
SnyAc Software Services
 
Imnaginecorp,

I can see why Andy would like docked windows. They have the advantage that the user can't move another form in front of them, which makes them suitable for things like navigation and menu forms. And, unlike always-on-top forms, they don't obscure other windows.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike:
True, but only if Dock = 0 (top) In any other position they could obscure other forms...

Andy:
If you set the height of the form to 44 in design mode before you save, when shown and docked the form will have a height of 44. In Form.Activate() you could put something like:
IF this.Docked = .f.
this.Height = _screen.height
ENDIF

BUT: the problem is when the form is moved and re-docked the height returns to the default
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top