INTERACT FORUM
Windows => Plug-in Development => Topic started by: RhinoBanga on November 14, 2002, 12:12:52 am
-
Hi Guys,
I have been looking at MJ9's plugin interface and I can't seem to get it to work.
I figured out that you moved the registry keys to HKEY_LOCAL_MACHINE so the plugin is now visible within MJ but in v8 the control's ::OnCreate is called prior to Init but in v9 I never get the ::OnCreate and as such I can't create any windows as I don't have a parent hWnd.
Any ideas?
-
We'll look into it. Hopefully within the next couple of builds it's be fixed.
Thanks for everything Rhino.
-
Thanks Matt ... I guess I'd better uninstall v9 until then :(
-
From what I can tell, MJ isn't doing anything different.
Take a careful look at your messge map for your control.
The Sleep Timer looks like this:
BEGIN_MSG_MAP(CSleepTimerCtrl)
CHAIN_MSG_MAP(CComCompositeControl<CSleepTimerCtrl>)
COMMAND_HANDLER(IDC_SLEEP, BN_CLICKED, OnClickedSleep)
MESSAGE_HANDLER(WM_TIMER, OnTimer)
MESSAGE_HANDLER(WM_SIZE, OnSize)
END_MSG_MAP()
That CHAIN_MSG_MAP part steals the WM_INITDIALOG message, so it never makes it through.
Also, depending on the type of control, you may need to handle WM_INITDIALOG instead of WM_CREATE.
The easiest solution would be to call your OnCreate(...) code from Init(...) if it hasn't been run. Use GetParent() if you need a parent.
Does that help at all? Let me know what you figure out...
-
Matt,
Here's my chain map:
BEGIN_MSG_MAP(CInterface)
CHAIN_MSG_MAP(CComControl<CInterface>)
DEFAULT_REFLECTION_HANDLER()
MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
END_MSG_MAP()
And I can definately state that OnCreate is called prior to Init as here is what I do:
LRESULT CInterface::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
AFX_MANAGE_STATE( AfxGetStaticModuleState() );
// Store the hWnd
AlbumView::m_hWnd = m_hWndCD;
// Are we on Windows XP?
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof( vi );
GetVersionEx( &vi );
m_bIsXPOrGreater = ( vi.dwMajorVersion > 5 || (vi.dwMajorVersion == 5 && vi.dwMinorVersion >= 1) );
m_hAppIcon = AfxGetApp()->LoadIcon( IDI_APP_ICON );
// TODO : Add Code for message handler. Call DefWindowProc if necessary.
return DefWindowProc( uMsg, wParam, lParam );
}
And in Init I use AlbumView::m_hWnd as the parent hWnd for all my top level controls.
I will download the latest version of v9 tomorrow and try it again but nothing has changed from my end so it must be something within MJ.
As a test do you have a version of sleep timer converted to work under MJ9? Maybe we could use that to identify the issue?
-
Yeah, I played with Sleep Timer. The version 8 one works. So did one I rebuilt under VS.NET today.
And I did a side-by-side compare of the interface plugin creation code, and the only difference is the registry keys. The only other thing I could imagine would be if somehow the MJFrame (the parent of the control) is in a different state during creation than it was in MJ 8. Seems like a stretch though.
Let me know what you find...
-
Matt,
There is definately an issue.
Using the MSDEV ATL COM wizard I created a DLL. I then inserted an ATL object of type FullControl. I then added the Init and Terminate methods then a handler for OnCreate. Within each of these I placed a call to MessageBox.
In v8 I see OnCreate, Init and Terminate.
In v9 (both b77 and b80) I see Init and Terminate only.
I will send you the sample app in a separate email but it took me 2 minutes to create.
UPDATE
I'm at work and couldn't find your email address Matt so I sent it to matt@jriver.com ... hopefully it will get to you!
-
You need to add this:
m_bWindowOnly = TRUE;
to the constructor of your CComControl. Otherwise, make sure you pick "Windowed only" when using the wizard.
Don't ask why :P
Thanks Rhino.
-Matt
-
WOOHOO!! ;D ;D ;D
A very strange one indeed.