[求助]大马..帮我改一下嘛.谢谢..怎样让窗口在游戏前面
<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> <p>你还可以看一下这里</p><p></p><p><a href="http://hack.gameres.com/showthread.asp?threadid=25797">http://hack.gameres.com/showthread.asp?threadid=25797</a></p> <p>我这里没有游戏。。。。。。</p><p>我回去用星际魔兽等试下看看</p><p>我还有CS,红警。。。。。。</p> <p>还有一个方法是创建一个全屏窗口,把游戏设为该全屏窗口的子窗口,然后再创建第3个窗口,就是你要呼出的窗口,这种方法也只对一部分游戏有效。</p><p></p><p></p><p>这个不行,,,游戏会变黑了..什么都看不见...</p> <p>看来要具体问题具体处理....</p><p>每个游戏可能都有一定的不同</p><p>我记得原来搞传奇时,就是直接设置子窗体的</p><p>不过游戏我N久没搞过了,哈....</p> <p>因为有些游戏对焦点有处理,只能由自己的窗体得到焦点</p><p>如果焦点非自己,就恢复自己为焦点</p><p>如此N次,就会认为使用了非法程序,于是就退出程序。。。</p><p>面对这样的游戏,是否可以考虑一下输入法窗体那种不夺取焦点的窗体呢?</p> 这个有一个最简单的方法,那就是,你用setparent把你的窗体挂在游戏的窗口下,而且设为最前面
页:
[1]