joynerCN

So I have a program for my job that allows the user to open any number of individual windows that each display a customizable amount of data, type of data, etc. But that part's unimportant, the important thing is, unlimited windows are openable. The window attributes themselves are stored in a list of open windows.

What I'd like to implement is the ability to choose some preset layouts. I know how I can programmatically create new windows, but my issue is arranging them.

What do y'all suggest as the best way to do this, handling different screen resolutions and stuff like that A percentage of the user's screen width perhaps And do y'all have any methods to suggest using besides the normal setCoord, setWidth and setHeight



Re: Visual Basic Language Tips on Window Attributes (size, location, etc.)

joynerCN

And, a followup question - how do you edit a window's location programmatically Neither window.Location nor window.SetDesktopLocation worked for me.



Re: Visual Basic Language Tips on Window Attributes (size, location, etc.)

spotty

Look in the help at the anchor and dock properties of the form which enables you to link the control sizes to the form size so as the form is resized the controls inside will size up as well.

An example of this may be a grid control in a form - when you resize the form it allows more of the cells to be seen.

You may also want to set a minimum size for - minimum size property.





Re: Visual Basic Language Tips on Window Attributes (size, location, etc.)

joynerCN

That's not really what I'm going for - I want to create the entire new window in a certain spot on the screen, not create the controls at a certain spot on the form.



Re: Visual Basic Language Tips on Window Attributes (size, location, etc.)

spotty

Simple set the top, left, height and width properties of the form you wish to create.

 





Re: Visual Basic Language Tips on Window Attributes (size, location, etc.)

joynerCN

According to the Visual Studio pop-up API, that's also for positioning a control in context to its container, which, given the fact that it isn't work, I assume isn't the Windows desktop.



Re: Visual Basic Language Tips on Window Attributes (size, location, etc.)

spotty

The following allows me to position my forms initial location on the screen. Whether it is positioned relative to the screen size or just by giving it specific values this allows me to modify position or size of windows.

Top Left....

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Me
.Width = 100
.Height = 100
.Top = (Screen.PrimaryScreen.WorkingArea.Top)
.Left = (Screen.PrimaryScreen.WorkingArea.Left)

End With
End Sub
End Class


Moves further down the screen and further to the right.


Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Me
.Top = 250
.Left = 250
.Width = 100
.Height = 100
End With
End Sub
End Class

Should Center the form

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Me
.Width = 100
.Height = 100
.Top = (Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2
.Left = (Screen.PrimaryScreen.WorkingArea.Width - Me.Width) / 2

End With
End Sub
End Class


Bottom Right


Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Me
.Width = 100
.Height = 100
.Top = (Screen.PrimaryScreen.WorkingArea.Height - Me.Height)
.Left = (Screen.PrimaryScreen.WorkingArea.Width - Me.Width)

End With
End Sub
End Class





Re: Visual Basic Language Tips on Window Attributes (size, location, etc.)

joynerCN

Maybe there's my problem - it isn't Form1 I'm positioning, it's other new forms created by Form1. So, for example:

Dim mapTabbedFloat As New Float() 'Float' is an empty Windows Form that just contains user controls

(stuff to add controls to the above Float)

mapTabbedFloat.Size = New Size(730, 560)

mapTabbedFloat.Top = Screen.PrimaryScreen.WorkingArea.Top

mapTabbedFloat.Left = Screen.PrimaryScreen.WorkingArea.Left

mapTabbedFloat.Show()

Those .Top and .Left methods are the ones I've tried .Top/.Left = 0 and .Location=(0,0) and .SetDesktopLocation.





Re: Visual Basic Language Tips on Window Attributes (size, location, etc.)

spotty

Try rearranging the order - show is before the top and left properties. This seems to work and is repositioning and resizing a form from form1.

Example

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As New Form2
With x
.Width = 100
.Height = 200
.Show()
.Top = Screen.PrimaryScreen.WorkingArea.Top
.Left = Screen.PrimaryScreen.WorkingArea.Left
End With
End Sub
End Class