|
<p>大马..帮我改一下嘛.谢谢..怎样让窗口在游戏前面</p><p></p><p>Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer<br/>Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long<br/>Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long<br/>Private 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<br/>Private Const HWND_TOPMOST& = -1<br/>Private Const SWP_NOSIZE& = &H1<br/>Private Const SWP_NOMOVE& = &H2</p><p>Private Sub Timer1_Timer()<br/> Dim hwnd As Long '定义句柄变量<br/> If myhotkey(123) Then '当在游戏中按下F12键<br/> hwnd = FindWindow("游戏标题自己改以下", vbNullString)<br/> pAssignContainer Form1.hwnd, hwnd '设置为子窗体<br/> Form1.Visible = True<br/> Call SetWindowPos(Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)<br/> End If<br/>End Sub</p><p>Private Function pAssignContainer(lFrmPtr As Long, lPicPtr As Long) As Long '设置子窗体函数<br/> pAssignContainer = SetParent(lFrmPtr, lPicPtr)<br/>End Function<br/>'检测键状态的函数<br/>Private Function myhotkey(vkeycode) As Boolean<br/> myhotkey = GetAsyncKeyState(vkeycode)<br/>End Function</p> |
|