高手指点!关于进程关闭的问题?分不够,可以加啊!! 我用api编了个显示bmp位图的程序,然后,再在主窗口和子窗口中都显示同一个位图,为什么我的程序关闭之后,进程没有关闭,而且占cpu利用率特别大?请问,这是那出来问题?怎么解决?多谢,帮忙!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你是用VC编的吧?你是不是把LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM IParam)函数中的case WM_DESTROY:PostQuitMessage(0);这一句删除了? 下面是主窗口和子窗口的消息处理函数,高手指点一下啊!功能是点击主窗口的某个菜单(fanshe或xuanzhuan)创建并显示一个子窗口。LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; //TCHAR szHello[MAX_LOADSTRING]; //TCHAR szOk[MAX_LOADSTRING]; //LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); //LoadString(hInst, IDS_OK, szOk, MAX_LOADSTRING); switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_EXIT: delete cr; DestroyWindow(hWnd); break; case fanshe://自定义的菜单id case xuanzhuan:自定义的菜单id if (hWndchild == NULL ) { RECT rt; GetClientRect (hWnd, &rt); hWndchild = CreateWindow ( szchild, "ChildBitmap", WS_CHILDWINDOW | WS_VISIBLE | WS_CAPTION | WS_SYSMENU, 10,10, 3 * rt.right / 4, 3 * rt.bottom / 4, hWnd,NULL, hInst, NULL); break; } return (DefWindowProc(hWnd,message,wParam,lParam)); //MessageBox ( hWnd, "lsfj","lsj",MB_OK); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... RECT rt; GetClientRect(hWnd, &rt); DrawBitmap (hdc, hWnd); EndPaint(hWnd,&ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0;}LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; //TCHAR szHello[MAX_LOADSTRING]; //TCHAR szOk[MAX_LOADSTRING]; //LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); //LoadString(hInst, IDS_OK, szOk, MAX_LOADSTRING); switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWndchild, (DLGPROC)About); break; case IDM_EXIT: hWndchild = NULL; DestroyWindow(hWndchild); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... RECT rt; GetClientRect(hWndchild, &rt); ChuliBitmap (hdc, hWnd); EndPaint(hWndchild,&ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0;} 用SDK编程,消息循环是自己控制的,不知你是怎么传递WM_EXIT命令消息的,从上面看,如果命令消息传递到hWnd里,则hWndChild是得不到的。建议解决办法,试一下:主窗口里: case IDM_EXIT: delete cr; DestroyWindow(hWndChild);//加上。 DestroyWindow(hWnd); break; 设置鼠标的问题 函数拦截出现问题 VC/MFC-----模拟鼠标键盘 请问为啥msdn上VC2005的Sample Application不能Build呢 WinSocket应用的问题 即将离校,发帖咨询 刚开始学MFC,请各位进来看下,帮我 在程序里面怎么得到“虚拟专用连接”或者拨号连接 多文档程序 SDK,如何使主窗口居中显示? 如何得到软驱是否存在及其型号 一个简单浏览器开发问题,急用。。帮帮忙。。。。
你是不是把LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM IParam)函数中的case WM_DESTROY:PostQuitMessage(0);这一句删除了?
功能是点击主窗口的某个菜单(fanshe或xuanzhuan)创建并显示一个子窗口。
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc; //TCHAR szHello[MAX_LOADSTRING];
//TCHAR szOk[MAX_LOADSTRING];
//LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
//LoadString(hInst, IDS_OK, szOk, MAX_LOADSTRING);
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
delete cr;
DestroyWindow(hWnd);
break;
case fanshe://自定义的菜单id
case xuanzhuan:自定义的菜单id
if (hWndchild == NULL )
{
RECT rt;
GetClientRect (hWnd, &rt);
hWndchild = CreateWindow (
szchild,
"ChildBitmap",
WS_CHILDWINDOW | WS_VISIBLE | WS_CAPTION | WS_SYSMENU,
10,10,
3 * rt.right / 4,
3 * rt.bottom / 4,
hWnd,NULL,
hInst, NULL);
break;
}
return (DefWindowProc(hWnd,message,wParam,lParam));
//MessageBox ( hWnd, "lsfj","lsj",MB_OK);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
DrawBitmap (hdc, hWnd); EndPaint(hWnd,&ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc; //TCHAR szHello[MAX_LOADSTRING];
//TCHAR szOk[MAX_LOADSTRING];
//LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
//LoadString(hInst, IDS_OK, szOk, MAX_LOADSTRING);
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWndchild, (DLGPROC)About);
break;
case IDM_EXIT:
hWndchild = NULL;
DestroyWindow(hWndchild);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWndchild, &rt);
ChuliBitmap (hdc, hWnd); EndPaint(hWndchild,&ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
建议解决办法,试一下:
主窗口里:
case IDM_EXIT:
delete cr;
DestroyWindow(hWndChild);//加上。
DestroyWindow(hWnd);
break;