Custom border ...

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
11 posts Page 1 of 2
Contributors
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Custom border ...
M1z23R
Ok so ....

If you want to create a for example "STAR" to be your forms border you have to do the following ;))
Open up new project and set the following settings of your form :
-Border style - None
-Transparency key - Yellow !

When you set that, enter this in the "Form1.vb" - codes
Code: Select all
Public class Form1

   Private IsFormBeingDragged As Boolean = False
    Private MouseDownX As Integer
    Private MouseDownY As Integer[code]
Ok, so this is to get mouse position X - left/right and for Y position - Up/Down and variable to check
if you are moving the mouse while you are holding your click - "mouse down"

[code]
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
        If e.Button = MouseButtons.Left Then
            IsFormBeingDragged = True
            MouseDownX = e.X
            MouseDownY = e.Y
        End If
    End Sub[code]
This is to check if the mouse is clicked ... if it is : "IsFormBeingDragged = True" - that means that the form moves if mouse is clicked and moved ...


[code]Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp
        If e.Button = MouseButtons.Left Then
            IsFormBeingDragged = False
        End If
    End Sub[code]
This is to "disable" FormDragging  .... - When the mouse click is released ....

[code]Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
        If IsFormBeingDragged Then
            Dim temp As Point = New Point()
            temp.X = Me.Location.X + (e.X - MouseDownX)
            temp.Y = Me.Location.Y + (e.Y - MouseDownY)
            Me.Location = temp
            temp = Nothing
        End If
    End Sub

End class
This is what to do when the mouse is moved ... !!!

So when you have that, you can now move your form with NO BORDER STYLE by just dragging it (with mouse click held down) ....
Now open up MS PAINT and create a "STAR" like this !!!
[img]http://www.freeimagehosting.net/uploads/a8ee94ed63.png[/img]
but be careful ... THE COLOR MUST BE SOLID !!!!
You can also download this picture for trying this :)
Now set the Forms Background image to this image ...
And add a button named Button1, double click on it and add the following :
The button should be inside the star ....

Code: Select all
MsgBox("Hello world !!!")
Press F5 to debug it and test it out ...


NOTE : "THE STAR IS NOW YOUR "FORM" , ALL THAT WILL BE SEEN HAS TO BE INSIDE THE STAR !!! "
Last edited by M1z23R on Tue Sep 28, 2010 6:29 pm, edited 1 time in total.
User avatar
Axel
Coding God
Coding God
Posts: 1928
Joined: Sun Jun 27, 2010 9:15 pm

Re: Custom border ...
Axel
this is to easy + i saw this code on another website
give a credit if this isn't yours
http://vagex.com/?ref=25000
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Custom border ...
Codex
Hello and welcome to CodenStuff

What you could do is explain the code and you will get great comments cooll;

always remember to give credits to original author.
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: Custom border ...
M1z23R
Ok thank you for your advise ... But the code is all mine :D Honestly ... ;)
User avatar
Axel
Coding God
Coding God
Posts: 1928
Joined: Sun Jun 27, 2010 9:15 pm

Re: Custom border ...
Axel
nope i rly saw EXACTLY the same code with "temp" and such
http://vagex.com/?ref=25000
User avatar
Agust1337
Coding God
Coding God
Posts: 2456
Joined: Fri Feb 19, 2010 8:18 pm

Re: Custom border ...
Agust1337
Hello M1z23R,
I gotta say this:
This has been posted really often here(moving borderless windows)
Top-notch casual Dating
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: Custom border ...
M1z23R
This tutorial is about creating custom border, not "moving form without border" ....
User avatar
Agust1337
Coding God
Coding God
Posts: 2456
Joined: Fri Feb 19, 2010 8:18 pm

Re: Custom border ...
Agust1337
M1z23R wrote:
This tutorial is about creating custom border, not "moving form without border" ....
Well still there are few of these
Top-notch casual Dating
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: Custom border ...
XTechVB
try to use the ' in the code comments
You can find me on Facebook or on Skype mihai_92b
User avatar
Axel
Coding God
Coding God
Posts: 1928
Joined: Sun Jun 27, 2010 9:15 pm

Re: Custom border ...
Axel
M1z23R wrote:
This tutorial is about creating custom border, not "moving form without border" ....
Code: Select all
  Private IsFormBeingDragged As Boolean = False
    Private MouseDownX As Integer
    Private MouseDownY As Integer[code]
Ok, so this is to get mouse position X - left/right and for Y position - Up/Down and variable to check
if you are moving the mouse while you are holding your click - "mouse down"

[code]
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
        If e.Button = MouseButtons.Left Then
            IsFormBeingDragged = True
            MouseDownX = e.X
            MouseDownY = e.Y
        End If
    End Sub[code]
This is to check if the mouse is clicked ... if it is : "IsFormBeingDragged = True" - that means that the form moves if mouse is clicked and moved ...


[code]Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp
        If e.Button = MouseButtons.Left Then
            IsFormBeingDragged = False
        End If
    End Sub[code]
This is to "disable" FormDragging  .... - When the mouse click is released ....

[code]Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
        If IsFormBeingDragged Then
            Dim temp As Point = New Point()
            temp.X = Me.Location.X + (e.X - MouseDownX)
            temp.Y = Me.Location.Y + (e.Y - MouseDownY)
            Me.Location = temp
            temp = Nothing
        End If
    End Sub
3/4th of your code tells a different story
http://vagex.com/?ref=25000
11 posts Page 1 of 2
Return to “Tutorials”