hwnd = CreateWindow (szAppName, // window class name TEXT ("The Hello Program"), // window caption WS_OVERLAPPEDWINDOW, // window style CW_USEDEFAULT, // initial x position CW_USEDEFAULT, // initial y position CW_USEDEFAULT, // initial x size CW_USEDEFAULT, // initial y size NULL, // parent window handle NULL, // window menu handle hInstance, // program instance handle NULL) ; // creation parameters
BOOL TRUE FALSEFALSE == false 都是0
TRUE != true,
一个是1,一个是-1(FFFFFFFF)
bool sss=true 或bool=-1还是会出错啊!
D:\VC++原代码\Chap03\HelloWin\Hellowin.c(64) : error C2065: 'bool' : undeclared identifier
D:\VC++原代码\Chap03\HelloWin\Hellowin.c(64) : error C2146: syntax error : missing ';' before identifier 'dffdsf'
D:\VC++原代码\Chap03\HelloWin\Hellowin.c(64) : error C2065: 'dffdsf' : undeclared identifier
Error executing cl.exe.
PAINTSTRUCT ps ;
RECT rect ;
bool dffdsf=-1 ; switch (message)
{
case WM_CREATE:D:\VC++原代码\Chap03\HelloWin\Hellowin.c(64) : error C2065: 'bool' : undeclared identifier
D:\VC++原代码\Chap03\HelloWin\Hellowin.c(64) : error C2146: syntax error : missing ';' before identifier 'dffdsf'
D:\VC++原代码\Chap03\HelloWin\Hellowin.c(64) : error C2065: 'dffdsf' : undeclared identifier
================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★ 浏览帖子速度极快![建议系统使用ie5.5以上]。 ★ 多种帖子实现界面。
★ 保存帖子到本地[html格式]★ 监视您关注帖子的回复更新。
★ 可以直接发贴、回复帖子★ 采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录!
★ 支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名 ●
可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
Http://www.ChinaOK.net/csdn/csdn.rar
Http://www.ChinaOK.net/csdn/csdn.exe [自解压]
#define false 0
#define ture 1
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("HelloWin") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ; wndclass.style = CS_HREDRAW |CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow (szAppName, // window class name
TEXT ("The Hello Program"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
ShowWindow (hwnd, iCmdShow) ;
//ShowWindow (hwnd, SW_SHOWMAXIMIZED) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
bool dffdsf=-1 ; switch (message)
{
case WM_CREATE:
if (PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ){
// MessageBox(hwnd,TEXT("DD"),TEXT("ss"),MB_OK);
}
// ShowWindow(hwnd,SW_SHOWMAXIMIZED);
return 0 ;
case WM_SIZE:
//MessageBox(hwnd,TEXT("DD"),TEXT("ss"),MB_OK);
return 0;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
GetClientRect (hwnd, &rect) ;
DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
EndPaint (hwnd, &ps) ;
// MessageBox(hwnd,TEXT("DD"),TEXT("ss"),MB_OK);
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}出错信息如下:
--------------------Configuration: HelloWin - Win32 Debug--------------------
Compiling...
Hellowin.c
D:\VC++原代码\Chap03\HelloWin\Hellowin.c(65) : error C2065: 'bool' : undeclared identifier
D:\VC++原代码\Chap03\HelloWin\Hellowin.c(65) : error C2146: syntax error : missing ';' before identifier 'dffdsf'
D:\VC++原代码\Chap03\HelloWin\Hellowin.c(65) : error C2065: 'dffdsf' : undeclared identifier
Error executing cl.exe.HelloWin.exe - 3 error(s), 0 warning(s)
毕竟两者还是有点区别的啊~~~
BOOL 0,1[FALSE,TRUE]
没有 bool 这个数据类型吧!
BOOL是MFC中定义的:
typedef int BOOL;
其实BOOL是int型的数据,它有TRUE(1)和FALSE(0)两个值