How to compile a pgm example: "bmpbutn.asm" in EC ?

Started by vmars316, April 30, 2011, 09:19:11 PM

Previous topic - Next topic

vmars316

Greets,
I would like to compile a pgm example: "bmpbutn.asm"
It has a bunch of related files in:
Folder   C:\masm32\examples\exampl04\bmpbutn 

Pls, how can I compile it in EC?

Thanks...vmars316
.
All things in moderation, except for love and forgiveness...vmars316
.
www.QuickerThanASpark.com

Ramon Sala

Hi,

There is some source code missing in the bmpbutn example. The BmpButton procedure is called in line 151 of the bmpbutns.asm files, but that procedure does not exist. So, the project cannot be built.

However, I have prepared a simple EC visual project doing the same for you to see how it works. Please download the attached zip file.

Ramon


Greetings from Catalonia

jj2007

Quote from: Ramon Sala on April 30, 2011, 10:10:21 PM
There is some source code missing in the bmpbutn example. The BmpButton procedure is called in line 151 of the bmpbutns.asm files, but that procedure does not exist. So, the project cannot be built.

Builds just fine here - see \masm32\m32lib\bmpbutn.asm :wink

vmars316

Thanks Folks.
But I am confused,
where is the msg loop"
    .WHILE TRUE                                                         ; Enter message loop
                invoke GetMessage, ADDR msg,NULL,0,0
                .BREAK .IF (!eax)
                invoke TranslateMessage, ADDR msg
                invoke DispatchMessage, ADDR msg
   .ENDW

I am on page:   C:/masm32/EasyCode.Ms/Iczelion_Tutorials_html/tut5.html
and thought there needed to be a msgLoop. Need Help.
Thanks...vmars



.
All things in moderation, except for love and forgiveness...vmars316
.
www.QuickerThanASpark.com

dedndave

    .WHILE TRUE                                                         ; Enter message loop
                invoke GetMessage, ADDR msg,NULL,0,0
                .BREAK .IF (!eax)
                invoke TranslateMessage, ADDR msg
                invoke DispatchMessage, ADDR msg
   .ENDW


that is a while/end loop
it breaks after GetMessage if EAX is 0
in "real asm" - lol - it looks like this
loop00: INVOKE  GetMessage,addr msg,NULL,0,0
        test    eax,eax
        jz      loop01

        INVOKE  TranslateMessage,addr msg
        INVOKE  DispatchMessage,addr msg
        jmp     loop00

loop01:

oex

Quote from: dedndave on May 01, 2011, 02:01:27 AM
.WHILE TRUE                                                         ; Enter message loop
                invoke GetMessage, ADDR msg,NULL,0,0
                .BREAK .IF (!eax) || eax==-1
                invoke TranslateMessage, ADDR msg
                invoke DispatchMessage, ADDR msg
.ENDW

http://msdn.microsoft.com/en-us/library/ms644936(v=vs.85).aspx

"If there is an error, the return value is -1"
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

that's true
here is the code i use...
;EDI = 0

        pushad                                     ;create stack space for MSG structure
        jmp short mLoop1

mLoop0: INVOKE  TranslateMessage,esp
        INVOKE  DispatchMessage,esp

mLoop1: mov     eax,esp
        INVOKE  GetMessage,eax,edi,edi,edi
        neg     eax                                ;exit only
        shr     eax,1                              ;if 0 or -1
        jnz     mLoop0

        pop     eax                                ;EAX = MSG.hWnd, [ESP] = MSG.message
        JMP     ExitProcess                        ;[ESP+4] = MSG.wParam

PUSHAD creates 32 bytes of stack space
we want to exit with MSG.wParam as the parm for ExitProcess, which does not care about a RET address   :P
no need to balance the stack, as ExitProcess releases the stack as process context

NEG EAX/SHR EAX,1 allows the loop to continue for any value other than 0 or -1

i could reduce it a little more by using EBP (or EBX or ESI) to point to ESP
;EDI = 0

        pushad                                     ;create stack space for MSG structure
        mov     ebp,esp
        jmp short mLoop1

mLoop0: INVOKE  TranslateMessage,ebp
        INVOKE  DispatchMessage,ebp

mLoop1: INVOKE  GetMessage,ebp,edi,edi,edi
        neg     eax                                ;exit only
        shr     eax,1                              ;if 0 or -1
        jnz     mLoop0

        pop     eax                                ;EAX = MSG.hWnd, [ESP] = MSG.message
        JMP     ExitProcess                        ;[ESP+4] = MSG.wParam

same size - just simpler code inside the loop   :P

dedndave

i have considered trying something like this...
        jmp short mLoop1

mLoop0: INVOKE  TranslateMessage,ebp
        INVOKE  DispatchMessage,ebp

mLoop1: INVOKE  GetMessage,ebp,edi,edi,edi
        inc     eax
        jz      mLoop1

        dec     eax
        jnz     mLoop0

so - if GetMessage returns an error, it skips that message and gets the next one
not sure if it would be the right way to go - lol
they aren't very specific in their documentation about conditions that cause -1 to be returned   :P
and, i don't know of any way to force it to happen for testing

dedndave

i saw what you said, Peter   :bg
that method wouldn't really test anything

in the msdn example code, they show a commented spot where...
"handle the error and possibly exit" is the approach - lol

seems to me that...
"ignore the error and keep on trucking" should work, too
seeing as they tell us nothing about what errors to write code for   :lol

oex

:lol my 007 post, written on the forum in lemon juice would have fooled many but obviously not you Dave.... I tend to assume that at least if I write for the errors in their code that they know about at least then it is easy to field customer support for those they dont know about....
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

vmars316

Sorry, I am still back at "no loop".

I did a search on both:

Ramon BmpButton.zip
and
jj2007 \masm32\m32lib\bmpbutn.asm

and still neither of them have a TRANSLATE or DISPATCH statement in their source.
BmpButton.zip does have both,
but in BmpButton.obj, not in the source.

Pls, I wonder if someone could take me, step by step,
from 'bmpbutn.asm' file, to turning it into an EC_Project.
That would be a great help.

Thanks...vmars
.
All things in moderation, except for love and forgiveness...vmars316
.
www.QuickerThanASpark.com

jj2007

vmars,

Like all Masm32 library sources, \masm32\m32lib\bmpbutn.asm is not a standalone program, but rather a procedure that you can call. Your own windows routines must handle the message loop.

Gunner

~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

vmars316

Quote from: jj2007 on May 01, 2011, 11:45:21 PM
Like all Masm32 library sources, \masm32\m32lib\bmpbutn.asm is not a standalone program, but rather a procedure that you can call. Your own windows routines must handle the message loop.
Oh, I see.
Guess I'll get back to this when I need to add Lib programs to my projects. Thanks...
Quotethis should help you... search is your friend 
http://www.masm32.com/board/index.php?topic=2791.0
Oops! I forgot I had asked this before.
Thanks Gunner,
I put a note in my 'DownloadThis Folder' for your 'File Type Editor'.
I read your 'programs I use'.
Back in the win98/XP days, I used to have a free program (InCntrl) that I would run before and after a program install.
And it would show me all changes to my system by that install.
I would like to get something like that again.

One of my favorite freewares is AgentRansack.
An extremely fast hardDrive Search pgm.
Sooo much better/Faster than win7 search.
Thanks...vmars
.
All things in moderation, except for love and forgiveness...vmars316
.
www.QuickerThanASpark.com

Ramon Sala

Hi vmars316,

Attached is the Iczelion's bmpbutton example in an EC Classic project (pure assembly), so that you can see the button's style, how it is created and centered on the parent window and how it is subclassed in order to process the WM_LBUTTONDOWN and WM_LBUTTONUP messages.

Ramon

Greetings from Catalonia