Tells the plug-in when a window is created, moved, sized, or destroyed.
#include <npapi.h> NPError NPP_SetWindow(NPP instance, NPWindow *window);
The function has the following parameters:
- Pointer to the current plug-in instance. Must be embedded or full-screen.
- Pointer to the window into which the instance draws. The window structure contains a window handle and values for top left corner, width, height, and clipping rectangle (see note on Unix below).
- If successful, the function returns NPERR_NO_ERROR.
- If unsuccessful, the plug-in is not loaded and the function returns an error code. For possible values, see Error Codes.
The browser calls
NPP_SetWindow after creating the instance to allow drawing to begin. Subsequent calls to
NPP_SetWindow indicate changes in size or position; these calls pass the same NPWindow object each time, but with different values. If the window handle is set to null, the window is destroyed. In this case, the plug-in must not perform any additional graphics operations on the window and should free any associated resources.
The data structure passed in
NPP_SetWindow is an NPWindow object, which contains the coordinates of the instance's area and various platform-specific data. This window is valid for the life of the instance, or until
NPP_SetWindow is called again with a different value.
For windowed plug-ins on Windows and Unix, the window parameter contains a handle to a subwindow of the browser window hierarchy. On Mac OS, this field points to an NP_Port structure. For windowless plug-ins, it is a platform-specific handle to a drawable.
Before setting the window parameter to point to a new window, it is a good idea to compare the information about the new window to the previous window (if one existed) to account for any changes.
For windowless plugins,
NPP_SetWindow is called with a
0,0,0,0 to signal that the plugin is not visible.
NOTE: NPP_SetWindow is useful only for embedded (NP_EMBED) or full-screen (NP_FULL) plug-ins, which are drawn into windows. It is irrelevant for hidden plug-ins.