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.