目前分類:把code變不cold... (3)

瀏覽方式: 標題列表 簡短摘要

今天遇到一件很見鬼的事: 隱藏視窗的 Close button

在 WPF 屬性裡居然找不到...........

 

碼的...這很簡單的視窗屬性, 

MFC有, 

但WPF居然沒有,

真的是讓我有點傻眼...

 

所以勒, 

自己動手刻一個吧!!!

 

step1: 在Window 的 Class 裡定義視窗的style, 並將 user32.dll import 進來

private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x80000;
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

 

step2: 在Window 的 Loaded 事件裡取得 window handle, 並再設回去給視窗

private void onLoad(object sender, RoutedEventArgs e)
{
       var hwnd = new WindowInteropHelper(this).Handle;
       SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
}

 

 變身前:

  close_button-e

 

變身後:

close_button-n    

 

以上!!

兩步驟, 惱人的 Close button 不見囉!!!

 

dearsoul 發表在 痞客邦 留言(1) 人氣()

 

桌面右下角, 有一排雜七雜八的小程式,

該怎樣讓我們寫好的程式, 放在工作列呢?

 

這是本週要在會議上要跟大家分享的小程式...

這次很迅速的就完成了 (果然有認真有差~~~)

呼~~~~~~~

 

dearsoul 發表在 痞客邦 留言(0) 人氣()

 

有半天的時間都在研究"比對字串和字元的方法"

結果...用個很簡單的方式就成功了...

真是去你的C++!!!!!!!!!!!!!!

 

dearsoul 發表在 痞客邦 留言(1) 人氣()