xroot Posted December 18, 2009 Share Posted December 18, 2009 Can someone tell me what is going wrong, why "LoadMenuIndirect" can't return a menu handle when I use the $SM structure but returns a menu handle when I use $SM2 structure.I can not see the difference between the two structures, only the way I load them and the datadump of each structure are equal.(see output)Struct $SM Ptr=0x01AD025C Menu hWnd=0x00000000 LoadMenuIndirect=The operation completed successfully.Struct $SM2 Ptr=0x01ACFD78 Menu hWnd=0x006D0369 LoadMenuIndirect=The operation completed successfully.Struct $SM Data=0x000000009000460069006C006500000000009001410062006F007500740042006F007800000000000000000080009101450078006900740000000Struct $SM2 Data=0x000000009000460069006C006500000000009001410062006F007500740042006F007800000000000000000080009101450078006900740000000expandcollapse popup#Include <WinAPI.au3> Func Set_Menu($Type,$mTit,$MEM=128) If $Mflag Then Global $SM=DllStructCreate("byte["&$MEM&"]"),$pSM=DllStructGetPtr($SM) $Mflag=0 EndIf $pSM+=$POS $POS=6 DllStructSetData(DllStructCreate("byte[8]",$pSM),1,0) DllStructSetData(DllStructCreate("byte[4]",$pSM+4),1,$Type) DllStructSetData(DllStructCreate("wchar["&StringLen($mTit)&"]",$pSM+$POS),1,$mTit) $POS+=StringLen($mTit)*2+2 Return EndFunc Func Set_Item($Type=0,$mID=0,$mTit="") $pSM+=$POS $POS=4 DllStructSetData(DllStructCreate("byte[4]",$pSM),1,$Type) DllStructSetData(DllStructCreate("byte[4]",$pSM+2),1,$mID) DllStructSetData(DllStructCreate("wchar["&StringLen($mTit)&"]",$pSM+$POS),1,$mTit) $POS+=StringLen($mTit)*2+2 Return EndFunc $xMenu="0x000000009000460069006C006500000000009001410062006F007500740042006F0078"& _ "00000000000000000080009101450078006900740000000000000000" Global $SM2=DllStructCreate("byte["&StringLen($xMenu)&"]"),$pSM2=DllStructGetPtr($SM2) DllStructSetData($SM2,1,$xMenu) Global $Mflag=1,$Pos=0 Set_Menu(144,"File") Set_Item(0,400,"AboutBox") Set_Item() ;Seperator Set_Item(128,401,"Exit") $Menu=DllCall("user32.dll","hwnd","LoadMenuIndirectA","ptr",$pSM) consolewrite("Struct $SM Ptr="&$pSM&" Menu hWnd="&$Menu[0]&" LoadMenuIndirect="&_WinAPI_GetLastErrorMessage()) $Menu=DllCall("user32.dll","hwnd","LoadMenuIndirectA","ptr",$pSM2) consolewrite("Struct $SM2 Ptr="&$pSM2&" Menu hWnd="&$Menu[0]&" LoadMenuIndirect="&_WinAPI_GetLastErrorMessage()) consolewrite("Struct $SM Data="&DllStructGetData($SM,1)&@lf&"Struct $SM2 Data="&DllStructGetData($SM2,1)) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now