views:

350

answers:

8

I would like to find the values of some of windows API constants, such as, but not limited to *LVM_ENABLEGROUPVIEW* & *WM_SHOWWINDOW*

Looking on the net lead me to MSDN which tells me what they are used for, but not the underlying values.

There is a very similar question on stackOverflow, Where can I find a list of windows API constants, but all the answers are for .net, or assume that I have the Windows SDK, that as far as I know I don't have.

So where can I find them?

If it makes a difference I am using Delphi 2007, and although it has a lot of the contents in the Messages unit, it does not have all of them, including some of the newest ones.

Thanks

+1  A: 

You can look at the windows unit source (and related units) for the constants. They have limited comments for their use.

The windows SDK help provides some more answers.

Else the MSDN on the internet.

Getting a complete list will require some research. But in the end you will be able to find all the answers.

Gamecat
+11  A: 

Download the SDK and search the header files (all the .h files) using your favorite full-text search tool.

Pinvoke.net can serve in a pinch (Constants) but doesn't necessarily have everything.

The message values are constant across all development environments.

Kevin Montrose
+1, the SDK is the ultimate source.
mghie
A: 

You can probably find at least most of the constants in the Wine project files. The project is supposed to provide a Windows runtime environment on Linux machines, so the constant should be the same as in the real Windows SDK. Having that said, it is not an official Microsoft resource, and searching Linux files to get Windows constants seems awkward.

In general, I would recommend downloading the real Windows SDK. It is free, and if all you need are the constants, you can get rid of the rest. If you do prefer to take the chance with Wine, their site has an internal search engine that will get you to the definition you're looking for.

eran
+2  A: 

Most of them can be found in the VCL source, primarily in the Windows.pas file. Your best bet is to do a Search|Find In Files, type the name of the constant you want to find the value for, set the Search Directories option, set the file mask to *.pas, and enter the path to the folder containing Windows.pas. The IDE will find all uses of the constant and put them in a Search Results window; double-clicking on the source line in that window will open the file at that line.

Others can, as Kevin and GameCat mentioned, can be found in the header (.h) files in the Windows SDK, downloadable from MSDN.

Ken White
Windows.pas doesn't have the constants for the bulk of the common controls. Those are in CommCtrl.pas.
Cobus Kruger
@Cobus: Did I say Windows.pas had them ALL? :-) You must have missed the "Find in Files" part of my post. It covers the ones NOT found in Windows.pas.
Ken White
+1  A: 

You can use ApiViewer. Initially developed for VB6, it can be set up to show declarations in object pascal language which could save you some typing.

Mind you though, its database is not perfect. Some function definitios are incorrect, some constants too (like 0xFFFF instead of 0xFFFFFFFF).

GSerg
+1 for what looks like a great tip!
Cobus Kruger
A: 

In addition to what others have said (all valid and good advices), Google is your friend. Search for "#define WM_Whatever".

For example: http://www.google.si/search?&q=%23define+LVM_ENABLEGROUPVIEW

gabr
+1  A: 

LVM_ENABLEGROUPVIEW and co are located in CommCtrls.pas - they probably are in Delphi 2007, but I haven't checked:

  LVM_FIRST               = $1000;     
  LVM_SETGROUPMETRICS         = LVM_FIRST + 155;
  LVM_GETGROUPMETRICS         = LVM_FIRST + 156;
  LVM_ENABLEGROUPVIEW         = LVM_FIRST + 157;
  LVM_SORTGROUPS              = LVM_FIRST + 158;

WM_SHOWWINDOW should be in Windows.pas for Delphi 2007 - start searching for SW_HIDE. Alternatively you could go look at this post on translating API calls, which not only has the values you're looking for but also shows how to use them in a type-safe manner.

Delphi 2007's CommCtrl.pas has a lot of messages and API macros that are not used anywhere in the VCL, are not documented in Delphi and the unit is always well worth a look.

More generally, if you look up any API call on MSDN (or the Delphi help files), it lists the name of the header file right at the bottom under Function Information. If this header is in Win*.h, go look at Windows.pas. Most other things are to be found in the pas file with that name (so commctrl.h becomes commctrl.pas).

Update: LVM_ENABLEGROUPVIEW as well as the ListView_EnableGroupView macro are available on Delphi 2007.

Cobus Kruger
+2  A: 

The excellent Delphi JEDI project has converted most of the Windows API header files into delphi / pascal. Check out win32api at the JEDI site.

Dave Glassborow