Author Topic: Updates of "dlgmaker" and "wmaker"  (Read 675 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 9749
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Updates of "dlgmaker" and "wmaker"
« on: January 17, 2022, 04:17:19 PM »
I have modernised the interfaces and code designs with both code generators , added GDI+ support for loading JPG and PNG images and in the include file, added useful macros for a number of memory assignment and allocation tasks. Both will still build competitively small executables based on fully documented Windows API functions. In both the dialog and Window creation code, these tools produce what is commonly called BOILER PLATE CODE, the basic building blocks for Windows applications.

You don't have to be limited to beginner style DDT code, once you have mastered DDT, this is the next step, expanding your DDT knowledge to write true Windows code with all of its advantages.

The macros in the include file deal with methods for LOCAL data and GLOBAL initialised and uninitialised data, as well as system based API memory allocation functions, all available via the methods that basic uses to provide LOCAL and GLOBAL data.

    MACRO FUNCTION globalstr(quoted_text,bytecount)
    MACRO FUNCTION fixedmem(bytecount)
    MACRO FUNCTION localstr(quoted_text,bytecount)
    MACRO FUNCTION localmem(bytecount)

  ' ------------------
  ' GlobalAlloc macros
  ' ------------------
    MACRO FUNCTION malloc(bcnt) = GlobalAlloc(%GMEM_FIXED or %GMEM_ZEROINIT,bcnt)
    MACRO FUNCTION msize(hMem)  = GlobalSize(hMem)
    MACRO FUNCTION mrealloc(hMem,bcnt) = GlobalReAlloc(hMem,bcnt,%GMEM_MOVEABLE or %GMEM_ZEROINIT)
    MACRO FUNCTION mfree(hMem)  = GlobalFree(hMem)

  ' ----------------
  ' HeapAlloc macros
  ' ----------------
    MACRO FUNCTION halloc(bcnt) = HeapAlloc(GetProcessHeap,%HEAP_ZERO_MEMORY,bcnt)
    MACRO FUNCTION hrealloc(hMem,bcnt) = HeapReAlloc(GetProcessHeap,%HEAP_ZERO_MEMORY,hMem,bcnt)
    MACRO FUNCTION hsize(pMem) = HeapSize(GetProcessHeap,%HEAP_NO_SERIALIZE,pMem)
    MACRO FUNCTION hfree(pMem) = HeapFree(GetProcessHeap,%HEAP_NO_SERIALIZE,pMem)

  ' -------------------
  ' VirtualAlloc macros
  ' -------------------
    DECLARE FUNCTION Virtual_Alloc LIB "Kernel32.dll" ALIAS "VirtualAlloc"( _
                     BYVAL lpAddress AS DWORD, BYVAL dwSize AS DWORD, _
                     BYVAL flAllocationType AS DWORD, BYVAL flProtect AS DWORD) AS DWORD

    DECLARE FUNCTION Virtual_Free LIB "Kernel32.dll" ALIAS "VirtualFree"( _
                     BYVAL lpAddress AS DWORD, BYVAL dwSize AS DWORD, _
                     BYVAL dwFreeType AS DWORD) AS DWORD

    MACRO MEM_COMMIT  = &H00001000
    MACRO MEM_RESERVE = &H00002000
    MACRO MEM_RELEASE = &H00008000
    MACRO PAGE_EXECUTE_READWRITE = &H40

  ' --------------------------
  ' allocate executable memory
  ' --------------------------
    MACRO FUNCTION exalloc(bcnt)
    END MACRO = Virtual_Alloc(0,bcnt,MEM_COMMIT or MEM_RESERVE,PAGE_EXECUTE_READWRITE)

    MACRO FUNCTION exfree(hmem)
    END MACRO = Virtual_Free(hmem,0,MEM_RELEASE)

As time allows, there will be more examples using both code generators.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 9749
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Updates of "dlgmaker" and "wmaker"
« Reply #1 on: January 18, 2022, 09:30:23 PM »
Two demos based from DlgMaker templates.

1. PngImage - Using GDI+ to load a PNG file as a bitmap and display in the client area.

2. A resizable window by simply changing the dialog's style to WS_OVERLAPPEDWINDOW in the resource script, "Extras.rc".
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: