成都网站建设设计

将想法与焦点和您一起共享

介绍C#窗体拖动事件

C#窗体拖动事件

从网上看到了一个C#窗体拖动事件,超级简洁,至少现在这个阶段我是看起来有困难的,有兴趣的哥们们可以讨论下

 
 
 
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;usingSystem.Text;
  6. using System.Windows.Forms;
  7. namespaceWindowsApplication2{
  8. publicpartialclassForm1:Form
  9. {
  10. privateconstintWM_NCHITTEST=0x84;
  11. //这几行真够晕的,貌似调用了基本函数饿
  12. privateconstintHTCLIENT=0x1;
  13. privateconstintHTCAPTION=0x2;
  14. publicForm1()
  15. {
  16. InitializeComponent();
  17. }
  18. protectedoverridevoidWndProc(refMessagem)
  19. {
  20. switch(m.Msg)
  21. {
  22. caseWM_NCHITTEST:base.WndProc(refm);
  23. if((int)m.Result==HTCLIENT)m.Result=(IntPtr)HTCAPTION;
  24. return;
  25. break;
  26. }
  27. base.WndProc(refm);
  28. }
  29. }
  30. }

以上介绍C#窗体拖动事件,我试过了,可以运行,就是貌似***那个break有点问题,看不懂……嘿嘿 还得继续努力啊!


当前文章:介绍C#窗体拖动事件
本文路径:http://chengdu.cdxwcx.cn/article/dpiphpp.html