Ejemplo n.º 1
0
/* Browser is providing us with a window */
static NPError NPP_SetWindow(NPP instance, NPWindow* window)
{
	NPError result = NPERR_NO_ERROR;
	PluginInstance* This;

	if (instance == NULL) return NPERR_INVALID_INSTANCE_ERROR;

	This = (PluginInstance*) instance->pdata;

	if( This->fhWnd != NULL ) {   /* If we already have a window... */

		if( (window == NULL) || ( window->window == NULL ) ) {
			/* There is now no window to use. get rid of the old
			 * one and exit. */
			BeforeDestroyWindow(This);
			This->fWindow=window;
			return NPERR_NO_ERROR;
		}

		else if ( This->fhWnd == (HWND) window->window ) {
			/* The new window is the same as the old one. Redraw and get out. */
			This->fWindow=window;

			InvalidateRect( This->fhWnd, NULL, FALSE );
			/* UpdateWindow( This->fhWnd ); */
			return NPERR_NO_ERROR;
		}
		else {
			/* Unsubclass the old window, so that we can subclass the new
			 * one later. */
			BeforeDestroyWindow(This);
		}
	}
	else if( (window == NULL) || ( window->window == NULL ) ) {
		/* We can just get out of here if there is no current
		 * window and there is no new window to use. */
		This->fWindow=window;

		return NPERR_NO_ERROR;
	}

	/* Subclass the new window so that we can begin drawing and
	 * receiving window messages. */
	This->fDefaultWindowProc = (WNDPROC)SetWindowLong( (HWND)window->window, GWL_WNDPROC, (LONG)PluginWindowProc);
	This->fhWnd = (HWND) window->window;
	SetProp( This->fhWnd, gInstanceLookupString, (HANDLE)This);

	This->fWindow = window;
	find_window_size(This);

	set_scrollbars(This);

	InvalidateRect( This->fhWnd, NULL, TRUE );
	UpdateWindow( This->fhWnd );

	return result;
}
Ejemplo n.º 2
0
static NPError NPP_Destroy(NPP instance, NPSavedData** save)
{
	PluginInstance* This;

	if (instance == NULL) return NPERR_INVALID_INSTANCE_ERROR;
	This = (PluginInstance*) instance->pdata;

	if(!This) return NPERR_INVALID_INSTANCE_ERROR;

	if(This->mng) {
		This->dynamicmng=0;
		mng_cleanup(&This->mng); 
		This->mng=0;
	}
	if(This->lpdib) {
		free(This->lpdib);
		This->lpdib=NULL;
	}
	if(This->mngdata) {
		free(This->mngdata);
		This->mngdata=NULL;
		This->bytesalloc=0;
	}
	if(This->textdata) {
		free(This->textdata);
		This->textdata=NULL;
	}

	if( This->fhWnd ) { // un-subclass the plugin window
		BeforeDestroyWindow(This);
	}

	if(This->bkgdbrush) DeleteObject((HGDIOBJ)This->bkgdbrush);

	if(This) {
		if(instance->pdata) free(instance->pdata);
		instance->pdata = NULL;
	}

	return NPERR_NO_ERROR;
}
Ejemplo n.º 3
0
STDMETHODIMP CBar::DeactivateWindow()
{
	BeforeDestroyWindow();
	return InPlaceDeactivate();
}