1. <nobr id="easjo"><address id="easjo"></address></nobr>

      <track id="easjo"><source id="easjo"></source></track>
      1. 
        

      2. <bdo id="easjo"><optgroup id="easjo"></optgroup></bdo>
      3. <track id="easjo"><source id="easjo"><em id="easjo"></em></source></track><option id="easjo"><span id="easjo"><em id="easjo"></em></span></option>
          貴州做網站公司
          貴州做網站公司~專業!靠譜!
          10年網站模板開發經驗,熟悉國內外開源網站程序,包括DEDECMS,WordPress,ZBlog,Discuz! 等網站程序,可為您提供網站建設,網站克隆,仿站,網頁設計,網站制作,網站推廣優化等服務。我們專注高端營銷型網站,企業官網,集團官網,自適應網站,手機網站,網絡營銷,網站優化,網站服務器環境搭建以及托管運維等。為客戶提供一站式網站解決方案?。?!

          screencapture(怎么用C#做Screen Capture程序)

          來源:互聯網轉載 時間:2024-05-06 12:25:01

          在掌握了一些C#源代碼后,可以得到用C#做Screen Capture程序的源代碼(Capture.cs),具體如下:

          1. usingSystem;

          2. usingSystem.Drawing;

          3. usingSystem.Collections;

          4. usingSystem.componentmodel;

          5. usingSystem.Windows.Forms;

          6. usingSystem.Data;

          7. usingSystem.Drawing.Imaging;

          8. usingSystem.IO;

          9. //導入在程序中使用到的名稱空間

          10. publicclassCapture:Form

          11. {

          12. privateSystem.ComponentModel.Containercomponents=null;

          13. privateIconmNetTrayIcon=newIcon("Tray.ico");

          14. privateBitmapMyImage=null;

          15. privateNotifyIconTrayIcon;

          16. privateContextMenunotifyiconMnu;

          17. publicCapture()

          18. {

          19. //初始化窗體中使用到的組件

          20. InitializeComponent();

          21. }

          22. protectedoverridevoidOnActivated(EventArgse)

          23. {

          24. this.Hide();

          25. }

          26. [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]

          27. privatestaticexternboolBitBlt(

          28. IntPtrhdcDest,//目標設備的句柄

          29. intnXDest,//目標對象的左上角的X坐標

          30. intnYDest,//目標對象的左上角的X坐標

          31. intnWidth,//目標對象的矩形的寬度

          32. intnHeight,//目標對象的矩形的長度

          33. IntPtrhdcSrc,//源設備的句柄

          34. intnXSrc,//源對象的左上角的X坐標

          35. intnYSrc,//源對象的左上角的X坐標

          36. System.Int32dwRop//光柵的操作值

          37. );

          38. [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]

          39. privatestaticexternIntPtrCreateDC(

          40. stringlpszDriver,//驅動名稱

          41. stringlpszDevice,//設備名稱

          42. stringlpszOutput,//無用,可以設定位"NULL"

          43. IntPtrlpInitData//任意的打印機數據

          44. );

          45. publicvoidcapture(objectsender,System.EventArgse)

          46. {

          47. this.Visible=false;

          48. IntPtrdc1=CreateDC("DISPLAY",null,null,(IntPtr)null);

          49. //創建顯示器的DC

          50. Graphicsg1=Graphics.FromHdc(dc1);

          51. //由一個指定設備的句柄創建一個新的Graphics對象

          52. MyImage=newBitmap(Screen.PrimaryScreen.Bounds.Width,
            Screen.PrimaryScreen.Bounds.Height,g1);

          53. //根據屏幕大小創建一個與之相同大小的Bitmap對象

          54. Graphicsg2=Graphics.FromImage(MyImage);

          55. //獲得屏幕的句柄

          56. IntPtrdc3=g1.GetHdc();

          57. //獲得位圖的句柄

          58. IntPtrdc2=g2.GetHdc();

          59. //把當前屏幕捕獲到位圖對象中

          60. BitBlt(dc2,0,0,Screen.PrimaryScreen.Bounds.Width,
            Screen.PrimaryScreen.Bounds.Height,dc3,0,0,13369376);

          61. //把當前屏幕拷貝到位圖中

          62. g1.ReleaseHdc(dc3);

          63. //釋放屏幕句柄

          64. g2.ReleaseHdc(dc2);

          65. //釋放位圖句柄

          66. MyImage.Save("c:\\MyJpeg.jpg",ImageFormat.Jpeg);

          67. MessageBox.Show("已經把當前屏幕保存到C:\\MyJpeg.jpg文件中!");

          68. this.Visible=true;

          69. }

          70. publicvoidExitSelect(objectsender,System.EventArgse)

          71. {

          72. //隱藏托盤程序中的圖標

          73. TrayIcon.Visible=false;

          74. //關閉系統

          75. this.Close();

          76. }

          77. //清除程序中使用過的資源

          78. publicoverridevoidDispose()

          79. {

          80. base.Dispose();

          81. if(components!=null)

          82. components.Dispose();

          83. }

          84. privatevoidInitializeComponent()

          85. {

          86. //設定托盤程序的各個屬性

          87. TrayIcon=newNotifyIcon();

          88. TrayIcon.Icon=mNetTrayIcon;

          89. TrayIcon.Text="用C#做ScreenCapture程序";

          90. TrayIcon.Visible=true;

          91. //定義一個MenuItem數組,并把此數組同時賦值給ContextMenu對象

          92. MenuItem[]mnuItms=newMenuItem[3];

          93. mnuItms[0]=newMenuItem();

          94. mnuItms[0].Text="捕獲當前屏幕!";

          95. mnuItms[0].Click+=newSystem.EventHandler(this.capture);

          96. mnuItms[1]=newMenuItem("-");

          97. mnuItms[2]=newMenuItem();

          98. mnuItms[2].Text="退出系統";

          99. mnuItms[2].Click+=newSystem.EventHandler(this.ExitSelect);

          100. mnuItms[2].DefaultItem=true;

          101. notifyiconMnu=newContextMenu(mnuItms);

          102. TrayIcon.ContextMenu=notifyiconMnu;

          103. //為托盤程序加入設定好的ContextMenu對象

          104. this.SuspendLayout();

          105. this.AutoScaleBaseSize=newSystem.Drawing.Size(5,13);

          106. this.ClientSize=newSystem.Drawing.Size(320,56);

          107. this.ControlBox=false;

          108. this.MaximizeBox=false;

          109. this.MinimizeBox=false;

          110. this.WindowState=System.Windows.Forms.FormWindowState.Minimized;

          111. this.Name="capture";

          112. this.ShowInTaskbar=false;

          113. this.Text="用C#做ScreenCapture程序!";

          114. this.ResumeLayout(false);

          115. }

          116. staticvoidMain()

          117. {

          118. Application.Run(newCapture());

          119. }

          120. }

          感謝各位的閱讀,以上就是“怎么用C#做Screen Capture程序”的內容了,經過本文的學習后,相信大家對怎么用C#做Screen Capture程序這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是本站,小編將為大家推送更多相關知識點的文章,歡迎關注!

          標簽:screencapture-

          c語言中正確的字符常量是用一對單引號將一個字符括起表示合法的字符常量。例如‘a’。數值包括整型、浮點型。整型可用十進制,八進制,十六進制。八進制前面要加0,后面...

          2022年天津專場考試原定于3月19日舉行,受疫情影響確定延期,但目前延期后的考試時間推遲。 符合報名條件的考生,須在規定時間登錄招考資訊網(www.zha...

          :喜歡聽,樂意看。指很受歡迎?!巴卣官Y料”喜聞樂見:[ xǐ wén lè jiàn ]詳細解釋1. 【解釋】:喜歡聽,樂意看。指很受歡迎。2. 【示例】:這是...

          三花轉債上市價格預測是多少?三花智控6月29日收盤價24.01,轉股價格21.55,當前轉股價值111.42。三花智控5月31日(申購日前一工作日)收盤價為22.32,申購日6月1日。在這過去的近一個月時間里,三花智控股價上漲7.6%,轉股價值從103.57上漲到111.42。三花轉債AA+級別,規模30億, 原始股東配售率74.08%,單賬戶頂格申購中0.094簽,溢價率由申購前一日的-3.45...

          (資料圖片)最近這段時間總有小伙伴問小編李易峰主演的電視劇有哪些電視劇是什么,小編為此在網上搜尋了一些有關于李易峰主演的電視劇有哪些電視劇的知識送給大家,希望能解答各位小伙伴的疑惑。李易峰,1987年5月4日出生于四川成都,中國內地男演員、流行樂歌手、影視制片人,畢業于四川師范大學電影電視學院。2007年,參加東方衛視選秀娛樂節目《加油!好男兒》的比賽,獲得全國總決賽第八名,從而正式出道。李易峰主...

          所謂價格歧視,是指壟斷廠商為了獲得超額利潤,而實行的有差別的價格政策。價格其實分為三個等級,等級數字越小,壟斷廠商賺取的超額利潤就越多。價格歧視的三種類型例子如下:一、一級價格歧視-看人定價不同的人為相同商品或服務所愿意支付的最高價格是不同的。一個旅游紀念品,經濟條件好的人可能愿意花500元去購買,經濟條件一般的人可能最多只愿意出300元。那么為了多掙錢,景區賣旅游紀念品的老板會上下打量每一個詢價...

          TOP
          国产初高中生视频在线观看|亚洲一区中文|久久亚洲欧美国产精品|黄色网站入口免费进人
          1. <nobr id="easjo"><address id="easjo"></address></nobr>

              <track id="easjo"><source id="easjo"></source></track>
              1. 
                

              2. <bdo id="easjo"><optgroup id="easjo"></optgroup></bdo>
              3. <track id="easjo"><source id="easjo"><em id="easjo"></em></source></track><option id="easjo"><span id="easjo"><em id="easjo"></em></span></option>