|
-
Apr 4th, 2000, 04:05 AM
#1
Thread Starter
Lively Member
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
-
Apr 4th, 2000, 06:41 AM
#2
Fanatic Member
Use the win api function call GetWindowRect???
{;->
DocZaf
-
Apr 5th, 2000, 02:08 AM
#3
Thread Starter
Lively Member
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
-
Apr 5th, 2000, 02:24 AM
#4
-
Apr 6th, 2000, 04:26 AM
#5
Thread Starter
Lively Member
No i dont get the design time values i set even with this.
-
Apr 6th, 2000, 05:39 AM
#6
Thread Starter
Lively Member
Hey People
Iam running out of time any help appreciated
-
Apr 7th, 2000, 12:09 AM
#7
Thread Starter
Lively Member
Urgently need help on this
Use the win api function call GetWindowRect???
{;->
DocZaf
-
Apr 7th, 2000, 06:48 AM
#8
transcendental analytic
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.
-
Apr 10th, 2000, 01:09 AM
#9
Thread Starter
Lively Member
I tried this
But this gives me only run time height if i do
Bottom - top
i need something similar to VC++
PreCreateForm()
-
Apr 10th, 2000, 04:10 AM
#10
Thread Starter
Lively Member
well its not precreateform()
its PreCreateWindow() in vC++ i need a function similar to that
-
Apr 10th, 2000, 06:27 AM
#11
Hyperactive Member
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.
-
Apr 10th, 2000, 07:16 AM
#12
Fanatic Member
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
{;->
-
Apr 10th, 2000, 08:28 AM
#13
Thread Starter
Lively Member
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
-
Apr 11th, 2000, 07:13 AM
#14
Thread Starter
Lively Member
Hey ppl i thought u were smart for this
I need help fast
-
Apr 11th, 2000, 09:38 AM
#15
Fanatic Member
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
{;->
-
Apr 12th, 2000, 03:27 AM
#16
Thread Starter
Lively Member
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
-
Apr 12th, 2000, 07:27 AM
#17
Fanatic Member
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.
-
Apr 12th, 2000, 11:47 PM
#18
Thread Starter
Lively Member
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
-
Apr 13th, 2000, 07:19 AM
#19
Fanatic Member
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
-
Apr 13th, 2000, 11:42 PM
#20
Thread Starter
Lively Member
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.
-
Apr 16th, 2000, 08:56 AM
#21
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|