全屏游戏窗口化问题???向高手求救!!!!!(在线等待) ( 积分: 0 )

  • 主题发起人 主题发起人 zxflsx
  • 开始时间 开始时间
Z

zxflsx

Unregistered / Unconfirmed
GUEST, unregistred user!
我现在在玩网络游戏“飙车”,他是800*600的全屏游戏,我做了一个窗口化程序,但切换以后,游戏就退出了,它是用VC++编的游戏。我怀疑它是在程序里限制了游戏的窗口变化,并且在游戏当中不能用TAB+ALT切换别的画面。无法查看进程。请高手帮我解决一下或给些提示。万分感谢。
 
我现在在玩网络游戏“飙车”,他是800*600的全屏游戏,我做了一个窗口化程序,但切换以后,游戏就退出了,它是用VC++编的游戏。我怀疑它是在程序里限制了游戏的窗口变化,并且在游戏当中不能用TAB+ALT切换别的画面。无法查看进程。请高手帮我解决一下或给些提示。万分感谢。
 
代码:<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, StdCtrls;<br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;procedure FormCreate(Sender: TObject);<br> &nbsp; &nbsp;procedure FormClose(Sender: TObject; var Action: TCloseAction);<br> &nbsp;private<br> &nbsp; &nbsp;procedure HotKeyDown(var Msg:Tmessage);message WM_HOTKEY;<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp;end;<br>var<br> &nbsp;Form1: TForm1;<br> &nbsp;HotKeyid:Integer;<br> &nbsp;pHwnd:Hwnd;<br> &nbsp;style,exstyle:longint;<br> &nbsp;devmode1:DEVMODE;<br><br>implementation<br><br>{$R *.dfm}<br>procedure TForm1.FormCreate(Sender: TObject);<br><br>begin<br> &nbsp;HotKeyid:=GlobalAddAtom('MyHotKey')-$C00;<br> &nbsp;RegisterHotKey(Handle,HotKeyid,0,VK_ADD);<br>end;<br>procedure TForm1.HotKeyDown(var Msg:Tmessage);<br>begin<br> &nbsp;if (Msg.LParamLo=0) and (Msg.LParamHi=VK_ADD) then<br> &nbsp; begin<br> &nbsp; &nbsp; pHwnd:=GetForegroundWindow();<br> &nbsp; &nbsp; if EnumDisplaySettings(0,0,devmode1) then<br> begin<br> &nbsp;devmode1.dmPelsWidth:=1024;<br> devmode1.dmPelsHeight:=768;<br> &nbsp;devmode1.dmBitsPerPel:=32;<br> devmode1.dmDisplayFrequency:=75;<br> ChangeDisplaySettings(devmode1,0);<br> &nbsp;end;<br><br> &nbsp;style:=GetWindowLong(pHwnd,GWL_STYLE);<br> &nbsp;style:=WS_CAPTION or WS_VISIBLE ;<br> &nbsp;SetWindowLong(pHwnd,GWL_STYLE,style);<br><br> &nbsp;exstyle:=GetWindowLong(pHwnd,GWL_EXSTYLE);<br> exstyle:=WS_EX_APPWINDOW or WS_EX_WINDOWEDGE;<br> SetWindowLong(pHwnd,GWL_EXSTYLE,exstyle);<br><br> &nbsp;SetWindowPos(pHwnd,HWND_NOTOPMOST,0,0,800,600,SWP_SHOWWINDOW);<br> &nbsp; ShowWindow(pHwnd,SW_SHOWNORMAL);<br> <br> &nbsp; &nbsp; end;<br>end;<br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br> &nbsp; &nbsp;UnRegisterHotKey(handle,HotKeyid);<br>end;<br><br>end.
 
问题发现了,这个程序在WIN2000下能行,但在XP下不行。但又有个问题看代码:界面隐藏了却无法还原,帮忙看看:<br>unit Unit1;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, StdCtrls;<br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;procedure FormCreate(Sender: TObject);<br> &nbsp; &nbsp;procedure FormClose(Sender: TObject; var Action: TCloseAction);<br> &nbsp;private<br> &nbsp; &nbsp;procedure HotKeyDown(var Msg:Tmessage);message WM_HOTKEY;<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp;end;<br>var<br> &nbsp;Form1: TForm1;<br> &nbsp;HotKeyid,HotKeyid1,HotKeyid2:Integer;<br> &nbsp;pHwnd:Hwnd;<br> &nbsp;style,exstyle:longint;<br> &nbsp;devmode1:DEVMODE;<br><br>implementation<br>uses Math;<br>{$R *.dfm}<br><br><br>procedure TForm1.FormCreate(Sender: TObject);<br><br>begin<br> &nbsp;HotKeyid:=GlobalAddAtom('MyHotKey')-$C00;<br> &nbsp;[red]RegisterHotKey(Handle,HotKeyid1,0,VK_F9);<br> &nbsp;RegisterHotKey(Handle,HotKeyid2,0,VK_F10);<br> &nbsp;RegisterHotKey(Handle,HotKeyid,0,VK_F11);[/red]<br><br>end;<br>procedure TForm1.HotKeyDown(var Msg:Tmessage);<br>begin<br> &nbsp;if (Msg.LParamLo=0) and (Msg.LParamHi=VK_F11) then<br> &nbsp;begin<br> &nbsp; &nbsp; pHwnd:=GetForegroundWindow();<br> &nbsp; &nbsp; if EnumDisplaySettings(0,0,devmode1) then<br> &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;devmode1.dmPelsWidth:=1024;<br> &nbsp;devmode1.dmPelsHeight:=768;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; devmode1.dmBitsPerPel:=32;<br> &nbsp;devmode1.dmDisplayFrequency:=75;<br> &nbsp;ChangeDisplaySettings(devmode1,0);<br> &nbsp;end;<br> &nbsp; &nbsp; &nbsp; style:=GetWindowLong(pHwnd,GWL_STYLE);<br> &nbsp; &nbsp; &nbsp; style:=WS_OVERLAPPEDWINDOW or WS_VISIBLE ;<br> &nbsp; &nbsp; &nbsp; SetWindowLong(pHwnd,GWL_STYLE,style);<br> &nbsp; &nbsp; &nbsp; exstyle:=GetWindowLong(pHwnd,GWL_EXSTYLE);<br> &nbsp; &nbsp; &nbsp; exstyle:=WS_EX_APPWINDOW or WS_EX_WINDOWEDGE;<br> &nbsp; &nbsp; &nbsp; SetWindowLong(pHwnd,GWL_EXSTYLE,exstyle);<br> &nbsp; &nbsp; &nbsp; SetWindowPos(pHwnd,HWND_NOTOPMOST,0,0,800,600,SWP_SHOWWINDOW);<br> &nbsp; &nbsp; &nbsp; &nbsp; ShowWindow(pHwnd,SW_SHOWNORMAL);<br> &nbsp;end;<br> &nbsp; &nbsp;if (Msg.LParamLo=0) and (Msg.LParamHi=VK_F10) then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowWindow(pHwnd,SW_HIDE);<br> &nbsp; [red] if (Msg.LParamLo=0) and (Msg.LParamHi=VK_F9) then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowWindow(pHwnd,SW_RESTORE);[/red]<br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br> &nbsp; &nbsp;UnRegisterHotKey(handle,HotKeyid);<br>end;<br><br>end.
 
游戏,一般用到了directx吧。。。首先就是个SetCooperativeLevel,若是,则你也得尝试directx下弹出窗口。。。。
 
to:江南草<br>能不能具体说一下如何调用DX的函数,有什么D7下编DX游戏的书吗?<br><br>注释一下:一般网络的3D游戏用到DX编程,DX的函数可以控制显示,使程序独占显示设备,不能运行其他程序。我想知道有什么方法可以象GETWINDOWLONG()函数一样得到自己想要的窗口信息。我不知道如何引入和调用DX的函数。
 
后退
顶部