News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

GUI and SetPixel

Started by zekyr, August 01, 2011, 07:57:59 AM

Previous topic - Next topic

zekyr

Hello! So I spent all weekend learning as much as I could and I really can't get enough of masm! I'm addicted even if I dont know all that much yet :)

But i had a question about how to write pixels that may change; like if i had a buffer and i wanted to change the buffer every loop and reblit it to the screen or something.



include \masm32\include\masm32rt.inc

WindowCallback PROTO :HWND, :UINT, :WPARAM, :LPARAM

.code
start:
invoke GetModuleHandle, 0
invoke DialogBoxParam, eax, 1, 0, ADDR WindowCallback, 0
invoke ExitProcess, 0

WindowCallback proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
    LOCAL hFile:HANDLE
    LOCAL hDC:HDC
    mov eax, uMsg

    .if     eax == WM_CLOSE         
         invoke EndDialog, hWnd, 0     
    .elseif eax == WM_PAINT         
         mov hDC, rv(GetDC, hWnd)
         xor    esi, esi     
         xor    edi, edi
         .while esi < 256        ;draw weird sin(x*y) == 0 looking thingie
             .while edi < 256
                 mov eax, edi
                 mul esi
                 invoke SetPixel, hDC, edi, esi, eax
                 inc    edi
              .endw
              xor edi, edi
              inc esi
         .endw         
         invoke ReleaseDC, hWnd, hDC   
    .else
        mov eax, 0
    .endif
    ret
WindowCallback endp
end start


im not too sure how to go about doing something like that. i was looking at an example with the createcompatibledc to create sort've a thing to grab graphics from then using bitblt to draw to the form but thats for static graphics isnt it? :(

qWord

hi,
You can use Get/SetDIBits to manipulate pixel data of a memory DC (CretaeCompatibleDC).
However, in your case it is much simpler to record all points in an array, which passed to Polyline().
FPU in a trice: SmplMath
It's that simple!