More Related Content
Similar to WPF開発での陥りやすい罠 (20)
WPF開発での陥りやすい罠
- 16. なぜこんなに違いがあるのか?
仮説1) Adobe Flashの対抗製品として出されたから。
→今は亡きSilverlightの上位機能版、WPFを先に作り簡素化する形で
Silverlightが作られた。(Flashもいまだ全盛なのでもったいない)
仮説2)とにかくGPUをつかって表示したかったから。
→確かに表示は早いけど搭載機能が早熟だった。
仮説3)このスマホのタッチアプリ戦国時代を見越していたから。
→時代を先取りしすぎた。
- 23. WPF開発でやらかしたこと
閉じるボタンの無効化などが簡単にできない。
→なんとかWindowsAPIを利用して対応。
//WindowsApiを宣言して閉じるボタンを無効化する
private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x80000;
[DllImport("user32.dll", SetLastError = true)]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
private void Window_ContentRendered(object sender, EventArgs e)
{
//閉じるボタンを無効化
var hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
}