时间:2021-05-28
复制代码 代码如下:
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);
}
}
}
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例讲述了asp.net提取多层嵌套json数据的方法。分享给大家供大家参考,具体如下:在.net2.0中提取这样的json:复制代码代码如下:{"name
本文实例讲述了ASP.NET中的用法,分享给大家供大家参考。具体如下:在ASP.NET的.aspx页面中,可以在代码标签中通过添加代码。其实,这里的代码和.cs
本文实例讲述了Asp.NET调用百度翻译的方法。分享给大家供大家参考。具体分析如下:Asp.NET调用百度翻译,如下图所示:HTML代码如下:复制代码代码如下:
本文实例讲述了ASP.NET实现将word文档转换成pdf的方法,分享给大家供大家参考。具体实现步骤如下:一、添加引用复制代码代码如下:usingMicroso
本文实例讲述了asp.net实现将ppt文档转换成pdf的方法。分享给大家供大家参考。具体实现方法如下:一、添加引用复制代码代码如下:usingMicrosof