By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,234 Members | 1,869 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,234 IT Pros & Developers. It's quick & easy.

Non-Rectangular Form Question

P: n/a
Hi,

i have some questions about non-rectangular forms

1) i build a form as a non-rectangular by setting the form background to
some bmp file and the transparenceyKey to the
color which i want to make transparent and every thing ok BUT when i m
replacing the bmp
file i can see the new one in the form designer but when i m running the
program i m getting the old bmp file.
i tried to remove the background but it didn't help.
what i m missing ?

2) how can i make a non-rectangular form for monitors which working with
more than 24 bit color depth ?

3) how can i make the non-rectangular form to be resizable ?

4) how can i prevent the duplicating of the background bmp file on the form
?

--
Best Regards ,

Tiraman :-)
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
* "Tiraman" <ti*****@netvision.net.il> scripsit:
i have some questions about non-rectangular forms

1) i build a form as a non-rectangular by setting the form background to
some bmp file and the transparenceyKey to the
color which i want to make transparent and every thing ok BUT when i m
replacing the bmp
file i can see the new one in the form designer but when i m running the
program i m getting the old bmp file.
i tried to remove the background but it didn't help.
what i m missing ?

2) how can i make a non-rectangular form for monitors which working with
more than 24 bit color depth ?


Instead of using 'TransparencyKey' to archieve transparency, you can
create a 'System.Drawing.Drawing2D.GrpahicsPath' or appropriate shape,
create a 'Region' object from it and assign it to the form's 'Region'
property at runtime.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2

P: n/a
Hi,

How to do it yourself.
http://msdn.microsoft.com/library/de...lStudioNET.asp

Region master controls
http://www.windowsforms.com/Samples/...179&tabindex=4

MSDN TV episode on Region master controls.
http://msdn.microsoft.com/msdntv/epi...H/manifest.xml

Ken
-----------------------
"Tiraman" <ti*****@netvision.net.il> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
Hi,

i have some questions about non-rectangular forms

1) i build a form as a non-rectangular by setting the form background to
some bmp file and the transparenceyKey to the
color which i want to make transparent and every thing ok BUT when i m
replacing the bmp
file i can see the new one in the form designer but when i m running
the
program i m getting the old bmp file.
i tried to remove the background but it didn't help.
what i m missing ?

2) how can i make a non-rectangular form for monitors which working with
more than 24 bit color depth ?

3) how can i make the non-rectangular form to be resizable ?

4) how can i prevent the duplicating of the background bmp file on the
form
?

--
Best Regards ,

Tiraman :-)

Nov 20 '05 #3

P: n/a
Hi Tiraman,

What I find one of the nicest samples I have made.

See beneath (You can open a project and just paste above the end class
line).

I hope this helps?

Cor

\\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner and Fergus
Cooney
Private WithEvents button1 As New Button
Private mouseX, mouseY As Integer
Private myMouseDown As Boolean
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim g As New System.Drawing.Drawing2D.GraphicsPath
g.AddString("HTH" & vbCrLf & "Cor", _
System.Drawing.FontFamily.GenericSansSerif, _
System.Drawing.FontStyle.Bold, 200, _
New Point(0, 0), _
System.Drawing.StringFormat.GenericDefault)
Me.BackColor = Color.Red
Me.Region = New System.Drawing.Region(g)
g.Dispose()
Me.AutoScaleBaseSize = New System.Drawing.Size(0, 0)
Me.ClientSize = New System.Drawing.Size(500, 450)
button1.BackColor = System.Drawing.SystemColors.ActiveCaptionText
button1.ForeColor = System.Drawing.Color.Black
button1.Location = New System.Drawing.Point(425, 18)
button1.Size = New System.Drawing.Size(20, 20)
Me.Controls.Add(button1)
button1.Text = "X"
Me.Location = New System.Drawing.Point(50, 50)
End Sub
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles button1.Click
Me.Close()
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal _
e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
myMouseDown = True
mouseX = Cursor.Position.X - Me.Location.X
mouseY = Cursor.Position.Y - Me.Location.Y
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Static LastCursor As Point
Dim NowCursor As Point = New Point(Cursor.Position.X,
Cursor.Position.Y)
If Point.op_Inequality(NowCursor, LastCursor) Then
If myMouseDown Then
Me.Location = New System.Drawing.Point(Cursor.Position.X _
- mouseX, Cursor.Position.Y - mouseY)
End If
LastCursor = Cursor.Position
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
myMouseDown = False
End Sub
///
Nov 20 '05 #4

P: n/a
Hi Cor,

it is a nice example :-)
so 10x and bye

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:u3**************@TK2MSFTNGP12.phx.gbl...
Hi Tiraman,

What I find one of the nicest samples I have made.

See beneath (You can open a project and just paste above the end class
line).

I hope this helps?

Cor

\\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner and Fergus Cooney
Private WithEvents button1 As New Button
Private mouseX, mouseY As Integer
Private myMouseDown As Boolean
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim g As New System.Drawing.Drawing2D.GraphicsPath
g.AddString("HTH" & vbCrLf & "Cor", _
System.Drawing.FontFamily.GenericSansSerif, _
System.Drawing.FontStyle.Bold, 200, _
New Point(0, 0), _
System.Drawing.StringFormat.GenericDefault)
Me.BackColor = Color.Red
Me.Region = New System.Drawing.Region(g)
g.Dispose()
Me.AutoScaleBaseSize = New System.Drawing.Size(0, 0)
Me.ClientSize = New System.Drawing.Size(500, 450)
button1.BackColor = System.Drawing.SystemColors.ActiveCaptionText
button1.ForeColor = System.Drawing.Color.Black
button1.Location = New System.Drawing.Point(425, 18)
button1.Size = New System.Drawing.Size(20, 20)
Me.Controls.Add(button1)
button1.Text = "X"
Me.Location = New System.Drawing.Point(50, 50)
End Sub
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles button1.Click
Me.Close()
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal _
e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
myMouseDown = True
mouseX = Cursor.Position.X - Me.Location.X
mouseY = Cursor.Position.Y - Me.Location.Y
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Static LastCursor As Point
Dim NowCursor As Point = New Point(Cursor.Position.X,
Cursor.Position.Y)
If Point.op_Inequality(NowCursor, LastCursor) Then
If myMouseDown Then
Me.Location = New System.Drawing.Point(Cursor.Position.X _
- mouseX, Cursor.Position.Y - mouseY)
End If
LastCursor = Cursor.Position
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
myMouseDown = False
End Sub
///

Nov 20 '05 #5

P: n/a
hello ken,

10x for the articles, they are good !

bye
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:eL**************@TK2MSFTNGP09.phx.gbl...
Hi,

How to do it yourself.
http://msdn.microsoft.com/library/de...us/dv_vstechar
t/html/vbtchShapedWindowsFormsControlsInVisualStudioNET.a sp
Region master controls
http://www.windowsforms.com/Samples/...mId=179&tabind
ex=4
MSDN TV episode on Region master controls.
http://msdn.microsoft.com/msdntv/epi...20040401WinFor
msMH/manifest.xml
Ken
-----------------------
"Tiraman" <ti*****@netvision.net.il> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
Hi,

i have some questions about non-rectangular forms

1) i build a form as a non-rectangular by setting the form background to
some bmp file and the transparenceyKey to the
color which i want to make transparent and every thing ok BUT when i m replacing the bmp
file i can see the new one in the form designer but when i m running
the
program i m getting the old bmp file.
i tried to remove the background but it didn't help.
what i m missing ?

2) how can i make a non-rectangular form for monitors which working with
more than 24 bit color depth ?

3) how can i make the non-rectangular form to be resizable ?

4) how can i prevent the duplicating of the background bmp file on the
form
?

--
Best Regards ,

Tiraman :-)


Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.