The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on June 09, 2008, 01:41:58 PM

Title: Id menu problem
Post by: ragdog on June 09, 2008, 01:41:58 PM
hi i have a little problem with this routine
error A2098: invalid operand for OFFSET

hButtonID[esi]    has the button id's from .ini file , example 9000-9010.
how i can add this id's to the menu



LOCAL    hButtonID[256]:BYTE


      xor esi, esi
      .while (byte ptr hButtonID[esi] != 0)
         invoke GetPrivateProfileString, addr szToolbars, addr hButtonID[esi], 0,\
                                          addr hToolName, 256, addr szIniFile
               
            lea edx, hToolName
            xor edi, edi
           push eax
           
         .while (eax)
            .if byte ptr[edx+edi] == ','
                  mov byte ptr[edx+edi], 0
               .break
            .endif
               inc edi
               dec eax
         .endw

               mov     mii.fType, MFT_STRING
           mov     eax,offset hButtonID[esi]  ;<<<<<<<<<<<<<<<< hButtonID[esi] has the new ids
               mov     mii.wID,eax
               mov     mii.hSubMenu, 0
               mov     eax,offset hToolName
               mov     mii.dwTypeData,eax
            INVOKE     InsertMenuItem, hSMenu3, 0, TRUE, addr mii   ; Adds to the end
            INVOKE     DrawMenuBar, hWnd
            add esi, 9
   
      .endw


thanks in forward
Title: Re: Id menu problem
Post by: Jimg on June 09, 2008, 01:50:46 PM
The problem is that hButtonId lives on the stack, so it's address isn't known at assembly time.
Use lea eax,hButtonID[esi] instead.
Title: Re: Id menu problem
Post by: ragdog on June 09, 2008, 03:11:26 PM
thanks for your help

This works not correct :(
I want to id's for the menu button of the ini file

my ini

[too]
9001=string1
9002=string2
9003=string3


lea ebx,hButtonID[esi]


               mov     mii.wID, 9001
               mov     mii.hSubMenu, 0
               mov     eax, offset hToolName
               mov     mii.dwTypeData, eax


have an idea
Title: Re: Id menu problem
Post by: Jimg on June 09, 2008, 03:19:29 PM
opps.  Sorry, I misread what you were doing.

so you want the VALUE at hButtonID(esi).  Just use it.

mov eax,dword ptr hButtonID[esi]

or did I misunderstand again?
Title: Re: Id menu problem
Post by: ragdog on June 09, 2008, 03:30:03 PM
hmm works not

have you an another idea?
Title: Re: Id menu problem
Post by: Jimg on June 09, 2008, 04:07:47 PM
Okay, one more try.

MENUITEMINFOA.wID expects a 32 bit integer value.

hButtionID contains the string representation of the values.

so you have to convert from string to integer first, then put the value in .wID

eg.
invoke atol,addr hSubMenu(esi)  ; don't forget to save ecx and edx if needed
mov mmi.wID,eax
Title: Re: Id menu problem
Post by: ragdog on June 09, 2008, 04:31:07 PM
nice is perfect  :U

thanks you
Title: Re: Id menu problem
Post by: ragdog on June 09, 2008, 05:58:24 PM
hi

i have a another problem with my menu

the first menu entry does not work the 2 and 3 works not corectly

and the menu id´s move´s to a on entry further  ::)
no idea why

can your help me please?


Title: Re: Id menu problem
Post by: Jimg on June 09, 2008, 06:42:48 PM
I don't know why you were subtracting 5, I would have added 6.

               lea     ebx, hButtonID[esi]
;               sub     ebx,5
                add ebx,6
            invoke     atol, ebx
Title: Re: Id menu problem
Post by: ragdog on June 09, 2008, 06:46:49 PM
 :bg super

total simply mistake!!!

thanks for your works and help


greets
ragdog