主题:[讨论]一个很郁闷的问题
[code=c]
请填写代码
//请帮我看看下面一段程序
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK WindowxProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS wncls;
wncls.cbClsExtra=0;
wncls.cbWndExtra=0;
wncls.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);
wncls.hCursor=LoadCursor(NULL,IDC_ARROW);
wncls.hIcon=LoadIcon(NULL,IDI_ERROR);
wncls.hInstance=hInstance;
wncls.lpfnWndProc=WindowxProc;
wncls.lpszClassName="xiaohei";
wncls.lpszMenuName=NULL;
wncls.style=CS_HREDRAW|CS_VREDRAW;
RegisterClass(&wncls);
HWND hwnd;
hwnd=CreateWindow("xiaohei","威信",WS_OVERLAPPEDWINDOW,
20,50,600,300,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_NORMAL);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowxProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch (uMsg)
{
case WM_CHAR:
char szchar[20];
sprintf(szchar,"the chars is %d",wParam);
MessageBox(hwnd,szchar,"键盘消息!",NULL);
break;
case WM_LBUTTONDOWN:
HDC hdc;
MessageBox(hwnd,"鼠标按下","xiaohei123",NULL);
hdc=GetDC(hwnd);
TextOut(hdc,60,150,"小河向东流!",strlen("小河向东流!"));
ReleaseDC(hwnd,hdc);
break;
case WM_RBUTTONDOWN:
MessageBox(hwnd,"右键按下!","xiaohei123",0);
hdc=GetDC(hwnd);
TextOut(hdc,100,250,"你好呀!",strlen("你好呀!"));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
PAINTSTRUCT ps;
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,100,200,"小黑来了!",strlen("小黑来了!"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if (IDYES==MessageBox(hwnd,"是否要关闭窗口?","xiaohei123",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
//在编译和链接以及运行的时候没啥问题,就是是关闭了窗口,
这个程序的进程仍然没有关闭,请问是怎么回事呀?
[/code][code=c]
请填写代码
[/code][code=c]
请填写代码
[/code]
请填写代码
//请帮我看看下面一段程序
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK WindowxProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS wncls;
wncls.cbClsExtra=0;
wncls.cbWndExtra=0;
wncls.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);
wncls.hCursor=LoadCursor(NULL,IDC_ARROW);
wncls.hIcon=LoadIcon(NULL,IDI_ERROR);
wncls.hInstance=hInstance;
wncls.lpfnWndProc=WindowxProc;
wncls.lpszClassName="xiaohei";
wncls.lpszMenuName=NULL;
wncls.style=CS_HREDRAW|CS_VREDRAW;
RegisterClass(&wncls);
HWND hwnd;
hwnd=CreateWindow("xiaohei","威信",WS_OVERLAPPEDWINDOW,
20,50,600,300,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_NORMAL);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowxProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch (uMsg)
{
case WM_CHAR:
char szchar[20];
sprintf(szchar,"the chars is %d",wParam);
MessageBox(hwnd,szchar,"键盘消息!",NULL);
break;
case WM_LBUTTONDOWN:
HDC hdc;
MessageBox(hwnd,"鼠标按下","xiaohei123",NULL);
hdc=GetDC(hwnd);
TextOut(hdc,60,150,"小河向东流!",strlen("小河向东流!"));
ReleaseDC(hwnd,hdc);
break;
case WM_RBUTTONDOWN:
MessageBox(hwnd,"右键按下!","xiaohei123",0);
hdc=GetDC(hwnd);
TextOut(hdc,100,250,"你好呀!",strlen("你好呀!"));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
PAINTSTRUCT ps;
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,100,200,"小黑来了!",strlen("小黑来了!"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if (IDYES==MessageBox(hwnd,"是否要关闭窗口?","xiaohei123",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
//在编译和链接以及运行的时候没啥问题,就是是关闭了窗口,
这个程序的进程仍然没有关闭,请问是怎么回事呀?
[/code][code=c]
请填写代码
[/code][code=c]
请填写代码
[/code]