The MASM Forum
General => The Workshop => Topic started by: zedd151 on September 21, 2022, 03:59:58 AM
-
I think I've got this coded correctly... :biggrin:
.elseif uMsg == WM_PAINT
invoke BeginPaint, hWin, addr ps
mov hDC, eax
invoke CreateCompatibleDC, hDC
mov mDC, eax
invoke CreateCompatibleBitmap, hDC, cwidth, cheight
mov hBmp, eax
invoke SelectObject, mDC, hBmp
mov hOld, eax
;; this is the part that I usually miss... :P
invoke BitBlt, mDC, 0, 0, cwidth, cheight, hDC, 0, 0, SRCCOPY
;; drawing functions called here
;; ----------------------------
invoke FillRect, mDC, addr back_rect, hBlackBr ;; draw grid background
invoke FillRect, mDC, addr innr_rect, hWhiteBr ;; used only for demo
;; ----------------------------
invoke BitBlt, hDC, 0, 0, cwidth, cheight, mDC, 0, 0, SRCCOPY
invoke DeleteObject, hBmp
invoke SelectObject, mDC, hOld
invoke DeleteDC, mDC
invoke EndPaint, hWin, addr ps
I usually miss a detail :rolleyes: here in WM_PAINT but I think I've nailed it here. :cool: If I've missed any steps, lemme know.
edit = change the attachment gdi bug, now fixed
-
I prefer to keep WM_PAINT minimal, so only BitBlt bitmap and update bitmap outside WM_PAINT
-
I prefer to keep WM_PAINT minimal
Me too, and WndProc in general as well. The code example posted was only for others to verify that I had not missed any steps in WM_PAINT.
so only BitBlt bitmap and update bitmap outside WM_PAINT
Good plan.
But attaching C code? :tongue: NoCforMeEither lol.
Luckily translation from C to ASM not so difficult. I got the gist of what the code was doing, and I checked in olly to be sure.
-
Luckily translation from C to ASM not so difficult.
C--> ASM not hard at all. C++ difficult or impossible (without a set of "flat" functions).
-
The original test piece was flawed. Must have been a copy/paste (variable) error on my part. jj discovered the gdi leak bug in the sudoku thread. Good thing it was found, as this would have been the basis for my Basic Window template code. (without the sudoku related code of course, but including the base WM_PAINT code) If that happened it would have propagated through my next ??? number of projects. :toothy: Thanks, jj
-
Some info
http://winprog.org/tutorial/bitmaps.html