如何使普通菜单变成XP风格的菜单?

xmzhy 2003-12-20 10:16:04
请问如果不引用控件,如何使普通菜单变的漂亮起来,像.Net风格或像XP风格?
...全文
32 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
aidy 2003-12-23
  • 打赏
  • 举报
回复
好,收藏
airon2002 2003-12-23
  • 打赏
  • 举报
回复
.net风格menu
1.把 owerDraw 设为 true
2.写重载


Eg:

Private Sub mItem1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles mItem1.DrawItem, mItem2.DrawItem
Dim fselected As Boolean = CType(e.State And DrawItemState.Selected, Boolean)
Dim g1 As Graphics = e.Graphics
Dim p1 As Point
p1.X = e.Bounds.X : p1.Y = e.Bounds.Y
'////全部的区域
Dim mRect As New Rectangle(e.Bounds.Left + 1, e.Bounds.Top, e.Bounds.Width - 2, e.Bounds.Height)
'////除外框的填充区域
Dim mRectFill As New Rectangle(e.Bounds.Left + 2, e.Bounds.Top + 1, e.Bounds.Width - 2 - 1, e.Bounds.Height - 1)

If fselected Then '选中
e.Graphics.DrawRectangle(New Pen(SystemColors.ControlDarkDark), mRect)
'g1.DrawLine(New Pen(Color.White), e.Bounds.Left + 2, e.Bounds.Top + CType(e.Bounds.Height - 2, Integer), e.Bounds.Left + e.Bounds.Width - 2, e.Bounds.Top + CType(e.Bounds.Height - 2, Integer))
'g1.DrawLine(New Pen(Color.White), e.Bounds.Left + 2, e.Bounds.Top + CType(e.Bounds.Height - 1, Integer), e.Bounds.Left + e.Bounds.Width - 2, e.Bounds.Top + CType(e.Bounds.Height - 1, Integer))
Else
If CType(e.State And DrawItemState.HotLight, Boolean) Then
'mouse 移动到的图型
e.Graphics.DrawRectangle(New Pen(Color.FromArgb(10, 36, 106)), mRect)
e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(182, 189, 210)), mRectFill)
Else
'正常状态的图形
e.Graphics.DrawRectangle(New Pen(Color.FromArgb(212, 208, 200)), mRect)
e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(212, 208, 200)), mRectFill)
End If
End If
g1.DrawString(sender.text, e.Font, New SolidBrush(Color.Black), p1.X + 2, p1.Y + 3)
End Sub
Private Sub mItem1_MeasureItem(ByVal sender As Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles mItem1.MeasureItem, mItem2.MeasureItem
Dim mStringFormat As New StringFormat
mStringFormat.HotkeyPrefix = Drawing.Text.HotkeyPrefix.Show
e.ItemWidth = CInt(e.Graphics.MeasureString(Me.Text, Me.Font, 1000, mStringFormat).Width) + 2 * 4
'处理快捷键(ShortCut)
'e.ItemHeight = 10
End Sub
y1g1y1 2003-12-23
  • 打赏
  • 举报
回复
难道没有看看这张贴?

http://expert.csdn.net/Expert/TopicView1.asp?id=2529339
xmzhy 2003-12-22
  • 打赏
  • 举报
回复
poni(poni):
能否提供动态库?(xmzhy@21cn.com)不用动态库如何处理?
ld_key 2003-12-20
  • 打赏
  • 举报
回复
xtragrid www.devexpress.com
poni 2003-12-20
  • 打赏
  • 举报
回复
我有动态库,要的话发email:zjf@iholley.com
hivak47 2003-12-20
  • 打赏
  • 举报
回复
其实你把xp下的几个文件考到你的系统并覆盖就行了。。。。。。。
youngby 2003-12-20
  • 打赏
  • 举报
回复
完整事例以及代码下载:

http://www.codeproject.com/cs/miscctrl/JPEnhancedXPButton.asp
rock29 2003-12-20
  • 打赏
  • 举报
回复
呵呵,给你推荐一个:
http://www.codeproject.com/vb/net/vsnetstylemenusvb.asp
还有源代码呢!
simanh 2003-12-20
  • 打赏
  • 举报
回复
老问题了,找以前的post吧
xmzhy 2003-12-20
  • 打赏
  • 举报
回复
gOODiDEA(无语):
不能解决问题,请问还有什么办法?
gOODiDEA 2003-12-20
  • 打赏
  • 举报
回复
Windows Forms XP style on VS.NET

http://www.csdn.net/develop/article/20/20435.shtm

16,722

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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