asp.net 圖標(biāo)提取以及圖標(biāo)轉(zhuǎn)換的實(shí)例代碼
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);
}
}
}
相關(guān)文章
asp.net Repeater分頁實(shí)例(PageDataSource的使用)
Asp.net提供了三個(gè)功能強(qiáng)大的列表控件:DataGrid、DataList和Repeater控件,但其中只有DataGrid控件提供分頁功能。相對(duì)DataGrid,DataList和Repeater控件具有更高的樣式自定義性,所以很多時(shí)候我們喜歡使用DataList或Repeater控件來顯示數(shù)據(jù)2013-04-04.Net Core導(dǎo)入千萬級(jí)數(shù)據(jù)至Mysql數(shù)據(jù)庫的實(shí)現(xiàn)方法
今天我們談?wù)凪ySQL怎么高性能插入千萬級(jí)的數(shù)據(jù)的,討論這個(gè)問題牽扯到一個(gè)數(shù)據(jù)遷移功能,高性能的插入數(shù)據(jù),接下來通過本文給大家分享幾種實(shí)現(xiàn)方法,感興趣的朋友跟隨小編一起學(xué)習(xí)下吧2021-05-05Asp.net TreeView來構(gòu)建用戶選擇輸入的方法 推薦
選擇優(yōu)于輸入,這是一般人的共識(shí),面對(duì)繁多的數(shù)據(jù),提供良好的選擇界面,一方面增強(qiáng)用戶的界面體驗(yàn),一方面也提高了數(shù)據(jù)的準(zhǔn)確性,更節(jié)省了用戶的寶貴時(shí)間。2009-12-12ASP.Net MVC 布局頁、模板頁使用方法詳細(xì)介紹
這篇文章主要介紹了ASP.Net MVC 布局頁、模板頁使用方法詳細(xì)介紹,需要的朋友可以參考下2017-08-08ASP.NET堆和棧四之對(duì)托管和非托管資源的垃圾回收和內(nèi)存分配
這篇文章介紹了.NET堆和棧中對(duì)托管和非托管資源的垃圾回收和內(nèi)存分配,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-08-08