|
本帖最后由 玲心韩雪 于 2012-11-28 17:32 编辑
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using SkinSharp;
- using System.IO;
- namespace My_Software
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- SkinH_Net Skin_Net = new SkinH_Net();
- int Hwnd = new int();
- [System.Runtime.InteropServices.DllImport("user32.dll",EntryPoint= "MessageBoxA")]
- private static extern int MessageBoxA(int Hwnd, string Tip, string Text, int val);
- // 信息框
- [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "FindWindowA")]
- private static extern int FindWindowA(string lpClassName, string lpWindowName);
- // Class&&Name 取Form句柄
- [System.Runtime.InteropServices.DllImport("SetDiaphaneity.dll", EntryPoint = "SetDiaphaneity")]
- private static extern int SetDiaphaneity(int a, int b);
- // Class&&Name 取Form句柄
- [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetWindowPos")]
- private static extern int SetWindowPos(int Long, int LongA, int LongB, int LongC, int LongD, int LongE, int LongF);
- // 设置窗口位置
- private void Form1_Load(object sender, EventArgs e)
- {
- this.Text = "使用信息框弹出消息小案例";
- this.button1.Text = "Open(&O)";
- this.openFileDialog1.FileName = "(请选择您欲选择的文件)";
- string namespaceAbc = ".she";
- Random ran=new Random();
- int Random = ran.Next(1, 3); // 取随机数不知是否为置入随机数种子为系统时间这个Random的置随机数种子命令函数不知道望高人指点一二
- switch (Random) // 80%语言switch不可以直接提供返回值函数求值需装入变量后继续
- {
- case 1:
- namespaceAbc = ("Aero").ToString() + (string)namespaceAbc;
- break;
- case 2:
- namespaceAbc = ("QQ2008").ToString() + (string)namespaceAbc;
- break;
- default:
- namespaceAbc = ("skinh").ToString() + (string)namespaceAbc;
- break;
- }
- this.Skin_Net.AttachEx(namespaceAbc, "");
- this.Skin_Net.SetAero(-1);
- this.openFileDialog1.Filter = "*.Txt|*.txt|*.Ini|*.ini|*.Cfg|*.cfg|*.Inf|*.inf|*.All|*.*"; // 对话框文件过滤器
- string []Cm=new string [2];
- Cm[1]=this.Text;
- Hwnd = FindWindowA(Cm[0], Cm[1]);
- this.openFileDialog1.Title = "OpenFileDialog";
- this.openFileDialog1.DefaultExt = "";
- SetTouMing(Hwnd,-1,128,2);
- // SetDiaphaneity(Hwnd, 188); 额如果使用该接口函数那么就得程序挂起
- SetWindowPos(Hwnd, -1, 0, 0, 0, 0, 3);
- // 设置窗口总在最前
- // 使用本代码可能造成窗口标题栏脱变
- // 存在于Skin#下、
- AnimateWindow(Hwnd, 1288, 22);
- }
- [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetWindowLongA")]
- private static extern int GetWindowLongA(int hwnd, int nIndex);
- // 获取窗口信息
- [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetWindowLongA")]
- private static extern int SetWindowLongA(int hwnd, int nIndex, int dwNewLong);
- // 设置窗口信息
- [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetLayeredWindowAttributes")]
- private static extern int SetLayeredWindowAttributes(int hwnd, int crKey, int alrf, int dwFlags);
- // 设置透明函数
- [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "AnimateWindow")]
- private static extern int AnimateWindow(int hwnd, int dwTime, int dwFlags);
- // 动画窗口
- bool SetTouMing(int CHwnd,int CrKey,int bAlpha,int dwFlags)
- {
- int Ret = new int();
- Ret = GetWindowLongA(CHwnd, -20);
- Ret = Ret | 524288;
- SetWindowLongA(CHwnd, -20, Ret);
- if (SetLayeredWindowAttributes(CHwnd, CrKey, bAlpha, dwFlags) != 0)
- {
- return true;
- }
- return false;
- }
- [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "FlashWindow")]
- private static extern int FlashWindow(int Hwnd, bool dwY);
- private void button1_Click(object sender, EventArgs e)
- {
- string flieName;
- if (this.openFileDialog1.ShowDialog() == DialogResult.OK) // 对话框.打开显示 == 对话框返回如果是确认钮 所谓 True
- {
- flieName = this.openFileDialog1.FileName; // 将对话框中的文件名返回到变量
- StreamReader flieStream = new StreamReader(flieName, System.Text.Encoding.Default); // 初始化字节集流对象..编码为系统当前默认Ausic码
- flieName = flieStream.ReadToEnd()+Environment.NewLine; //从首读到尾 And 换行符
- int rtr = MessageBoxA(Hwnd, flieName, "信息:", 64 + 1);
- // if rtr = 1 确认被单击 And 2 取消==关闭钮
- flieStream.Close();// 关闭字节流对象
- FlashWindow(Hwnd, true);
- }
- else
- {
- MessageBoxA(Hwnd, "您点击了取消所以执行Commonde失败", "信息:", 64);
- }
- }
- }
- }
复制代码 下载地址:: 要求装入 FW 4.0 框架...程序结构框架///最好具备VS2010以及更高
My Software.rar
(440.19 KB, 下载次数: 15)
|
|