开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 2394|回复: 2
收起左侧

[C#源码] C# 窗体半透明+openfile文件对话框及字节流文本信息框输出Such

[复制链接]
结帖率:33% (3/9)
发表于 2012-11-28 17:29:26 | 显示全部楼层 |阅读模式   四川省成都市
本帖最后由 玲心韩雪 于 2012-11-28 17:32 编辑
123

1.JPG
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using SkinSharp;
  10. using System.IO;
  11. namespace My_Software
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19. SkinH_Net Skin_Net = new SkinH_Net();
  20. int Hwnd = new int();
  21. [System.Runtime.InteropServices.DllImport("user32.dll",EntryPoint= "MessageBoxA")]
  22. private static extern int MessageBoxA(int Hwnd, string Tip, string Text, int val);
  23. // 信息框
  24. [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "FindWindowA")]
  25. private static extern int FindWindowA(string lpClassName, string lpWindowName);
  26. // Class&&Name 取Form句柄
  27. [System.Runtime.InteropServices.DllImport("SetDiaphaneity.dll", EntryPoint = "SetDiaphaneity")]
  28. private static extern int SetDiaphaneity(int a, int b);
  29. // Class&&Name 取Form句柄
  30. [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetWindowPos")]
  31. private static extern int SetWindowPos(int Long, int LongA, int LongB, int LongC, int LongD, int LongE, int LongF);
  32. // 设置窗口位置
  33. private void Form1_Load(object sender, EventArgs e)
  34. {
  35. this.Text = "使用信息框弹出消息小案例";
  36. this.button1.Text = "Open(&O)";
  37. this.openFileDialog1.FileName = "(请选择您欲选择的文件)";
  38. string namespaceAbc = ".she";
  39. Random ran=new Random();
  40. int Random = ran.Next(1, 3); // 取随机数不知是否为置入随机数种子为系统时间这个Random的置随机数种子命令函数不知道望高人指点一二
  41. switch (Random) // 80%语言switch不可以直接提供返回值函数求值需装入变量后继续
  42. {
  43. case 1:
  44. namespaceAbc = ("Aero").ToString() + (string)namespaceAbc;
  45. break;
  46. case 2:
  47. namespaceAbc = ("QQ2008").ToString() + (string)namespaceAbc;
  48. break;
  49. default:
  50. namespaceAbc = ("skinh").ToString() + (string)namespaceAbc;
  51. break;
  52. }
  53. this.Skin_Net.AttachEx(namespaceAbc, "");
  54. this.Skin_Net.SetAero(-1);
  55. this.openFileDialog1.Filter = "*.Txt|*.txt|*.Ini|*.ini|*.Cfg|*.cfg|*.Inf|*.inf|*.All|*.*"; // 对话框文件过滤器
  56. string []Cm=new string [2];
  57. Cm[1]=this.Text;
  58. Hwnd = FindWindowA(Cm[0], Cm[1]);
  59. this.openFileDialog1.Title = "OpenFileDialog";
  60. this.openFileDialog1.DefaultExt = "";
  61. SetTouMing(Hwnd,-1,128,2);
  62. // SetDiaphaneity(Hwnd, 188); 额如果使用该接口函数那么就得程序挂起
  63. SetWindowPos(Hwnd, -1, 0, 0, 0, 0, 3);
  64. // 设置窗口总在最前
  65. // 使用本代码可能造成窗口标题栏脱变
  66. // 存在于Skin#下、
  67. AnimateWindow(Hwnd, 1288, 22);

  68. }

  69. [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetWindowLongA")]
  70. private static extern int GetWindowLongA(int hwnd, int nIndex);
  71. // 获取窗口信息
  72. [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetWindowLongA")]
  73. private static extern int SetWindowLongA(int hwnd, int nIndex, int dwNewLong);
  74. // 设置窗口信息
  75. [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetLayeredWindowAttributes")]
  76. private static extern int SetLayeredWindowAttributes(int hwnd, int crKey, int alrf, int dwFlags);
  77. // 设置透明函数
  78. [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "AnimateWindow")]
  79. private static extern int AnimateWindow(int hwnd, int dwTime, int dwFlags);
  80. // 动画窗口
  81. bool SetTouMing(int CHwnd,int CrKey,int bAlpha,int dwFlags)
  82. {
  83. int Ret = new int();
  84. Ret = GetWindowLongA(CHwnd, -20);
  85. Ret = Ret | 524288;
  86. SetWindowLongA(CHwnd, -20, Ret);
  87. if (SetLayeredWindowAttributes(CHwnd, CrKey, bAlpha, dwFlags) != 0)
  88. {
  89. return true;
  90. }
  91. return false;
  92. }
  93. [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "FlashWindow")]
  94. private static extern int FlashWindow(int Hwnd, bool dwY);
  95. private void button1_Click(object sender, EventArgs e)
  96. {
  97. string flieName;
  98. if (this.openFileDialog1.ShowDialog() == DialogResult.OK) // 对话框.打开显示 == 对话框返回如果是确认钮 所谓 True
  99. {
  100. flieName = this.openFileDialog1.FileName; // 将对话框中的文件名返回到变量
  101. StreamReader flieStream = new StreamReader(flieName, System.Text.Encoding.Default); // 初始化字节集流对象..编码为系统当前默认Ausic码
  102. flieName = flieStream.ReadToEnd()+Environment.NewLine; //从首读到尾 And 换行符
  103. int rtr = MessageBoxA(Hwnd, flieName, "信息:", 64 + 1);
  104. // if rtr = 1 确认被单击 And 2 取消==关闭钮
  105. flieStream.Close();// 关闭字节流对象
  106. FlashWindow(Hwnd, true);
  107. }
  108. else
  109. {
  110. MessageBoxA(Hwnd, "您点击了取消所以执行Commonde失败", "信息:", 64);
  111. }
  112. }
  113. }
  114. }
复制代码
下载地址::  要求装入 FW 4.0 框架...程序结构框架///最好具备VS2010以及更高
My Software.rar (440.19 KB, 下载次数: 15)

点评

软体无毒无害...大小只有12.3KB   四川省成都市  发表于 2012-11-28 17:50
结帖率:33% (3/9)
 楼主| 发表于 2012-11-28 17:35:32 | 显示全部楼层   四川省成都市
由于该网吧只有
MS-FW3.5的安装包无法执行4.0的软体结构体
现在就没有发图希望谅解
有SkinSharp皮肤Aero递加效果
3.JPG
软体文件包

点评

Properties 为软体附加信息   四川省成都市  发表于 2012-11-28 17:36
回复 支持 反对

使用道具 举报

结帖率:33% (3/9)
 楼主| 发表于 2012-11-28 17:46:26 | 显示全部楼层   四川省成都市
高级函数代码
  1. bool SetTouMing(int CHwnd,int CrKey,int bAlpha,int dwFlags)

  2. {

  3. int Ret = new int();

  4. Ret = GetWindowLongA(CHwnd, -20);

  5. Ret = Ret | 524288;

  6. SetWindowLongA(CHwnd, -20, Ret);

  7. if (SetLayeredWindowAttributes(CHwnd, CrKey, bAlpha, dwFlags) != 0)

  8. {

  9. return true;

  10. }

  11. return false;

  12. }

复制代码
此代码如果用于E语言就是透明窗口也可以为单项透明控件

点评

单词变量名 Ret 意味 Retrun 返回的意思   四川省成都市  发表于 2012-11-28 17:49
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 诚聘英才| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 800073686,邮箱:800073686@b.qq.com
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表