|
-
Feb 19th, 2002, 02:57 PM
#1
Thread Starter
Addicted Member
Eliminating Paint Without A Hit
How do I get rid of the WM_PAINT method? I have a multithread app that has one thread painting the window and another (the win main) doing all the back end work, so I need to remove the begin paint and end paint, but whenever I pull them out of the application the processor gets maxed out, I have included a WALP I wrote, does anyone know how to safely remove the WM_PAINT?
things I have tried:
WM_PAINT return(0);
WM_PAINT:
BeginPaint(0,0);
EndPaint(0,0);
return(0);
Removing it all together (WM_PAINT) forces windows to handle the paint and I get nothing at all.
<code>
#include <windows.h>
/* function prototypes */
LRESULT CALLBACK WindowProc (HWND, UINT, WPARAM, LPARAM);
char szAppName[] = "Skeleton";
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR lpszCmdLine, int nCmdShow){
HWND hwnd; /* handle of client area */
MSG msg; /* messages (i.e., user activity) */
WNDCLASSEX wndclass; /* window class to create */
/* register class, unless previously registered */
if (!hPrevInstance) {
wndclass.cbSize = sizeof (wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WindowProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = 0;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = 0;
wndclass.lpszClassName = szAppName;
wndclass.hIconSm = NULL;
RegisterClassEx (&wndclass);
}
hwnd = CreateWindow (szAppName, "Skeleton Windows Program",
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,NULL, NULL, hInstance, NULL);
ShowWindow (hwnd, nCmdShow);
UpdateWindow (hwnd);
/* event loop */
while (GetMessage (&msg, NULL, 0, 0)) {
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
/* Window procedure for client area */
LRESULT CALLBACK WindowProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HINSTANCE hInstance; /* same as instance in WinMain() */
HDC hDC; /* handle to device context -- allows screen output */
PAINTSTRUCT ps; /* not really "used" (yet), but required anyway */
RECT rect; /* size of client area */
RECT gradiant;
switch (message) {
case WM_CREATE:
return (0);
case WM_PAINT:
BeginPaint (0, 0);
EndPaint (0, 0);
return 0;
case WM_DESTROY :
PostQuitMessage (0);
return 0;
}
return DefWindowProc (hwnd, message, wParam, lParam);
}
</code>
-
Feb 19th, 2002, 05:17 PM
#2
Add a ValidateRect(hwnd, NULL); to the WM_PAINT handler.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 20th, 2002, 02:06 AM
#3
Thread Starter
Addicted Member
thanks
hey thanks that worked great, I was scratching my head for a while on that one!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|