0
Dim workspace(1 To 4) As Long ' (1)=left (2)=top (3)=right (4)=bottom
    SystemParametersInfo &H30, 0, workspace(1), 0 ' &h30 = get workspace size
    Dim X As Long, Y As Long, w As Long, h As Long
    X = workspace(1) * Screen.TwipsPerPixelX
    Y = workspace(2) * Screen.TwipsPerPixelY
    w = workspace(3) * Screen.TwipsPerPixelX - X
    h = workspace(4) * Screen.TwipsPerPixelY - Y
    Move X + 0.1 * w, Y + 0.1 * h, 0.8 * w, 0.8 * h ' 10% margins

in vb6 is working why in vb.net not working. Can you help me. Please???

3
Contributors
4
Replies
6
Views
8 Years
Discussion Span
Last Post by sknake
0
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		Dim newHeight As Integer = Math.Truncate(SystemInformation.WorkingArea.Height * 0.8)
		Dim newWidth As Integer = Math.Truncate(SystemInformation.WorkingArea.Width * 0.8)
		Me.Height = newHeight
		Me.Width = newWidth

		Me.Top = Math.Truncate((SystemInformation.WorkingArea.Height - Me.Height) / 2.0)
		Me.Left = Math.Truncate((SystemInformation.WorkingArea.Width - Me.Width) / 2.0)
	End Sub
0
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		Dim newHeight As Integer = Math.Truncate(SystemInformation.WorkingArea.Height * 0.8)
		Dim newWidth As Integer = Math.Truncate(SystemInformation.WorkingArea.Width * 0.8)
		Me.Height = newHeight
		Me.Width = newWidth

		Me.Top = Math.Truncate((SystemInformation.WorkingArea.Height - Me.Height) / 2.0)
		Me.Left = Math.Truncate((SystemInformation.WorkingArea.Width - Me.Width) / 2.0)
	End Sub

Not I want... I want how to make main form large: entire workspace less 10% margins on each side. But thanks your replies. Can you help me.. I stuck in here...

0

the code that snake posted is exactlly what you wanted. just add this code in your form.load event of your main form and its doing its job as requested.

0

>> Not I want... I want how to make main form large: entire workspace less 10% margins on each side. But thanks your replies. Can you help me.. I stuck in here...

I take 80% of the working space size (10% left + 10%right = 20%) and center the form. Its the same thing, my math is just a little different. By making the form 80% of the working space then centering it ... it will leave 10% on each edge

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.