Copy Code code as follows:
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= "Application |*.dll;*.exe| all program |*.*";
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= "Picture |*.jpg;*.png;*.bmp| all program |*.*";
openfiledialog1.filter= "Picture |*.jpg;*.png;*.bmp| application |*.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 Gets the stream
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)
{
Releasing mouse capture for the current application
ReleaseCapture ();
Send a message to let the system mistakenly think you pressed the mouse over the title stop
SendMessage (int) this. handle,wm_nclbuttondown,htcaption,0);
}
}
}