The MASM Forum

Projects => MASM32 => WINDOWS.INC Project => Topic started by: minor28 on September 29, 2014, 11:03:35 PM

Title: MENUITEMINFO
Post by: minor28 on September 29, 2014, 11:03:35 PM
Windows.inc
Code: [Select]
MENUITEMINFOA STRUCT
  cbSize        DWORD      ?
  fMask         DWORD      ?
  fType         DWORD      ?
  fState        DWORD      ?
  wID           DWORD      ?
  hSubMenu      DWORD      ?
  hbmpChecked   DWORD      ?
  hbmpUnchecked DWORD      ?
  dwItemData    DWORD      ?
  dwTypeData    DWORD      ?
  cch           DWORD      ?
MENUITEMINFOA ENDS

http://msdn.microsoft.com/en-us/library/windows/desktop/ms647578(v=vs.85).aspx
Code: [Select]
typedef struct tagMENUITEMINFO {
  UINT      cbSize;
  UINT      fMask;
  UINT      fType;
  UINT      fState;
  UINT      wID;
  HMENU     hSubMenu;
  HBITMAP   hbmpChecked;
  HBITMAP   hbmpUnchecked;
  ULONG_PTR dwItemData;
  LPTSTR    dwTypeData;
  UINT      cch;
  HBITMAP   hbmpItem;
} MENUITEMINFO, *LPMENUITEMINFO;

Is windnows.inc missing hbmpItem?
Title: Re: MENUITEMINFO
Post by: jj2007 on September 29, 2014, 11:20:25 PM
Is windows.inc missing hbmpItem?

That's the purpose of cbSize: tell Windows which version you are using.
hbmpItem is not essential and was introduced a bit later.
Title: Re: MENUITEMINFO
Post by: minor28 on September 30, 2014, 07:32:41 AM
Yes it is true, but if I tell Windows that I want the newer version then it does not exist in windows.inc
Title: Re: MENUITEMINFO
Post by: dedndave on September 30, 2014, 10:41:35 AM
so, define your own structure
Code: [Select]
MENUITEMINFO2
  MENUITEMINFO <>
  hbmpItem     HBITMAP ?
MENUITEMINFO2
Title: Re: MENUITEMINFO
Post by: ToutEnMasm on October 02, 2014, 05:33:15 PM

Only the translated sdk allow this form
Quote
MENUITEMINFOA   STRUCT DEFALIGNMASM
   cbSize DWORD ?
   fMask DWORD ?
   fType DWORD ? ; used if MIIM_TYPE (4.0) or MIIM_FTYPE (>4.0)
   fState DWORD ? ; used if MIIM_STATE
   wID DWORD ? ; used if MIIM_ID
   hSubMenu DWORD ? ; used if MIIM_SUBMENU
   hbmpChecked DWORD ? ; used if MIIM_CHECKMARKS
   hbmpUnchecked DWORD ? ; used if MIIM_CHECKMARKS
   dwItemData ULONG_PTR ? ; used if MIIM_DATA
   dwTypeData DWORD ? ; used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0)
   cch DWORD ? ; used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0)
IF ( WINVER GE 00500h)
   hbmpItem DWORD ? ; used if MIIM_BITMAP
ENDIF ;/* WINVER >= 0x0500 */
MENUITEMINFOA      ENDS

Like this you have the right structure with the correct alignment
Title: Re: MENUITEMINFO
Post by: hutch-- on October 02, 2014, 07:19:27 PM
This will always be the case as Microsoft keep adding things to the API and support structures and equates. If a version does not do what you require because a later version has been aded by Microsoft, simply define your own. Call it something slightly different so that if and when the master include file is updated, it will not clash with it.
Title: Re: MENUITEMINFO
Post by: jj2007 on October 02, 2014, 07:56:12 PM
simply define your own

Yes indeed. Dave's suggestion is simple and straightforward :t

so, define your own structure
Code: [Select]
MENUITEMINFO2
  MENUITEMINFO <>
  hbmpItem     HBITMAP ?
MENUITEMINFO2
Title: Re: MENUITEMINFO
Post by: dedndave on October 02, 2014, 08:09:35 PM
i guess mine is less than ideal
if Hutch changes the structure in windows.inc, it will break the code   :(
Title: Re: MENUITEMINFO
Post by: jj2007 on October 03, 2014, 04:10:42 AM
if Hutch changes the structure in windows.inc, it will break the code   :(

ifndef helps:

include \masm32\include\masm32rt.inc

MyRECT struct
  RECT <>
  ifndef RECT.left
   left dd ?
  endif
  ifndef OneMore
   OneMore   dd ?
  endif
MyRECT ends

.code
therect MyRECT <<1, 2, 3, 4>, 5>

start:
   print str$(therect.left), 9, "left", 13, 10
   print str$(therect.top), 9, "top", 13, 10
   print str$(therect.right), 9, "right", 13, 10
   print str$(therect.bottom), 9, "bottom", 13, 10
   inkey str$(therect.OneMore), 9, "onemore", 13, 10
   exit

end start