用API函數(shù),以下代碼Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
成都創(chuàng)新互聯(lián)云計算的互聯(lián)網服務提供商,擁有超過13年的服務器租用、雙線服務器托管、云服務器、網站空間、網站系統(tǒng)開發(fā)經驗,已先后獲得國家工業(yè)和信息化部頒發(fā)的互聯(lián)網數(shù)據(jù)中心業(yè)務許可證。專業(yè)提供云主機、網站空間、域名申請、VPS主機、云服務器、香港云服務器、免備案服務器等。
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As LongPrivate Const WS_EX_LAYERED = H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = H2
Private Const LWA_COLORKEY = H1Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_TOPMosT = -1
Private Const SWP_NOMOVE = H2
Private Const SWP_NosIZE = H1
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_KEYDOWN = H100
Const WM_KEYUP = H101
Const WM_CHAR = H102
Const VK_F1 = H70
Private Sub SendF1(hwnd) '調用這個過程即可對目標窗體發(fā)送F1鍵
Call PostMessage(hwnd, WM_KEYDOWN, VK_F1, 0)
Call PostMessage(hwnd, WM_KEYUP, VK_F1, 0)
End Sub這里是發(fā)送F1的實例,各個按鍵對應的虛擬鍵碼,要到網上查
可以
做中小游戲
但它有個缺點,游戲比專業(yè)軟件開發(fā)的運行速度要慢
大游戲,最好使用專業(yè)游戲開發(fā)軟件
新建一個Sub : Main
Private Sub Main()
xxx.show 'xxx指啟動窗體
'載入圖片、數(shù)據(jù)庫之類的
Unload xxx
{from}.show '{from}指主界面
End Sub
然后在工程-屬性將"Main"作為啟動對象
假設有三張圖片在資源里,VB.NET不允許資源的名字是純數(shù)字,假設取名Image1,Image2......
Dim Images() As System.Drawing.Bitmap = {My.Resources.Image1, My.Resources.Image2, My.Resources.Image3}
Dim CurrentImage As Integer
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
If CurrentImage 2 Then CurrentImage += 1 Else CurrentImage = 0
PictureBox1.Image = Images(CurrentImage)
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If CurrentImage 0 Then CurrentImage -= 1 Else CurrentImage = 2
PictureBox1.Image = Images(CurrentImage)
End Sub
很簡單啊,軟糖給你代碼
For?i?=?1?To?9999
Dim?名稱?As?String?=?String.Format("Img{0}.png",?編號)?'會返回Img1.png,Img2.png...
picturebox1.Image?=?Bitmap.FromFile(名稱)
Next
滿意請采納,謝謝。