pretty code

2014年10月26日 星期日

Autosize in wxWidgets with wxDev-C++

If you want the app to change it's layout when window is maximal, you must use sizers. There are many sizers in wxWidgets, such as wxBoxSizer, wxGridSizer and wxFlexGridSizer.

When I have two vertical parts in window and I want the bottom part is fixed size, I can use wxBoxSizer and put two panels on wxBoxSizer. Here is settings about these components.

wxBoxSizer:
Orientation is wxVertical.

wxPanel1(top):
wxALIGN_TOP is true.
wxEXPAND is true.
Stretch Factor is 1.

wxPanel2(bottom):
wxALIGN_BOTTOM is true.
wxEXPAND is true.

If you set Stretch Factor, the part will be adjusted size when window is maximal.


2014年10月19日 星期日

大法官觀後感

昨天去看了電影-大法官
覺得這部電影有很多點可以在看完後好好想想
But 人生總是會有 But ...

看完電影準備去運動時
開車由建國高架往南
剛從南京上閘道後就被後面一台小車撞到
我前面因為有車要下建國
當時我的車已踩煞車
幾乎是快停止的狀態
居然也能被撞到
不知道駕駛當時在想什麼

不過最白吃的還是我本人
當時看一下以為只撞到保險桿
就叫他開車要小心點
換來一句謝謝後就離開

開到公園後
下車仔細看看
才發現左輪上方板金受損
輪圈受損
保險桿也受損
害我一整個心情不好

幸好熟悉的輪胎行晚上有營業
晚上花了 7000 換掉 4 個輪圈
輪胎因為沒事故不用換掉
不然至少還要換掉 2 個才能平衡
再加上板金
我想這次被撞沒花個一萬塊跑不掉

那位大哥
遇到我是你運氣好
請你下次好好小心開車
車上還載著家人
為什麼不更小心點

可憐我的小白


2014年10月18日 星期六

How to catch windows message in wxWidgets

1. Add define in your header file.

WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);

2. Add implement in your cpp file.

WXLRESULT XXX::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
    switch(message)
    {
        case WM_KEY:
            break;
        default:
            break;
    }  
 
    return ZZZ::MSWWindowProc(message, wParam, lParam);
 }

XXX is your class name and ZZZ is the base class that you derive.

3. You can catch the windows message what you want now.

2014年10月10日 星期五

Update wxWidgets' libs in wxDev-C++

Because the wxWidgets's version is 2.9.3 in wxDev-C++, I want to use the new version, this is the steps how to do:

My wxDev-C++'s installing path is "C:\wxDev-Cpp".

1. Download the wxWidget's source and unzip to C:\wxWidgets.
2. Open cmd window and type "set path=C:\wxDev-Cpp\MinGW32\bin". Then "cd wxWidgets\build\msw".
3. Type "mingw32-make -f makefile.gcc UNICODE=1 SHARED=0 BUILD=release MONOLITHIC=1".
4. After compiling it, copy "C:\wxWidgets\lib\gcc_lib\*.a" to C:\wxDev-Cpp\lib\wx\gcc_lib".
5. Replace "C:\wxDev-Cpp\include\common" from "C:\wxWidgets\include".
6. Copy "C:\wxWidgets\lib\gcc_lib\mswu\wx\setup.h" to "C:\wxDev-Cpp\include\common\wx".
7. Change wxWidgets's version in wxDev-C++ -> Tools -> Compiler Options -> Version info.
8. Before you compile old project, remember to del all *.o in "project\Objects\MingW".
9. Enjoy it.

2014年8月15日 星期五

Ubuntu 啟動相關檔案

/etc/init.d/xxxxx
啟動 script 放置處

/etc/rcx.d/
啟動 level 對應的服務 script, 由系統產生

為了避免影響其他服務
開機想要自動執行的
可以寫在 /etc/rc.local


2014年7月16日 星期三

cmd 指定路徑

cmd /K "cd /d D:\PathName"

只要在批次檔用此語法
便可以開啟一個指定路徑的 DOS 視窗
在 XP 應該蠻有用的

如果是 Win7 以上
只要在資料夾按下 Shift + 滑鼠右鍵
便可以開啟該路徑的 DOS 視窗

2014年7月5日 星期六

自然人憑證解鎖 6981 錯誤

不管是使用 HiCOS 或是 MOICA 網站上的解鎖功能
如果出現 6981 的錯誤代碼
請先檢查是否使用有鍵盤的讀卡機
據客服說法是因為解鎖時程序被有鍵盤的讀卡機擋下所致
此問題只能找讀卡機廠商解決

感覺這個問題不太好解
廠商回了一次電話後就沒有下文

最快的解決之道就是找人借一個普通的讀卡機
終於我又有自然人憑證可用了

另外如果像我是使用 Win8 64 的人
如果有遇到安裝讀卡機驅動失敗的情形
請先記得將讀卡機拔掉
安裝程序便能順利安裝成功