[slinkelist] RE: Hardcore slink-e ActiveX programming question

CHRIS PRICE MRPINKY@prodigy.net
Tue, 1 Feb 2000 13:46:59 -0500


>I've come across something that I'm not sure what is going on. In my plugin
>DLL (written in VC++), I can make my dialog box OK and display it when
>WinAmp loads. However as soon as I add the Slink-e ActiveX control to the
>dialog resource, it won't load the dialog (.DoModal() returns -1). This
>also happens if I add any type of ActiveX control.
>
>So, my guess is that there is something special about using ActiveX
>controls in a dialog box created in a DLL. Does anyone know of any such
>restrictions or have any suggestions?
>
>Does anyone know an easy way to load the Slink-e control directly rather
>than "cheating" and loading as a dialog box control?

You won't need a dialog box to do what you are trying to do.  From MSVC, add
the control to your project, and that will cause the wrapper class to be
created.  You need to make sure that you call CoInitialize and
AfxEnableControlContainer when your plug-in is intialized.  The wrapper
class created by MSVC is a subclass of CWnd and to create one of these
correctly, you must call its Create method with a pointer to a valid CWnd
parent window (thats where your dialog was previously serving).  You can
create a simple CWnd object like:
CWnd *parent = new CWnd();
parent->CreateEx(NULL,AfxRegisterWndClass(NULL),NULL,NULL,CRect(0,0,2,2),
NULL, 0);
Normally, window objects aren't visible unless you show them or set up their
class or window properties to be visible.  That parent window will suffice
to be the parent of your control when you call its Create method...since you
don't have UI considerations.

That's it!  You might need to be concerned with threading issues.  I'm not
sure what the threading model is of the WinAmp plugin architecture.  The key
is, call CoInitialize on whatever thread you plan to create the control
on...and make sure that that thread has a message pump.  If you try it on
the main thread that WinAmp calls you on, and you see that messages aren't
flowing in/out of the control, you can pretty much guess that the thread is
not calling Get and DispatchMessage(), so you'll need to create your own
thread with a message pump and create your control on its execution.

Good Luck!