您可以用下面給出這一小段代碼檢測當(dāng)前屏幕分辨率,然后根據(jù)結(jié)果作出反應(yīng)──例如,重新調(diào)整窗體大小以適應(yīng)用程序戶分辨率。
10年積累的成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站設(shè)計(jì)后付款的網(wǎng)站建設(shè)流程,更有樊城免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
Public Function CheckRez(pixelWidth As Long, pixelHeight As Long) As Boolean
'
Dim lngTwipsX As Long
Dim lngTwipsY As Long
'
' convert pixels to twips
lngTwipsX = pixelWidth * 15
lngTwipsY = pixelHeight * 15
'
' check against current settings
If lngTwipsX Screen.Width Then
CheckRez = False
Else
If lngTwipsY Screen.Height Then
CheckRez = False
Else
CheckRez = True
End If
End If
'
End Function
Next, run the following code at the start of the program:
If CheckRez(640, 480) = False Then
MsgBox "Incorrect screen size!"
Else
MsgBox "Screen Resolution Matches!"
End If
[DllImport("user32.dll", EntryPoint = "GetDC")]
public static extern IntPtr GetDC(IntPtr hWnd);
[DllImport("user32.dll", EntryPoint = "ReleaseDC")]
public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
先找到你要截圖的那個(gè)窗體的 句柄 然后根據(jù)這個(gè)句柄得到改窗體的DC 創(chuàng)建一個(gè)bitmap 然后填充 得到的bitmap后 顯示到picturebox里面
既然能夠取得整個(gè)屏幕,可以取到整個(gè)屏幕以后創(chuàng)建一個(gè)全屏窗體顯示靜態(tài)的屏幕圖像,然后在窗體上實(shí)現(xiàn)部分截取。
估計(jì)別的截圖也是這個(gè)原理,因?yàn)橐稽c(diǎn)開始截圖屏幕就變?yōu)殪o態(tài)不動(dòng)了,肯定是在截圖初期復(fù)制了當(dāng)時(shí)的屏幕場景