Ok, I know this is a very simple problem but im tossing it out for anyone who can help me wrap my mind around this as it pertains to ASM: I was happily coding until I decided i would write a proc and pass the address of a RECT structure as one of its arguments, and deal with that address pointer within the proc.. (simple concept in C :) ). My problem is i can't wrap my mind around how i would assign this address to a Rect struct within the proc. or be able to get the compiler to realize this DWORD address is actually a lpRect such that i can access its members without having to count bytes to offset to the members... somthing like

DoSomething PROC :DWORD

.data

Rect1  RECT { 1 , 2, 3, 4 }

.code

....
invoke DoSomething, ADDR Rect1
....

DoSomething PROC lpRect:DWORD

    mov eax, .bottom 

    ; or somthing simular...
    ....

    return 0

DoSomething ENDP
I know this is a simple problem, and i have probably seen its solution somewhere in all that i have read lately (just not sure where... ) Thanx for your help. NaN edit: added code tags Hiro This message was edited by Hiroshimator, on 2/8/2001 2:03:06 AM
Posted on 2001-02-08 00:42:00 by NaN
Ah, yes, while im buggin for advice i might as well toss this one out as well... Its more annoying than of urgency, but how do i make the MessageBox API not ding everytime it is invoked?? Is there a MB_OK_NODING or something??? :P Anyways thanx again for the help. NaN
Posted on 2001-02-08 00:55:00 by NaN
Since a RECT is a structure, all you need do is tell the compiler what kind of pointer you have, and it happily adds the offsets for you. Example:


GetWidth PROC lpRectWORD
; calculates the width of a rect from (right-left)
; returns width in eax
    mov ecx, lpRect
    mov eax, (RECT PTR ).right
    sub eax, (RECT PTR ).left
    ret
GetWidth  ENDP
Posted on 2001-02-08 02:05:00 by Ernie
Nan, just pass the data as a RECT data type, easiest way to do it. If you need the structure filled and available after return of the proc, pass its address and pull it apart manually. Regards, hutch@pbq.com.au

    PROTOTYPE

    TestRect PROTO :RECT

=====================================

    CALLING procedure

    mov eax, 1
    mov Rct.left, eax
    mov eax, 2
    mov Rct.top, eax
    mov eax, 3
    mov Rct.right, eax
    mov eax, 4
    mov Rct.bottom, eax

    invoke TestRect,Rct

=====================================

PROCEDURE

; ########################################################################

TestRect proc Rct:RECT

    ShowReturn 0,Rct.top

    ret

TestRect endp

; ########################################################################
Posted on 2001-02-08 04:13:00 by hutch--
hutch, Doesn't declaring the parameter as a RECT mean you're pushing all 4 elements on the stack? That's not so bad for that structure, but what about something else huge? Ernie
Posted on 2001-02-08 13:30:00 by Ernie
Thanx again Ernie you hit the nail on the head.. (i knew it was just a matter of somesorta syntax..) Hutch, thank you as well, but that is what i settled with. I decided to ask for help because I also realize this mearly passes the entire stucture on the stack and managing pointers would be better :) Oh ya... any ideas on the annoying bell thing in MessageBoxes??? :D NaN
Posted on 2001-02-08 18:52:00 by NaN
The best way to get rid of that annoying beep is to unplug the speakers, turn down the volume... or... stream your mp3's so loud that you can't here the beep :D _Shawn
Posted on 2001-02-09 16:14:00 by _Shawn
Messageboxes beep as part of their intrinsic behavior. Perhaps you could make your own MessageBox procedure using a dialog box, and NEVER EVER PROGRAM IN THAT ANNOYING BEEP!!! Just a thought. :-) PS (actually a serious thought) MS is very into 'internationalzation' of software (in fact, they earn more money off non-english OS & app versions). But, Japanese for one get quite embarased by beeps. It's cultural, the avoidance of mistakes. Qurious there is no flag to enable or disable the beep. Perhaps they hid that feature in the os build.
Posted on 2001-02-09 18:59:00 by Ernie
Agreed, The Pseudo Messagebox Dialog box was my only idea of a solution... but i didnt want to go ahead if there was a simple solution. ;) Shawn, Thanx for the advice, It was at least creative.. :D NaN
Posted on 2001-02-09 20:25:00 by NaN
You could turn off the "Default sound" in Control Panel - Sounds... :)
Posted on 2001-02-09 20:36:00 by S/390