Results 1 to 21 of 21

Thread: Design time Form Height

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76
    At design time i am setting form.Height = 8190

    But at run time i get different value in MDI
    i just want to get the form.hieght at design time.
    I mean i want to read the value 8190 atleast if not setting it to 8190..

    How do i get it.

    I cant hard code it i need to read the value iam doing some object repositioning (Flexing) based on the difference between Design time form size and run time form size

  2. #2
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    Use the win api function call GetWindowRect???

    {;->
    DocZaf

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76
    Well it gives the form top and bottom at run time
    i want to read the design time height at run time

    Use the win api function call GetWindowRect???

    {;->
    DocZaf


  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    myHeight=myRECT.top-myRECT.bottom

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76
    No i dont get the design time values i set even with this.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76
    Hey People

    Iam running out of time any help appreciated

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76

    Urgently need help on this


    Use the win api function call GetWindowRect???

    {;->
    DocZaf


  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    The declaration:
    Code:
    Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    In your code:
    Code:
    GetWindowRect(hwnd, RECT)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76
    I tried this
    But this gives me only run time height if i do
    Bottom - top
    i need something similar to VC++
    PreCreateForm()

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76

    Question

    well its not precreateform()
    its PreCreateWindow() in vC++ i need a function similar to that

  11. #11
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308
    You are talking about child form?
    if so then childs are dependant on the size of the parent.
    I think you have two choises:
    1. Set desired height in form load event;
    2. Set form1 border style "not resizable"

    should work.

  12. #12
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554

    Exclamation

    Ok, lets start at the beginning:
    Your not being very clear.

    To start with at run time are you using the same scalemode as you are at desing time?

    If you are, then at design time the form can be any size, and i expect your setting it in the form_load event, or whatever.

    So how about, the first lines in your form load event, store the initial value:

    initheight=me.height
    initwidth=me.width

    and once the form is visible, say stick a button on it and in the click event for that button:

    dim title as string
    dim msg as string

    title="Information."
    msg="Init Height=" & initheight & vbcrlf
    msg=msg & "Init Width=" & initwidth & vbcrlf
    msg=msg & "Run Height="& me.height &vbcrlf
    msg=msg & "Run Width=" & me.width & vbcrlf
    msg = msg &"Thanks ALL you guys."

    msgbox msg,64,title

    Let us know how you get on

    DocZaf
    {;->

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76
    Ok, But that still gives me the run time value only even
    if i set Scalemode same as what i had at design time.

    Actually i need design time height to do flexing of controls ( if u have used Videosoft ). If u strecth a form the controls stretch to a certain point (rather rearrange position if iam correct)..

    I need to do that

    Thanks

    Satish

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76

    Angry

    Hey ppl i thought u were smart for this
    I need help fast

  15. #15
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    Hi Satish,

    Try this: I must admit i've not tried it myself

    Description:
    Code snippet which repositions and resizes all the controls on a form whenever the form is resized.
    Author:
    Justin Manley
    Version Compatibility:
    VB5,6

    Declarations:
    Private Type CtrlProportions
    HeightProportions As Single
    WidthProportions As Single
    TopProportions As Single
    LeftProportions As Single
    End Type


    Code:
    Dim ProportionsArray() As CtrlProportions

    Sub InitResizeArray()
    On Error Resume Next
    Dim I As Integer
    ReDim ProportionsArray(0 To Controls.Count -1)
    For I = 0 To Controls.Count -1
    With ProportionsArray(I)
    .HeightProportions = Controls(I).Height / ScaleHeight
    .WidthProportions = Controls(I).Width / ScaleWidth
    .TopProportions = Controls(I).Top / ScaleHeight
    .LeftProportions = Controls(I).Left / ScaleWidth
    End Width
    Next I
    End Sub

    Sub ResizeControls()

    On Error Resume Next
    Dim I As Integer
    For I = 0 To Controls.Count -1
    With ProportionsArray(I)
    ' move and resize controls
    Controls(I).Move .LeftProportions * ScaleWidth, .TopProportions * ScaleHeight, .HeightProportions * ScaleHeight,
    .WidthProportions * ScaleWidth
    End With
    Next I
    End Sub

    'Form initialize event
    Private Sub Form_Initialize()
    InitResizeArray
    End Sub

    'Form resize event
    Sub Form_Resize()
    ResizeControls
    End Sub


    Not my code,
    Code by Justin Manley

    DocZaf
    {;->

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76

    Question

    I think there is some bug in this code which iam not able clear out try with a form
    When u resize a form the whole thing goes haywire
    Meanwhile after lunch i will debug this code...
    Hoping u sent me this code with minor bugs (Typos)

    Cheers....

    Satish

  17. #17
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    My apologies Sat,

    Like I said I did not get the time to try the code my self!

    DocZaf
    {;->

    I will try to get some free time tomorrow to test it out and let you know how i got on.

  18. #18

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76
    Sorry to trouble you somuch.
    Dont break u r head too much on it.
    I already told my office ppl that its impossible so any sqeeeky solution i can get is a Big Bonus...
    Even i tried to debug for some time
    This is where i think the problem is

    In the code u gave there is a
    Sub Resize()
    which contains this code

    ' move and resize controls
    Controls(I).Move .LeftProportions * ScaleWidth, .TopProportions * ScaleHeight, .HeightProportions * ScaleHeight,
    .WidthProportions * ScaleWidth

    Well Looks like the problem is with .LeftProportions which is coming in some 0.34231111 (some number like this)

    Thanks

    Satish

  19. #19
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    Ok Sat heres the code:

    '--> declarations
    Option Explicit

    Private Type ControlsSizes
    csTop As Single
    csLeft As Single
    csWidth As Single
    csHeight As Single
    End Type
    Private AllControls() As ControlsSizes


    '--> form initialize event
    Private Sub Form_Initialize()
    Dim counta As Integer
    ReDim Preserve AllControls(Controls.Count - 1)
    For counta = 0 To Controls.Count - 1
    With AllControls(counta)
    .csTop = Controls(counta).Top / ScaleHeight
    .csLeft = Controls(counta).Left / ScaleWidth
    .csWidth = Controls(counta).Width / ScaleWidth
    .csHeight = Controls(counta).Height / ScaleHeight
    End With
    Next
    End Sub

    '--> general procedure
    maybe this code could be moved into the form_resize event
    see notes at bottom of this page
    Private Sub Do_Resize()
    Dim counta As Integer
    For counta = 0 To Controls.Count - 1
    With AllControls(counta)
    Controls(counta).Move .csLeft * ScaleWidth, .csTop * ScaleHeight, .csWidth * ScaleWidth, .csHeight * ScaleHeight
    End With
    Next
    End Sub

    Private Sub Form_Resize()
    Do_Resize
    End Sub


    Make sure that you test to see that the controls are not resized beyond their physical limits (ie dont go into negatives and not too big either)

    DocZaf


  20. #20

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76
    Hey somebody sent me this give it a look and give me ur comments :
    How about calculating the ideal design-time size at run-time, eg:

    ' (DesignHeight is either a local static or a module-level property) if DesignHeight=0 then
    ' where Control1 is near the top of the form, and Control2 is near the bottom of the form
    ' (assumes scalemode=twips; if not, convert using ScaleX & ScaleY) DesignHeight = Control2.top + Control2.Height + 2*Control1.top + (height-scaleheight)
    endif

    I've done this type of thing successfully many times.

    If you are handing the form over to another programmer, both controls could be invisible labels giving instructions to him at design-time, eg. Control1.Caption = "Position this label level with the topmost visible control on the form".

    Steve.

  21. #21

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76
    I tried using this code
    seems to be ok
    How about calculating the ideal design-time size at run-time, eg:

    ' (DesignHeight is either a local static or a module-level property) if DesignHeight=0 then
    ' where Control1 is near the top of the form, and Control2 is near the bottom of the form
    ' (assumes scalemode=twips; if not, convert using ScaleX & ScaleY) DesignHeight = Control2.top + Control2.Height + 2*Control1.top + (height-scaleheight)
    endif

    I've done this type of thing successfully many times.

    If you are handing the form over to another programmer, both controls could be invisible labels giving instructions to him at design-time, eg. Control1.Caption = "Position this label level with the topmost visible control on the form".

    Steve.

    [/B][/QUOTE]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width