I'm don't understand how to do the more complicated macros...Is there some tutorial on macros, or
info text?

This is my current problem,
I like calling MessageBox in below way in my code, and would like to have a macro for it:

push MB_OK
call @f
db "title",0
@@: call @f
db "goodbye cruel world",0
@@: push NULL ; ( or hWnd )
call MessageBox

Thanks in advance. :tongue:
Posted on 2002-09-12 08:40:50 by david
MsgBox MACRO titl:REQ, txt:REQ, button:=<MB_OK>, hnd:=<NULL>

LOCAL _1,_2

push button
call _1
db titl,0
_1: call _2
db txt,0
_2: push hnd ; ( or hWnd )
call MessageBoxA
use like:

MsgBox "Dude:", "Where is my car?"
Posted on 2002-09-12 10:27:54 by bitRAKE
Thanks!! :) Just what I wanted!!

Can you explain these:

Does the 'REQ' mean the variable is a string?

Does the < >-brackets mean the contents inside the brackets is a define?
Posted on 2002-09-12 10:40:18 by david
:REQ means value is required.
:=<{?}> means default value.

All arguments to macros are strings - there is no exception. MASM may evaluate the argument before passing it to the macro, but the macro always gets a string. MASM may evaluate the argument inside the macro when it is used, but the macro argument is always a string. :)
Posted on 2002-09-12 10:49:54 by bitRAKE
Great! I see things more clearly now! Soon I'll be the master of macros!!

Is there more handy 'evaluation-specifiers' (what to call it?)
like the

:REQ and :=<{?}>

Posted on 2002-09-12 11:09:10 by david
:VARARG means grab all remaining arguments into one string (comma separated). Read chapter 9 of the MASM manual. Also, look at the example on the board and you will understand more.
Posted on 2002-09-12 15:30:42 by bitRAKE
I use MB macro at debug stage of multiprocess project.
It let me see in which process it appears.

.model flat, stdcall
option casemap:none

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

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

$T MACRO sText
local szDummy
IF @SizeStr(<sText>)
szDummy db sText, 0
szDummy db 0
EXITM <offset szDummy>

sub esp, 128
mov eax, esp
invoke GetModuleFileName, NULL, eax, 128
mov eax, esp
push MB_OK
push eax
push $T(<mes>)
invoke GetActiveWindow
push eax
call MessageBox
add esp, 128

MB "qwerty"
end start
Posted on 2002-09-13 01:33:05 by Four-F
Cool! Thanks, this helps me!
Posted on 2002-09-13 06:59:29 by david