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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a form at a specific location 1

Status
Not open for further replies.

fordboy0

Programmer
Jan 24, 2003
13
US
I did a search through the forums and found an answer, but it doesn't work. :(

I am using two monitors with the desktop spread across both. I have a preview form that needs to open and be sized on one of the monitors. I haven't found any form methods or properties that seem to support this.

Perhaps someone with more experience than I could show how to do it with the API. Please? :D

Once again, thanks in advance!

-Jeff
 
When you set the AutoCenter property of the form, it's automatically centered within the app window. If you need to change it's size after that, you can adjust the width of both the form and the window containing it.

This is from the Help on InsideHeight:

InsideHeight Property
See Also Applies To Example Specifics
You can use the InsideHeight property (along with the InsideWidth property) to determine the height and width (in twips) of the window containing a form. Read/write Long.

expression.InsideHeight

expression Required. An expression that returns one of the objects in the Applies To list.

Remarks
The InsideHeight and InsideWidth properties are available only by using a macro or Visual Basic and can be set at any time.

If you want to determine the interior dimensions of the form itself, you use the Width property to determine the form width and the sum of the heights of the form's visible sections to determine its height (the Height property applies only to form sections, not to forms). The interior of a form is the region inside the form, excluding the scroll bars and the record selectors.

You can also use the WindowHeight and WindowWidth properties to determine the height and width of the window containing a form.

If a window is maximized, setting these properties doesn't have any effect until the window is restored to its normal size.

Example
The following example shows how to use the InsideHeight and InsideWidth properties to compare the inside height and width of a form with the height and width of the form's window. If the window's dimensions don't equal the size of the form, then the window is resized to match the form's height and width.

Sub ResetWindowSize(frm As Form)
Dim intWindowHeight As Integer
Dim intWindowWidth As Integer
Dim intTotalFormHeight As Integer
Dim intTotalFormWidth As Integer
Dim intHeightHeader As Integer
Dim intHeightDetail As Integer
Dim intHeightFooter As Integer

' Determine form's height.
intHeightHeader = frm.Section(acHeader).Height
intHeightDetail = frm.Section(acDetail).Height
intHeightFooter = frm.Section(acFooter).Height
intTotalFormHeight = intHeightHeader _
+ intHeightDetail + intHeightFooter
' Determine form's width.
intTotalFormWidth = frm.Width
' Determine window's height and width.
intWindowHeight = frm.InsideHeight
intWindowWidth = frm.InsideWidth

If intWindowWidth <> intTotalFormWidth Then
frm.InsideWidth = intTotalFormWidth
End If
If intWindowHeight <> intTotalFormHeight Then
frm.InsideHeight = intTotalFormHeight
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top