In-Memory Dialogs

Started by MichaelW, August 09, 2008, 09:08:37 PM

Previous topic - Next topic

MichaelW

I decided to stop and post this before it turned into a career. My original idea was to create a more beginner-friendly version of the MASM32 in-memory dialogs, and then create a bunch of small, single-file demos each of which focused on some relatively narrow area of Windows GUI programming. I started out intending to avoid macros and the MASM high-level syntax altogether, but I soon realized that the extra code required to do this was going to more or less obscure the GUI programming that I was trying to demonstrate. So I changed directions and started using macros and the MASM high-level syntax basically everywhere I could, but I still stuck with my decision to use procedures instead of macros to create the dialog templates. I ended up with 27 files total and 17 demos, with the demos ranging in size from 63 lines to 324 lines, including the headers, comments, blank lines, etc.

BTW, I am aware that there are some inconsistencies in the coding style and commenting, and that some things that should be commented have not been, and that there are probably some bugs that I failed to find. These problems are an unfortunate byproduct of having too much to do and too little time to do it.

[attachment deleted by admin]
eschew obfuscation

Biterider

Congrats, very nice work! Very clear and full of usefull things!  :U

Regards,

Biterider

Vortex

Very nice work. Thanks Michael.

PBrennick

Micheal,
Vortex and I are working on a patch to the GeneSys SDK with a release goal of sometime next week. Are you willing to consider allowing us to add this (with proper credits, of course)?

Also, is this yours and can I add it?



        .486                            ; Create 32 bit code
        .model  flat, stdcall           ; 32 bit memory model
        option  casemap :none           ; case sensitive

        include \masm32\include\windows.inc
        include \masm32\macros\macros.asm
        include \masm32\include\kernel32.inc
        include \masm32\include\masm32.inc
        include \masm32\include\user32.inc

        includelib  \masm32\lib\kernel32.lib
        includelib  \masm32\lib\masm32.lib
        includelib  \masm32\lib\user32.lib


.const

.data

.data?

.code

Start:  invoke  SetPriorityClass, FUNC(GetCurrentProcess), REALTIME_PRIORITY_CLASS
        invoke  GetTickCount
        push    eax

        ; ---------------------
        ; Run your code here
        ; ---------------------

        invoke  GetTickCount
        pop     ecx
        sub     eax, ecx
        fn      MessageBox, hWnd, str$(eax), str$(rcnt), MB_OK
        invoke  SetPriorityClass, FUNC(GetCurrentProcess), NORMAL_PRIORITY_CLASS
        mov     eax, input(13, 10, "Press enter to exit...")
        exit

        end     Start


If it is, can we add it , with credit?

-- Paul
The GeneSys Project is available from:
The Repository or My crappy website

MichaelW

Hi Paul, you can do anything you wish with anything I have posted. I don't recall that particular code, but I have doubts that it is mine because I generally avoid placing labels on a line with other code. Also, I think REALTIME_PRIORITY_CLASS is not suitable for a beginner trying to time code that may have serious bugs, because under some conditions it could cause Windows to crash. HIGH_PRIORITY_CLASS would be a safer alternative.

What sort of patch?
eschew obfuscation

PBrennick

Michael,

First of all, this is more the type of thing that you know about than I. Would you rewrite that code as YOU think it ought to be? It will be added to the editor, not sure where but that is something that may be useful.

About the patch, I am writing an installable update for the GeneSys SDK as Vortex has a lot of new stuff as well as I and the editor needs updating. Pelle's tools need updating and we are adding Japheth's tools so that I can integrate them into the editor.

The include system needs updating, as well.

The patch will install itself over an existing installation. In a month or so, a major release will appear. The patch will be posted on GHirai's website as well as mine.

Thank you for your offer of help and perhaps I will add the macros, also. I was afraid to ask thinking they may be too advanced for my users. MASM32 is the best place for them, I think, but I will talk to my buddy about it.

You are a nice man,
--Paul
The GeneSys Project is available from:
The Repository or My crappy website

MichaelW

Paul, this is what I came up with:

;=========================================================================
include \GeneSys\include\GeneSysRt.inc
include \GeneSys\macros\macros.asm
;=========================================================================
.data
    str1 db "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",0
    str2 db "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",0
.code
;=========================================================================
start:
;=========================================================================

    ;---------------------------------------------------------------
    ; This code measures the execution time, in milliseconds, for a
    ; block of code. It temporarily increases the process priority
    ; class to minimize the number of interruptions. It syncs with
    ; the timer at the start of the timed interval to improve the
    ; accuracy of the results. It runs 10 trials and captures the
    ; shortest execution time, on the assumption that the shortest
    ; time is the most accurate time, with the longer times
    ; resulting from interruptions. For best accuracy the timed code
    ; should take at least several hundred milliseconds to execute,
    ; and this will usually require that the code be executed in a
    ; loop with a large loop count.
    ;---------------------------------------------------------------

    invoke GetCurrentProcess
    invoke SetPriorityClass, eax, HIGH_PRIORITY_CLASS

    mov ebx, -1

    REPEAT 10

      @@:
        invoke GetTickCount
        push eax
        invoke GetTickCount
        pop edx
        cmp eax, edx
        je  @B
        push eax

        ;----------------------------
        ; Start of code to be timed.
        ;----------------------------

        mov esi, 1000000
        .WHILE esi
          invoke szComp, ADDR str2, ADDR str1
          dec esi
        .ENDW

        ;--------------------------
        ; End of code to be timed.
        ;--------------------------

        invoke GetTickCount
        pop edx
        sub eax, edx

        cmp eax, ebx
        jnb @F
        mov ebx, eax
      @@:

    ENDM

    invoke MessageBox, 0, str$(ebx), chr$("Elapsed ms"), MB_OK

    invoke GetCurrentProcess
    invoke SetPriorityClass, eax, NORMAL_PRIORITY_CLASS

    invoke ExitProcess, 0

;=========================================================================

end start


Regarding the macros, would it help if I thoroughly commented them?

eschew obfuscation

PBrennick

Michael, thanks for the wrapper thing and it would be wonderful if you commented the macros. It would help my users to understand.

-- Paul
The GeneSys Project is available from:
The Repository or My crappy website

UtillMasm

i opened the readme.txt file in my notepad editor.

then apear a strange character.

i want konw that you guys Windows's system locale setting.

i'm using Windows-936 now as Windows system locale.

[attachment deleted by admin]

MichaelW

Yes, now that I check, the original file on my system has that character in place of the apostrophe in "application's". The character is character code 92h, instead of 27h. I'm not sure how it got there, but one possible explanation is that I created the file in Word and then converted it to a text file.
eschew obfuscation