简简单单的问题,如何使一个躲在后面的form跳到前面来,得到焦点?(20分)

F

fanciex

Unregistered / Unconfirmed
GUEST, unregistred user!
简简单单的问题,如何使一个躲在后面的form跳到前面来,得到焦点?
thank you!
 
form2.show;
form2.setfocus;
 
form2.setfocus;无效啊!它根本不动。
 
不动?
什么意思,不跳到前面来?我这可以啊!是不是和你的form1的显示方式有关
 
你知道如何用sendmessage做同样的效果吗?
 
是啊。说不定你的form1是模式显示
form1.showmodal
 
form2.bringtofront;
 
如果只是简单的要使它跳到前面, 用Form.show就可以了! 没必要有到消息机制!
 
form2.bringtofront也无效!我在托盘区单击图标可执行其他代码,
但一换成setfocus,bringtofront就不行!大家有没碰到?
 
你能不能讲明白点,一头雾水,不懂你到底要干什么。
 
你最好把你的程序说详细一点,
form1如何显示,
如何调用form2的,
调用的时候你要执行什么代码
 
procedure TForm1.OnIconNotify(var Message: TMessage);

begin
if not Busy then
begin
Busy :=true;
if Message.LParam=WM_LBUTTONDOWN then
begin
//form1.Show;
form1.SetFocus;
//if Application.MessageBox('Are you sure close?','Exit',MB_YESNO)=IDYES then Close;
//form1.BringToFront;
//popupmenu1.Popup(mouse.CursorPos.X,mouse.CursorPos.Y);
end;
 
如果用popupmenu1.Popup(mouse.CursorPos.X,mouse.CursorPos.Y);很正常!
 
解决!用
application.BringToFront;可以
但不知道原因,有谁能指点迷津!
谢谢各位乐心!
 
delphi 关于bringtofront的帮助:
Sets the last active window as the topmost window on the desktop above all other applications.
procedure BringToFront;
Description
Use BringToFront to find the window owned by the MainForm that was last active and bring it to
the foreground. BringToFront also tests to see if the window is visible and enabled before
making it the topmost window.
应该对你有所帮助!
 
多人接受答案了。
 
顶部