PRB: Plug-in Fails to Load in Internet Explorer If It Is Compiled with UNICODE Flag (293100)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 5.5

This article was previously published under Q293100

SYMPTOMS

When you use the Netscape Plug-in Software Development Kit (SDK) to implement a plug-in, if you compile the plug-in with the _UNICODE flag for globalization purposes, you receive the following error message in Internet Explorer:
An error occurred in this plugin.
This problem does not occur when you compile the plug-in normally (or with the _MBCS flag).

CAUSE

The sample plug-in code that Netscape provides does not use the CallWindowProc function to call the default WNDPROC for the plug-in window; the sample code just calls the function pointer that the SetWindowLong function returns directly. This causes an exception (which Internet Explorer handles) because, in a Unicode build, SetWindowLong does not return a function pointer but returns a special handle that CallWindowProc translates into a WNDPROC address.

This is a bug in the Netscape Plug-in SDK sample code.

RESOLUTION

The following code is incorrect in the Plug-in WNDPROC code:
This->fDefaultWindowProc(hWnd, Msg, wParam, lParam);
				
To resolve this problem, modify the code as follows:
CallWindowProc(This->fDefaultWindowProc, hWnd, Msg, wParam, lParam);
				
This problem may not apply to all versions of the samples from Netscape. Because the sample is from a third-party Web site, it may change, and you may encounter problems that this article does not resolve. The sample inside winNPSDK.zip (2.25MB, last modified October 21, 1997) does not exhibit this problem.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Download the Netscape SDK zipped files from the following Netscape Web site:
  2. Unzip the files, and open Simple.mdp in the PluginSDK\Examples\Simple\Windows folder.
  3. In Visual C++ version 6.0 or later, convert the project into .dsw format.
  4. Delete the following files from the Source folder:
    • Npsimple.c
    • Stubs.c
    • Npwin.cpp

  5. Add the following files to the Source folder:
    • Npsimple.c (from PluginSDK\Examples\Simple\Source)
    • Stubs.c (from PluginSDK\Examples\Simple\Source)
    • Npwin.cpp (from PluginSDK\Examples\Common)

  6. In the project settings, insert the _UNICODE flag into preprocessor definitions.
  7. From the Build menu, click Rebuild all to rebuild all the components.
  8. Put the compiled DLL into the Plug-in directory of the Program Files\Internet Explorer\Plugins folder.
  9. Open the HTML file in PluginSDK\Examples\Simple\Testing to load the plug-in. After the page loads, you receive the above-mentioned error message.
NOTE: Plug-ins draw (and do everything else) by calling SetWindowLong to subclass the HWND that they are passed through the NPP_SetWindow function.

The third-party products that are discussed in this article are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.

Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.

Modification Type:MajorLast Reviewed:11/5/2003
Keywords:kbprb KB293100