发布于 2016-06-15 04:47:57 | 149 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

ASP.NET

ASP.NET 是.NET FrameWork的一部分,是一项微软公司的技术,是一种使嵌入网页中的脚本可由因特网服务器执行的服务器端脚本技术,它可以在通过HTTP请求文档时再在Web服务器上动态创建它们。 指 Active Server Pages(动态服务器页面) ,运行于 IIS(Internet Information Server 服务,是Windows开发的Web服务器)之中的程序 。


asp.net 图标提取以及图标转换的实例代码,需要的朋友可以参考一下


using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Resources;
using System.Reflection;
using System.Runtime.InteropServices;


namespace newExtIcon
{
    public partial class MainForm : Form
    {   
        public Assembly asm = Assembly.GetExecutingAssembly();
        public MainForm()
        {
            InitializeComponent();       
        }

        void MainForm_Load(object sender ,EventArgs e)
        {
            lbl_display.Text ="No Work !";   

        }

        void btnExtractClick(object sender, EventArgs e)
        {
            Random rd = new Random();
            openFileDialog1.Filter="应用程序|*.dll;*.exe|所有程序|*.*";
            if(openFileDialog1.ShowDialog()== DialogResult.OK)
            {
                Icon icon = Icon.ExtractAssociatedIcon(openFileDialog1.FileName);
                FileStream fileStream = new FileStream("d:\\"+rd.Next(1,100000)+".ico",FileMode.Create);
                icon.Save(fileStream);
                fileStream.Close();       
                lbl_display.Text="Work Done!";
            }
            else
            {
                return ;
            }
        }

        void BtnChangeClick(object sender, EventArgs e)
        {
            Size sz = new Size(32,32);
            Random rd = new Random();
            openFileDialog1.Filter="图片|*.jpg;*.png;*.bmp|所有程序|*.*";
            //openFileDialog1.Filter="图片|*.jpg;*.png;*.bmp|应用程序|*.dll;*.exe";
            if(openFileDialog1.ShowDialog()== DialogResult.OK)
            {
                using(Bitmap bm = new Bitmap(openFileDialog1.FileName))
                {
                    using(Bitmap IconBM = new Bitmap(bm,sz))
                    {
                        using(Icon icon_t = Icon.FromHandle(IconBM.GetHicon()))
                        {
                            FileStream fileStream = new FileStream("d:\\"+rd.Next(1,100000)+".ico",FileMode.Create);
                            icon_t.Save(fileStream);
                            fileStream.Close();   
                            lbl_display.Text="Work Done!";        
                        }
                    }
                }
            }
            else
            {
                return ;
            }

        }
        void Pic_Click(object sender, System.EventArgs e)
        {
            int int_index = Convert.ToInt32(((PictureBox)sender).Tag) ;
            switch(int_index)
            {
                case 1:
                    this.Close();
                    Application.Exit();
                    break;
                case 2:
                    WindowState = FormWindowState.Minimized;
                    break;
                default :
                    break;

            }

        }

        void Pic_Hover(object sender,EventArgs e)
        {
            string  name_1 = "btn_close_hightligth.png";
            string name_2 ="btn_mini_highlight.png";
            Bitmap bm_1 = new Bitmap(asm.GetManifestResourceStream(name_1));
            Bitmap bm_2 = new Bitmap(asm.GetManifestResourceStream(name_2));
            int int_index = Convert.ToInt32(((PictureBox)sender).Tag) ;
            switch(int_index)
            {
                case 1:
                    pictureBox1.BackgroundImage=bm_1;
                    break;
                case 2:
                    pictureBox2 .BackgroundImage = bm_2;
                    break;
                default :
                    break;

            }
        }
        void Pic_Leave(object sender,EventArgs e)
        {
            string  name_1 = "btn_close_down.png";
            string  name_2 ="btn_mini_down.png";
            Bitmap bm_1 = new Bitmap(asm.GetManifestResourceStream(name_1));
            Bitmap bm_2 = new Bitmap(asm.GetManifestResourceStream(name_2));
            //GetMainfestResourceStream获取的是流
            int int_index = Convert.ToInt32(((PictureBox)sender).Tag) ;
            switch(int_index)
            {
                case 1:
                    pictureBox1.BackgroundImage=bm_1;
                    break;
                case 2:
                    pictureBox2 .BackgroundImage = bm_2;
                    break;
                default :
                    break;

            }
        }

        private const int WM_NCLBUTTONDOWN = 0xA1;
        private const int HTCAPTION = 2;

        [DllImport("user32.dll")]
        private static extern int SendMessage (int hwnd, int wMsg, int wParam, int lParam);

        [DllImport("user32.dll")]
        private static extern int ReleaseCapture();

        private void form_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            //为当前的应用程序释放鼠标捕获
            ReleaseCapture();
            //发送消息,让系统误以为你在标题拦上按下鼠标
            SendMessage((int)this.Handle,WM_NCLBUTTONDOWN,HTCAPTION,0);
        }
    }
}



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务