窗体如果永远在最前面 也许和DirecTX有关(100分)

I

itren

Unregistered / Unconfirmed
GUEST, unregistred user!
大家都知道 通过 fsStayOnTop 可以设置永远在最前面。
但是如果此时 是 DirectX类的程序运行,就可以让这个窗体在后面了/
还有即使是个窗体 也设成 fsStayOnTop 但永远只有一个在最前!
如何禁止别的窗体和 程序在我的窗体的最前啊? ..
多多帮忙啊?
 
----------------------------------------------------代码一
用SetWindowPos
例:SetWindowPos(form2.handle,HWND_TOPMOST,form1.Left,form1.Top,form1.Width,form1.Height,0);
-----------------------------------------------------代码二
你可以用程序的方法实现:

首先获取该窗口的句柄。Gettopwindow();如果中是想把该窗口中
画面的部分抓取,则需要得到它的 DC ,可用getdc();得到。
然后用函数抓取就可以了。bitblt();函数可以复制窗体。
-----------------------------------------------------代码三
下面,是抓图源代码,里面有你要的代码:
你自己试试看吧。

{our callback function prototype}
function EnumerateWindows(hWnd: HWND; lParam: LPARAM): BOOL; stdcall;
var
Form1: TForm1;

implementation

procedure TForm1.Button1Click(Sender: TObject);
begin
{empty the listbox that will hold the window names}
ListBox1.Items.Clear;

{enumerate all the top-level windows in the system}
EnumWindows(@EnumerateWindows,0);
end;

{these steps execute for every top-level window in the system}
function EnumerateWindows(hWnd: HWND; lParam: LPARAM): BOOL;
var
TheText: Array[0..255] of char; // this holds the window text
begin
{if the window does not have any text...}
if (GetWindowText(hWnd, TheText, 255)=0) then
{...display the window handle and a note...}
Form1.ListBox1.Items.Add(Format('%d = {This window has no text}',[hWnd]))

else
{otherwise display the window handle and the window text}
Form1.ListBox1.Items.Add(Format('%d = %s',[hWnd,TheText]));

{continue enumeration}
Result:=TRUE;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
FoundWindow: HWND;
WindowText: array[0..255] of char;
begin
{find a TEdit child window}
FoundWindow:=FindWindowEx(Form1.Handle, 0, 'TEdit',nil);

{get its text...}
GetWindowText(FoundWindow, WindowText, 255);

{...and display it}
Label1.Caption:='FindWindowEx found window handle '+IntToStr(FoundWindow)+
': '+WindowText;

end;
 
不会要经常检查自己是否不在最前了吧?
有没有什么消息之类的可以处理?
 
好像没有,我也一直在找这个门题的最好的方法;
 
GZ 可能也要写一个DirectX窗口吧。
 
问题是: 即使DirectX 窗口也只能有一个在前面啊?
 
如果可以把自己窗口设定为游戏的子窗口呢?
 
似乎在理论上不可行的!呵呵!大家来灌水啊啊!
 
快来灌水!
 
别灌纯水。
 
把你的程序界面blt到游戏的主图面上,hook鼠标、键盘消息自己处理
 
to gxcooo:
Blt 是什么??
如何能进行??
说明好吗?

 
啊。。。扑。。。
 
我用了比较笨的方法解决了:
呵呵! 用一个timer 定时检查,活动窗口的句柄Getactivewindow().如果不是自己的客户窗体.
就把自己设置成前面的. setforeground()
希望有更好的方法! 大家快来灌水!有没有 DirectX 来实现的.
 
gxcooo: 能讲讲DirectX blt 到..... 是什么意思啊?
 
顶部