Non-Rectangular Form Question

  • Thread starter Thread starter Herfried K. Wagner [MVP]
  • Start date Start date
H

Herfried K. Wagner [MVP]

* "Tiraman said:
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.
 
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
?
 
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
///
 
Back
Top