急: 如何使用c#自定义Windows Forms窗体外观???!!!

syinter 2002-11-10 02:39:51
相信大家都用过MediaPlayer 7/8/9,我要的效果就要像WM换了皮肤后那样!!!

如何实现那种不规则外观的窗口呢

高手一定要指点一二,越详细越好!!!!

(BTW: 我看完<<C#高级编程>>和<<Windows Forms高级编程>>后仍然没有个具体的概念,大概只知道要继承System.Windows.Forms ...)
...全文
137 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
qaqaqa 2002-11-10
  • 打赏
  • 举报
回复
我自己做的控件。。、清你试用。。。www.chinadeer.com/c.zip
visualcpu 2002-11-10
  • 打赏
  • 举报
回复
mark
saucer 2002-11-10
  • 打赏
  • 举报
回复
Shaped Windows Forms and Controls in Visual Studio .NET
http://msdn.microsoft.com/library/en-us/dv_vstechart/html/vbtchshapedwindowsformscontrolsinvisualstudionet.asp?frame=true

NonRectangular Forms
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=417
syinter 2002-11-10
  • 打赏
  • 举报
回复
谢谢各位,我通过MSDN文档已经掌握了做法,谢谢saucer!!
yqjyn 2002-11-10
  • 打赏
  • 举报
回复
我这里有一个vb.net 写的例子你可以参考一下!
Imports System.Drawing.Drawing2D
Public Class Form2
Inherits System.Windows.Forms.Form
Private IsDraging As Boolean = False 'Varible for draging from
Private lCurX, lCurY As Long 'needed for current x, y values
Private WithEvents tTimer As Timer = New Timer() 'setup timer (no need for a formcontrol)
#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'Form2
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)
Me.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
Me.ClientSize = New System.Drawing.Size(272, 150)
Me.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.Name = "Form2"
Me.Text = "Form2"

End Sub

#End Region

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'avvio in un altro thread la costruzione della grafica
'Dim t2 As System.Threading.Thread = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf drawScocca))
't2.Start()
drawScocca()
End Sub

Private Sub drawScocca()
Dim Path As New GraphicsPath()

Dim g As Graphics = Me.CreateGraphics
Dim b As New Bitmap("scocca.gif")

Dim x, y, i As Long
Dim rect As Rectangle

Dim colorFirst As Color = b.GetPixel(1, 1)
For x = 0 To b.Width - 1
For y = 0 To b.Height - 1
If b.GetPixel(x, y).Equals(colorFirst) Then
'non lo disegno perch?devo fare la trasparenza
Else
rect = New Rectangle(x, y, 1, 1)
Path.AddRectangle(rect)
End If
Next y
Next x

Me.Region = New Region(Path)
End Sub


Private Sub Form2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

Dim g As Graphics = Me.CreateGraphics
Dim b As New Bitmap("scocca.gif")

g.DrawImage(b, 0, 0, b.Width, b.Height)
g.Dispose()
End Sub

Private Sub Form2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
lCurX = e.X : lCurY = e.Y 'Set the Current x and y values
IsDraging = True 'Begin Draging Form
tTimer.Enabled = True 'Enable Drag Timer
End Sub

Private Sub tTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tTimer.Tick
'Checks the state of the mouseevent and moves form Accordingly
If IsDraging = True Then
'Move the form accordingly to cursor x, y positions (minus) the current form x, y positions
Dim curxx As Integer = Cursor.Position.X
Dim curyy As Integer = Cursor.Position.Y
Me.SetDesktopLocation(curxx - lCurX, curyy - lCurY)
End If
'tTimer.Enabled = False 'Cancel timer, no longer needed
End Sub

Private Sub Form2_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
IsDraging = False 'No Longer Moving Form
tTimer.Enabled = False 'Cancel Timer
End Sub
End Class

111,093

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧