The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Jimg on July 30, 2005, 03:54:44 PM

Title: Macros from Win32.hlp
Post by: Jimg on July 30, 2005, 03:54:44 PM
Ok, time for the next dumb question.

When using the win32.hlp file, there is often mention of macros that are available.  For example-
QuoteThe LVM_SETITEMSTATE message changes the state of an item in a list view control. You can explicitly send this message or by using the ListView_SetItemState macro.

I've always used sendmessage but in the back of my mind, I always meant to find out how to use these macros.  What is the exact form of the line of assembler to call this macro?  My first guess would be-
ListView_SetItemState hLv,ebx,ecx,LVIF_STATE

but masm hates that.  Second, third, and fourth guesses were no better.  Is this just some leftover 'C' junk or can we actually use these macros?
Title: Re: Macros from Win32.hlp
Post by: Vortex on July 30, 2005, 05:25:57 PM
There is no such a macro in Masm but you can build it. Probably, it's a construct related to C
Title: Re: Macros from Win32.hlp
Post by: hutch-- on July 30, 2005, 05:52:32 PM
Jim,

You would need to work out the actual API call required to do what you are after. It certainly is a target for writng a macro but you need the technical data to do it first.
Title: Re: Macros from Win32.hlp
Post by: Jimg on July 30, 2005, 07:04:05 PM
Thanks all, that is what I suspected.  It's just irritating to constantly have these references to non-existant macros or at least not knowing weither they exist or not.  Thanks again, I'll just ignore the references.  Perhaps we need to create our own asm-centric win32.hlp :wink
Title: Re: Macros from Win32.hlp
Post by: PBrennick on July 31, 2005, 12:22:41 AM
Jimq,
What would we do?  Decompile the help file, search and delete all references to the word 'macro' and then recompile it?  :green2

Paul
Title: Re: Macros from Win32.hlp
Post by: Jimg on July 31, 2005, 12:29:57 AM
Among other things, yes!

I've already done this once, just to get the "find" button to show up.
Title: Re: Macros from Win32.hlp
Post by: PBrennick on July 31, 2005, 12:41:10 AM
Jimq,
Do you mean it defaults to find?  That is something I never thought of and is very useful.  It is the only tab I every use.

Paul
Title: Re: Macros from Win32.hlp
Post by: Jimg on July 31, 2005, 01:52:11 AM
Well, not defaults to find exactly, but the find button is always available, so that you don't have to hit index first to get to the find screen.
Title: Re: Macros from Win32.hlp
Post by: PBrennick on July 31, 2005, 02:08:23 AM
Jimq,
Oh, yeah, that is irritating.  Maybe I will do the same thing.

Paul
Title: Re: Macros from Win32.hlp
Post by: GregL on July 31, 2005, 03:55:26 AM
ListView_SetItemState Macro (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/listview/macros/listview_setitemstate.asp)

It's in 'commctrl.h'.


#define ListView_SetItemState(hwndLV, i, data, mask) \
{ LV_ITEM _ms_lvi;\
  _ms_lvi.stateMask = mask;\
  _ms_lvi.state = data;\
  SNDMSG((hwndLV), LVM_SETITEMSTATE, (WPARAM)(i), (LPARAM)(LV_ITEM *)&_ms_lvi);\
}


As stated above, you would have to translate it to a MASM macro.

Title: Re: Macros from Win32.hlp
Post by: Jimg on July 31, 2005, 04:03:53 AM
Thanks Greg.  So it is pure 'C' stuff then.
Title: Re: Macros from Win32.hlp
Post by: hutch-- on July 31, 2005, 04:50:20 AM
Jim,

Give this a blast as it may do the job. I have no code set up to test it but it just loads the structure and does a SendMessage().


    ListView_SetItemState MACRO handl,i,data,mask
      IFNDEF @lvi@
      .data?
        @lvi@ LV_ITEM <>
      .code
      ENDIF
      mov eax, mask
      mov @lvi@.mask, eax
      mov eax, data
      mov @lvi@.data, eax
      invoke SendMessage,handl,LVM_SETITEMSTATE,i,ADDR @lvi@
    ENDM
Title: Re: Macros from Win32.hlp
Post by: PBrennick on July 31, 2005, 12:42:45 PM
Hutch,
If I read that script from the header file correctly, what I see is a generic SendMessage macro that can be used to send ANY message.  That would be a very powerful addition to your preprocessor set.  Very easy to create, also.

Paul
Title: Re: Macros from Win32.hlp
Post by: Jimg on July 31, 2005, 02:47:33 PM
Very nice Hutch.

Thanks everybody.  If you look at the first post, that macro was just an example, something I happened to be looking at just then, not a particular macro I needed.  I just wanted to know about the macros described in win32.hlp in general, and I now have the answer, ignore them!