将窗体显示在最前面。我在form1窗体放了三个button1.button2,button3
分别用来显示form2和form3的。button1.onclick;内容如下。form2:=Tform2.create(application);
form2.parent:=form1;
form2.showl;button2.onclickform3:=Tform3.create(application);
FORM3.parent:=form1.
form3.show;
点击button3的时候怎样让button1显示在最前面, 知道窗体的句柄。
如果没有FORM3.parent:=form1.和form2.parent:=form1;是非常好实现。
有没有人遇到过我要求的这种问题.
分别用来显示form2和form3的。button1.onclick;内容如下。form2:=Tform2.create(application);
form2.parent:=form1;
form2.showl;button2.onclickform3:=Tform3.create(application);
FORM3.parent:=form1.
form3.show;
点击button3的时候怎样让button1显示在最前面, 知道窗体的句柄。
如果没有FORM3.parent:=form1.和form2.parent:=form1;是非常好实现。
有没有人遇到过我要求的这种问题.
解决方案 »
- delphi 技术越牛,寿命越短,工资不一定越高--谢谢
- 如何通过mac找到IP和用户名
- 请教关于TRY异常抛出的调试问题
- 如何判断用ShellExecute打开的程序的执行情况?
- 关于DELPHI的打印的问题
- 菜鸟提问!如何获得ListView中被选中的项?
- 怎样把delpi做的程序封装成一个类或做成一个模板可以被别人继承
- query控件select出来的记录怎么进行查找啊
- 控件问题!很好解决!!!!!!!!!!!
- 请问在dbgrid中如何才能得到当前行焦点改变的事件?
- 高手指教,怎样根据指定的用户名判断改用户对网络上或者本机的共享目录有写权限!
- 用query控件进行数据的修改,我的怎么都修改不了,怎么回事啊,是不是query属性要改什么啊?
SetActiveWindow(form1.Handle);
function ForceForegroundWindow(hwnd: THandle): boolean;
const
SPI_GETFOREGROUNDLOCKTIMEOUT = $2000;
SPI_SETFOREGROUNDLOCKTIMEOUT = $2001;
var
ForegroundThreadID: DWORD;
ThisThreadID : DWORD;
timeout : DWORD;
begin
if IsIconic(hwnd) then ShowWindow(hwnd, SW_RESTORE); if GetForegroundWindow = hwnd then Result := true
else begin // Windows 98/2000 doesn't want to foreground a window
//when some other
// window has keyboard focus if ((Win32Platform = VER_PLATFORM_WIN32_NT) and
(Win32MajorVersion > 4)) or
((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
((Win32MajorVersion > 4) or ((Win32MajorVersion = 4) and
(Win32MinorVersion > 0)))) then
begin // Code from Karl E. Peterson,www.mvps.org/vb/sample.htm
// Converted to Delphi by Ray Lischner
// Published in The Delphi Magazine 55, page 16 Result := false;
ForegroundThreadID := GetWindowThreadProcessID
(GetForegroundWindow,nil);
ThisThreadID := GetWindowThreadPRocessId(hwnd,nil);
if AttachThreadInput(ThisThreadID, ForegroundThreadID,
true) then
begin
BringWindowToTop(hwnd); // IE 5.5 related hack
SetForegroundWindow(hwnd);
AttachThreadInput(ThisThreadID, ForegroundThreadID,
false);
Result := (GetForegroundWindow = hwnd);
end;
if not Result then begin // Code by Daniel P. Stasinski SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0,
@timeout, 0);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
TObject(0), SPIF_SENDCHANGE);
BringWindowToTop(hwnd); // IE 5.5 related hack
SetForegroundWindow(hWnd);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
TObject(timeout), SPIF_SENDCHANGE);
end;
end
else begin
BringWindowToTop(hwnd); // IE 5.5 related hack
SetForegroundWindow(hwnd);
end; Result := (GetForegroundWindow = hwnd);
end;
end;
上面的函数也可以让他暂时置前,想总置前还需要研究!
呵呵,我也懒得研究,等人吧!
获得窗口的句柄可用如下方法:
procedure TForm1.Button3Click(Sender: TObject);
var
hCurrentWindow: HWnd;
szText: array[0..254] of char;
begin
hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin
if GetWindowText(hCurrentWindow, @szText, 255) > 0 then
Memo1.Lines.Add(StrPas(@szText));
hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
end;
end;
这里找不到答案吗?来这里试试看!
这里有问必答
http://systemer.51.net/cgi-bin/leoboard.cgi
希望你能在这里找到你满意的答案
=========================================
csdn比大富翁气氛活多了。