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.
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();