Anybody see what I did wrong?
-
I'm using Visual C++ 6.0 SP5 I create a new MFC Appwizard project, I choose SDI with doc/view architecture support, then I leave everything at the defaults until it asks me How do you want your toolbars to look? and I choose Internet Explorer Rebars then finish. Next I enter the Project menu and choose Add to project then Components and Controls. This opens up the Components and Controls Gallery. In there I pick the Registered ActiveX Controls folder and find the Microsoft Multimedia Control (for me it is version 6.0) and insert it leaving all the options at their defaults. In the resource editor under dialogs I edit the IDR_MAINFRAME dialog and add the multimedia control to it from my controls palette. I double click my newly created multimedia control and Classwizard pops up with a message saying IDR_MAINFRAME is a new resource... do you want to add a class for it? and I choose select an existing class and choose CMainFrame. Now I close Classwizard and go back to the resource editor and right click my multimedia control and choose events to add the OnPlayClick event handler. It prompts me for the name of the event handler and I just leave it as the default OnPlayClickMmcontrol1. Then in the code for the event handler I just put something simple to test out the button like
AfxMessageBox("bleah");
Next I edit the end of the CMainFrame::OnCreate function like so in order to initialize the multimedia control (this assumes you have c:\windows\media\ding.wav available):... ... // get a pointer to the multimedia control Cmci* mci = (Cmci*) m_wndDlgBar.GetDlgItem(IDC_MMCONTROL1); // initialize the multimedia control mci->SetFileName("c:\\windows\\media\\ding.wav"); mci->SetCommand("Open"); return 0;
I also include the multimedia control header in mainfrm.cpp like so to satisfy the compiler#include "mci.h"
I run the program and the multimedia control works except the OnPlayClick event handler doesn't seem to get called. If I do the same idea but with a dialog based program instead of SDI then it will work normally. I think for some reason the activeX control won't deliver events when it is on the dialogbar but I can't fathom why. anybody know why? I am stumped... Any ideas are appreciated. -Oinka -
I'm using Visual C++ 6.0 SP5 I create a new MFC Appwizard project, I choose SDI with doc/view architecture support, then I leave everything at the defaults until it asks me How do you want your toolbars to look? and I choose Internet Explorer Rebars then finish. Next I enter the Project menu and choose Add to project then Components and Controls. This opens up the Components and Controls Gallery. In there I pick the Registered ActiveX Controls folder and find the Microsoft Multimedia Control (for me it is version 6.0) and insert it leaving all the options at their defaults. In the resource editor under dialogs I edit the IDR_MAINFRAME dialog and add the multimedia control to it from my controls palette. I double click my newly created multimedia control and Classwizard pops up with a message saying IDR_MAINFRAME is a new resource... do you want to add a class for it? and I choose select an existing class and choose CMainFrame. Now I close Classwizard and go back to the resource editor and right click my multimedia control and choose events to add the OnPlayClick event handler. It prompts me for the name of the event handler and I just leave it as the default OnPlayClickMmcontrol1. Then in the code for the event handler I just put something simple to test out the button like
AfxMessageBox("bleah");
Next I edit the end of the CMainFrame::OnCreate function like so in order to initialize the multimedia control (this assumes you have c:\windows\media\ding.wav available):... ... // get a pointer to the multimedia control Cmci* mci = (Cmci*) m_wndDlgBar.GetDlgItem(IDC_MMCONTROL1); // initialize the multimedia control mci->SetFileName("c:\\windows\\media\\ding.wav"); mci->SetCommand("Open"); return 0;
I also include the multimedia control header in mainfrm.cpp like so to satisfy the compiler#include "mci.h"
I run the program and the multimedia control works except the OnPlayClick event handler doesn't seem to get called. If I do the same idea but with a dialog based program instead of SDI then it will work normally. I think for some reason the activeX control won't deliver events when it is on the dialogbar but I can't fathom why. anybody know why? I am stumped... Any ideas are appreciated. -OinkaHas the function
AfxOleInit()
been called somewhere in your codes? Sonork 100.41263:Anthony_Yio -
Has the function
AfxOleInit()
been called somewhere in your codes? Sonork 100.41263:Anthony_YioHi Anthony, no that function is not called anywhere in the project. Is it needed? I can't find any documentation about it other than what I found in msdn: Remarks Initializes the OLE DLLs.
MSDN you suck!
anyways, I tried adding a call toAfxOleInit()
but all it did was make an assertion fail. When I looked into this I found out that it was checking to see ifAfxOleInit()
has been called twice. So even though the function call doesn't appear in any of MY code, the framework seems to have called the function for me behind the scenes. See Ask Dr. GUI #57[^] so yeah I still can't figure out how to get the event handler to work. -
Hi Anthony, no that function is not called anywhere in the project. Is it needed? I can't find any documentation about it other than what I found in msdn: Remarks Initializes the OLE DLLs.
MSDN you suck!
anyways, I tried adding a call toAfxOleInit()
but all it did was make an assertion fail. When I looked into this I found out that it was checking to see ifAfxOleInit()
has been called twice. So even though the function call doesn't appear in any of MY code, the framework seems to have called the function for me behind the scenes. See Ask Dr. GUI #57[^] so yeah I still can't figure out how to get the event handler to work. -
The control will send the notification to it's parent window (the dialog bar). You could put a trace for it in the dlg bar's PreTranslateMessage, just to check what's happening, or use SPY++ to spy on the dialog bar. Steve S
Hey Steve, With your help I finally got this damn thing to work :-D Since the CDialogBar class (the one that was created in the OnCreate method of the CMainFrame class) was getting my messages I replaced it with a class of my own derived from CDialogBar and added my message map and eventsink map and it works now. Here's an even harder question: why in the hell did microsoft make me jump through that many hoops just to use a bloody activeX control in a toolbar? Isn't there an easier way? thanks, -Oinka
Microsft Sucks!