|
Amar Sutar wrote: [id(3), helpstring("method get_StreamMediaType")] HRESULT get_StreamMediaType([in,out] AM_MEDIA_TYPE* pVal);
AM_MEDIA_TYPE present in 'strmif.h' file.
it better you copy that structure in your IDL file!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
There is also a strmif.idl file, which includes axcore.idl which defines that structure AM_MEDIA_TYPE, so I would import "strmif.idl"; to get hold of the definiton
|
|
|
|
|
I want to create a DLL which will have to create windows and dialogs, and wanted to use WTL for creating the DLL. I know it's possible to create a DLL with MFC and so thought it might be possible to do it with WTL. Is this the case and if so does anyone have a demo project available ?
|
|
|
|
|
|
Thanks again hfry! On first look I found two relevant source files - wtldlldialog.zip AND WTL_DLL.ZIP. It's too late now to check them out, but I will look at them over the next couple of days...... I may be back in the near future asking more questions
Let me give you some background to my problem.... I have a C-based app which has a plugin interface which supports certain features. When implementing these features, it is sometimes necessary to create windows and/or dialogs. I wanted to create it using WTL so that I can benefit from all of WTL's great classes for GUI implementation (including CDialogResize).
Anyway, that's the second time you've helped me, and I really appreciate it.
Best Regards.....
|
|
|
|
|
|
I have ATL 3.1 and WTL 7.0 installed. Are they compatible?
The reason for this is that Windows 2000 comes with ATL 3.1 and since I didn't get WTL 3.1 anywhere, I downloaded WTL 7.0. Everything was working fine, till I had to use the CPaneContainer class. To use this class I had to include atlctrlx.h to my project and that's where all the trouble started. Now it throws an error at compile time saying...
d:\program files\microsoft visual studio\vc98\include\atlctrlx.h(802) : error C2039: 'ShellExecute' : is not a member of '`global namespace''
Could anyone tell me why this error? Is it due to the version incompatibility? If yes then can anyone guide me to a download link to WTL 3.1 or ATL 7.0. Will ATL 7.0 work on Windows 2000?
Thanks...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Hi,
I got hold of the culprit. The error was occuring due to the WIN32_LEAN_AND_MEAN macro. When the macro was defined it removed the header where ShellExecute was declared.
Thanks....
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Yes, you can use WTL 7 with VC 6 (WTL is AFAIK still being kept backward compatible with VC 6).
#include the right header to get the ShellExecute() definition.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
I am creating a console application,in which I create an instance on IE and hook an event sink to it.The main code is as follows:
CoInitializeEx(NULL, COINIT_MULTITHREADED);
IWebBrowser2* disp;
HRESULT hr;
hr=CoCreateInstance(CLSID_InternetExplorer,NULL,CLSCTX_LOCAL_SERVER,IID_IWebBrowser2,(void**)&disp);
if(SUCCEEDED(hr))
{
disp->put_Visible(TRUE);
LPSTREAM pStream = NULL;
//marshalling the broser interface
hr = CoMarshalInterThreadInterfaceInStream(IID_IWebBrowser2, disp, &pStream);
.......
HANDLE hThread = CreateThread(NULL, 0, ThreadProc1,pStream, 0, &dwThreadID);
WaitWithMessageLoop(hThread);
......
}
}
...........
disp->Navigate2(&vurl, &ve, &ve, &ve, &ve); */
CoUninitialize();
In threadprocfunction,i create an instance of teh sick and hook it to IE
CoInitialize(NULL);
........
// get proxy to interface and release IStream
HRESULT hr = CoGetInterfaceAndReleaseStream(pStream, IID_IWebBrowser2, (LPVOID*)&psIE);
HRESULT hr=CoCreateInstance(CLSID_InternetExplorer,NULL,CLSCTX_LOCAL_SERVER,IID_IWebBrowser2,(void**)&psIE);
....... //Create the listener instance
hr = CoCreateInstance(CLSID_emplaybacksink,NULL,CLSCTX_INPROC_SERVER,IID_Iemplaybacksink,(void**)&tsink);
....... {
AtlAdvise( psIE,pUnk,DIID_DWebBrowserEvents2,&m_dwCookie);
........ }
The Atladvise action causes IE to hang during navigation.It proceeds only after the application has exitted.It seems there is a deadlock when IE calls back into the event sink.How can i avoid it?
|
|
|
|
|
1. You shouldn't call CoInitialize in the thread-proc (don't know if that affects you problem, though).
2. You CoCreateInstance Internet Explorer in your thread-proc, replacing the interface pointer passed (by marshalling) to the thread.
I think the main thing is that your thread doesn't have a message loop, so it's unlikely that connection points will work, as they rely (IIRC) on Windows messages.
Why use multiple threads, anyway? Connection points & IE work fine in a single-threaded app...
|
|
|
|
|
Stuart Dootson wrote: 1. You shouldn't call CoInitialize in the thread-proc (don't know if that affects you problem, though).
Yes, you should. Every thread that uses COM must initialise COM; these calls are also how you inform COM of your thread's threading model.
Stuart Dootson wrote: that connection points will work, as they rely (IIRC) on Windows messages.
No they don't. They are simply interface method calls, typically calls to IDispatch::Invoke . STA threads are required to have message pumps but MTAs do not need them. The only time when not having a message pump will affect calling a connection point is if the sink is in a STA and it is called from another apartment. This issue is not related to connection points; it's a general issue.
Steve
|
|
|
|
|
Actually i had initalized my new thread within an MTA too;but the results did not change .
When i try this with a GUI based application - firing the IE on the click of a button ;everything is fine - and the component receives the call-back on navigatecomplte/documentcomplte etc.
Is tehre any suggestion no how to make the console application implement a message handling framework as a ATL GUI based application?
|
|
|
|
|
Here's a complete example. It handles the new window and quit events from IE. It's a console app using no libraries (apart from the standard library) and uses two MTA threads like your code:
---------------------------------------
// Console.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <objbase.h>
#include <Exdisp.h>
#include <ocidl.h>
#include <EXDISPID.H>
#include <iostream>
HANDLE g_hThread = NULL;
HANDLE g_hBail = NULL;
class CMyDispatch : public IDispatch
{
public:
/* IUnknown methods */
STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject)
{
if (!ppvObject)
{
return E_POINTER;
}
*ppvObject = NULL;
if ( IsEqualIID(iid, IID_IUnknown) || IsEqualIID(iid, IID_IDispatch) )
{
*ppvObject = this;
return S_OK;
}
return E_NOINTERFACE;
}
STDMETHOD_(ULONG, AddRef)(void)
{
return 0;
}
STDMETHOD_(ULONG, Release)(void)
{
return 0;
}
/* IDispatch methods */
STDMETHOD(GetTypeInfoCount)(UINT * pctinfo)
{
if (!pctinfo)
{
return E_POINTER;
}
*pctinfo = 0;
return S_OK;
}
STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo **pptinfo)
{
if (!pptinfo)
{
return E_POINTER;
}
*pptinfo = NULL;
return E_NOTIMPL;
}
STDMETHOD(GetIDsOfNames)(REFIID riid, OLECHAR **rgszNames, UINT cNames, LCID lcid, DISPID *rgdispid)
{
return E_NOTIMPL;
}
STDMETHOD(Invoke)(
DISPID dispidMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS *pdispparams,
VARIANT *pvarResult,
EXCEPINFO *pexcepinfo,
UINT *puArgErr)
{
if (wFlags & DISPATCH_METHOD)
{
switch (dispidMember)
{
case DISPID_NEWWINDOW2:
std::cout << "DISPID_NEWWINDOW2" << std::endl;
return S_OK;
case DISPID_ONQUIT:
std::cout << "DISPID_ONQUIT" << std::endl;
SetEvent(g_hBail);
return S_OK;
}
}
return DISP_E_MEMBERNOTFOUND;
}
};
CMyDispatch g_EventHandler;
DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
IWebBrowser2 *pWB = NULL;
IStream *pMarshalData = static_cast<IStream*>(lpParameter);
HRESULT hr = CoGetInterfaceAndReleaseStream(
pMarshalData,
__uuidof(pWB),
reinterpret_cast<void**>(&pWB)
);
if ( SUCCEEDED(hr) )
{
hr = pWB->put_Visible(VARIANT_TRUE);
IConnectionPointContainer *pCPC;
hr = pWB->QueryInterface(&pCPC);
if ( SUCCEEDED(hr) )
{
IConnectionPoint *pCP = NULL;
hr = pCPC->FindConnectionPoint(DIID_DWebBrowserEvents2, &pCP);
if ( SUCCEEDED(hr) )
{
DWORD Cookie;
hr = pCP->Advise(&g_EventHandler, &Cookie);
WaitForSingleObject(g_hBail, INFINITE);
pCP->Unadvise(Cookie);
pCP->Release();
}
pCPC->Release();
}
pWB->Release();
}
CoUninitialize();
return 0;
}
void DoStuff()
{
g_hBail = CreateEvent(NULL, TRUE, FALSE, NULL);
IWebBrowser2 *pWB = NULL;
HRESULT hr;
hr = CoCreateInstance(
CLSID_InternetExplorer,
NULL,
CLSCTX_LOCAL_SERVER,
IID_IWebBrowser2,
reinterpret_cast<void**>(&pWB)
);
if ( SUCCEEDED(hr) )
{
IStream *pMarshalData;
hr = CoMarshalInterThreadInterfaceInStream(__uuidof(pWB), pWB, &pMarshalData);
if ( SUCCEEDED(hr) )
{
DWORD ThreadId;
g_hThread = CreateThread(
NULL, // lpThreadAttributes
0, // dwStackSize
&ThreadProc, // lpStartAddress
pMarshalData, // lpParameter
0, // dwCreationFlags
&ThreadId // lpThreadId
);
if (g_hThread)
{
WaitForSingleObject(g_hThread, INFINITE);
CloseHandle(g_hThread);
g_hThread = NULL;
}
else
{
pMarshalData->Release();
}
}
pWB->Release();
}
CloseHandle(g_hBail);
}
int main(int argc, char* argv[])
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
DoStuff();
CoUninitialize();
return 0;
}
Steve
|
|
|
|
|
So did you solve your problem? If so how? The people that contributed are generally interested in knowing the outcome. This is a small price to pay for free technical support.
Steve
|
|
|
|
|
Sorry for the delay in reply steve.Still workign out how to trap the documentcomplete event - the problem is if we set the event to signalled state(setevent) from documentcomplete;the browser continues to hang -doing setevent in the quit event is not an option for me ,as the app would play all the html events without any manual intervention.
Just trying to figure out if its a behaviour of documentcomplete stage,or some mistake on my part.
Thanks a lot for the help - will keep posted about my findings
|
|
|
|
|
I am using multiple threads because i am facing the same problem in a single-threaded app too.In that case too , the browsers just fires the beforenavigate and hangs.It proceeds forward with the navigation( and fires the navigatecomplete/documentcomplete events) only when i exit out of the application.
Is it essential for the client application to be a GUI based ?
|
|
|
|
|
Hi. I believe WTL is a library built to enhance the ATL windowing features. Just like we can statically link ATL's functions into our application by using the _ATL_STATIC_REGISTRY Macro, is there any way in which we can statically link the WTL library to our applications.
Thanks.
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
I think there is no such thing as linking to WTL. WTL should become a part of the application code. You can check with the Dependency Walker utility that comes with VS6.
this is this.
|
|
|
|
|
WTL is made up entirely of header files, so there's no WTL library to link with, either statically or dynamically.
|
|
|
|
|
But WTL is built on top of ATL. Although lots of ATL is header files there are parts of it that can be either statically of dynamically linked. WTL will inherit this from ATL.
Steve
|
|
|
|
|
So what you mean is, there is no wtl.dll like atl.dll for WTL? WTL is just header files which wrap aound ATL! And if I use the _ATL_STATIC_REGISTRY macro then the ATL.DLL gets statically linked to my applications along with WTL?
Thanks so much for your answers!
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
TechyMaila wrote: So what you mean is, there is no wtl.dll like atl.dll for WTL? WTL is just header files which wrap aound ATL! And if I use the _ATL_STATIC_REGISTRY macro then the ATL.DLL gets statically linked to my applications along with WTL?
I believe so: but _ATL_STATIC_REGISTRY only controls the registration code.
Steve
|
|
|
|
|
TechyMaila wrote: And if I use the _ATL_STATIC_REGISTRY macro then the ATL.DLL gets statically linked to my applications along with WTL?
That's only needed *IF* you use the COM registration bit of ATL. I have several WTL Win32 applications. They don't link against WTL *OR* ATL libraries, as all of teh ATL and WTL code is compiled into the executable.
|
|
|
|
|
You're after the _ATL_DLL define (for the rest of ATL apart from the registration code). Also if you use ATL's ActiveX containment code it uses the type library which is in "ATL.dll" with of without _ATL_DLL defined.
Steve
|
|
|
|
|