|
in debug mode...
I have know a null pointer in breakpoint, but that is ATL inline code...I cann't control call a null pointer...
I think I sink event is in wrong way, but what is right?
thanks~~
|
|
|
|
|
King_jinjing wrote: I think I sink event is in wrong way, but what is right?
Your sink code looks OK to me - I built a small trial application yesterday, using your code, and it loaded the web page OK and called the event handler as expected.
I used Visual Studio 2003 - which are you using?
I'll have another look at it on Monday - I don't have access to a Windows machine except at work, and I certainly won't be there over the weekend.
|
|
|
|
|
OK....
I use VS2005...WIN2000...I have to upload my Solution file?
I think, I have try other way again.. Today, I compile a WTL webbrowser example with web event, that work is OK.
Thanks.
|
|
|
|
|
I think your problem is that you haven't defined an ATL 'module' object. ATL tries to reference the module object in the CComTypeHolder::GetTI method (when it's locking the critical section), so if you haven't defined one, it'll crash there.
Here's what I have in place of your WinMain :
class CHostActiveXModule : public CAtlExeModuleT<CHostActiveXModule>
{
public :
CMainWindow m_wndMain;
HRESULT PreMessageLoop(int nCmdShow)
{
m_libid = LIBID_ATLLib;
HRESULT hr = CAtlExeModuleT<CHostActiveXModule>::PreMessageLoop(nCmdShow);
if (SUCCEEDED(hr))
{
AtlAxWinInit();
hr = S_OK;
RECT rc;
rc.top = rc.left = 100;
rc.bottom = rc.right = 500;
m_wndMain.Create(NULL, rc, _T("Host Calendar") );
m_wndMain.ShowWindow(nCmdShow);
}
return hr;
}
HRESULT PostMessageLoop()
{
AtlAxWinTerm();
return CAtlExeModuleT<CHostActiveXModule>::PostMessageLoop();
}
};
CHostActiveXModule _AtlModule;
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int nShowCmd)
{
return _AtlModule.WinMain(nShowCmd);
}
|
|
|
|
|
Oh~~~OK~~I got~~~~
It's very very very very powerful~~
Right,I haven't defined an ATL 'module' object...
Thanks,very very very much..
You solve my problem.
|
|
|
|
|
Hi,
I would like to learn about services and searched for the articles. But none of them were useful to me. Some of the articles are in fact nice, but not for a beginner like me . I would like to know about 1) what services are 2) where they can be used 3) how to use ATL Com AppWizard to create the service using Service(Exe) server type 4) A simple example (almost all the ones I have gone through today are looking like small projects, making the things more complicated for me to understand)
Could anyone post some nice article regarding this?
Thanks in advance.
Taruni
|
|
|
|
|
Taruni wrote: (almost all the ones I have gone through today are looking like small projects, making the things more complicated for me to understand)
That is because complex problems are solved by simplifying them into their constituent parts and solving the smaller problems. You are not likely to find a single example that walks through from your start to your end. That need is specific to you.
Taruni wrote: I would like to know about 1) what services are
This would be a good place for you to start[^]
led mike
|
|
|
|
|
std::vector<myclass> vec;
MyClass & get_selected()
{
std::list<myclass>::iterator it=vec.begin();
for (;it!=vec.end();++it) {
if (it->is_selected())
return &*it;
}
return NULL;
}
|
|
|
|
|
followait wrote: Is it the address of the element in the vector,
and is it safe?
Yes, &*it is the address of the vector element that the iterator refers to.
Whether it's "safe" or not depends on what you mean by "safe".
It is safe regarding if the address returned really is the address of the contained element.
But considering that you are handing out a non-const pointer or reference to the object, the caller may change it at will. This could of course be considered as "not safe" in some way.
However, your code snippet doesn't seem to compile correctly.
In your function declaration you say that the return type is a reference to a myclass object, but you actually return a pointer to it unless you've omitted something important. The return statement should read 'return *it; '.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Design suggestion: you're probably better off following what the STL algorithms do in this case, and return an iterator:
std::vector<myclass> vec;
std::vector<myclass>::iterator get_selected()
{
for (std::vector<myclass>::iterator it=vec.begin();it!=vec.end();++it)
{
if (it->is_selected())
return it;
}
return vec.end();
}
or even use the algorithms provided in the STL...
std::vector<myclass> vec;
std::vector<myclass>::iterator get_selected()
{
return std::find_if(vec.begin(), vec.end(), std::mem_fun_ref(&myclass::is_selected));
}
|
|
|
|
|
|
I think you can't save this address, for example as a class member.
If you add new elements to the vector it may need additional memory,
which means he must allocate new memory for the whole vector and copy
all his data. So every address to the old memory will be invalid
afterwards.
|
|
|
|
|
Even if you change to returning an iterator, be careful about doing any operations that invalidate the iterator.
|
|
|
|
|
I tried to follow the naming convention of STL, but encounter a problem.
For example:
class round_rect
{
...
}
Sometimes, in the context, I need no special object name,
I tried to name it as round_rect, so it became:
round_rect round_rect;
I want to know how STL name this?
BTW: google suggests RoundRect , but if I want to keep the naming convention consistent,
the member function also need capital letters. However I prefer the STL way.
|
|
|
|
|
the_round_rect ?
See, that's why I like Camel-Casing things. I'd have this:
class RoundRect
{
...
};
RoundRect roundRect;
All hail the case-sensitivity of C++!
|
|
|
|
|
Hi I have an ATL plugin which needs to receive the "WM_DISPLAYCHANGE" message, when windows resolution changes.
I've added a handler as follows
class ATL_NO_VTABLE CWebPluginControl :
public CComObjectRootEx<ccomsinglethreadmodel>,
public IDispatchImpl,
public IPersistStreamInitImpl<cwebplugincontrol>,
public IOleControlImpl<cwebplugincontrol>,
public IOleObjectImpl<cwebplugincontrol>,
public IOleInPlaceActiveObjectImpl<cwebplugincontrol>,
public IViewObjectExImpl<cwebplugincontrol>,
public IOleInPlaceObjectWindowlessImpl<cwebplugincontrol>,
public ISupportErrorInfo,
public IPersistStorageImpl<cwebplugincontrol>,
public ISpecifyPropertyPagesImpl<cwebplugincontrol>,
public IQuickActivateImpl<cwebplugincontrol>,
public IDataObjectImpl<cwebplugincontrol>,
public IProvideClassInfo2Impl<&CLSID_WebPluginControl, &DIID__IWebPluginControlEvents, &LIBID_WebPluginLib>,
public IObjectSafetyImpl<cwebplugincontrol,>,
public IConnectionPointContainerImpl<cwebplugincontrol>,
public IConnectionPointImpl<cwebplugincontrol,&diid__iwebplugincontrolevents>,
public IPropertyNotifySinkCP<cwebplugincontrol>,
public IPersistPropertyBagImpl<cwebplugincontrol>,
public CComCoClass<cwebplugincontrol,>,
public CComControl <cwebplugincontrol>,
public CProxy_IWebPluginControlEvents<cwebplugincontrol>
...
CWebPluginControl();
~CWebPluginControl();
BEGIN_MSG_MAP(CWebPluginControl)
...
MESSAGE_HANDLER(WM_DISPLAYCHANGE, OnDisplayChange)
...</cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></ccomsinglethreadmodel>
But my OnDisplayFunction never gets hit when i change resolutions. So my question is, does IE(using IE 7) forward this message? If so why am I not able to pick it up?
Thanks for your time,
Chris
|
|
|
|
|
The evidence certainly points to 'no', doesn't it?
The easiest way to check is to stick a conditional breakpoint on the BEGIN_MSG_MAP(CWebPluginControl) line, set to trigger when WM_DISPLAYCHANGE is received (looking at the definition of the BEGIN_MSG_MAP macro in atlwin.h , the message ID is sent in the parameter uMsg ). If this doesn't trigger, then you could use Spy++[^] or Winspector[^] to confirm that IE is receiving WM_DISPLAYCHANGE.
One possible work-around - check the screen resolution in each message handler and react appropriately when you detect a change. I would have thought that you'd get a WM_PAINT pretty soon after the resolution change, which you could use as a trigger.
|
|
|
|
|
Thanks, I tried your suggestion using the breakpoint and using spy++ and I see the message going into IE but not being passed to my plugin. So as you said I'm using the WM_PAINT message now, and detecting a resolution change.
Thanks,
Chris
|
|
|
|
|
I created a BHO project with C++ for IE, I retrieve a response time (end to end) for page. but I need more information : the download timing for each object in page, all request sending...
Have you any idea?
Thanks
|
|
|
|
|
It's been a while since I've looked at WebBrowser events, but I don't think you get a notification with a URL for each item in the page. You can listen for DownloadBegin and DownloadEnd , but those don't have any parameters; you're guaranteed to get one for each item that the browser downloads, but you don't get the actual URLs.
|
|
|
|
|
Thanks for response.
yes, it's right. but I found a tool(httpwatch,) that use add-ons to watch or spy Internet explorer, and of course without a proxy. so the solution is exist.
I would know how it's worked?
best regards.
|
|
|
|
|
Hi,
I have worked on ATL projects in VC2003 and above, but I have never created them from scratch. They have all originally been projects that evolved from VC6 code.
How do people handle deployment and dependencies of the projects? Under VC6 the .idl file is shown as being part of the project, and therefore you could modify where the .tlb and .h and .c files where generated. At my current company we have a .\TLB directory off the branch root. How can I make the .tlb file end up there? I cannot see either the idl file, or its project settings.
Peter
|
|
|
|
|
Hah Hah I've figured it out. The ATL project had been supplied to be by a collegue, and he had left the defaulted "Attributed" item in the ATL Project wizard.
If you create a project and clear this the .idl files appear just as they did with VC6.
|
|
|
|
|
How do people who create attributed atl projects manage the output files?
|
|
|
|
|
Does anyone know what valid values can be returned from FinalConstruct?
Originally I was helping out some colleagues on how to set the error information in an ATL component. They wanted to be able to set the COM error information. I showed them what to do so that their COM object implemented ISupportErrorInfo. They want to return information to the client if there is an error accessing certain state information needed for the COM object to do its job. So I told them to put their code in FinalConstruct, but they are saying that the error info in _com_error::Description() is blank. An HRESULT had been set in _com_error, but it just showed as a hex value when added to the watch window with m"_hRes, hr".
When they created their COM object they didn't know to click supports ISupportErrorInfo in the atl object wizard, so this has all been added by hand.
I tried to test this using a dummy com object implementation on my PC, but the client returns REGDB_E_CLASSNOTREG. I did find a nntp message saying that you should not set any rich error info in FinalConstruct but just to return an HRESULT. However if I return any HRESULT other than S_OK, the client returns REGDB_E_CLASSNOTREG.
I have tried other code of ours that tries to set rich error info with AtlReportError etc, but I don't think this ever gets called because they are just constructing other COM objects that usually succeed. When I deliberately change the active code line to set the error information then they too return REGDB_E_CLASSNOTREG.
|
|
|
|
|