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);
}
}
}
推荐阅读
-
asp.net 图标提取以及图标转换的实例代码
-
asp.net 图标提取以及图标转换的实例代码
-
Android 改变图标原有颜色和搜索框的实例代码
-
Android 改变图标原有颜色和搜索框的实例代码
-
BootStrap表单验证 FormValidation 调整反馈图标位置的实例代码
-
JavaScript中的图标库Chart.js代码实例
-
BootStrap表单验证 FormValidation 调整反馈图标位置的实例代码
-
vue 图标选择器的实例代码
-
php导出csv格式数据并将数字转换成文本的思路以及代码分享_php实例
-
php导出csv格式数据并将数字转换成文本的思路以及代码分享_php实例