WPFでtitleありclose buttonなしのwindowを表示しようと考えました。
http://haneisu.blog.fc2.com/blog-entry-164.html
のとおりに、
using System;
using System.Windows;
using System.Windows.Controls;
using System.Runtime.InteropServices;
using System.Windows.Interop;
namespace wpfapplication {
public partial class subwindow1 : Window {
// classの中に記述
[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
const int GWL_STYLE = -16;
const int WS_SYSMENU = 0x80000;
protected override void OnSourceInitialized(EventArgs e) {
base.OnSourceInitialized(e);
IntPtr handle = new WindowInteropHelper(this).Handle;
int style = GetWindowLong(handle, GWL_STYLE);
style = style & (~WS_SYSMENU);
SetWindowLong(handle, GWL_STYLE, style);
}
}
}
としてうまくいきました。
ところでこれ、複数のsubwindowで使いたいので共通classにしたいと考えました。
namespace windowstyle{
public class window : Window {
として、
subwindow1のfieldに
windowstyle.window win = new windowstyle.window();
と書いたのですがこれでは[×]が残ったままでした。
OnSourceInitializedはprotectedなのですが、これをpublicにして呼べばよいですか?
EventArgs eには何を渡せばよいでしょう?
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。