神奇好望角 The Magical Cape of Good Hope

          庸人不必自擾,智者何需千慮?
          posts - 26, comments - 50, trackbacks - 0, articles - 11
            BlogJava :: 首頁 ::  :: 聯系 :: 聚合  :: 管理
          用 NetBeans 開發一個簡單的 Windows XP 程序 - 其二 Developing A simple Windows XP Application with NetBeans - Part 2
            在項目節點上右鍵轉到“屬性 → C/C++ → C 編譯器”節點,在“命令行”中設置“其他選項”為 -mwindows;再轉到“鏈接器 → 庫”,單擊“庫”右邊的省略號按鈕,接著單擊“添加選項”,設置“其他選項”為 -lcomctl32     Right click the project node and go to "Properties → C/C++ → C Compiler" node, in "Command Line" set "Additonal Options" to -mwindows; then go to "Linker → Libraries", click the ellipsis button to the right of "Libraries", click "Add Option" and set "Other Option" to -lcomctl32.
            這時如果直接執行“生成項目”,則會輸出以下錯誤:     If we directly execute "Build Project" right now, the following errors will be complained:
          1. WinHello.c:6: error: `INITCOMMONCONTROLSEX' undeclared (first use in this function)
          2. WinHello.c:6: error: (Each undeclared identifier is reported only once
          3. WinHello.c:6: error: for each function it appears in.)
          4. WinHello.c:6: error: parse error before "init"
          5. WinHello.c:7: error: `init' undeclared (first use in this function)
          6. WinHello.c:8: error: `ICC_STANDARD_CLASSES' undeclared (first use in this function)
            結構體 INITCOMMONCONTROLSEXcommctrl.h 中聲明,commctrl.h 位于 mingw\include。打開這個頭文件,查找 INITCOMMONCONTROLSEX,發現它包含在一段預處理指令中:     Constuct INITCOMMONCONTROLSEX is decleared in commctrl.h, which is inside mingw\include. Open this header file and search INITCOMMONCONTROLSEX, and the following segment of preprocessed commands will be found:
          1. #if (_WIN32_IE >= 0x0300)
          2. typedef struct tagINITCOMMONCONTROLSEX {
          3.     DWORD dwSize;
          4.     DWORD dwICC;
          5. } INITCOMMONCONTROLSEX,*LPINITCOMMONCONTROLSEX;
          6. #endif
            再查找 _WIN32_IE,找到:     Then search _WIN32_IE and find:
          1. #if 0
          2. #define _WIN32_IE 0x0300
          3. #endif
            #if 0 表示在默認情況下,永遠不會定義 _WIN32_IE。注釋掉行 1 和行 3,再編譯,仍然出錯:     #if 0 means _WIN32_IE would never be definded by default. Comment line 1 and line 3, compile and still gets errors:
          1. WinHello.c:8: error: `ICC_STANDARD_CLASSES' undeclared (first use in this function)
          2. WinHello.c:8: error: (Each undeclared identifier is reported only once
          3. WinHello.c:8: error: for each function it appears in.)
            像上面一樣去查找 ICC_STANDARD_CLASSES,這次要把 windef.h 中的 WINVER 改為 0x0501。我覺得不必擔心改了這些會帶來什么壞處。這些變量存在的意義是定義或不定義一些 API,以便為不同版本的 Windows 開發程序。如今 Windows Vista 已經出來了,世界進步很快,有新東西為什么不用呢?     Search ICC_STANDARD_CLASSES as above, and this time modify WINVER in windef.h to 0x0501. I don't think it necessary to warry that these modifications do any thing bad. The purpose of the existance of these variables is to define some APLs or not, for the sake of developing applications for various versions of Windows. Windows Vista has been present, and the world is rapidly progressing, so why not use new things?
            現在編譯運行,不會出錯了,但風格是 9x/2000 那種老土的,這是因為默認情況下 NetBeans 不知道如何編譯 rc 文件。解決這一問題的辦法是自定義一個 Makefile。     Compile, run, and no error now, but the style is ugly as 9x/2000's, that's because by default NetBeans dosen't know how to compile rc files. The solution to this peoblem is to write a custom Makefile.
            好像差不多長了,下次繼續。     This seems long enough and is to be continued next time.

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 周口市| 康定县| 运城市| 靖边县| 常宁市| 嘉峪关市| 印江| 安龙县| 儋州市| 上思县| 长汀县| 闽清县| 新晃| 眉山市| 忻州市| 资中县| 娱乐| 乃东县| 西丰县| 铜川市| 昆山市| 澳门| 紫金县| 舞阳县| 博乐市| 太和县| 田阳县| 民和| 普陀区| 来安县| 元谋县| 阳城县| 荆州市| 湘乡市| 定南县| 衡山县| 会昌县| 泗洪县| 蛟河市| 循化| 如皋市|