Author Topic: GDI base rectangle algo.  (Read 65 times)


  • Administrator
  • Member
  • ******
  • Posts: 6857
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
GDI base rectangle algo.
« on: January 12, 2020, 03:58:40 AM »
While old GDI is not much use with complex shapes or animation, it does simple things very economically. The following algo does either plain filed rectangles or alternately a filled rectangle with a different coloured border of use defined width. As normal an algo of this type must be called from within a WM_PAINT message something like the following snippet.

      .case WM_PAINT
        rcall BeginPaint,hWin,ptr$(ps)
        invoke FilledRct,hWin,200,95,600,200,000000FFh,000000FFh,2
        rcall EndPaint,hWin,ptr$(ps)

The algorithm.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

 FilledRct proc hndl:QWORD,tx:QWORD,ty:QWORD,wd:QWORD,ht:QWORD,FillCol:QWORD,PenCol:QWORD,PenWid:QWORD

    LOCAL hPen  :QWORD
    LOCAL hOld  :QWORD
    LOCAL hBrsh :QWORD
    LOCAL oldbr :QWORD

    LOCAL rWid  :QWORD
    LOCAL rHgt  :QWORD

    mov rax, tx
    add rax, wd
    mov rWid, rax

    mov rax, ty
    add rax, ht
    mov rHgt, rax

    mov hDC,  rvcall(GetDC,hndl)
    mov hPen, rvcall(CreatePen,PS_SOLID,PenWid,PenCol)
    mov hOld, rvcall(SelectObject,hDC,hPen)

    mov lbCol.lbStyle, BS_SOLID
    mov rax,  FillCol
    mov lbCol.lbColor, eax
    mov lbCol.lbHatch, 0

    mov hBrsh, rvcall(CreateBrushIndirect,ptr$(lbCol))
    mov oldbr, rvcall(SelectObject,hDC,hBrsh)

    invoke Rectangle,hDC,tx,ty,rWid,rHgt

    rcall SelectObject,hDC,oldbr
    rcall SelectObject,hDC,hOld
    rcall DeleteObject,hBrsh
    rcall DeleteObject,hPen
    rcall ReleaseDC,hDC


 FilledRct endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
hutch at movsd dot com    :biggrin:  :skrewy: