窗口化程序求助 ( 积分: 100 )

  • 主题发起人 主题发起人 Angell1124
  • 开始时间 开始时间
A

Angell1124

Unregistered / Unconfirmed
GUEST, unregistred user!
我在玩游戏时,用窗口化程序把游戏的全屏改为窗口,但是他的坐标还是全屏的。也就是说<br>鼠标点不到位置。<br>我用的窗口化程序代码如下:<br> 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>鼠标点不到位置。<br>我用的窗口化程序代码如下:<br> 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);
 
MapWindowPoints 将一个窗口客户区坐标的点转换到另一窗口的客户区坐标系统<br>ClipCursor 限制鼠标移动区域
 
但是这是同一个窗口呀。
 
我做了一个窗口化的程序,能把所有的程序都变为800*600的窗口化!但不能运行外部程序,一旦运行就退出程序了,这个问题正在解决当中,可以告诉我代码,我给你发一份代码!
 
我的邮箱: angell1124@eyou.com
 
求高手帮帮忙
 
var<br> &nbsp;h:hwnd;<br>begin<br> &nbsp;h:=findwindow(nil,pchar(edit1.Text));<br> &nbsp;SetActiveWindow(h);<br><br><br> &nbsp;h:=findwindow(nil,pchar(edit1.Text));<br> &nbsp;if h&lt;&gt;0 then<br> &nbsp;SetWindowPos(h,HWND_TOPMOST,-10, -45, &nbsp;self.Width+10, &nbsp;self.Height,SWP_SHOWWINDOW or SWP_NOACTIVATE);<br><br> &nbsp;windows.setParent(h,handle);<br>————以前找别人要来的代码
 
楼主,我也做了个窗口化程序,我不太清楚你说的坐标问题是怎么回事。但我想问问你你的程序在把游戏窗口化后能同时用别的软件吗(如QQ)<br>我的代码:<br>现在我的代码可以让任何窗口变成800*600的窗口,并可隐藏和显示。但有个问题就是在窗口化后,无法运行其他程序,一但运行,则窗口化的游戏就退出了。(MU登陆器就没事是用VC编的),高手帮解释一下,多多指点!!!!急盼!!!!!!!!!!!!!<br>unit Unit1;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, StdCtrls, Menus, SUIPopupMenu, CoolTrayIcon, ExtCtrls, jpeg;<br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;CoolTrayIcon1: TCoolTrayIcon;<br> &nbsp; &nbsp;Timer1: TTimer;<br> &nbsp; &nbsp;Image1: TImage;<br> &nbsp; &nbsp;PopupMenu1: TPopupMenu;<br> &nbsp; &nbsp;N1: TMenuItem;<br> &nbsp; &nbsp;N2: TMenuItem;<br> &nbsp; &nbsp;procedure FormCreate(Sender: TObject);<br> &nbsp; &nbsp;procedure FormClose(Sender: TObject; var Action: TCloseAction);<br> &nbsp; &nbsp;procedure N1Click(Sender: TObject);<br> &nbsp; &nbsp;procedure N2Click(Sender: TObject);<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;pHmenu:HMENU;<br> &nbsp;style,exstyle:longint;<br> &nbsp;devmode1:DEVMODE;<br> &nbsp;bool:boolean;<br>implementation<br>uses Unit2;<br>{$R *.dfm}<br><br><br>procedure TForm1.FormCreate(Sender: TObject);<br><br>begin<br> &nbsp;bool:=false;<br> &nbsp;form1.Hide;<br> &nbsp;//GlobalAddAtom函数得到唯一标识<br> &nbsp;HotKeyid2:=GlobalAddAtom('MyHotKey')-$C00;<br> &nbsp;HotKeyid:=GlobalAddAtom('MyHotKey1')-$C00;<br> &nbsp;//HotKeyId的合法取之范围是0x0000到0xBFFF之间, GlobalAddAtom函数得到的值<br> &nbsp;//在0xC000到0xFFFF之间,所以减掉0xC000来满足调用要求。<br> &nbsp;RegisterHotKey(Handle,HotKeyid,0,VK_F11);<br> &nbsp;RegisterHotKey(Handle,HotKeyid1,0,VK_F9);<br> &nbsp;//热键的辅助按键包括Mod_Ctrl 、Mod_Alt、Mod_Shift,对于Windows兼容键盘还支持Windows<br> &nbsp;//键,即其键面上有Windows标志的那个键,其值为Mod_win。<br> &nbsp;//上面 的代码注册了一个热键:ALT+F8。当然如果你希望象TAKEIT那样,只用F8, 就这么写:<br> &nbsp;//RegisterHotKey(Handle, hotkeyid, 0, VK_F8);<br><br>end;<br>//按下定义的全局热键所响应的代码<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(); //得到在屏幕上最前端的窗口的句柄;也可以用其他API函数指定某个特定窗口<br> &nbsp; &nbsp; //以下是把定义把屏幕变更为1024*768,32位色彩,刷新率为75赫兹<br> &nbsp; &nbsp; if EnumDisplaySettings(0,0,devmode1) then<br> &nbsp; begin<br> &nbsp; &nbsp; devmode1.dmPelsWidth:=1024;<br> &nbsp; devmode1.dmPelsHeight:=768;<br> &nbsp; &nbsp; devmode1.dmBitsPerPel:=32;<br> &nbsp; devmode1.dmDisplayFrequency:=75;<br> ChangeDisplaySettings(devmode1,0);<br> &nbsp;end;<br> &nbsp;pHmenu:=CreateMenu();<br> &nbsp;SetMenu(pHwnd,pHmenu);<br> &nbsp;//得到窗口原来的属性<br> &nbsp;style:=GetWindowLong(pHwnd,GWL_STYLE);<br> &nbsp;//定义新属性<br> &nbsp;style:=WS_OVERLAPPEDWINDOW or WS_VISIBLE ;<br> &nbsp;//更改窗口属性<br> &nbsp;SetWindowLong(pHwnd,GWL_STYLE,style);<br> &nbsp;//得到窗口扩展属性<br> &nbsp;exstyle:=GetWindowLong(pHwnd,GWL_EXSTYLE);<br> &nbsp;//定义新扩展属性<br> exstyle:=WS_EX_APPWINDOW or WS_EX_WINDOWEDGE;<br> &nbsp;//更改窗口扩展属性<br> SetWindowLong(pHwnd,GWL_EXSTYLE,exstyle);<br> &nbsp;//更改的屏幕以屏幕的0,0为坐标,大小为800*600<br> &nbsp;SetWindowPos(pHwnd,HWND_NOTOPMOST,0,0,800,600,SWP_SHOWWINDOW);<br> &nbsp; ShowWindow(pHwnd,SW_SHOWNORMAL);<br> &nbsp;end;<br><br>if (Msg.LParamLo=0) and (Msg.LParamHi=VK_F9) then<br> &nbsp; &nbsp;if bool=false then<br> &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; ShowWindow(pHwnd,SW_HIDE); //隐藏窗口<br> &nbsp; &nbsp; &nbsp; bool:=true;<br> &nbsp; &nbsp; &nbsp;end<br> &nbsp; &nbsp; else<br> &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; //if (Msg.LParamLo=0) or (Msg.LParamHi=VK_F9) then<br> &nbsp; &nbsp; &nbsp; ShowWindow(pHwnd,SW_RESTORE); //恢复窗口<br> &nbsp; &nbsp; &nbsp; bool:=false;<br> &nbsp; &nbsp; &nbsp;end;<br>end;<br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br> &nbsp; &nbsp;UnRegisterHotKey(handle,HotKeyid); &nbsp;//注销热键<br>end;<br><br>procedure TForm1.N1Click(Sender: TObject);<br>begin<br> &nbsp;UnRegisterHotKey(handle,HotKeyid);<br> &nbsp;form1.Close;<br>end;<br><br>procedure TForm1.N2Click(Sender: TObject);<br>begin<br> &nbsp;form2.show;<br>end;<br><br>end.
 
一般是用DX吧!
 
To:寻路<br>也有人和我说过,但没有这方面的书,在D7里怎么使用DX啊,不是做个游戏,而是改变现有的游戏显示控制模式(我没安DX控件,是声明文件)
 
后退
顶部