| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1598 人关注过本帖, 1 人收藏
标题:制作美化的系统右击菜单
只看楼主 加入收藏
heyu52
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2008-4-11
收藏(1)
 问题点数:0 回复次数:7 
制作美化的系统右击菜单
using System.Drawing;
using System.Windows.Forms;

namespace
{
    public class ChangeSystemMenuColor
    {
        public static void SystemMenuColor(Form frm, Color color)
        {

            Win32.MENUINFO MENUINFO = new Win32.MENUINFO();
            MENUINFO.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(MENUINFO);
            MENUINFO.fMask = 2;

            Bitmap bmp = new Bitmap(200, 200);

            Brush b;
            b = new SolidBrush(color);

            Graphics g = Graphics.FromImage(bmp);
            g.FillRectangle(b, new Rectangle(0, 0, 200, 200));

            if (bmp == null) MENUINFO.hbrBack = 0; else MENUINFO.hbrBack = Win32.CreatePatternBrush((bmp.GetHbitmap()).ToInt32());
            try
            {
                Win32.SetMenuInfo(Win32.GetSystemMenu(frm.Handle.ToInt32(), 0), ref MENUINFO);

            }
            catch
            {


            }
        }

        public static void SystemMenuColor(Form frm, Image image)
        {
            Win32.MENUINFO MENUINFO = new Win32.MENUINFO();
            MENUINFO.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(MENUINFO);
            MENUINFO.fMask = 2;

            Bitmap bmp = new Bitmap(200, 200);

            Brush b;
            b = new System.Drawing.TextureBrush(image);

            Graphics g = Graphics.FromImage(bmp);
            g.FillRectangle(b, new Rectangle(0, 0, 200, 200));

            if (bmp == null) MENUINFO.hbrBack = 0; else MENUINFO.hbrBack = Win32.CreatePatternBrush((bmp.GetHbitmap()).ToInt32());
            try
            {
                Win32.SetMenuInfo(Win32.GetSystemMenu(frm.Handle.ToInt32(), 0), ref MENUINFO);

            }
            catch
            {


            }
        }

        public static void SystemMenuColor(Form frm, Color color1, Color color2, int direct)
        {
            Win32.MENUINFO MENUINFO = new Win32.MENUINFO();
            MENUINFO.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(MENUINFO);
            MENUINFO.fMask = 2;

            Bitmap bmp = new Bitmap(200, 200);

            Brush b;
            Point p1, p2;
            if (direct == 0)
            {
                p1 = new Point(0, 0);
                p2 = new Point(200, 0);
            }
            else if (direct == 1)
            {
                p1 = new Point(0, 0);
                p2 = new Point(0, 200);
            }
            else if (direct == 2)
            {
                p2 = new Point(0, 0);
                p1 = new Point(200, 200);
            }
            else
            {
                p2 = new Point(200, 0);
                p1 = new Point(0, 200);
            }
            b = new System.Drawing.Drawing2D.LinearGradientBrush(p1, p2, color1, color2);

            Graphics g = Graphics.FromImage(bmp);
            g.FillRectangle(b, new Rectangle(0, 0, 200, 200));

            if (bmp == null)
                MENUINFO.hbrBack = 0;
            else
                MENUINFO.hbrBack = Win32.CreatePatternBrush((bmp.GetHbitmap()).ToInt32());
            try
            {
                Win32.SetMenuInfo(Win32.GetSystemMenu(frm.Handle.ToInt32(), 0), ref MENUINFO);
            }
            catch
            {


            }
        }

        public static void UnSystemMenuColor(Form frm)
        {
            Win32.MENUINFO MENUINFO = new Win32.MENUINFO();
            MENUINFO.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(MENUINFO);
            MENUINFO.fMask = 2;
            MENUINFO.hbrBack = 0;
            try
            {
                Win32.SetMenuInfo(Win32.GetSystemMenu(frm.Handle.ToInt32(), 0), ref MENUINFO);

            }
            catch
            {


            }
        }

    }
}

未命名.jpg (15.34 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 菜单 系统 制作 
2008-04-11 13:18
coolszy
Rank: 1
来 自:编程论坛
等 级:新手上路
帖 子:241
专家分:5
注 册:2007-11-3
收藏
得分:0 
不错
满漂亮的啊

天道酬勤
2008-04-11 19:19
野比
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:1627
专家分:516
注 册:2007-5-24
收藏
得分:0 
很华丽。

女侠,约吗?
2008-04-11 20:17
jye123
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2008-4-2
收藏
得分:0 
的确很好看!
2008-04-15 15:28
shezhenhui1989
Rank: 1
来 自:安徽
等 级:新手上路
帖 子:287
专家分:0
注 册:2008-2-1
收藏
得分:0 
还可以啊
2008-04-15 15:31
wuhongyao3
Rank: 1
等 级:新手上路
帖 子:202
专家分:0
注 册:2006-4-18
收藏
得分:0 
学习一下
挺漂亮的。

2008-04-16 10:55
simpson
Rank: 3Rank: 3
等 级:论坛游民
威 望:7
帖 子:863
专家分:17
注 册:2006-11-16
收藏
得分:0 
走 ________Oooo .........................
过 ________(___) ..................
路 _________)_/ .................
过 oooO____(_/ ................
的 (___) ...................
都 __( .......................
要 ___)____Oooo ......................
留 ________(___) ...................
个 _________)_/ .................
印 oooO____(_/ ..............
啊 (___) ....
呵 __( .......
呵 ___) ...........
路过看帖,礼貌顶贴!HOHO

全国最大的 Java专业电子书免费分享[url]http:///in.asp?id=xrmao[/url]
2008-04-16 11:53
lvfan10
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-4-23
收藏
得分:0 
如何使用啊?
2013-01-17 22:51
快速回复:制作美化的系统右击菜单
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035572 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved