Page 1 of 1

100% CPU Usage normal?

PostPosted: Sep 10, 2001 @ 9:03pm
by Avatar

Re: 100% CPU Usage normal?

PostPosted: Sep 10, 2001 @ 11:18pm
by Dan East

Re: 100% CPU Usage normal?

PostPosted: Sep 10, 2001 @ 11:21pm
by Dan East
To make your app fullscreen, and hide the SIP button, etc., do the following whenever you receive a WM_ACTIVATE message when your app is gaining activation:<br>[fixed]<br>SHFullScreen(hWnd, SHFS_HIDETASKBAR|SHFS_HIDESIPBUTTON);<br>MoveWindow(hWnd, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), TRUE);<br>[/fixed]<br><br>Dan East

Re: 100% CPU Usage normal?

PostPosted: Sep 11, 2001 @ 1:55am
by Digby
You shouldn't need the Sleep() call to yield.  GetMessage() will block when there are no more messages to process and the OS scheduler should switch to another process if one is waiting to run.  You might have something screwed up in your WndProc, or if you have a timer running that is generating messages GetMessage will never block.<br><br>How are you determining the current CPU usage?<br><br>

Re: 100% CPU Usage normal?

PostPosted: Sep 13, 2001 @ 2:26am
by Avatar
Thanks for the help.<br>First problem (100% CPU) was fixed by remarking of the empty 'case WM_PAINT' (well, it's empty @ the moment), though Sleep(x) also worked. Programmers take notice - never leave empty WM_PAINT case! Or you will be wasting CPU without reason.<br>Second question (full screen) was fixed w/ those 2 API calls. Thanks again.<br><br>BTW, any idea as to why an empty case statement (and yes, it did have break in it) would cause the CPU to go to 100%?<br><br>And as to how I measured the CPU usage - task manager on win2k ;)

Re: 100% CPU Usage normal?

PostPosted: Sep 13, 2001 @ 10:08am
by Dan East
You must call BeginPaint and EndPaint if you handle a WM_PAINT message. Windows will send your app a WM_PAINT if your window's update region is not empty (which indicates which portions of your window need to be redrawn). BeginPaint / EndPaint clears the update region, so Windows will not call WM_PAINT again unless part of the window needs to be redrawn, or you explicitly call RedrawWindow, etc. You can also use ValidateRect to validate your Window's entire client area to prevent more WM_PAINT messages. However, if you don't ever paint in WM_PAINT, then don't even handle the message. <br><br>Dan East

Re: 100% CPU Usage normal?

PostPosted: Sep 13, 2001 @ 5:30pm
by RICoder
Have you considered peekmessage instead of getmessage?

Re: 100% CPU Usage normal?

PostPosted: Sep 13, 2001 @ 7:21pm
by Digby
>>And as to how I measured the CPU usage - task manager on win2k  <br><br>Duh.  I knew about that.  I was under the impression that you were running your app on a Pocket PC and had some way to get the CPU usage.<br><br>

Re: 100% CPU Usage normal?

PostPosted: Sep 13, 2001 @ 7:54pm
by Avatar

Re: 100% CPU Usage normal?

PostPosted: Sep 13, 2001 @ 7:56pm
by Avatar

Re: 100% CPU Usage normal?

PostPosted: Sep 13, 2001 @ 8:21pm
by Moose or Chuck

Re: 100% CPU Usage normal?

PostPosted: Sep 13, 2001 @ 11:57pm
by Digby

Re: 100% CPU Usage normal?

PostPosted: Sep 14, 2001 @ 10:51am
by Dan East