|
OK - I think I've got an automated solution for you. Note - this was done with VS2003...
- Create an ATL DLL project.
- Add an 'ATL Control' class. Use some throwaway name for the control interface (because you *will* be throwing it away ), but make sure the class names are ones you're happy with.
- Copy'n'paste your IDL interface into the new projects IDL file
- In the Class View, right click the ATL Control class and select Add->Implement Interface... The interface you want to implement should be in the dialog that appears. Select it and click Finish. This should create bare method definitions.
Note that I've not determined what happens to event definitions.
|
|
|
|
|
Fantastic solution
Worked like a treat! Events too!
Thanks loads
Tom
It will always be the bane of the civilised as to what to do with the barbarian
|
|
|
|
|
Ah. That's how you get to it. I knew it was around here somewhere
Steve S
Developer for hire
|
|
|
|
|
Hi all,
I am a beginner in ATL programming . How I can use IHTMLDocument2 or IWebBrowser2 Objects in my ATL programme made by using "Simple Object"
Please Help me,
Thanks in Advance
George K Jolly
-- modified at 2:16 Tuesday 3rd October, 2006
|
|
|
|
|
Typically you use the standard COM connection point mechanism to receive events.
Steve
|
|
|
|
|
Hi Steve,
Thanks for reply,
I am a beginner in ATL programming. I Just want to know ,How to implement any COM Object for eg: IWebBrowser2 or IHtmldocument etc. in My ATL Programme. So that I can catch any event from my webbrowser or Html Document. Is there any example codes available.
Thanks
George K Jolly
|
|
|
|
|
while compiling my first WTL prog I got lots of errors saying
C:\VISUALSTUDIO_6.0\WTL71\INCLUDE\atlapp.h(396) : error C2872: 'ATL' : ambiguous symbol
i read lots of articles on the net n readme file as well but not able to get rid of this.
it seems a common error generated due to bug in atlbase.h but how to come out of it.
please help me
thanx in advance
|
|
|
|
|
Google is your friend...that would point you to this[^], which recognises the problem and describes a workaround:
It's a bug in ATL that affects WTL. The readme.html file included with
WTL7.5 (the latest WTL version, available at
http://sourceforge.net/projects/wtl) describes the workaround:
... Surround atlbase.h include declaration with following statements:
#define ATL ATLFIX
#include <atlapp.h>
#undef ATL
namespace ATL = ::ATLFIX;
It also describes the nature of the bug and the reason for the error
message.
|
|
|
|
|
a class inherited from 2 or more class can i cast the pointer of this new class to a pointer of 1st parent and call a function and then cast it again to a pointer of the 2nd parent and call its function. and if it is allowed what is the rules and limitation to do this?
|
|
|
|
|
The example below shows two base classes (A and B ) and a class that derives from them both (C ). Now, you can cast a C* pointer to A* or B* with static_cast . This will call non-virtual methods on A or B respectively. However, for virtual methods, you need to explicitly ask for the parent classes version, as shown in the comments.
So...to get what you want, you don't actually need a cast at all - just specify that you want to call the parent classes method using the class-name:: notation.
#include <iostream>
class A
{
public:
void M() { std::cout << "A::M - this = " << (int)this << "\n"; }
virtual void X() { std::cout << "A::X - this = " << (int)this << "\n"; }
};
class B
{
public:
void N() { std::cout << "B::N - this = " << (int)this << "\n"; }
virtual void Y() { std::cout << "B::X - this = " << (int)this << "\n"; }
};
class C : public A, public B
{
public:
void M() { std::cout << "C::M - this = " << (int)this << "\n"; }
void N() { std::cout << "C::N - this = " << (int)this << "\n"; }
virtual void X() { std::cout << "C::X - this = " << (int)this << "\n"; }
virtual void Y() { std::cout << "C::Y - this = " << (int)this << "\n"; }
};
int main(int, char**)
{
C c;
c.X();
c.A::X();
static_cast<A*>(&c)->X();
static_cast<A*>(&c)->A::X();
c.M();
c.A::M();
static_cast<A*>(&c)->M();
static_cast<A*>(&c)->A::M();
c.Y();
c.B::Y();
static_cast<B*>(&c)->Y();
static_cast<B*>(&c)->B::Y();
}
|
|
|
|
|
|
Demian Panello wrote: I have added the WM_DRAWITEM function but the program never reach that function.
Did you set the owner draw style?
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
Hi.
The control class has the WM_DRAWITEM handle. It's a composite control and there is a template dialog where I put the controls, (but no dialog class), so, I want to paint with a bitmap resource the background.
Is WM_DRAWITEM the appropriate handle ?? I don't think so, because is it subclassed of what??.
WM_ERASEBKGND maybe??
I think I have a feature here, a mixed feature inside my head with all this painting stuff.
Thank you.
Demian.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Which class has the WM_DRAWITEM-handler? If it's the combobox itself, you need to reflect the WM_DRAWITEM message back to the combobox class. That is easily done with REFLECT_NOTIFICATIONS() inside the message map in the containing class/window.
If not, I bet led mike is onto something.
--
80 percent entertainment by volume
|
|
|
|
|
Hi.
The control class has the WM_DRAWITEM handle. It's a composite control and there is a template dialog where I put the controls, (but no dialog class), so, I want to paint with a bitmap resource the background.
Is WM_DRAWITEM the appropriate handle ?? I don't think so, because is it subclassed of what??.
I think I have a feature here, a mixed feature inside my head with all this painting stuff.
Thank you.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
I've created an ATL DLL that contains TCP connections inside. I use it with the Internet Explorer(HTML <object> tag+JavaScript). It runs fine. The problem arises when I open multiple instances of IE. It disturbs the previous connection. I dont know why. But when the same DLL is used with an .exe application, It doesn't care about multiple instances.It runs fine independently. How can I achieve the same with IE? btw, why is it distrubing the other instance? is it not supposed to run on its own space? Please help. I'm tired refering for this issue for long. Today I dont wanna disturb Google because he's celebrating his b'day. .
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
VuNic wrote: It disturbs the previous connection
VuNic wrote: Today I dont wanna disturb Google today
Yeah well I don't think you will find anything looking for "disturb connection" anyway. Please link to the reference that you learned that phrase from.
VuNic wrote: is it not supposed to run on its own space?
I don't know, did you develop IE to run each instance in an isolated process?
Perhaps you should have considered the "threading" model for your ATL project.
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
Disturb connection: It breaks the TCP stream. The point why I used "disturb" is that I've programmed the clients to reconnect automatically. but I really dont understand the picture when to web pages are running with the dll.
For example,I try to run another when a similar page(that loads the dll and uses it with JS) is already running,
1. Disconnects the previous connection (client1 in page1)
-------- but client1 reconnects to server again.
2. Starts a new connection (client2 in page2)
3. Now I close any one these connection.
----This closes the other connection.
But this never happens when I use the Dll with a windows application. The exes run separately without *disturbing* eachother.
led mike wrote: Perhaps you should have considered the "threading" model for your ATL project.
Can you point me to some resources that actually deals with this?
It's an appartment threaded model and I've done everything to make sure it's thread safe. Inside every worker thread I've used CoInitializeEx(NULL, COINIT_MULTITHREADED); & CoUninitialize();
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
VuNic wrote: Can you point me to some resources that actually deals with this?
With threading issues? I always liked Richter's "Advanced Windows" book.
VuNic wrote: But this never happens when I use the Dll with a windows application.
Try changing the application to use the control from two different threads, you will likely see the same behavior.
VuNic wrote: It's an appartment threaded model
That just forces the entry from the same thread.
VuNic wrote: I've done everything to make sure it's thread safe.
That does not appear to be the case.
led mike
|
|
|
|
|
Thanks mike. I'd make these changes & check it again. Btw I need to learn a lot in this department. But the time contstraint drives me to look for a magical solution immediately. I think it won't work this time until I open the book again
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
Led, I solved that one. It's not a threading issue but a design issue. I have a separate tcp class for the tcp operation and I created a global object of it for my class's use."gobal" is the culprit & me too . Now I removed it and inherited my class from the tcp class. Now the problem doesn't happen again.
|
|
|
|
|
i create a WTL program that use a COleDateTime control and i define ATLcomTime.h file in the stdafx.h when i build the project in the debug config i builded will but when i build it in the release config i have a dozen of error that fall around undeclare identifier CTime and CTimeSpan
what is the problem, i thank greatly this site and any one who give me a help in this question or previous question
samy ibraheem
|
|
|
|
|
OK, I must of missed something here, but when I use a function object in a std::for_each loop, the constructor is called once (as expected), but the destructor is called multiple times! Can someone explain why this happens, and, more importantly, how I can have the destructor called just once. For example:
#include <algorithm>
#include <vector>
#include <iostream>
struct function_object
{
function_object()
{
std::cout << "function_object : " << this << std::endl;
}
~function_object()
{
std::cout << "~function_object : " << this << std::endl;
}
void operator()(int n) const
{
std::cout << n << std::endl;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<int> v;
v.push_back(1);
v.push_back(2);
std::for_each(v.begin(), v.end(), function_object());
return 0;
}
Now, when I run the above app it seems that multiple copies of the function_object struct are created, as the destructor trace code shows different pointers. However, as only one constructor is being called, I am a little confused. The output looks like this:
function_object : 0013FE4B
1
2
~function_object : 0013FE00
~function_object : 0013FE6F
~function_object : 0013FE4B
Any ideas on how to avoid this would be welcome.
Kicking squealing Gucci little piggy.
|
|
|
|
|
OK, so after digging around I realise I need to pass the function object by reference. The only syntax I can get to compile and link seems to be this:
std::vector<int> v;
v.push_back(1);
v.push_back(2);
function_object f;
std::for_each<std::vector<int>::const_iterator, function_object&>(v.begin(), v.end(), f);
Is this correct, 'cos it ain't purdy (OK, so the STL isn't pretty full stop, but...).
Man, the STL - always SO much to learn.
Kicking squealing Gucci little piggy.
|
|
|
|
|
STL passes many things by copy. Thus, while the default constructor is only called once, the copy-constructor may be called many times. To see this, modify your code slightly:
struct function_object
{
function_object()
{
std::cout << "function_object : " << this << std::endl;
}
function_object(const function_object& obj)
{
std::cout << "function_object (copy): " << this << std::endl;
}
~function_object()
{
std::cout << "~function_object : " << this << std::endl;
}
void operator()(int n) const
{
std::cout << n << std::endl;
}
};
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|