简体   繁体   English

Delphi中的Windows 7样式通知弹出窗口

[英]Windows 7 style Notifications Flyouts in Delphi

Regarding Notification Area recommendations by Microsoft, I'm looking for ideas or a Delphi component to implement Notification Area Flyouts . 关于Microsoft的通知区域建议,我正在寻找想法或Delphi组件来实现Notification Area Flyouts

替代文字

The first "natural" idea is to use a standard Delphi form, but I'm facing two issues with it: 第一个“自然”的想法是使用标准的Delphi表单,但我面临两个问题:

  1. I can't get the form border behavior using the standard "BorderStyle" property. 我无法使用标准的“BorderStyle”属性获取表单边框行为。 Tried to "mimic" the border using the GlassFrame property along with BorderStyle set to bsNone, but there's no GlassFrame when there's no border (at least, in Delphi 2007). 尝试使用GlassFrame属性“模仿”边框,并将BorderStyle设置为bsNone,但是没有边框时没有GlassFrame(至少在Delphi 2007中)。
  2. I can't figure out how to make the form close when the user clicks everywhere out of the form itself. 当用户点击表单本身的任何地方时,我无法弄清楚如何使表单关闭。 Yesterday I was trying with different messages, but no one works as expected. 昨天我尝试了不同的消息,但没有人按预期工作。

I will thank any clue or component to make it happen :) 我会感谢任何线索或组件来实现它:)

Best regards. 最好的祝福。

jachguate. jachguate。

ps. PS。 There's a related question in converting notification area icon to Program icon in Win7 (Delphi) . 在Win7(Delphi)中将通知区域图标转换为程序图标时存在相关问题。

update[0] I'm still looking for advise. 更新[0]我还在寻找建议。 @skamradt answer looks very good, but unfortunately doesn't work well in practice. @skamradt答案看起来非常好,但遗憾的是在实践中效果不佳。

update[1] Finally, The auto-close behavior is working with the WM_ACTIVATE message after a calling SetForegroundWindog to force flyout "activation" 更新[1]最后,在调用SetForegroundWindog强制弹出“激活”后,自动关闭行为正在使用WM_ACTIVATE消息

begin
  FlyoutForm.Show;
  SetForegroundWindow(FlyoutForm.Handle);
end;

Now, I'm looking for advise to reach the border behavior and visual style, because the closest behavior is achieved with style as WS_POPUP or WS_DLGFRAME, while the closest visual goal is achieved setting style as WS_POPUP or WS_THICKFRAME. 现在,我正在寻找建议来达到边界行为和视觉风格,因为最接近的行为是使用样式实现的WS_POPUP或WS_DLGFRAME,而最接近的视觉目标是将WSFOPUP或WS_THICKFRAME设置为样式。

I believe what your after is the following: 我相信你的后续是以下几点:

TForm1 = class(TForm)
  :
protected
  procedure CreateParams(var Params: TCreateParams); override;
  procedure WMActivate(Var msg:tMessage); message WM_ACTIVATE;
end;

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.Style := WS_POPUP or WS_THICKFRAME;
end;

procedure TForm4.WMActivate(var msg: tMessage);
begin
  if Msg.WParam = WA_INACTIVE then
    Hide; // or close
end;

This will give you a sizeable popup window with a glass frame. 这将为您提供一个带有玻璃框架的相当大的弹出窗口。 You can't move the window without additional programming, since the standard windows caption is missing. 由于缺少标准的Windows标题,因此无法在不进行其他编程的情况下移动窗口。 When another window gets focus, the FormDeactivate event gets fired...but only if you switch to another form in the same application. 当另一个窗口获得焦点时,FormDeactivate事件将被触发...但仅当您切换到同一应用程序中的另一个窗体时。 To handle it regardless of the application switched, use the message capture method. 无论切换应用程序如何处理它,请使用消息捕获方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM