を模倣したVista通知アイコンダイアログボックスとコンポーネントのラインナップ
-
21-08-2019 - |
質問
時シングルクリックする通知アイコンビスタなどのネットワークも音アイコンを提供します、チキンないcaptionlessダイアログを表示http://i.msdn.microsoft.com/Aa511448.NotificationArea22(en-us,MSDN.10)となります。png):
http://i.msdn.microsoft.com/Aa511448.NotificationArea22(en-us,MSDN.10)となります。png
たいのですがよく似これらのコンポーネントのラインナップ?を新しいウィンドウ設定WindowStyleを"なし"とResizeModeる"CanResize"を作り、結果のフレームがやや薄くなりすぎるので、ダイアログのサイズ変更をすることは望ましくない。設定ResizeModeる"NoResize"の結果ウィンドウのないエアロボーダー(薄2px線ボーダー)
解決 2
私はついにそれを考え出した:あなたは「CanResize」は、あなたがキャプションなしで正しい太枠を買ってあげるためには「なし」とResizeModeですのWindowStyleを設定した場合、唯一のヒッチは、あなたがまだウィンドウのサイズを変更できることです。。 P>
幸い、この問題は簡単にWindow
インスタンスに対してWM_NCHITTESTを取り扱うことにより、整流されます:
private IntPtr _hwnd;
protected override void OnSourceInitialized(EventArgs e) {
_hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
System.Windows.Interop.HwndSource.FromHwnd(_hwnd).AddHook(_WndProc);
base.OnSourceInitialized(e);
}
private const int WM_NCHITTEST = 132;
private const int HTCLIENT = 1;
private IntPtr _WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) {
// We should only receive messages for our own window handle.
System.Diagnostics.Debug.Assert(hwnd == _hwnd);
if (msg == WM_NCHITTEST) {
handled = true;
return (IntPtr)HTCLIENT;
}
return IntPtr.Zero;
}
Windowsのカーソルが境界線上にあることを知らせることがないことで、私たちは、サイズ変更カーソルを提示することはありません。
他のヒント
トリックは、国境にあなたの自己を追加することです。私は、メインのコンテンツ要素DockPanelを作り、境界線を追加することによって、そのようにしました。あなたはVistaのスタイルの窓に合わせて、外観をカスタマイズするために境界線を使用することができます。私はその特定の一つに名前を付けることはできませんので、色とよくないんだけど、例としてグレーを使用します。
タグ以下をお試しください
<Window x:Class="WpfApplication10.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1"
Height="300"
Width="300"
WindowStyle="None"
ResizeMode="NoResize">
<DockPanel>
<Border
BorderBrush="Gray"
BorderThickness="5">
<TextBlock>Here we go</TextBlock>
</Border>
</DockPanel>
</Window>
あなたが必要とする何WPFは、Windowsで利用可能なすべてのオプションを公開するものではありませんが、のPInvokeを使用してそれらを自分で設定することができ、ウィンドウスタイルの適切な組み合わせを指定することです。
私は今、Vistaマシンで私はテストのスタイルの組み合わせは(C#で)正しい見た目が、スタイルのリストを与えるかを確認することができないではないよここに<のhref = "ですhttp://のPInvoke。ネット/ default.aspxを/ USER32 / GetWindowLong.html」のrel = "nofollowをnoreferrer"> http://pinvoke.net/default.aspx/user32/GetWindowLong.html の
あなたのしているWindowクラスでます:
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong);
[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
private const int GWL_STYLE = -16;
private const int GWL_EXSTYLE = -20;
private const UInt32 SWP_NOSIZE = 0x0001;
private const UInt32 SWP_NOMOVE = 0x0002;
private const UInt32 SWP_NOZORDER = 0x0004;
private const UInt32 SWP_NOREDRAW = 0x0008;
private const UInt32 SWP_NOACTIVATE = 0x0010;
private const UInt32 SWP_FRAMECHANGED = 0x0020;
public override void OnSourceInitialized(EventArgs e)
{
IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
// set styles to a combination of WS_ flags and exstyles to a combination of WS_EX_ flags
SetWindowLong(hwnd, GWL_STYLE, styles);
SetWindowLong(hwnd, GWL_EXSTYLE, exstyles);
// and to activate changes:
SetWindowPos(hwnd,IntPtr.Zero,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_FRAMECHANGED);
}
私は私がこれまでに作ってみたものを掲載したい考え出し。これはかなり近づきます:
<Window.Style>
<Style TargetType="{x:Type Window}">
<Setter Property="AllowsTransparency" Value="True" />
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="BorderBrush" Value="{x:Null}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="ResizeMode" Value="NoResize" />
<Setter Property="SizeToContent" Value="WidthAndHeight" />
<Setter Property="WindowStyle" Value="None" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<Border BorderThickness="1" CornerRadius="4" Background="{x:Null}">
<Border.BorderBrush>
<SolidColorBrush Color="{x:Static SystemColors.WindowFrameColor}" Opacity="0.75" />
</Border.BorderBrush>
<Border BorderThickness="5" Background="{x:Null}">
<Border.BorderBrush>
<SolidColorBrush Color="{x:Static SystemColors.ActiveBorderColor}" Opacity="0.5" />
</Border.BorderBrush>
<Border BorderThickness="1" Background="White">
<Border.BorderBrush>
<SolidColorBrush Color="{x:Static SystemColors.WindowFrameColor}" Opacity="0.75" />
</Border.BorderBrush>
<ContentPresenter />
</Border>
</Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Style>
明らかに、彼らは国境の真ん中を描くためにActiveWindowBorderColorにだけ透明度以上のものを使用しています。下の3/4が黒のオーバーレイを持っていながら、トップ1/4が白のオーバーレイを持っているようです。また、外側の境界は、右と下縁にアクセントカラーを有しています。私は本当のためにこれを行うとしたら、私はそのような小さな細部のすべてを処理し(と私がしたいなら、私にサイズを変更できるようにする)と、リソース・ディクショナリにウィンドウのスタイルを投げるために国境から派生したユーザーコントロールを作成することになります。