主頁(yè) > 知識(shí)庫(kù) > asp.net 圖標(biāo)提取以及圖標(biāo)轉(zhuǎn)換的實(shí)例代碼

asp.net 圖標(biāo)提取以及圖標(biāo)轉(zhuǎn)換的實(shí)例代碼

熱門(mén)標(biāo)簽:凱立德導(dǎo)航官網(wǎng)地圖標(biāo)注 鄭州400電話辦理 聯(lián)通 智能電話營(yíng)銷(xiāo)外呼系統(tǒng) 五常地圖標(biāo)注 萊蕪?fù)夂綦婁N(xiāo)機(jī)器人價(jià)格 電銷(xiāo)語(yǔ)音自動(dòng)機(jī)器人 長(zhǎng)春呼叫中心外呼系統(tǒng)哪家好 戶(hù)外地圖標(biāo)注軟件手機(jī)哪個(gè)好用 地圖標(biāo)注和認(rèn)領(lǐng)

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

標(biāo)簽:宣城 西寧 湖州 福州 衢州 紅河 西藏 岳陽(yáng)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp.net 圖標(biāo)提取以及圖標(biāo)轉(zhuǎn)換的實(shí)例代碼》,本文關(guān)鍵詞  asp.net,圖標(biāo),提取,以及,轉(zhuǎn)換,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net 圖標(biāo)提取以及圖標(biāo)轉(zhuǎn)換的實(shí)例代碼》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于asp.net 圖標(biāo)提取以及圖標(biāo)轉(zhuǎn)換的實(shí)例代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章