Can anyone help me with this code problem. I am responding to the WM_PAINT message to initialize my window with a black background. The problem is that everytime a WM_PAINT message is sent ....( like when you move the cursor over the close button).....the code gets processed again. It doesn't interfere with the window functioning but why have code thats an artery clogger. There must be a better way to initialize the window without responding to WM_PAINT....
I havr tried to initialize the window in WM_CREATE but then only the caption bar appears.


message loop:
-------------------------------------------------------------------------------
.ELSEIF uMsg==WM_PAINT
invoke BeginPaint,hWnd,ADDR ps
mov hdc,eax
invoke GetClientRect,hWnd,ADDR rect
call LAP
invoke EndPaint,hWnd,ADDR ps

__________________________________________________________________________________________

lap proc hWnd

invoke CreateCompatibleBitmap,hdc,rect.right,rect.bottom
mov hbmp,eax
invoke SelectObject,cdc,hbmp
invoke SelectObject,cdc,mypen
invoke CreateSolidBrush,0h
mov mybrush,eax
invoke SelectObject,cdc,mybrush
invoke Rectangle,cdc,rect.left,rect.top,rect.right,rect.bottom

invoke BitBlt,hdc,rect.left,rect.top,rect.right,rect.bottom,cdc,rect.left,1,SRCCOPY

invoke DeleteObject,hbmp
invoke DeleteObject,mypen
invoke DeleteObject,mybrush


xor eax,eax

ret 0
LAP endp



:confused:
Posted on 2001-08-30 19:18:58 by titan
I dont play around with this stuff to much... but when you create your window, in the WNDCLASSEX structure:
typedef struct _WNDCLASSEX { // wc

UINT cbSize;
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HANDLE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;
HICON hIconSm;
} WNDCLASSEX;

The hbrBackground can be set to a brush color of your choice... This will get around dealing with the WM_PAINT message entirely...

When the class structure is being filled try something like this:



invoke CreateSolidBrush, Green
mov wc.hbrBackground, eax


Like i said, im not a master of the GDI but i think this should work for you...

Hope it helps..
:alright:
NaN
Posted on 2001-08-30 19:30:58 by NaN
Thanks NAN

Got rid of a lot of code and realized how poorly i was writing it.


A newbie is a newbie:alright:
Posted on 2001-08-30 22:18:32 by titan
We have all done it, its the only way to truely learn..

Happy coding..

NaN
Posted on 2001-08-30 23:41:06 by NaN