News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Id menu problem

Started by ragdog, June 09, 2008, 01:41:58 PM

Previous topic - Next topic

ragdog

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

Jimg

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.

ragdog

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

Jimg

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?

ragdog

hmm works not

have you an another idea?

Jimg

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

ragdog

nice is perfect  :U

thanks you

ragdog

#7
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?



Jimg

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

ragdog

 :bg super

total simply mistake!!!

thanks for your works and help


greets
ragdog