怎样禁用双击窗体图标关闭窗体
来源:优易学  2011-12-31 15:13:40   【优易学:中国教育考试门户网】   资料下载   IT书店
  Net由于对WindowsAPI的透明度增强,很多Winform开发者都不太了解经典的win32消息方面的知识。
  所有窗体上的鼠标反映都可以用WndProc拦截,除了系统菜单、标题栏、系统按纽还包括客户区。
  usingSystem;
  usingSystem.Windows.Forms;
  usingSystem.Runtime.InteropServices;
  namespaceWindowsApplication1
  {
  publicpartialclassForm1:Form
  {
  publicForm1()
  {
  InitializeComponent();
  }
  [DllImport("user32.dll")]
  privatestaticexternIntPtrGetSystemMenu(IntPtrhWnd,boolbRevert);
  protectedoverridevoidWndProc(ref Messagem)
  {
  if(m.Msg==0x112)
  {
  if(m.WParam.ToInt32()==61539||m.WParam.ToInt32()==61587)
  {
  Console.WriteLine(m.WParam);
  return;
  }
  }
  base.WndProc(ref m);
  }
  }
  }

责任编辑:小草

文章搜索:
 相关文章
热点资讯
热门课程培训