|
ATL ActiveX control embedded in Internet Explorer not receiving WM_CREATE, WM_DESTROY, WM_SHOWWINDOW messages.
Other messages (WM_LBUTTONDOWN for example) are successfully handled.
The same control embedded in the test application works fine (all messages are received).
Thanks in advance
Oleg
|
|
|
|
|
Hi, i am using transform function to transform a vector to a map but getting the following error.
multiMapType.obj : error LNK2001: unresolved external symbol "struct std::pair<enum PC::PC_type,class PC> __cdecl std::make_pair(enum PC::PC_type const &,class PC const &)" (?make_pair@std@@YA?AU?$pair@W4PC_type@PC@@V2@@1@ABW4PC_type@PC@@ABV4@@Z)
Debug/MultiMapType.exe : fatal error LNK1120: 1 unresolved externals
The code snippet is as follows
int main( )
{
const PC::PC_type kind[] = { PC::IBM,PC::IBM, PC::Dell, PC::HP,PC::HP, PC::HP };
const int num_appliances = 3;
vector<PC> v;
for( int i = 0; i < num_appliances; ++i )
v.push_back( PC( kind[i], i, i ) );
typedef multimap<PC::PC_type,PC> PC_multimap_type;
PC_multimap_type stock;
const PC desired( PC::HP );
transform( kind, kind+num_appliances, v.begin(),inserter( stock, stock.end() ),make_pair<PC::PC_type,PC> );
PC_multimap_type::const_iterator stock_end = stock.end();
PC_multimap_type::const_iterator spot = stock.find( desired.appliance() );
if( spot != stock_end )
spot->second.print();
else
cout << "Don't have a " << desired.name() << " in stock\n";
return 0;
}
Please help.
Thanks
|
|
|
|
|
Given that I've made assumptions about context (definitions of PC? PC_type? headers you include?), it's difficult to say if I've done the same as you.
But your code compiles and links for me under VS2008. What version are you using?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
Thanks for replying. I am using VS98(VC6.0) .
The headers file and defination of PC is as follows
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
class PC
{
public:
enum PC_type { Dell, HP, IBM, Compaq };
PC( PC_type appliance = Dell, int model = 220,
int serial = 0 );
bool operator<( const PC& rhs ) const;
PC_type appliance() const;
int model() const;
string name() const;
void print() const;
int serial() const;
private:
PC_type appliance_;
int model_;
int serial_;
};
|
|
|
|
|
ashtwin wrote: Thanks for replying. I am using VS98(VC6.0)
My commiserations - VC6 sucks for template usage.
Anyway - try declaring the make_pair instance you need before main():
template std::pair<PC::PC_type,PC> std::make_pair<PC::PC_type,PC>(PC::PC_type,PC);
int main( )
{
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi, i tried the declaration before main
template std::pair<PC::PC_type,PC> std::make_pair<PC::PC_type,PC>(PC::PC_type,PC);
int main( ){
but still getting the same error.
May be some problem in project settings.
|
|
|
|
|
No, shouldn't be project settings. And I don't have VC6 to test with. Oh well.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The program is getting build properly if i use a function insted of make_pair in the last parameter of the function transform and return a pair from that function.
pair<PC::PC_type, PC> MyFunction(PC::PC_type pcType, PC pc)
{
return make_pair(pcType, pc);
}
transform( kind, kind+num_appliances, v.begin(),inserter( stock, stock.end() ),MyFunction);
|
|
|
|
|
Yes...I should have mentioned that solution In this one, you're not asking the compiler to automatically instantiate a function from the reference in transform, so yes, it includes all the necessary code.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Does it mean that whatever i was doing earlier was not correct.
|
|
|
|
|
Ummm - it should have been correct and OK - but VC6 is a bit rubbish, which is why it didn't work.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Ok, so the problem is with vc6.
Thanks for the help.
|
|
|
|
|
Sorry, the declaration before main is
template std::pair<PC::PC_type,PC> std::make_pair<PC::PC_type,PC>(PC::PC_type,PC);
|
|
|
|
|
My (not easy) problem is related to ATL/COM interfaces. I already posted it here in the COM forum section but I'm not sure where to categorize it (and I see more activity in this section).
If anyone has any insights where the problem is, any help would be greatly appreciated (I will make an article from project).
|
|
|
|
|
I have an ATL exe with a single ATL simple object. I have implemented a connection point using these instructions:
http://www.codeguru.com/cpp/com-tech/atl/atl/article.php/c3623/[^]
Is this *all* you need to do to get a working connection point setup?
I followed these instructions exactly and everything builds and runs fine. m_vec.GetSize() even shows that there are connections from a client. But the client never receives any callbacks. The client is some c# conn point client code that has been working fine with another object for months.
I just want to make sure I haven't missed something vital before I start tearing apart the C# code.
As a side note, since the server and client are running in separate processes, I have my ATL object passing its 'this' pointer up to a global list. When the event happens, my handler just iterates through the list calling 'Fire_XXX' on each instance of the ATL object. I don't know if this is right, but I tried it with and without this approach and it doesn't make any difference on the client side.
Thanks!
|
|
|
|
|
From a quick skim of your link, yes, this is all you need to do to get a connection point up and running. It should work OK out-of-process, from without your additions. Having written the object in ATL,
I'd advise writing a simple test client using a Win32 project in C++ that creates the object, calls advise and then tests your event without the complications of C# and .NET.
|
|
|
|
|
I have 2 DLLs, one is inheriting and implementing functions from the other. After implementing these functions, they are visible to other applications.(c# interop) I would like to add yet another function to the inheriting DLL(of my own making). I have done this but the method never shows up to external apps. I am using the format(among others):
public:
STDMETHOD(FunctionName)(Args);
The inheriting DLL does not provide an interface, but the functions *do* show up and I can call them fine. But no matter how I add that 1 function, I cannot get it to export. I have even tried creating a completely separate(3rd) ATL object with a single interface exporting a single function and inheriting/implementing that as well. Everything builds and runs fine, just no function. I just used the nifty little "Implement Interface" wizard and it created all the necessary spaghetti.
So the question is: How do I export a public function from an ATL object?
Note: The original DLL I am inheriting from is not mine, it's part of an SDK and I have no control over it. I just use it.
I am confident this all stems from my completely perverted understanding of interfaces and how they work, but this got dumped in my lap with the obligatory truncated timetable.
I am using XP SP3, VS2003 for the unmanaged code(SDK mandates that I use 2003), and VS2005 for the managed stuff. Thanks!
|
|
|
|
|
It's a bit hard to solve your problem without more information. I can't decide if you're trying to export a new function from a dll or expose a new COM interface or new COM interface method.
|
|
|
|
|
Thanks for the response and sorry for the confusion. This is probably like asking a blind man to describe what his attacker looked like, but:
My dll inherits from another dll and implements it's functions. These functions are visible to outside objects. I want to add another function(public, interface, however) that originates only in my dll but is also visible to outside objects. My dll is a COM dll with MFC and ATL support. When I look at it in the Class View, there is no interface listed for my class. I found an article on MSDN that gave some sketchy instructions for adding an interface to an existing COM object both manually and through a wizard.
I added the interface manually into the IDL and everything compiled fine. The interface showed up in the Class View and I was able to add a method to it fine. The problem was, the wizard never put the stubs in the .h and .cpp files. I added them manually as well and compiled. C# then complained that QueryInterface failed with a "NOINTERFACE" when I tried to use the interface.
Then I tried to add an interface via the "Implement Interface" wizard, but it will only use interfaces via an existing TLB. This is when I created another separate ATL simple object with an interface and single method. I used the wizard on this tlb and it created everything(including the stubs) perfectly. Still when I try to use the interface, while it does not complain, my single function does not show up.
So I'm guessing my specific question is; how do I add a *new* interface to an *existing* COM object?
I realize I'm probably asking you to describe what shape I'm thinking of, so feel free to forward me to a tarot reader.
|
|
|
|
|
asdfhjkasdf dfhjksdf wrote: complained that QueryInterface failed with a "NOINTERFACE"
Sounds like you need to add code to your ATL Objects QueryInterface method that will provide your interface when it's asked for as that's where the error code E_NOINTERFACE is returned if you have'nt done this.
|
|
|
|
|
Perhaps this is my problem. My object doesn't have a QueryInterface method. Isn't this added automatically when the object is created or ATL support is added?
|
|
|
|
|
Any interface e.g. IMyInterface should inherit from the IUnknown interface and its the IUnknown that has three methods: QueryInterface AddRef and Release. Without seeing the code it's hard to say whats going on.
The ATL Wizard usually create these for you.
Two possibilities come to mind:
Add a QueryInterface method and see if you get complaints about one already existing so you can find it
or:
Create a simple Win32 exe in the same VS solution, After using OLEInitialise create an instance of your COM object using CoCreateInstance and then call QueryInterface and step in to see what's going on.
|
|
|
|
|
I just started the entire dll from scratch. New ATL project, added a simple ATL object and inherited from CAxDialog and the other class just like the old dll. I now have a valid interface and I can add my method to it. Everything works great and I can see my new method plus the inherited ones from c# since I finally have a %#@#$ interface. I started copying in chunks of code from the old class used to implement the inherited interface. There are a couple of calls to _Module that it's crapping out on. So I added it to Stdafx.h like the other class. In the form of:
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
Now the build errors on this line stating:
error C2146: syntax error : missing ';' before identifier '_Module'
If I comment out the line, it builds fine.
Why the heck would they waterboard at Gitmo when they could just sit them down and make them learn COM/ATL?
|
|
|
|
|
You'll find _Module is used for entry points such as DllGetClassObject and DllRegisterServer. You can either read up on it or you could try creating a new (temporary) Dll with the ATL Wizard in a new solution just to see where Module is used and to find where your project is missing it. I have a feeling it was remamed at some point, perhaps after VC6, so it could be just the name that's different.
|
|
|
|
|
You're exactly right. I found out about 9pm last night that the CComModule stuff gets put in there by 6.0. If you create a project in 6.0 and import it into 2003, 2003 builds it fine. If you just add in the code in 2003, sheer panic. So I created the entire project from scratch in 6.0, imported it into 2003, and added all the necessary inheritance/implementation stuff, and IT WORKS! Just like I wanted.
Almost.
Everything works as planned except that when I access it from c# and call my method, there is a global var in the module that is set by another application that my function needs. It always turns up null. I think it's because c# instantiates a new instance of the module and that var hasn't been set yet. So now I am off to try to figure out how set up a singleton ATL object. So far I've been unable to find out how to do this via a wizard.
Thanks for your help!
|
|
|
|