神奇好望角 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.

只有注册用户登录后才能发表评论。


网站导航: