WM

zhaozj2021-02-08  293

Some articles have been copied and can't be uploaded. I don't know what to go back. Let's give you this first, then say it later!

Although this is older, there is always someone needs it. I think, huh! Or when you take up your disk space WM_APPCommand and Enhance Enterprise 1.0 Introduction To create a good user record, hardware suppliers are now open and control software The standard input device (such as keyboard and mouse) adds additional buttons and buttons. These additional input paths can open program, control audio and media program, and open and control Internet browsers. Before Windows 2000 is released, the Windows operating system requires hardware manufacturers to upgrade hardware standards for these enhancements. Windows 2000 Operating System BATA 3, with new Windows APIs named WM_APCommand, providing local support for 15 new multimedia events. When these new multimedia events occur, this newly defined message is notified in the focus. 2.0 WM_APCOMMAND_ENABED MULT WM_APCOMMAND API messages in the local operating system, define direct ways to receive enhanced button event notifications for program. Then, the program can initialize any predefined features connected to a particular key event. For example, an MDI can use the Backward and Forward events to circulate document windows. Add a WM_APCommand handle to make programs to work with new HID devices that support this extended keyboard, mouse, and other new HID devices that support this extension. When a supported key or button is pressed, a series of events occur and cause the WM_APCommand message to send the input focus window. If the window does not processes the WM_APPCommand message, the operating system "bubbling" to the window of the window, so thus three until the top window. This process ends if either window processing messages and returns TRUE. If the top-level window does not proceed, the WM_APPCommand message is sent to the shell hook. 2.1 Use DEFWindowProc to clear the WM_APPCommand series rely on programs that can properly handle unused Windows messages. Developers should continue to deliver unused keyboards, mouse, and WM_APPCommand messages to DEFWINDOWPROC. Useless messages without this way will be interrupted will interrupt the WM_APCommand series. 2.2 WM_AppCommand For most programming, the most natural way to process the keyboard button event is to support the new multimedia keyboard key and mouse button by using the virtual key (VKS) transmitted by WM_KEYDOWN and WM_KEYUP messages. Do not use VKS recommended. There are two reasons for this. First, use WM_APPCommand, you need to establish all HID device support that can generate this message (such as a keyboard, and mouse). Since further support for all types of enhancements is added to Windows 2000, there will be a list of upgraded devices that do not generate VKS but WM_APPCommand, and the second, wm_keydown or wm_keyup message is sent to the window with input focus, and will not "bubble "Go to the father window. This causes the control "Eat" these key messages and interrupts the WM_APPCommand series. Figure 1 WM_APCOMMAND3.0 Troubleshooting Question 1: WM_APPCommand-Enabled program, no response WM_APCOMMAND message may be 1: Nothing returns the correct return value. It is very important to return the correct value at each stage of the process. When a WM_KEYDOWN message is processed, the return value should be false (or 0). When the WM_XBUTTON or WM_APPCOMMAND message is processed, the return value should be true (or 1). Figure 1 provides detailed information, an appendix A provides a routine.

Possible Cause 2: No unprocessed message for DEFWINDOWPROC. When you add WM_APCOMMAND support in the program, the unprocessed message is transmitted to DEFWINDOWPROC instead of calling DEFWINDOWPROC for message clearance, there is a common error. In Windows 2000, a WM_APPCommand message is generated by DEFWINDOWPROC when a virtual key code is known or an Xbutton message arrives. Figure 1 provides detailed information, an appendix A provides a routine. Possible cause 3: The control "eat" message. Note: The WM_KeyDown message is sent by the focus to the window instead of the front desk window, and does not "bubbling" to the parent window. This means that buttons and other controls can receive these messages and can "eat" them. In all program message processing mechanisms, it is important to use DEFWIndowProc. Figure 1 provides detailed information, an appendix A provides a routine. 4.0 WM_APPCommand Requirements In Windows 2000, use Microsoft IntelliTy Pro 1.0 or IntelliPoint 3.0 software to enhance local WM_APPCommand support, IntelliTy Pro and Intellipoint imitates enhanced WM_APPCommand support on traditional Microsoft operating systems. Use Microsoft Intellitype Pro: Windows 2000: 1.0 Enhanced Edition Support Beta 3; 1.1 Enhancement Support Windows 2000. Final release Windows NT4.0: Support Service PRO 1.0 . Support Service PRO 3 and subsequent versions support. Windows 95/98: Supported by Intellitype Pro 1.0 . Windows CE: does not support. Use Microsoft Intellipoint: Windows 2000: 3.0 Enhancement Support Beta 3; 3.01 Enhanced Edition supports Windows 2000. Final release. Windows NT4.0: Service Pack 3 and subsequent versions supported by IntelliPoint 3.0 . Windows 95/98: Supported by IntelliPoint 3.0 . Windows CE: Not supported. 5.0 WM_APPCommand features See 6.0 How to Handle WM_APPCommand Message Processing This message is like processing menu or toolbar commands. For example: The menu command can be processed in the window: Case WM_COMMAND: Switch (wparam) {copy IDC_PlayPause: onplaypause (hwnd); return false; case IDC_Stop: onstop (hwnd); return false;

Case IDC_PREV: OnPrev (hwnd); Return False;

Case IDC_Next: Onnext (hwnd); return false; [other commands ...]} [...]

Return DefWindowProc (HWND, Message, WPARAM, LPARAM); Keyboard command processing mode is similar. But there is an important difference: if the message is processed, the WM_APPCommand handler must return 1, not a common return value 0. It is also important to pass the code that is not available to DEFWIndowProc (). Thus, other programs can have the opportunity to handle them. case WM_APPCOMMAND: switch (GET_APPCOMMAND_LPARAM (lParam)) {case APPCOMMAND_MEDIA_PLAY_PAUSE: lr = OnPlayPause (hwnd); if (lr == NOERROR) return TRUE; break; case APPCOMMAND_MEDIA_STOP: lr = OnStop (hwnd); if (lr == NOERROR) Return True; Break;

Case appcommand_media_previoustrack: lr = onprev (hwnd); if (lr == noerror) Return TRUE; Break

Case appcommand_media_nexttrack: lr = onnext (hwnd); if (lr == noerror) return true; Break;}

Return DefWindowProc (Hwnd, Message, WPARAM, LPARAM);

6 WM_APPCommand_enabled program routines see Appendix A. 7 Enhance the Microsoft IntellitypePro software of the keyboard. In 1999, Microsoft Hardware Division introduced three new enhanced keyboards, new bonds (hotkeys) allowed users to control Internet browsers, media players, mail client programs, and unused mouse open programs. In Windows 2000, IntelliTyPro software enhances support for existing local operating systems, which also provides new key support for early Microsoft Operating System IntellitypePro. 7.1 WM_APCommand in Windows 2000 WM_APCommand runs IntelitypePro in Windows 2000, which is enhanced by the non-front program for subset of WM_APPCommand messages (all media messages and "home"), and enhanced local WM_APPCommand. If you are running Intellitype and a front desk window, you do not process messages generated by WM_AppCommand (and use defWindowProc to eliminate this use). Then INTELLITYPRO uploads the WM_APPCommand message to each of the primary windows in the current z-Order until this message is used to use this message or all windows ignore this message. 7.2 Microsoft IntellitypePro's WM_AppCommand on traditional Windows is consistent in the operating system, in the previous Microsoft Operating System release, IntelliTyPePro imitation Windows 2000 local WM_APCommand support. IntellityPepro also provides 7.1 description enhancements. Win32® programs running in Win95 / 98 / NT.40 (SP3 and later), if the IntelliTyPecro software is installed. Relying on the enhanced keyboard button will receive a WM_APCOMMAND message. The WM_APPCommand-Enabled program will work as in the local operating system. 7.3 Adding a Media Player to the IntellitypePro Media Menu Pressing the Media button to display the media player on the computer. The menu lists only list of players supported by local WM_AppCommand. You can add a new player to this list, but you cannot add your own player unless you work with all media keys on your keyboard. When the media key head is pressed, the search for the known media player is initialized. The supported media player list then appears in the registry key: HKEY_CURRENT_USER / SOFTWARE / Microsoft / Keyboard. In order to add a media player to this list, there must be the path to the new player .exe file and the name that wants to display in the media menu. 7.3.1 When adding a new player new player is added to the IntelliPro Media menu when you install it on your computer system. This process level needs to be executed. The registry is essentially a number of copies that are not allowed in the same primary key. All programs that use this method will be displayed on the media menu, and only the functionality of this enhanced keyboard keys by WM_APPCommand-Enabled or program supported by IntelliTyPro software. 7.3.2 When the new player lists the new player in the Media menu, it will immediately appear in the Media menu after being added to the registry and "Media" button. Only legal .exe files are listed. On each media key, before the media menu list, press the IntelliTyPro software unfounded .exe file exists in the list of the list.

7.3.3 Adding a player to the media menu step 1 Under the registry primary key HKEY_CURRENT_USER / SOFTWARE / Microsoft / Keyboard, check the primary key named "Native Media Players". If there is no existence, create it (see Appendix B Create the primary key) Example) 2 The primary key with two string values ​​under the primary key HKCU / Software / Microsoft / Keyboard / Native Media Players, which should be described by the newly added device. 3 In the newly created key, add a string value of "AppName", this value should be the name that is wanting to display in the Media menu (such as "New Player"). 4 In the newly created key, add a string value of "exec", this value should be the exact path of the player's .exe file (such as: c: / program files / newplayer / newplay.exe). 7.3.4 Routine Code Appendix B contains code that can add a media player to the IntelliTyPro Media menu. 8.0 WM_APPCommand and Microsoft Mouse Microsoft release a new five-click Intellimouse® resource manager, the new button defaults to forward and backwards, as the forward and backpoints in the Internet browser. Windows 2000 has support for these keys built-in messages. In a traditional Microsoft operating system, the new IntelliPoint 3.0 software adds full support to the new button. IntelliPoint 3.0 also allows this feature to be assigned on all Microsoft Mouse Products buttons. 8.1 Windows 2000 New Message Windows 2000 Add a new message to the new mouse button, the XButton message, similar to the triple button message, the main difference, the independent message of the two keys. Set a flag in WPARAM to specify that key to perform action. If keynion is a program that advances to the back function, it is best to handle the WM_APPCommand message. This recognizes the forward / backup function, regardless of whether the mouse, keyboard, or other future devices are connected. To replace the use of a button related to the mouse, an optional tool in the CAD program, a good method is to respond to the Xbutton message. When processing the XButton message, remember to return TRUE to prevent the generation of the WM_APPCommand message. If the program does not use the WM_APPCommand message itself, IntelliPoint will try to perform a forward / backpaper in a program that has not processed the WM_APCommand message. 8.3 WM_APCommand on the traditional operating system is a coherence of the program function in the operating system, and IntelliPoint 3.0 imitates the local WM_AppCommand and Xbutton support for Windows 2000. When INTELLIPOINT is installed, Win32 running on Windows 95/98 / NT4.0 will receive XButton and WM_APPCommand messages, as they run on the local operating system. 9.0 supports the five-button mouse, the new Windows message is as follows: WM_XBUTTONDOWNWM_XBUTTONUPWM_XBUTTONDBLCLKWM_NCXBUTTONDOWNWM_NCXBUTTONUPWM_NCXBUTTONDBLCLK Appendix A: Using a simple media player WM_APPCOMMAND this case is a simple media player handles all WM_APPCOMMAND and media events from enhanced keyboard enhanced. Increase the enhanced mouse support will add message handles for Xbutton messages: #include #include "resource.h"

LPARAM WINAPI MainWndProc (HWND, UINT, WPARAM, LPARAM); BOOL InitDialog (HWND); BOOL OnClose (HWND hwnd); BOOL OnTimer (HWND hwnd); BOOL OnPlayPause (HWND hwnd); BOOL OnStop (HWND hwnd); BOOL OnPrev ( HWND HWND); BOOL ONNEXT (HWND HWND);

//// the supported WM_APPCommand Events / / # ifNDEF WM_APPCommand

#define WM_APPCOMMAND 0x319 # define APPCOMMAND_MEDIA_NEXTTRACK 11 # define APPCOMMAND_MEDIA_PREVIOUSTRACK 12 # define APPCOMMAND_MEDIA_STOP 13 # define APPCOMMAND_MEDIA_PLAY_PAUSE 14 # define FAPPCOMMAND_MASK 0x8000 # define GET_APPCOMMAND_LPARAM (lParam) ((short) (HIWORD (lParam) & ~ FAPPCOMMAND_MASK))

#ENDIF

/// PLAYER constants // const uint display_timer_id = 100; const uint timer_interval = 1000; const uint num_tracks = 10;

Hinstance hinstance = 0;

Uint TrackIndex; uint tracktime;

Char sztrackindex [3]; char sztracktime [5];

Bool isplaying; bool isbetweentracks;

/ / -------------------------------------------------------------------------------------------- ------------ // WinMain () // // main windows routine. All the usual stuff./////---------------- --------------------------------------------- Int Pascal WinMain (Hinstance Hinstance, Hinstance Hprevinstance, LPSTR LPCMDLINE, INT NCMDSHOW) {:: hinstance = hinstance;

//// register the main window class // WNDCLASS WC;

wc.style = CS_VREDRAW | CS_HREDRAW; wc.lpfnWndProc = (WNDPROC) MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = DLGWINDOWEXTRA; wc.hInstance = hInstance; wc.hIcon = 0; wc.hCursor = LoadCursor (NULL, IDC_ARROW ); wc.hbrbackground = createsolidbrush (getSyscolor (color_background)); wc.lpszMenuname = null; wc.lpszclassname = "app_cmd";

IF (! RegisterClass (& WC)) Return False; // Create The Main Window As Dialog. // HWND HWndmain = Created, "App_CMD", 0, NULL); ShowWindow (HWndmain, Sw_Shownormal);

// Initialize Initdialog (HWndmain);

Msg Msg; While (GetMessage (& MSG, NULL, 0)) {TranslateMessage (& MSG); DispatchMessage (& MSG);} Return (msg.wparam);} // end winmain ()

/// * ---------------------------------------------- -------------- /// mainwndproc () - Main window callback procedure.// // ----------------- ------------------------------------------

LParam WinApi MainWndProc (HWND HWND, UINT MSG, WPARAM WPARAM, LPARAM LPARAM) {Switch (MSG) {

// Handle the WM_APPCOMMAND messages here Return TRUE if we handle the message.// case WM_APPCOMMAND: switch (GET_APPCOMMAND_LPARAM (lParam)) {case APPCOMMAND_MEDIA_PLAY_PAUSE: OnPlayPause (hwnd); return TRUE;.

Case appcommand_media_stop: onstop (hwnd); return true;

Case appcommand_media_previoustrack: onprev (hwnd); return true;

Case appcommand_media_nexttrack: onnext (hwnd); return true;} Break;

Case WM_Close: Return OnClose (HWND);

Case WM_TIMER: RETURN ONTIMER (HWND);

// Handle The interface Messages Here. Return False IF We Handle The Message // Case WM_COMMAND: Switch (WPARAM) {CASE IDC_PLAY: CASE IDC_PAUSE: ONPLAYPAUSE (HWND); RETURN FALSE

Case IDC_Stop: onStop (hwnd); Return False;

Case IDC_PREV: OnPrev (hwnd); Return False;

case IDC_NEXT: OnNext (hwnd); return FALSE;} break;} // Clean up any unused messages by calling DefWindowProc // return DefWindowProc (hwnd, msg, wParam, lParam);} //// Initialize the player UI // BOOL INITDIALOG (HWND HWND) {// Start on First TRACK TRACKINDEX = 0;

// Start at beginningning of track tracktime = 0;

// Don't Play Until the user tells us to isplaying = false;

// set the icon for the "play" Button Hicon Hicon = loading (Hinstance, MakeintResource (IDi_Play)); SenddlgiteMmessage (HWND, Idc_Play, BM_SetImage, Image_ICON, (LPARAM) HICON;

// set the icon for the "pause" Button Hicon = Loadicon (Hinstance, MakeintResource (IDI_PAUS)); SenddlgiteMmessage (hww, idc_pause, bm_setimage, image_icon, (lparam);

// set the icon for the "stop" button hicon = loading "; senddlgitemmessage (hww, idc_stop, bm_setimage, image_icon, (lparam) Hicon;

// set the icon for the "previous" Button Hicon = loading (Hinstance, MakeintResource); SenddlgiteMmessage (hww, idc_prev, bm_setimage, image_icon, (lparam) Hicon;

// set the icon for the "next" button hicon = loading (Hinstance, MakeintResource); SenddlgiteMmessage (hww, iDC_Next, BM_SetImage, Image_ICON, (LPARAM) HICON;

// Start a Timer To Update The Track Time Display SetTimer (Hwnd, Display_timer_ID, Timer_Interval, Null);

Return True;}

//// close the application // Bool onclose (hwnd hwnd) {killtimer (hwnd, display_timer_id); destroyWindow (hwnd); postquitMessage (0); return true;}

//// Update Track UI // void UpdateTrackInfo (HWND hwnd) {wsprintf (szTrackIndex, "% d", trackIndex 1); SetDlgItemText (hwnd, IDC_TRACKINDEX, szTrackIndex); wsprintf (szTrackTime, "0:% 02d", TrackTime); setdlgitemtext (hwnd, idc_tracktime, sztracktime);}

//// Timer controls how fast the UI "time" display changes // BOOL OnTimer (HWND hwnd) {if (isPlaying) {// make sure the display is visible UpdateTrackInfo (hwnd); HWND hwndDisplay = GetDlgItem (hwnd, IDC_TRACKTIME ); Showwindow (hwnddisplay, sw_show);

// Advance The Counter TRACKTIME;

// every track is 60 seconds if (trackTime> = 60) OnNext (hwnd); // advance to the beginning of the next track} else {// get the track time window HWND hwndDisplay = GetDlgItem (hwnd, IDC_TRACKTIME);

// Flash THE DISPLAY IF (ISWindowVisible (HWndDisplay)) showwindow (hwnddisplay, sw_hide); Else ShowWindow (HWndDisplay, SW_SHOW);

UpdateTrackInfo (HWND); Return True;}

//// Start / Pause The Ui's "Time" Index // Bool OnPlayPause (HWND HWND) {// Toggle Between Play and Pause isplaying =! Isplaying;

UpdateTrackInfo (HWND); Return True;}

//// stop the ui's "time" index // BOOL onstop (hwnd hwnd) {// stop playing and move to beginning of track isplaying = false; tracktime = 0; TRACKTIME = 0;

UpdateTrackInfo (HWND); Return True;}

/// goto the previous track // Bool Onprev (HWND HWND) {//iff the user is at the beginning of a track if (TrackTime <1) {// set the TRACK INDEX TO The Previous TRACK IF (TrackIndex = = 0) TrackIndex = NUM_TRACKS-1; Else --TrackIndex% = NUM_TRACKS;

// go back the beginning of the track tracktime = 0; UpdateTrackInfo (HWND); Return True;}

//// goto the next track // bool onnext (hwnd hwnd) {/ / go to the beginning of the next track trackIndex% = NUM_TRACKS; TrackTime = 0;

UpdateTrackInfo (HWND); Return True;}

Appendix B: An example of adding a media player to the IntelliTyPePro Media menu. #define mskb_key "Software // Microsoft // Keyboard // Native Media Players"

BOOL AddPlayerToRegistry (LPSTR szDisplayString, LPSTR szExePath) {// open Microsoft Keyboard Native Media key OR if it does not exist, create it HKEY hKey; DWORD dwDisposition;! If (ERROR_SUCCESS = RegCreateKeyEx (HKEY_CURRENT_USER, MSKB_KEY, 0, 0, REG_OPTION_NON_VOLATILE, Key_all_access, 0, & hkey, & dwdisposition) Return 0;

// create a key for new media player (using DisplayString as key name) HKEY hSubKey; if (! ERROR_SUCCESS = RegCreateKeyEx (hKey, szDisplayString, 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, & hSubKey, & dwDisposition)) return 0;

// Add AppName string value to new key and copy in the DisplayString if (ERROR_SUCCESS = RegSetValueEx (hSubKey, "AppName", 0, REG_SZ, (const BYTE *) szDisplayString, strlen (szDisplayString))!) Return 0;

// Add ExePath string value to new key and copy in the ExePath if (ERROR_SUCCESS = RegSetValueEx (hSubKey, "ExePath", 0, REG_SZ, (const BYTE *) szExePath, strlen (szExePath))!) Return 0; // close REG Keys if (Error_Success! = regcloseKey (HKEY)) Return 0; if (Error_Success! = RegcloseKey (HSubkey) Return 0;

Return 1;}

转载请注明原文地址:https://www.9cbs.com/read-1013.html

New Post(0)