博客园  :: 首页  :: 新随笔  :: 联系 :: 管理
上一页 1 2 3 4 5 6 7 8 9 10 ··· 13 下一页

2009年11月13日

摘要: 最近写了一个随机模拟的计算程序,因为计算耗时很长,所以运算中要输出一些信息,以方便用户随时了解运算的进度以及其他信息。最初打算写一个log窗口类,使用textbox控件以及 progressbar,后来发现挺麻烦,远不及console窗口下的console.write和console.writeline方便。于是尝试直接将信息输出到控制台窗口。 1、 在winform程序中调用console窗口。这个使用Win32 API来完成。关于AllocConsole函数和FreeConsole函数的详细信息可以参见这里和这里。VB.NET的代码如下:Form程序调用和释放Console窗口Code . 阅读全文

posted @ 2009-11-13 23:29 codingsilence 阅读(3766) 评论(0) 推荐(0) 编辑

摘要: [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); public const int WM_SYSCOMMAND = 0x0112; public const int SC_MOVE = 0xF010; public const int HTCAP 阅读全文

posted @ 2009-11-13 23:27 codingsilence 阅读(214) 评论(0) 推荐(0) 编辑

摘要: 添加引用:using System.Diagnostics;using System.Runtime.InteropServices;定义: Process process = null; IntPtr appWin; private string exeName = ""; [DllImport("user32.dll", EntryPoint = "GetWindowThreadProcessId", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = t 阅读全文

posted @ 2009-11-13 23:00 codingsilence 阅读(2129) 评论(0) 推荐(0) 编辑

摘要: 其实很简单,就一个ToolTip控件就完成了.1.设置ToolTip的IsBalloon属性为true2.设置ToolTip所属的控件3.设置要显示的信息代码可参考如下:如在做用户登录时.//气泡提示登录名已经存在ttMsg.SetToolTip(txtLoginName, "该登录名已存在");//ttMsg为ToolTip控件,txtLoginName为文本框ttMsg.Show("该登录名已存在", txtLoginName); 阅读全文

posted @ 2009-11-13 22:45 codingsilence 阅读(5946) 评论(1) 推荐(0) 编辑

2009年11月12日

摘要: 在.Net Framework SDK文档中,关于调用Windows API的指示比较零散,并且其中稍全面一点的是针对Visual Basic .net讲述的。本文将C#中调用API的要点汇集如下,希望给未在C#中使用过API的朋友一点帮助。另外如果安装了Visual Studio .net的话,在C:/Program Files/Microsoft Visual Studio .NET/FrameworkSDK/Samples/Technologies/Interop/PlatformInvoke/WinAPIs/CS目录下有大量的调用API的例子。 一、调用格式using System.R 阅读全文

posted @ 2009-11-12 19:18 codingsilence 阅读(123) 评论(0) 推荐(0) 编辑

摘要: 没有适合投放的广告 打开QQ的时候,总是会先听到一声咳嗽声,然后屏幕的右下角就会慢慢升起一个小窗口,占用的地方不大,又可以起到提示的作用。如果要写代码控制窗体的位置和透明度来实现这个功能,挺麻烦的。下面就让我们来看看,怎样用系统API来轻松实现这个功能。老规矩,先来介绍一下要用到的API函数:boolAnimateWindow(IntPtrhwnd,intdwTime,intdwFlags);从字面的意思来看,这个函数名为"活动的窗口",事实上也如此,通过这个函数,可以使我们的窗体动作丰富起来,来说明一下参数。 程序代码hwnd:指定产生动画的窗口的句柄dwTime:指定动 阅读全文

posted @ 2009-11-12 18:26 codingsilence 阅读(310) 评论(0) 推荐(0) 编辑

2009年11月11日

摘要: 靠边隐藏效果:当程序移动到显示的边界时,程序自动隐藏起来,留一条小边在外面,很酷的效果吧. 先介绍下实现原理,靠边隐藏无非就是判断窗体的位置和屏幕的四边的关系,当上左右三个方向超出的时候,就把窗体自动往上移,问题是...怎么判断窗体的位置呢?.Net里面有很方便的事件:LocationChanged,来判断窗体位置的变化,那又如何判断鼠标和窗体的关系呢?最简单的办法是用个 timer不停的去判断...,我最不想用这种方法实现,结果苦苦探寻了两个小时最终还是以这种最笨的方法来实现效果-_-#,如果不用timer,还有其他什么方法呢?我第一想到的是钩子,于是我拦截系统消息WM_MOVE,WM_M. 阅读全文

posted @ 2009-11-11 22:01 codingsilence 阅读(469) 评论(0) 推荐(0) 编辑

摘要: 我们用的比较多的非泛型集合类主要有 ArrayList类 和 HashTable类。我们经常用HashTable 来存储将要写入到数据库或者返回的信息,在这之间要不断的进行类型的转化,增加了系统装箱和拆箱的负担,如果我们操纵的数据类型相对确定的化用Dictionary<TKey,TValue> 集合类来存储数据就方便多了,例如我们需要在电子商务网站中存储用户的购物车信息(商品名,对应的商品个数)时,完全可以用 Dictionary<string, int> 来存储购物车信息,而不需要任何的类型转化。1.数组是固定大小的,不能伸缩。虽然System.Array.Resiz 阅读全文

posted @ 2009-11-11 08:09 codingsilence 阅读(156) 评论(0) 推荐(0) 编辑

2009年11月3日

摘要: VS2008中查看.NET源码的设置方法 阅读全文

posted @ 2009-11-03 22:59 codingsilence 阅读(500) 评论(1) 推荐(0) 编辑

2009年10月26日

摘要: 今用到DevExpress,想到换肤,参考了博友DevExpress换肤手把手教程,该文中已经实现了打开窗体换肤,但是以后打开窗体的皮肤如何设置呢,就没说了,但稍加扩展也可实现。我喜欢复杂问题简单化,在tannaiyin的基础上这么来弄 要简单得多。第一步让所有窗体都从DevExpress.XtraEditors.XtraForm继承。 第二步:添加两个引用: DevExpress.BonusSkins.v9.2 DevExpress.OfficeSkins.v9.2 第三步:在软件的入口Program类的main函数的第一行代码前加上:DevExpress.UserSkins.BonusSk 阅读全文

posted @ 2009-10-26 20:37 codingsilence 阅读(261) 评论(0) 推荐(0) 编辑

2009年10月24日

摘要: 一般情况下,Response.Redirect 方法是在服务器端进行转向,因此,除非使用 Response.Write(" <SCRIPT>window.location='http://dotnet.aspx.cc';</SCRIPT> ") 方法外,是不能在新窗口打开所指定的 URL 地址的。但是,如果仔细分析一下,如果设置 form 元素的 target 属性,还是有办法打开新窗口的。下面就是可以采用的两种方法。 方法一:在服务器端设置 target 属性,这个方法也非常适用于客户端不支持脚本的情况。代码如下:DOCTYPE h 阅读全文

posted @ 2009-10-24 08:19 codingsilence 阅读(242) 评论(0) 推荐(0) 编辑

2009年10月21日

摘要: <script><!--function conWrite(obj,size,msg){if (document.getElementById(obj) != null){ var length = size - document.getElementById(obj).value.length; if (length > 0) { document.getElementById(msg).innerHTML="您当前还可以输入<strong><span class=/"font_green/">" + l 阅读全文

posted @ 2009-10-21 21:57 codingsilence 阅读(178) 评论(0) 推荐(0) 编辑

2009年10月6日

摘要: 最近在公司做了一个小的视频处理网站,由于视频处理,网站在不同的服务器上,所以处理视频的时候得在网站服务器上通过wcf请求视频处理服务器处理视频,并将结果返回。我在写好这个wcf服务后寄宿到IIS里时遇到了不少的问题,下面是问题的描述,以及解决的方法。 问题1: 由于我这里的wcf服务是采用“WSHttpBinding”的方式,即安全绑定模式,客户端在引用这个服务后所生成的终结点配置(endpoint )就变成了<endpoint address="服务器机器名/*.svc"> ,如果是在局域网里,通过机器名访问服务器本来是没什么问题的,由于视频处理服务器不在本地 阅读全文

posted @ 2009-10-06 23:24 codingsilence 阅读(174) 评论(0) 推荐(0) 编辑

摘要: 大家都知道网卡的MAC地址可以从DOS窗口中通过输入"ipconfig /all"命令运行结果获得,那么这个问题的具体内容是: 在C#中运行一个dos命令,并截取相关输出、输出流。 具体代码如下:C# code tbResult.Text = ""; ProcessStartInfo start = new ProcessStartInfo("Ping.exe");//设置运行的命令行文件问ping.exe文件,这个文件系统会自己找到 //如果是其它exe文件,则有可能需要指定详细路径,如运行winRar.exe start.Argu 阅读全文

posted @ 2009-10-06 22:44 codingsilence 阅读(176) 评论(0) 推荐(0) 编辑

2009年9月16日

摘要: 诸多内容请参考MSDN:对象生存期:如何创建和销毁对象 http://msdn.microsoft.com/zh-cn/library/hks5e2k6.aspx 自动内存管理 http://msdn.microsoft.com/zh-cn/library/f144e03t.aspxFinalize 方法和析构函数 http://msdn.microsoft.com/zh-cn/library/0s71x931.aspx垃圾回收 http://msdn.microsoft.com/zh-cn/library/0xy59wtx.aspxCLR 完全介绍:管理对象生存期 http://msdn.m 阅读全文

posted @ 2009-09-16 22:36 codingsilence 阅读(124) 评论(0) 推荐(0) 编辑

2009年8月13日

摘要: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Reflection; public static class DataTableExtensions { /// <summary> /// DataTable 转换为List 集合 /// </summary> /// <typeparam 阅读全文

posted @ 2009-08-13 22:48 codingsilence 阅读(213) 评论(0) 推荐(0) 编辑

摘要: //dataset转实体类 public static IList<T> FillModel(DataSet ds) { List<T> l = new List<T>(); T model = default(T);if (ds.Tables[0].Columns[0].ColumnName == "rowId") { ds.Tables[0].Columns.Remove("rowId"); }foreach (DataRow dr in ds.Tables[0].Rows) {model = Activator. 阅读全文

posted @ 2009-08-13 22:08 codingsilence 阅读(247) 评论(0) 推荐(0) 编辑

摘要: 需要绑定实体数组比如Materiel[]绑定到界面(winform/webform都有),虽然可以直接绑定数组到GridView,但排序,过滤,查找等操作在数组里不是很方便。所以想借用DataTable做数据源。 最简单的方法就是手动建一个DataTable。为每个Materiel的property建一个Column,然后指明其数据类型。建好Table之后,循环为每个Materiel创建一个新行。如果多有几个界面,虽然做起来都差不多,但代码很难重用。 另外数据都是从WebService获取,form不允许直接访问DB,所以也不能通过ADO.net获取DataTable。 经过一段时间的考量后决 阅读全文

posted @ 2009-08-13 21:58 codingsilence 阅读(218) 评论(0) 推荐(0) 编辑

2009年8月10日

摘要: private void btnPrint_Click(object sender, EventArgs e) { SendKeys.Send("%{PRTSC}"); Application.DoEvents(); this.printDocument1.Print(); } private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { IDataObject iData = Clipboard.GetDataObject(); Im 阅读全文

posted @ 2009-08-10 21:01 codingsilence 阅读(120) 评论(0) 推荐(0) 编辑

摘要: 1、介绍 最近在做一个系统,要求在安装程序在完成安装之后删除自身。遇到这样的问题,当然要祭起”Google大法”。果不其然,与我想同问题的朋友还是不少。网上给出的方案里面大致有这么几种。2、方法(1)利用批处理文件,删除自身using System.Runtime.InteropServices; //****************************************添加引用[DllImport("kernel32.dll")] public static extern uint WinExec(string lpCmdLine, uint uCmdShow) 阅读全文

posted @ 2009-08-10 08:20 codingsilence 阅读(188) 评论(0) 推荐(0) 编辑

2009年8月6日

摘要: using System;using System.Collections.Generic;using System.Text;using Microsoft.Office.Interop.Word;using System.IO;using System.Web;using System.Data;using System.Reflection;using Microsoft.Win32;using System.Text.RegularExpressions;using System.Net;namespace OfficeOperate{ public class WordOperate 阅读全文

posted @ 2009-08-06 22:10 codingsilence 阅读(459) 评论(0) 推荐(0) 编辑

2009年8月4日

摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Drawing;using System.IO;namespace Microsoft.Form.Base{ class ImageToByte { /// <summary> /// 图片转换成字节流 /// </summary> /// <param name="img">要转换的Image对象</param> /// <retu 阅读全文

posted @ 2009-08-04 23:02 codingsilence 阅读(336) 评论(0) 推荐(0) 编辑

摘要: 一、给GridControl添加按钮列 最近搞项目,要给CrigControl添加按钮列。由于英文不好走了很多弯路。 现在终于搞好了。。 写下来,以防以后忘记 把列的ColumnEdit属性设置为RepositoryItemButtonEdit 把TextEditStyle属性设置为HideTextEditor; 把Buttons的Kind属性设置为Glyph; 把Buttons的HorzAlignment属性设置为Near; 如果要用到事件的话,还要注册事件。。。 列名.ButtonClick += new ButtonPressedEventHandler(列名_ButtonClick); 阅读全文

posted @ 2009-08-04 20:07 codingsilence 阅读(993) 评论(0) 推荐(0) 编辑

2009年8月3日

摘要: 以下代码已经有好多人写过,还望各位多多指教我只不过是整理了一下在我使用过程中的比较熟悉的,在以后的使用过程中会继续添加1.gridView 奇行与偶行交替变色this.gridView1.OptionsView.EnableAppearanceEvenRow = true;this.gridView1.OptionsView.EnableAppearanceOddRow = true;this.gridView1.Appearance.EvenRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int) 阅读全文

posted @ 2009-08-03 13:26 codingsilence 阅读(278) 评论(0) 推荐(0) 编辑

2009年7月30日

摘要: 使用方法在Program.cs里的Main里调用就好了LoadProcess.StarPoint()第1个参数是用来给已启动的进程发送的消息.. [STAThread] static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (LoadProcess.StarPoint("哈哈", true)) { Form2 _Form=new Form2(); LoadProcess.LoadP 阅读全文

posted @ 2009-07-30 20:23 codingsilence 阅读(289) 评论(0) 推荐(0) 编辑

摘要: 使用方法 private RegisterHotKeyClass _RegisKey = new RegisterHotKeyClass(); private void Form2_Load(object sender, EventArgs e) { _RegisKey.Keys = Keys.Q; _RegisKey.ModKey = RegisterHotKeyClass.MODKEY.MOD_CONTROL | RegisterHotKeyClass.MODKEY.MOD_ALT; _RegisKey.WindowHandle = this.Handle; _RegisKey.HotKe 阅读全文

posted @ 2009-07-30 16:58 codingsilence 阅读(229) 评论(0) 推荐(0) 编辑

2009年7月29日

摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Runtime.Serialization.Formatters.Binary;using System.IO;using System.IO.Compression;using System.Runtime.Serialization;namespace CommonClass{ class SerializeUtilty { /// <summary> / 阅读全文

posted @ 2009-07-29 23:24 codingsilence 阅读(240) 评论(0) 推荐(0) 编辑

2009年7月24日

摘要: 需要在SQL SERVER中创建数据库test, 然后再test中创建一个数据表ImageTable,含字段 id int 自动增长ImagePath nchar(50)Image image类型代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;using Syste 阅读全文

posted @ 2009-07-24 08:25 codingsilence 阅读(554) 评论(0) 推荐(0) 编辑

2009年7月22日

摘要: private void menuStepAdd_Click(object sender, EventArgs e){ frmAddStep addStep = new frmAddStep(); addStep.FormBorderStyle = FormBorderStyle.None; addStep.TopLevel = false; splitMain.Panel2.Controls.Add(addStep); addStep.Show();}//"不显示"tabControl1的tabPage2 this.tabControl1.TabPages.Remove( 阅读全文

posted @ 2009-07-22 22:45 codingsilence 阅读(414) 评论(0) 推荐(0) 编辑

摘要: string strIniFile = System.Windows.Forms.Application.StartupPath + “//setting.ini” 阅读全文

posted @ 2009-07-22 22:40 codingsilence 阅读(220) 评论(0) 推荐(0) 编辑

摘要: 在WebForm中,可以使用反射将业务对象绑定到 ASP.NET 窗体控件。最近做Winform项目,也参考WebForm中的代码实现同样的功能。 Winform没有提供类似WebForm中的FindControl方法,我于是用遍历控件的方式,写了一个类似WebForm中的这个方法,考虑到Winform中的很多控件放在Label、TabControl中,方法采用了递归的方式。 Winform和Winform的控件也有些区别,如在Winform中,DateTimePicker取值是用Value属性,在WebForm中使用SelectDate属性,在Winform中,有NumericUpDown控 阅读全文

posted @ 2009-07-22 22:39 codingsilence 阅读(229) 评论(0) 推荐(0) 编辑

摘要: 方法一:只禁止多个进程运行[STAThread]public static void Main(){bool ret;System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out ret);if (ret){ System.Windows.Forms.Application.EnableVisualStyles(); //这两行实现 XP 可视风格System.Windows.Forms.Application.DoEvents();System.Windows.Form 阅读全文

posted @ 2009-07-22 22:36 codingsilence 阅读(427) 评论(0) 推荐(0) 编辑

摘要: usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Web;usingSystem.Web.Caching;usingSystem.Threading;namespaceNPao.Tools.EntityDesign{publicclassCacheConfig{privatestaticHttpRuntime_httpRuntime;publicstaticCacheCache{get{EnsureHttpRuntime();returnHttpRuntime.Cache;}}privatestat 阅读全文

posted @ 2009-07-22 22:33 codingsilence 阅读(159) 评论(0) 推荐(0) 编辑

摘要: 先定义一个热键类using System;using System.Collections.Generic;using System.Text;using System.Runtime.InteropServices;using System.Windows.Forms;namespace ExcelReportDesigner{ class WinHotKey { public WinHotKey() { } //如果函数执行成功,返回值不为0。 //如果函数执行失败,返回值为0。要得到扩展错误信息,调用GetLastError。 [DllImport("user32.dll&qu 阅读全文

posted @ 2009-07-22 22:20 codingsilence 阅读(181) 评论(0) 推荐(0) 编辑

2009年7月21日

摘要: #region usingusing System;using System.Configuration;using System.Data;using Oracle.DataAccess.Client;#endregionnamespace WIS.Base.Data{/// <summary>/// <table style="font-size:12px">/// <tr><td><b>文 件 名</b>:DbObject.cs</td></tr> /// <tr&g 阅读全文

posted @ 2009-07-21 20:35 codingsilence 阅读(198) 评论(0) 推荐(0) 编辑

2009年7月20日

摘要: 装完 PowerDesigner 15 ,如果装Vs2008的 Add-in , 再到 Vs 里,发现写代码的智能感知出现1秒左右立刻没掉,非常不爽。上网找到,说是要去掉那个 spell check打开VS,在Model Tools->General Options->Add-Ins里,把Spell Checker这项取消我照样试过,发现一样,没有任何改善。既然是一个add-in,我删了你不就得了。于是。开始了。文件在C:/Program Files/sybase/PowerDesigner 15/Add-ins/Spell Checker/SpellChecker.dll各人的文 阅读全文

posted @ 2009-07-20 22:05 codingsilence 阅读(133) 评论(0) 推荐(0) 编辑

2009年7月16日

摘要: [STAThread]static void Main(){ Application.EnableVisualStyles(); DevExpress.UserSkins.OfficeSkins.Register(); DevExpress.Skins.SkinManager.EnableFormSkins(); DevExpress.Skins.SkinManager.EnableMdiFormSkins(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm());} 阅读全文

posted @ 2009-07-16 22:27 codingsilence 阅读(667) 评论(0) 推荐(0) 编辑

摘要: 第一、引用IrisSkin2.dll组件说明:IrisSkin2.dll是一个第三方组件第二、代码publicpartialclassForm1:Form{Sunisoft.IrisSkin.SkinEnginese=null;publicForm1(){InitializeComponent();se=newSunisoft.IrisSkin.SkinEngine();se.SkinAllForm=true;//这句话是用来设置整个系统下所有窗体都采用这个皮肤}privatevoidForm1_Load(objectsender,EventArgse){}privatevoidbutton1 阅读全文

posted @ 2009-07-16 21:39 codingsilence 阅读(148) 评论(0) 推荐(0) 编辑

摘要: DXperience v2009 vol 1 (9.1.3)汉化 本地化 编译脚本 试用版 更新说明 论坛 博客 资源 What's New in DXperience v2009 vol 1.3 2009-04-15http://www.devexpress.com/Downloads/NET/http://www.devexpress.com/Support/WhatsNew/DXperience/files/9.1.3.xmlDXperience 官方本地化资源 2009-04-21http://devexpress.com/Support/Center/KB/p/A421.as 阅读全文

posted @ 2009-07-16 18:04 codingsilence 阅读(297) 评论(0) 推荐(0) 编辑

2009年7月8日

摘要: Application.Exit和Environment.Exit(0)有什么退出方面的区别吗?Application.Exit:通知winform消息循环退出。会在所有前台线程退出后,退出应用强行退出方式,就像 Win32 的 PostQuitMessage()。它意味着放弃所有消息泵,展开调用堆栈,并将执行返回给系统 方法停止在所有线程上运行的所有消息循环,并关闭应用程序的所有窗口 Environment.Exit:立即终止当前进程,应用程序即强制退出。返回exitcode给操作系统,相比之下Environment.Exit更狠些 因此我们可以构造以下的restart()函数重新启动应用程 阅读全文

posted @ 2009-07-08 08:12 codingsilence 阅读(222) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 10 ··· 13 下一页