PM123 visual plug-ins

Visual plug-ins must implement and export the functions defined in plugin.h. The interface has changed with plug-in level 1.
Plug-ins with interface level 0 are no longer supported!

Before including any PM123 include file the macro VISUAL_PLUGIN_LEVEL must be defined if you want to use anything higher than level 1. Example:

     #define VISUAL_PLUGIN_LEVEL 1

Visual plug-ins must implement and export the functions defined in visual_plug.h.

HWND DLLENTRY vis_init( PVISPLUGININIT initdata );
Visual plug-in's vis_init() routine gets called every time plug-in gets activated. The VISPLUGININIT structure contains the initialization data that PM123 passes to the plug-in.
typedef struct {
  int           x, y, cx, cy;
   /* Location where the plug-in should create its window */
  HWND          hwnd;
   /* PM123's window handle */
  PPLUGIN_PROCS procs;
   /* Pointers to functions which plug-ins can utilize */
  int           id;
   /* Plug-in's ID (1-32) */
  char          *param;
   /* Parameters passed to the plug-in */
  HAB           hab;   
   /* PM123's anchor block handle */

} VISPLUGININIT, *PVISPLUGININIT;

On return from the initialization function, the function should return the plug-in's window handle. The plug-in shouldn't not rely that initdata structure is pointing to the right location all the time, instead it should make its own copy of the structure.

The pluig-in parameter param in the VISPLUGININIT structure optionally contains parameters from the skin's .SKN file.

If the plug-in creates a window, here's a window procedure you should base yours on:

MRESULT EXPENTRY PlugWinProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
  switch (msg)
  {
    case DM_DRAGOVER:
    case DM_DROP:
    case 0x041f:
    case 0x041e:
    case WM_CONTEXTMENU:
    case WM_BUTTON2MOTIONSTART:
    case WM_BUTTON1MOTIONSTART:
      WinSendMsg( plug.hwnd, msg, mp1, mp2 );
      break;

    /* your stuff */

    default:
      return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  }
}
If you want to create a window inside PM123's window, use WinCreateWindow() in vis_init():
WinRegisterClass( hab,
                  "ExamplePlugin",
                  PlugWinProc,
                  CS_SIZEREDRAW, 0 );

hwndClient = WinCreateWindow( initdata->hwnd,
                              "ExamplePlugin",
                              "PM123 Example Visual Plug-in",
                              WS_VISIBLE,
                              initdata->x,
                              initdata->y,
                              initdata->cx,
                              initdata->cy,
                              initdata->hwnd,
                              HWND_TOP,
                              initdata->id,
                              NULL,
                              NULL );
return hwndClient;
Visual plug-ins should deinitialize and destroy their windows and free allocated memory when receiving a
int DLLENTRY plugin_deinit();