[VB2003] Moving a form without border

P

peter hansen

By changing the backgroundimage of a form into a picture and then enable the
TransparencyColor you can make a form as a cirkel etc (the form has the same
'form' as the picture has). I have then disabled the FormBorderStyle (None)

By doing that I have no border I can click at to drag the form. How do I
make the form-area drag-able so that it is possible to click at a random
point at the form, hold down the mousebutton and then move the form?


// Peter
 
T

Tom Leylan

peter hansen said:
By doing that I have no border I can click at to drag the form. How do I
make the form-area drag-able so that it is possible to click at a random
point at the form, hold down the mousebutton and then move the form?

This should work:

Private _MouseDown As Boolean
Private _MouseX As Integer
Private _MouseY As Integer


Private Sub Form1_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
MyBase.MouseDown
_MouseDown = True
_MouseX = e.X
_MouseY = e.Y
End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
MyBase.MouseMove
If _MouseDown Then
Me.Left = Me.Left + (e.X - _MouseX)
Me.Top = Me.Top + (e.Y - _MouseY)
End If
End Sub

Private Sub Form1_MouseUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
MyBase.MouseUp
_MouseDown = False
End Sub
 
H

Herfried K. Wagner [MVP]

* "peter hansen said:
By changing the backgroundimage of a form into a picture and then enable the
TransparencyColor you can make a form as a cirkel etc (the form has the same
'form' as the picture has). I have then disabled the FormBorderStyle (None)

By doing that I have no border I can click at to drag the form. How do I
make the form-area drag-able so that it is possible to click at a random
point at the form, hold down the mousebutton and then move the form?

<http://www.google.de/groups?q=sendmessage+HTCAPTION+group:*dotnet*&ie=UTF-8>
 
P

peter hansen

Thanks - but why is it - anyway, that sometimes the transparent-thing
doesn't work.
Sometimes it works fine and sometimes it doesn't works.
I only change the BackgroundImage of the form and then set the
TransparencyKey to the color on the Bitmap that I want to make transparent -
in this case #00FFAA
Anyway its a BMP-picture but that shouldn't be the problem cause if I use
the colostandard like 'ControlText' or another color it works fine but if I
change the background into a picture it doesn't works

// Peter
 
T

Tom Leylan

peter hansen said:
Thanks - but why is it - anyway, that sometimes the transparent-thing
doesn't work.
Sometimes it works fine and sometimes it doesn't works.
I only change the BackgroundImage of the form and then set the
TransparencyKey to the color on the Bitmap that I want to make transparent -
in this case #00FFAA
Anyway its a BMP-picture but that shouldn't be the problem cause if I use
the colostandard like 'ControlText' or another color it works fine but if I
change the background into a picture it doesn't works

Hi Peter... any chance the bitmap doesn't contain a solid color? Just as a
test create another image and simply fill 1/2 of it with your color. If
that works I would suspect the image you were originally using. If it's a
photograph or it has a gradient background for instance not many pixels are
going to match.

Tom
 
P

peter hansen

Tom Leylan said:
if

Hi Peter... any chance the bitmap doesn't contain a solid color? Just as a
test create another image and simply fill 1/2 of it with your color. If
that works I would suspect the image you were originally using. If it's a
photograph or it has a gradient background for instance not many pixels are
going to match.

The picture is an octogon created in Illustrator, imported in PhotoShop
where the background has been modified, so that the octagon is the only
viewable area if the TransparentKey is set as the color applied in
PhotoShop. The picture should be used as a splash-screen like when you start
Word or another program with a splash-screen

But it doesn't work... *sigh*

Hmmm... isn't it possible that you would send me an example that works -
eMail:

kian at lflug . [ThisShouldBeRemoved]dk

// Peter
 
P

peter hansen

peter hansen said:
Tom Leylan said:
if

Hi Peter... any chance the bitmap doesn't contain a solid color? Just
as
a
test create another image and simply fill 1/2 of it with your color. If
that works I would suspect the image you were originally using. If it's a
photograph or it has a gradient background for instance not many pixels are
going to match.

The picture is an octogon created in Illustrator, imported in PhotoShop
where the background has been modified, so that the octagon is the only
viewable area if the TransparentKey is set as the color applied in
PhotoShop. The picture should be used as a splash-screen like when you start
Word or another program with a splash-screen

But it doesn't work... *sigh*

Hmmm... isn't it possible that you would send me an example that works -
eMail:

kian at lflug . [ThisShouldBeRemoved]dk

// Peter

Don't ask why but I restarted my computer and then the transparent-thing
worked :D great and thanks anyway :D

// Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top