怎么自动把窗体显示出来?
2008-11-27 21:10
288 查看
怎么自动把窗体显示出来? Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiAPI/html/delphi_20061119181326198.html
当窗体当前没有焦点,或者窗体被最小化了,在该窗体得到某一事件怎么显示窗体呀?让窗体得到焦点。我用以下代码不行:
procedure TForm1.WndProc(var message: TMessage);
var
dataStruct: PCOPYDATASTRUCT;
passingMessage: PMessage;
begin
inherited;
if message.Msg = WM_COPYDATA then begin
dataStruct := PCOPYDATASTRUCT(message.LParam);
passingMessage := PMessage(dataStruct.lpData);
if (passingMessage^.Msg = WM_KEYDOWN) then begin
//listBox1.Items.Add('message=' + IntToStr(passingMessage^.WParam));
if (passingMessage^.wParam = VK_HOME) then
begin
ShowWindow(self.Handle, SW_SHOWNORMAL or SW_RESTORE);
BringWindowToTop(self.Handle);
SetForegroundWindow(self.Handle);
end;
end;
end;
end;
窗体在任务栏一闪一闪得,就是不提前现实。
试下:
ShowWindow(Application.Handle, SW_SHOWNORMAL or SW_RESTORE);
帮顶
试了ShowWindow(Application.Handle, SW_SHOWNORMAL or SW_RESTORE);
也是一样,就是不提前显示出来
有用了,我发现如果最小化得时候采用Application.Handle就行了,哈哈,我再试试
目前处于别得窗体之后还不行
加上BringWindowToTop和SetForegroundWindow呢?用Application.Handle
我也是都在后面2函数上加上才能在最小化状态把窗体置前得。但是处于别得窗体之后还是不行。不知道怎么回事
不是你想SetForegroundWindow谁就可以SetForegroundWindow谁的。
(msdn只说win98/me是这样,其实2k/xp也一样)
the system restricts which processes can set the foreground window. A process can set the foreground window only if one of the following conditions is true:
The process is the foreground process.
The process was started by the foreground process.
The process received the last input event.
There is no foreground process.
The foreground process is being debugged.
The foreground is not locked (see LockSetForegroundWindow).
The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).
No menus are active.
不信可以自己试验,
搞一个程序只有:
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
SetForegroundWindow(Handle);
}
保存起来,运行它然后把窗体放在后面,这时它只能在任务栏里闪。
再搞一个程序:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
WinExec("C:\\Documents and Settings\\Ray\\桌面\\新建文件夹\\project1.exe",SW_SHOW);//运行上一个程序
}
这时按Button1就可以调到前面来。
学习接分;;;;;;;;;;;
leonatcs(LeonKennedy)(时常逛一逛csdn,有益身心健康。)
真是这样,只在任务栏里闪,但是有没有办法直接掉到前面来?如果不开新进程。因为这个进程要一直开着,比如游戏外挂。我看到别得游戏外挂可以做到。
谢谢
http://www.delphi2007.net/DelphiAPI/html/delphi_20061119181326198.html
当窗体当前没有焦点,或者窗体被最小化了,在该窗体得到某一事件怎么显示窗体呀?让窗体得到焦点。我用以下代码不行:
procedure TForm1.WndProc(var message: TMessage);
var
dataStruct: PCOPYDATASTRUCT;
passingMessage: PMessage;
begin
inherited;
if message.Msg = WM_COPYDATA then begin
dataStruct := PCOPYDATASTRUCT(message.LParam);
passingMessage := PMessage(dataStruct.lpData);
if (passingMessage^.Msg = WM_KEYDOWN) then begin
//listBox1.Items.Add('message=' + IntToStr(passingMessage^.WParam));
if (passingMessage^.wParam = VK_HOME) then
begin
ShowWindow(self.Handle, SW_SHOWNORMAL or SW_RESTORE);
BringWindowToTop(self.Handle);
SetForegroundWindow(self.Handle);
end;
end;
end;
end;
窗体在任务栏一闪一闪得,就是不提前现实。
试下:
ShowWindow(Application.Handle, SW_SHOWNORMAL or SW_RESTORE);
帮顶
试了ShowWindow(Application.Handle, SW_SHOWNORMAL or SW_RESTORE);
也是一样,就是不提前显示出来
有用了,我发现如果最小化得时候采用Application.Handle就行了,哈哈,我再试试
目前处于别得窗体之后还不行
加上BringWindowToTop和SetForegroundWindow呢?用Application.Handle
我也是都在后面2函数上加上才能在最小化状态把窗体置前得。但是处于别得窗体之后还是不行。不知道怎么回事
不是你想SetForegroundWindow谁就可以SetForegroundWindow谁的。
(msdn只说win98/me是这样,其实2k/xp也一样)
the system restricts which processes can set the foreground window. A process can set the foreground window only if one of the following conditions is true:
The process is the foreground process.
The process was started by the foreground process.
The process received the last input event.
There is no foreground process.
The foreground process is being debugged.
The foreground is not locked (see LockSetForegroundWindow).
The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).
No menus are active.
不信可以自己试验,
搞一个程序只有:
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
SetForegroundWindow(Handle);
}
保存起来,运行它然后把窗体放在后面,这时它只能在任务栏里闪。
再搞一个程序:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
WinExec("C:\\Documents and Settings\\Ray\\桌面\\新建文件夹\\project1.exe",SW_SHOW);//运行上一个程序
}
这时按Button1就可以调到前面来。
学习接分;;;;;;;;;;;
leonatcs(LeonKennedy)(时常逛一逛csdn,有益身心健康。)
真是这样,只在任务栏里闪,但是有没有办法直接掉到前面来?如果不开新进程。因为这个进程要一直开着,比如游戏外挂。我看到别得游戏外挂可以做到。
谢谢
相关文章推荐
- 实现TEXTAREA数据写入数据库后提取出来原样显示在网页TABLE上并自动换行
- 想知道CSDN的评论一提交上去就显示出来的AJAX是怎么实现的吗!!
- 在C#中 从一个picturebox中 按住鼠标左键不放 画一块区域后,另外一个picturebox(在一个winform 窗体上有两个picturebox )上马上把对应的截取图像显示出来
- C# 屏幕监控 自动截屏程序 主窗体隐藏,仅在进程中显示
- 怎么用一个程序向另一个程序发送字符并让其显示出来
- C# Tabcontrol组件怎么(切换)显示Form窗体
- 从数据库取出来的文字过长,怎么让单元格自动换行
- 文字过长,QLabel显示不全的问题,QLabel怎么自动分行显示
- 怎么去除table多余出来的行,我的table里面只显示一条记录,但是下面出现很多空白的行,要怎么去掉
- 显示桌面的图标没了,怎么能弄出来
- 使用该JavaBean可以将数据在JSP页面中以表格的形式显示出来,并具有动态排序、动态生成查询、自动分页功能
- Android之怎么隐藏EditText光标和自动显示键盘
- 怎么让文件的内容在textArea中显示出来?
- 设计一个如下图所示窗体:该窗体自动位于屏幕中央;大小不可调;最小化、最大化按钮不可用;窗体标题为“烟台大学”。在该窗体上,放置一个按钮、一个标签。单击按钮时,在标签上显示当前系统时间。
- C#窗体MessageBox显示自动消失(移动开发Pocket PC 2003)
- 把这个50个数的顺序打乱,分别显示出来??怎么做???
- C#窗体MessageBox显示自动消失
- Java/Android怎么让一张图片最简单的显示出来?不用布局.
- 动态创建TImage 在窗体显示出来,动态改变大小
- [置顶] Activity具体是怎么创建的?又是怎么显示出来的?