样式通知浮出控件

样式通知浮出控件

本文介绍了Delphi 中的 Windows 7 样式通知浮出控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于 Microsoft 的通知区域建议,我正在寻找想法或 Delphi 组件来实现 .

更新[0]我还在寻求建议.@skamradt 的答案看起来非常好,但不幸的是在实践中效果不佳.

更新[1]最后,自动关闭行为是在调用 SetForegroundWindog 后使用 WM_ACTIVATE 消息来强制弹出激活"

开始FlyoutForm.Show;SetForegroundWindow(FlyoutForm.Handle);结尾;

现在,我正在寻找达到边框行为和视觉样式的建议,因为最接近的行为是通过样式为 WS_POPUP 或 WS_DLGFRAME 来实现的,而最接近的视觉目标是通过将样式设置为 WS_POPUP 或 WS_THICKFRAME 来实现的.

解决方案

相信你的追求是:

TForm1 = 类(TForm):受保护过程 CreateParams(var Params: TCreateParams);覆盖;过程 WMActivate(Var msg:tMessage);消息 WM_ACTIVATE;结尾;过程 TForm1.CreateParams(var Params: TCreateParams);开始遗传;Params.Style := WS_POPUP 或 WS_THICKFRAME;结尾;过程 TForm4.WMActivate(var msg: tMessage);开始如果 Msg.WParam = WA_INACTIVE 那么隐藏;//或关闭结尾;

这将为您提供一个带有玻璃框架的相当大的弹出窗口.由于缺少标准窗口标题,因此您无法在没有额外编程的情况下移动窗口.当另一个窗口获得焦点时,FormDeactivate 事件会被触发......但前提是您切换到同一应用程序中的另一个窗体.无论应用程序切换如何处理,请使用消息捕获方法.

Regarding Notification Area recommendations by Microsoft, I'm looking for ideas or a Delphi component to implement Notification Area Flyouts.

The first "natural" idea is to use a standard Delphi form, but I'm facing two issues with it:

  1. I can't get the form border behavior using the standard "BorderStyle" property. 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).
  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.

ps. There's a related question in converting notification area icon to Program icon in Win7 (Delphi).

update[0]I'm still looking for advise. @skamradt answer looks very good, but unfortunately doesn't work well in practice.

update[1]Finally, The auto-close behavior is working with the WM_ACTIVATE message after a calling SetForegroundWindog to force flyout "activation"

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.

解决方案

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. When another window gets focus, the FormDeactivate event gets fired...but only if you switch to another form in the same application. To handle it regardless of the application switched, use the message capture method.

这篇关于Delphi 中的 Windows 7 样式通知浮出控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 08:05