Как использовать WM_APPCOMMAND в Delphi.

17:22
In article <3bb58d93_2@dnews>, Mikael Stalvik wrote:
> Has anybody of you tried to use WM_APPCOMMAND in Delphi?`

You are aware that it is only supported on Win2K?

The API headers define the message constant as

#define WM_APPCOMMAND 0x0319

So the matching Delphi declaration would be

Const
WM_APPCOMMAND = $0319;


With that you can declare a message handler. The message record is a
wee bit more complicated. Here is a bunch of other stuff related to the
message from winuser.h:

/* cmd for HSHELL_APPCOMMAND and WM_APPCOMMAND */
#define APPCOMMAND_BROWSER_BACKWARD 1
#define APPCOMMAND_BROWSER_FORWARD 2
#define APPCOMMAND_BROWSER_REFRESH 3
#define APPCOMMAND_BROWSER_STOP 4
#define APPCOMMAND_BROWSER_SEARCH 5
#define APPCOMMAND_BROWSER_FAVORITES 6
#define APPCOMMAND_BROWSER_HOME 7
#define APPCOMMAND_VOLUME_MUTE 8
#define APPCOMMAND_VOLUME_DOWN 9
#define APPCOMMAND_VOLUME_UP 10
#define APPCOMMAND_MEDIA_NEXTTRACK 11
#define APPCOMMAND_MEDIA_PREVIOUSTRACK 12
#define APPCOMMAND_MEDIA_STOP 13
#define APPCOMMAND_MEDIA_PLAY_PAUSE 14
#define APPCOMMAND_LAUNCH_MAIL 15
#define APPCOMMAND_LAUNCH_MEDIA_SELECT 16
#define APPCOMMAND_LAUNCH_APP1 17
#define APPCOMMAND_LAUNCH_APP2 18
#define APPCOMMAND_BASS_DOWN 19
#define APPCOMMAND_BASS_BOOST 20
#define APPCOMMAND_BASS_UP 21
#define APPCOMMAND_TREBLE_DOWN 22
#define APPCOMMAND_TREBLE_UP 23
 
#define FAPPCOMMAND_MOUSE 0x8000
#define FAPPCOMMAND_KEY 0
#define FAPPCOMMAND_OEM 0x1000
#define FAPPCOMMAND_MASK 0xF000
 
#define GET_APPCOMMAND_LPARAM(lParam) ((short)(HIWORD(lParam) & ~FAPPCOMMAND_MASK))
#define GET_DEVICE_LPARAM(lParam) ((WORD)(HIWORD(lParam) & FAPPCOMMAND_MASK))
#define GET_MOUSEORKEY_LPARAM GET_DEVICE_LPARAM
#define GET_FLAGS_LPARAM(lParam) (LOWORD(lParam))
#define GET_KEYSTATE_LPARAM(lParam) GET_FLAGS_LPARAM(lParam)


The macros have to be translated to functions. The best bet for a
message record would be something like

Type
TWMAppCommand = packed record
msg: Cardinal;
wnd: HWND;
keystate: Word;
deviceAndCommand: Word;
result: longint;
end;


With this you could translate the macros as

Function GetAppCommand( Const msg: TWMAppCommand ): Word;
Begin
Result := msg.DeviceAndCommand and not FAPPCOMMAND_MASK;
End;
 
Function GetDevice( Const msg: TWMAppCommand ): Word;
Begin
Result := msg.DeviceAndCommand and FAPPCOMMAND_MASK;
End;


The message handler declaration would amount to this:

Procedure WMAppCommand( Var msg: TWMAppCommand ); Message WM_APPCOMMAND;




Peter Below (TeamB) 100113.1101@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.