修复C程序中WNDCLASSEX的错误 [英] fix an error of WNDCLASSEX in c program

查看:105
本文介绍了修复C程序中WNDCLASSEX的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建Windows应用程序,但是在使用WNDCLASSEX定义窗口时,它会显示错误.我该如何纠正它.我正在使用Borland turbo C ++ 4.5编译器,并且仅将windows.h头文件添加到其中.

I am trying to create a windows application but when using WNDCLASSEX to define the window it shows an error. how i can rectified it. I am using Borland turbo C++ 4.5 compiler and only windows.h header file is added to it.

int WINAPI WinMain(HINSTANCE hInstance,
						 HINSTANCE hPrevInstance,
						 LPSTR lpCmdLine,
						 int nCmdShow)
{
	 WNDCLASSEX wcex;

	 wcex.cbSize = sizeof(WNDCLASSEX);
	 wcex.style          = CS_HREDRAW | CS_VREDRAW;
	 wcex.lpfnWndProc    = WndProc;
	 wcex.cbClsExtra     = 0;
	 wcex.cbWndExtra     = 0;
	 wcex.hInstance      = hInstance;
	 wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
	 wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
	 wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName   = NULL;
	 wcex.lpszClassName  = szWindowClass;
	 wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
}

推荐答案

WINDCLASSEX在Windows.h中包含的WinUser.h中定义:

WINDCLASSEX is defined in WinUser.h, which is included by Windows.h:

#if(WINVER >= 0x0400)
typedef struct tagWNDCLASSEXA {
    UINT        cbSize;
    /* Win 3.x */
    UINT        style;
    WNDPROC     lpfnWndProc;
    int         cbClsExtra;
    int         cbWndExtra;
    HINSTANCE   hInstance;
    HICON       hIcon;
    HCURSOR     hCursor;
    HBRUSH      hbrBackground;
    LPCSTR      lpszMenuName;
    LPCSTR      lpszClassName;
    /* Win 4.0 */
    HICON       hIconSm;
} WNDCLASSEXA, *PWNDCLASSEXA, NEAR *NPWNDCLASSEXA, FAR *LPWNDCLASSEXA;
typedef struct tagWNDCLASSEXW {
    UINT        cbSize;
    /* Win 3.x */
    UINT        style;
    WNDPROC     lpfnWndProc;
    int         cbClsExtra;
    int         cbWndExtra;
    HINSTANCE   hInstance;
    HICON       hIcon;
    HCURSOR     hCursor;
    HBRUSH      hbrBackground;
    LPCWSTR     lpszMenuName;
    LPCWSTR     lpszClassName;
    /* Win 4.0 */
    HICON       hIconSm;
} WNDCLASSEXW, *PWNDCLASSEXW, NEAR *NPWNDCLASSEXW, FAR *LPWNDCLASSEXW;
#ifdef UNICODE
typedef WNDCLASSEXW WNDCLASSEX;
typedef PWNDCLASSEXW PWNDCLASSEX;
typedef NPWNDCLASSEXW NPWNDCLASSEX;
typedef LPWNDCLASSEXW LPWNDCLASSEX;
#else
typedef WNDCLASSEXA WNDCLASSEX;
typedef PWNDCLASSEXA PWNDCLASSEX;
typedef NPWNDCLASSEXA NPWNDCLASSEX;
typedef LPWNDCLASSEXA LPWNDCLASSEX;
#endif // UNICODE
#endif /* WINVER >= 0x0400 */

typedef struct tagWNDCLASSA {
    UINT        style;
    WNDPROC     lpfnWndProc;
    int         cbClsExtra;
    int         cbWndExtra;
    HINSTANCE   hInstance;
    HICON       hIcon;
    HCURSOR     hCursor;
    HBRUSH      hbrBackground;
    LPCSTR      lpszMenuName;
    LPCSTR      lpszClassName;
} WNDCLASSA, *PWNDCLASSA, NEAR *NPWNDCLASSA, FAR *LPWNDCLASSA;
typedef struct tagWNDCLASSW {
    UINT        style;
    WNDPROC     lpfnWndProc;
    int         cbClsExtra;
    int         cbWndExtra;
    HINSTANCE   hInstance;
    HICON       hIcon;
    HCURSOR     hCursor;
    HBRUSH      hbrBackground;
    LPCWSTR     lpszMenuName;
    LPCWSTR     lpszClassName;
} WNDCLASSW, *PWNDCLASSW, NEAR *NPWNDCLASSW, FAR *LPWNDCLASSW;
#ifdef UNICODE
typedef WNDCLASSW WNDCLASS;
typedef PWNDCLASSW PWNDCLASS;
typedef NPWNDCLASSW NPWNDCLASS;
typedef LPWNDCLASSW LPWNDCLASS;
#else
typedef WNDCLASSA WNDCLASS;
typedef PWNDCLASSA PWNDCLASS;
typedef NPWNDCLASSA NPWNDCLASS;
typedef LPWNDCLASSA LPWNDCLASS;
#endif // UNICODE



如果您根本没有定义WINVER,或者尚未定义大于0x0400的WINVER,则不会定义它.

常见的Visual Studio样板内容会为您定义WINVER(通常在stdafx.h中),但是如果您使用的是Borland编译器,则需要在某处(在包含Windows的命令行或代码中)定义WINVER. h)为了定义WINDCLASSEX.



If you haven''t defined WINVER at all, or haven''t defined it to be greater than 0x0400, then it won''t get defined.

The usual visual studio boilerplate stuff will define WINVER for you (normally in stdafx.h), but if you are using a Borland compiler you''ll need to define WINVER somewhere (on the command line or in the code prior to including windows.h) in order to get WINDCLASSEX defined.


这篇关于修复C程序中WNDCLASSEX的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆