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???

Recommended Answers

All 4 Replies

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
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...

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.

>> 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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.