Difference between revisions of "SendMessage API"

From Winamp Developer Wiki
Jump to: navigation, search
 
m (Protected "SendMessage API" [edit=autoconfirmed:move=autoconfirmed])
(No difference)

Revision as of 14:08, 25 September 2008

Include files:

Winamp/wa_ipc.h
Winamp/ipc_pe.h

Although Winamp provides input plugins with a number of function pointers to make calls into Winamp, there are simply too many functions in the Winamp SDK to reasonably provide that for every available function. The API was expanded by means of special window messages that could be sent to the main winamp window. Although the API was built this was largely as an historical accident, but this part of API continues to gain new features as it has a number of advantages despite its quirks. A plugin can call a "function" in Winamp by passing a message with msg id == WM_WA_IPC (defined in Winamp/wa_ipc.h). The lParam value determines what function to call and the wParam contains a parameter relevant to the function (often a pointer to a struct in case multiple parameters are needed). These function calls are referred to as IPC's (inter-plugin communication) Despite the quirkiness and the odd reminiscence to DOS interrupt function calls, it does offer two major advantages:

  1. Windows automatically runs the SendMessage response on the "main" application thread, allowing plugins to make SendMessage calls on other threads safely.
  2. *this is important, this is how a lot of stuff gets done by plugins* - By subclassing the main Winamp window, a plugin can alter Winamp's handling of various API calls. This has become such a popular method used by plugin developers that Winamp often sends messages to itself as a way to notify plugins about various events.