News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

MENUITEMINFO

Started by minor28, September 29, 2014, 11:03:35 PM

Previous topic - Next topic

minor28

Windows.inc

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

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?

jj2007

Quote from: minor28 on September 29, 2014, 11:03:35 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.

minor28

Yes it is true, but if I tell Windows that I want the newer version then it does not exist in windows.inc

dedndave

so, define your own structure
MENUITEMINFO2
  MENUITEMINFO <>
  hbmpItem     HBITMAP ?
MENUITEMINFO2

TouEnMasm


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
Fa is a musical note to play with CL

hutch--

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.

jj2007

Quote from: hutch-- on October 02, 2014, 07:19:27 PMsimply define your own

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

Quote from: dedndave on September 30, 2014, 10:41:35 AM
so, define your own structure
MENUITEMINFO2
  MENUITEMINFO <>
  hbmpItem     HBITMAP ?
MENUITEMINFO2


dedndave

i guess mine is less than ideal
if Hutch changes the structure in windows.inc, it will break the code   :(

jj2007

Quote from: dedndave on October 02, 2014, 08:09:35 PM
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