windows程序中,怎么说_beginthread未定义?

sms88 2006-03-29 10:27:17
/*------------------------------------------------------------
HELLOWIN.C -- Displays "Hello, Windows 98!" in client area
(c) Charles Petzold, 1998
------------------------------------------------------------*/

#include <windows.h>
#include <process.h>
int xClient,yClient;
static HWND hWnd;
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 ;
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) ;
UpdateWindow (hwnd) ;

while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}

VOID Thread(PVOID pvoid)
{
HBRUSH hBrush;
HDC hdc;
int xLeft,xRight,yTop,yBottom,iRed,iGreed,iBlue;
while(TRUE)
{
xLeft=rand()% xClient;
xRight=rand()% xClient;
yTop=rand()% yClient;
yBottom=rand()% yClient;
iRed=rand()%255;
iGreed=rand()%255;
iBlue=rand()%255;
hdc=GetDC(hWnd);
hBrush=CreateSolidBrush(RGB(iRed,iGreed,iBlue));
SelectObject(hdc,hBrush);
Rectangle(hdc,min(xLeft,xRight),min(yTop,yBottom),
max(xLeft,xRight),max(yTop,yBottom));
ReleaseDC(hWnd,hdc);
DeleteObject(hBrush);
}
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
hWnd=hwnd;
switch (message)
{
case WM_CREATE:
_beginthread(Thread,0,NULL);
return 0 ;

case WM_SIZE:
xClient=LOWORD(lParam);
yClient=HIWORD(lParam);
return 0;

case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
...全文
178 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
tudou_nuaa 2006-03-30
  • 打赏
  • 举报
回复
需要多线程支持吧, 在Vc里面project setting 的c/c++ category中的code generation
User run-time lib 中 的多线程支持, 刚学,不足之处请指教
蒋晟 2006-03-30
  • 打赏
  • 举报
回复
Multithreaded versions of the C run-time libraries only.

To use _beginthread or _beginthreadex, the application must link with one of the multithreaded C run-time libraries.

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧