顯示具有 vb 標籤的文章。 顯示所有文章
顯示具有 vb 標籤的文章。 顯示所有文章
2010年2月20日 星期六

[程式]顯示大寫鍵是否被按下

        一般情況下,鍵盤會有燈號顯示是否為大寫輸入狀態,但我的NB為了節省空間竟然把它省略掉了。在輸入密碼一類的場合下,會帶來不小的困擾。老早就想寫個小程式來顯示,今天總算有時間來完成。這是個相當簡單的小程式,dowload IsCapital。解壓縮後,執行IsCapital即可,建議拉個捷徑到啟動底下,這樣下次開機就會自動執行。

當大寫鍵被按下時,狀態列就會出現A的圖示。









如果要關掉它,就要在大寫的狀態下,用右鍵點它選Exit即可。

2010年1月16日 星期六

[VB .NET] How to Cancel the Closing of Form

[English Ver.]
     There is a X button on top-right side of form. When user press it, will raise an closing event. Before VB .NET 2008, we can set e.cancel=true in closing event function to stop the closing process. But there's no such event function in VB .NET 2008. There is another methond to use the function. We have to refer to system.windows.presentation in References page ,and the OnClosing(byval e as system.componentmodel.canceleventargs) event function will be gernerated.  But the closing function doesn't have content. OnClosing function should be "overrides" to stop closing by setting e.cancel=true.
  
    About the development of ASSEditor, v0.6 has already done. And which remains a testing version. Main changes are to suport Janpanese and Korean ANSI encoding. Encoding-convert is a very import ability to this program. So, the user will get garbage as soon as the impropriate encoding is choosen. That is why I choose Unicode as default encoding, unless user try to change the encoding. The fewer number of ANSI file is, the less miss-coding will make.

VB .NET 如何取消(阻止) 表單關閉

在Windows的視窗中右上角有個X來讓使用者按下關閉,那麼要如何阻止表單關閉呢?在2008版之前,在closing event中可用e.cancel=true來阻止關閉行為,但在2008版的form物件並不存在closing event。然而有個onclosing event可以應用,但必須先在references中引入system.windows.presentation才會出現。因為onclosing函式是沒有內容的,所以必須用overrides覆寫,當使用者按下X後會引發onclosing event,在處理這個事件的函式中有被宣告為system.componentmodel.canceleventargs的類別e,設定e.cancel=true即可取消關閉的程序。

順便一提,ASSEditor又做了一些修改,主要是增加了日文和韓文的ANSI編碼。由於字元編碼的正確性是重點項目,所以對於不相容的編碼,ASSEditor會立即呈現出來。不像記事本,存檔前才要求使用者改以Unicode存檔。這是因為ASSEditor預設的編碼是Unicode,如果使用者不去變動自然不會有問題,但若被改用其他的ANSI編碼,就意味使用者對於編碼有一定認識。況且這樣的預設也是鼓勵使用Unicode,不再在使用傳統ANSI。對於編碼一致性有很大的幫助,減少ANSI檔案也就不用再猜它到底用何種編碼了。