标题:编译生成exe文件运行cpu 占用率100%????,任务管理器进程不能结束?消息死循 ...
取消只看楼主
whyan
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2008-10-4
 问题点数:0 回复次数:3 
编译生成exe文件运行cpu 占用率100%????,任务管理器进程不能结束?消息死循环吗?
我是vc++菜鸟,写windows程序时,编译生成exe文件运行cpu 占用率100%????
我是vc++菜鸟,写windows程序时,编译生成exe文件运行cpu 占用率100%????

#include "windows.h"
#include "stdio.h"
#include "string.h"

LRESULT CALLBACK WinProc(HWND hWnd,UINT Message,WPARAM wParam,LPARAM lParam);


int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
        {
            HWND hWnd;
            MSG Message;
            WNDCLASS WndClass;
            WndClass.hInstance=hInstance;
            WndClass.lpfnWndProc=WinProc;
            WndClass.lpszClassName="whyan";
            WndClass.lpszMenuName=NULL;
            WndClass.style=0;
            WndClass.cbClsExtra=0;
            WndClass.cbWndExtra=0;
            WndClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
            WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
            WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
            RegisterClass(&WndClass);

            hWnd=CreateWindow("whyan","whyan",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
            ShowWindow(hWnd,SW_SHOWNORMAL);
            UpdateWindow(hWnd);

            while(GetMessage(&Message,hWnd,0,0))
            {
                TranslateMessage(&Message);
                DispatchMessage(&Message);
            }
            return Message.wParam;
        }

LRESULT CALLBACK WinProc(HWND hWnd,UINT Message,WPARAM wParam,LPARAM lParam)
        {
            HDC hdc;
            HBRUSH hbrush;
            HPEN pen;
            PAINTSTRUCT pstr;
               
            switch (Message)
            {
            case WM_PAINT:
                hdc=BeginPaint(hWnd,&pstr);
                SetMapMode(hdc,MM_ANISOTROPIC);
                pen=(HPEN)GetStockObject(BLACK_PEN);
                hbrush=(HBRUSH)GetStockObject(DKGRAY_BRUSH);
                SelectObject(hdc,hbrush);
                SelectObject(hdc,pen);
                RoundRect(hdc,50,120,100,200,15,15);
                EndPaint(hWnd,&pstr);
            case WM_DESTROY:
                PostQuitMessage(0);
               
            default:
                return(DefWindowProc(hWnd,Message,wParam,lParam));
            }
            //return 0;
        }
搜索更多相关主题的帖子: cpu 管理器 exe 任务 进程 
2008-10-05 11:11
whyan
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2008-10-4
得分:0 
高手就是高手
谢谢指导,请问你有QQ吗,想拜你为师,以后多多指导!!
2008-10-05 13:26
whyan
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2008-10-4
得分:0 
你有没有QQ?网海无边,知音难求?交个朋友好吗?
你有没有QQ?网海无边,知音难求?交个朋友好吗?
2008-10-05 20:49
whyan
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2008-10-4
得分:0 
你跟我回复的菜单是什么意思,不是很懂!解释下行吗?
wc.lpszMenuName     = MAKEINTRESOURCE(LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU)));
2008-10-05 20:52



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-236442-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.425796 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved