asp.net如何實現(xiàn)圖標提取以及圖標轉(zhuǎn)換-創(chuàng)新互聯(lián)

這篇文章主要介紹了asp.net如何實現(xiàn)圖標提取以及圖標轉(zhuǎn)換,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

創(chuàng)新互聯(lián)建站長期為上千家客戶提供的網(wǎng)站建設(shè)服務(wù),團隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為合陽企業(yè)提供專業(yè)的做網(wǎng)站、網(wǎng)站建設(shè)合陽網(wǎng)站改版等技術(shù)服務(wù)。擁有10多年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。

復(fù)制代碼 代碼如下:


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="應(yīng)用程序|*.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|應(yīng)用程序|*.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)
        {
            //為當前的應(yīng)用程序釋放鼠標捕獲
            ReleaseCapture();
            //發(fā)送消息,讓系統(tǒng)誤以為你在標題攔上按下鼠標
            SendMessage((int)this.Handle,WM_NCLBUTTONDOWN,HTCAPTION,0);
        }
    }
}


感謝你能夠認真閱讀完這篇文章,希望小編分享的“asp.net如何實現(xiàn)圖標提取以及圖標轉(zhuǎn)換”這篇文章對大家有幫助,同時也希望大家多多支持創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識等著你來學(xué)習(xí)!

當前標題:asp.net如何實現(xiàn)圖標提取以及圖標轉(zhuǎn)換-創(chuàng)新互聯(lián)
轉(zhuǎn)載來源:http://www.muchs.cn/article18/ceocgp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)搜索引擎優(yōu)化、靜態(tài)網(wǎng)站、App開發(fā)全網(wǎng)營銷推廣、網(wǎng)站收錄

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)