window possition on screeen

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
7 posts Page 1 of 1
Contributors
User avatar
billyboy
VIP - Donator
VIP - Donator
Posts: 4
Joined: Sun Jul 26, 2009 7:20 pm

window possition on screeen
billyboy
:mrgreen: can u make a demo showin how to possition a window at diff places on the screen please mate like ur shortcut bar thing where its at side n stuff

cheers mate n wicked site
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: window possition on screeen
CodenStuff
Hello billyboy


Yes I can do that for you. If you create a new project and add 6 buttons to your form. Aslong as the buttons are in the correct orde then you can just copy and paste the following code. This code assumes that your buttons are in the following order:

Button1 Button2 Button3

Button4 Button5 Button6

Button7 Button8 Button9



Then copy this code into your project:
Code: Select all
Public Class Form1
    'TOP CENTER OF THE SCREEN
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.CenterToScreen()
        Me.Top = Screen.PrimaryScreen.Bounds.X
    End Sub
    'LEFT CENTER OF THE SCREEN
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Me.CenterToScreen()
        Me.Left = Screen.PrimaryScreen.Bounds.Y
    End Sub
    'RIGHT CENTER OF THE SCREEN
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Me.CenterToScreen()
        Me.Left = Screen.PrimaryScreen.Bounds.Width - Me.Width
    End Sub
    'BOTTOM CENTER OF THE SCREEN
    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Me.CenterToScreen()
        Me.Top = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
    End Sub
    'TOP LEFT OF THE SCREEN
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Top = Screen.PrimaryScreen.Bounds.Y
        Me.Left = Screen.PrimaryScreen.Bounds.Y
    End Sub
    'BOTTOM LEFT OF THE SCREEN
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Me.Top = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
        Me.Left = Screen.PrimaryScreen.Bounds.X
    End Sub
    'TOP RIGHT OF THE SCREEN
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.Top = Screen.PrimaryScreen.Bounds.Y
        Me.Left = Screen.PrimaryScreen.Bounds.Width - Me.Width
    End Sub
    'BOTTOM RIGHT OF THE SCREEN
    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        Me.Top = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
        Me.Left = Screen.PrimaryScreen.Bounds.Width - Me.Width
    End Sub
    'CENTER OF THE SCREEN
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Me.CenterToScreen()
    End Sub
End Class
I have quoted each button so you know which button positions the window in the different locations on screen

You can also download the source from the link below.
WindowPosition.zip

Hope that helps :D
You do not have the required permissions to view the files attached to this post.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Martin
Supreme VIP
Supreme VIP
Posts: 369
Joined: Sat Aug 01, 2009 12:26 pm

Re: window possition on screeen
Martin
I Neded This For My Program Thanks 8-)
Image
User avatar
billyboy
VIP - Donator
VIP - Donator
Posts: 4
Joined: Sun Jul 26, 2009 7:20 pm

Re: window possition on screeen
billyboy
wicked u rock dude cheers mate 5/5* ur tutorials r the best every other place i go to get help they all talk technical jibberish n is hard to understand but u make it easy for me u well rock
User avatar
billyboy
VIP - Donator
VIP - Donator
Posts: 4
Joined: Sun Jul 26, 2009 7:20 pm

Re: window possition on screeen
billyboy
jus one more thing mate can u show me how to make a window shake when click on it plz
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: window possition on screeen
CodenStuff
Hello billyboy,


Erm the only way that I know of is like this. Add a timer to your project and use the following code in it, it makes the form window shake.

Code for Timer:
Code: Select all
Public shake As Integer = 0
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Select Case shake
            Case 0
                Me.Location = New Point(Me.Location.X + 10, Me.Location.Y)
                Exit Select
            Case 1
                Me.Location = New Point(Me.Location.X, Me.Location.Y + 10)
                Exit Select
            Case 2
                Me.Location = New Point(Me.Location.X - 10, Me.Location.Y)
                Exit Select
            Case 3
                Me.Location = New Point(Me.Location.X, Me.Location.Y - 10)
                Exit Select
        End Select
        shake += 1
        shake = shake Mod 4
    End Sub
And then to make it start and stop shaking you could add a button to your from and use this code:
Code: Select all
If Timer1.Enabled = False Then
            Timer1.Enabled = True
        Else
            Timer1.Enabled = False
        End If
Hope thats what you wanted, ive never really needed to make a form shake but thats the only way I know how to do it.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Martin
Supreme VIP
Supreme VIP
Posts: 369
Joined: Sat Aug 01, 2009 12:26 pm

Re: window possition on screeen
Martin
The Shake Thing Is Good CodenStuff
Image
7 posts Page 1 of 1
Return to “Tutorial Requests”