Visual plug-ins

Visual plug-in's vis_init() routine gets called every time plug-in gets activated.
     HWND _System vis_init(PVISPLUGININIT initdata);
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 */
     } 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.

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:
                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);

Last revised July 3, 2000, Copyright © Taneli Leppä <rosmo@sektori.com>, Samuel Audet <guardia@cam.org>