#include <windows.h>
#include <winuser.h> LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("HelloWin") ;
HWND hwnd ;
MSG msg ;
WNDCLASwndclass ;
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.lpszMenuNam = 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) ;
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 ;
switch (message)
{
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) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}--------------------Configuration: hellowin - Win32 Debug--------------------
Compiling...
hellowin.c
d:\c\hellowin\hellowin\hellowin.c(19) : error C2065: 'WNDCLASwndclass' : undeclared identifier
d:\c\hellowin\hellowin\hellowin.c(22) : error C2065: 'wndclass' : undeclared identifier
d:\c\hellowin\hellowin\hellowin.c(22) : error C2224: left of '.style' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(24) : error C2224: left of '.lpfnWndProc' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(26) : error C2224: left of '.cbClsExtra' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(28) : error C2224: left of '.cbWndExtra' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(30) : error C2224: left of '.hInstance' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(32) : error C2224: left of '.hIcon' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(34) : error C2224: left of '.hCursor' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(36) : error C2224: left of '.hbrBackground' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(38) : error C2224: left of '.lpszMenuNam' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(40) : error C2224: left of '.lpszClassName' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(43) : warning C4133: 'function' : incompatible types - from 'int *' to 'const struct tagWNDCLASSA *'
Error executing cl.exe.hellowin.obj - 12 error(s), 1 warning(s)
#include <winuser.h> LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("HelloWin") ;
HWND hwnd ;
MSG msg ;
WNDCLASwndclass ;
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.lpszMenuNam = 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) ;
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 ;
switch (message)
{
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) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}--------------------Configuration: hellowin - Win32 Debug--------------------
Compiling...
hellowin.c
d:\c\hellowin\hellowin\hellowin.c(19) : error C2065: 'WNDCLASwndclass' : undeclared identifier
d:\c\hellowin\hellowin\hellowin.c(22) : error C2065: 'wndclass' : undeclared identifier
d:\c\hellowin\hellowin\hellowin.c(22) : error C2224: left of '.style' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(24) : error C2224: left of '.lpfnWndProc' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(26) : error C2224: left of '.cbClsExtra' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(28) : error C2224: left of '.cbWndExtra' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(30) : error C2224: left of '.hInstance' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(32) : error C2224: left of '.hIcon' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(34) : error C2224: left of '.hCursor' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(36) : error C2224: left of '.hbrBackground' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(38) : error C2224: left of '.lpszMenuNam' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(40) : error C2224: left of '.lpszClassName' must have struct/union type
d:\c\hellowin\hellowin\hellowin.c(43) : warning C4133: 'function' : incompatible types - from 'int *' to 'const struct tagWNDCLASSA *'
Error executing cl.exe.hellowin.obj - 12 error(s), 1 warning(s)
解决方案 »
- 如何在点击CMenu中的item时该弹出menu不消失?
- 请教:如何在CFormView中添加背景图片而不覆盖其他控件?
- 请问:怎么使clistctrl具有和excel类似的选中单元格方法?
- 要离开公司了,但也还是有点不舍!
- 有关回调函数和控制台程序的问题
- (在线等待)在使用EPSON OPOS POSPrinter ActiveX Control 开发打印程序时,怎么同时初始化、申明两台打印机
- 对同一个socket来说,完成端口可以同时提交多个操作请求吗,还是必须等上一个操作请求完成之后,再提交下一个请求?
- 一个 CListCtrl 的既显示文本又显示图标的列,我可以在运行的时候让它只显示文本吗?
- PeekMessage 和 GetMessage, SendMessage 和 PostMessage 有什么区别?
- 在ISPro中做的安装程序,如何开始就显示别的窗体?
- VC++数学函数的运算符
- 请问怎么解决用WinInet下载文件后端口无法关闭,总是处于Close_wait状态?
WNDCLASS wndclass;
Linking...
hellowin.obj : error LNK2001: unresolved external symbol __imp__DispatchMessageA@4
hellowin.obj : error LNK2001: unresolved external symbol __imp__TranslateMessage@4
hellowin.obj : error LNK2001: unresolved external symbol __imp__GetMessageA@16
hellowin.obj : error LNK2001: unresolved external symbol __imp__UpdateWindow@4
hellowin.obj : error LNK2001: unresolved external symbol __imp__ShowWindow@8
hellowin.obj : error LNK2001: unresolved external symbol __imp__CreateWindowExA@48
hellowin.obj : error LNK2001: unresolved external symbol __imp__MessageBoxA@16
hellowin.obj : error LNK2001: unresolved external symbol __imp__RegisterClassA@4
hellowin.obj : error LNK2001: unresolved external symbol __imp__GetStockObject@4
hellowin.obj : error LNK2001: unresolved external symbol __imp__LoadCursorA@8
hellowin.obj : error LNK2001: unresolved external symbol __imp__LoadIconA@8
hellowin.obj : error LNK2001: unresolved external symbol __imp__DefWindowProcA@16
hellowin.obj : error LNK2001: unresolved external symbol __imp__PostQuitMessage@4
hellowin.obj : error LNK2001: unresolved external symbol __imp__EndPaint@8
hellowin.obj : error LNK2001: unresolved external symbol __imp__DrawTextA@20
hellowin.obj : error LNK2001: unresolved external symbol __imp__GetClientRect@8
hellowin.obj : error LNK2001: unresolved external symbol __imp__BeginPaint@8
Debug/hellowin.exe : fatal error LNK1120: 17 unresolved externals
Error executing link.exe.hellowin.exe - 18 error(s), 0 warning(s)
d:\c\hellowin\hellowin\hellowin.c(19) : error C2065: 'WNDCLASwndclass' : undeclared identifier
WNDCLASwndclass 这个地方电子版少了个空格 WNDCLAS wndclass
就像有些事情一样,看上去很简单,可是做起来却不是那样!
Linking...
hellowin.obj : error LNK2001: unresolved external symbol __imp__GetStockObject@4
Debug/hellowin.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.hellowin.exe - 2 error(s), 0 warning(s)加上user32.lib了.怎么还有错误呢?
gdi.lib和wingdi.h
多谢大家.@.@