i have the following code in a form, i want to do a SetPixel on left mouse click (it must set a red pixel on 10,10). my code is the following:
if i change
.ELSEIF uMsg==WM_LBUTTONDOWN
to
.ELSEIF uMsg==WM_PAINT
my code works, but then it executes my code every time and i dont want that because its gona be bigger, is there some other way to do this? do i need to refresh my form or something before it becomes visible?
thnx, Scorpie
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL hdc:HDC
LOCAL ps:PAINTSTRUC
.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF uMsg==WM_LBUTTONDOWN
invoke BeginPaint,hWnd,ADDR ps
mov hdc, eax
invoke SetPixel,hdc,10,10,255
invoke EndPaint,hWnd,ADDR ps
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
if i change
.ELSEIF uMsg==WM_LBUTTONDOWN
to
.ELSEIF uMsg==WM_PAINT
my code works, but then it executes my code every time and i dont want that because its gona be bigger, is there some other way to do this? do i need to refresh my form or something before it becomes visible?
thnx, Scorpie
Hi....
I believe you ...i.e. I didn't do test...
But if really it doesn't work...then try to have this little change---
invoke SetPixel,ps.hdc,10,10,255
i.e. Structure PAINTSTRUC is...
I hope my help will be welcome for you...
Gerard...
----
I believe you ...i.e. I didn't do test...
But if really it doesn't work...then try to have this little change---
invoke SetPixel,ps.hdc,10,10,255
i.e. Structure PAINTSTRUC is...
PAINTSTRUCT STRUCT
hdc DWORD ?
fErase DWORD ?
rcPaint RECT <>
fRestore DWORD ?
fIncUpdate DWORD ?
rgbReserved BYTE 32 dup(?)
PAINTSTRUCT ENDS
hdc DWORD ?
fErase DWORD ?
rcPaint RECT <>
fRestore DWORD ?
fIncUpdate DWORD ?
rgbReserved BYTE 32 dup(?)
PAINTSTRUCT ENDS
I hope my help will be welcome for you...
Gerard...
----
it gives no error but so did my code, but i still cant see a pixel :(
I found...normally one has to use BeginPaint after a call of WM_PAINT ...
Then for your case....
Try to build a Dc then draw pixel then close Dc...
i.e. use following code...
Now it must corectly...I am sure I tested it...
Gerard..
-----
Then for your case....
Try to build a Dc then draw pixel then close Dc...
i.e. use following code...
.ELSEIF uMsg==WM_LBUTTONDOWN
invoke GetDC,hwnd
mov hDC,eax
invoke SetPixel,hDC,10,10,255
invoke ReleaseDC,hwnd,hDC
invoke GetDC,hwnd
mov hDC,eax
invoke SetPixel,hDC,10,10,255
invoke ReleaseDC,hwnd,hDC
Now it must corectly...I am sure I tested it...
Gerard..
-----
thnx :)
gona test it later, gota eat first now
edit: it works, kewl ty
btw i got another question, is it normal to put the painting at wm_paint instead of my methode? (and i mean even if there is some big code that is painting)
gona test it later, gota eat first now
edit: it works, kewl ty
btw i got another question, is it normal to put the painting at wm_paint instead of my methode? (and i mean even if there is some big code that is painting)
Painting your window is usually done in WM_PAINT - for normal GUI applications anyway.
Begin+EndPaint should only be used in WM_PAINT - and if you handle WM_PAINT, you really should use those two calls.
Never send a WM_PAINT message manually - use InvalidateRect API call instead.
Begin+EndPaint should only be used in WM_PAINT - and if you handle WM_PAINT, you really should use those two calls.
Never send a WM_PAINT message manually - use InvalidateRect API call instead.
so if i have a longer painting code its still better to put it in wm_paint ?