|
Hi there,
I'm a COM newby, and I'm trying to figure out this event sink thing. The typelib I am trying to use has a coclass in it with two interfaces. One is a dispinterface derived from IDispatch, it also exposes an outgoing interface/connection point thing (derived from IUnknown) which exposes two methods. Now according to the documentation these methods will get called at the apropriate time and the parameters to the call will contain the data I need. So how on earth do I go about hooking into that outgoing interface getting some event notification??
Does anyone know? Thanks in advance....
*¨¨`)
¸¸.·´ ¸.·*¨¨`)
(¸¸.·* ¸ .·*
¸¸.·*
(¸¸.~~> Joel Holdsworth.
|
|
|
|
|
You have to implement a sink object on the client side. Do a search at CodeProject, CodeGuru, and Google for examples.
Kuphryn
|
|
|
|
|
I have been going through the book Modern C++ Design. Obviously, since it is using generic programming alot of doesn't work on VC6, but I was curious about the following error when working with Object Factory example..
I have a class defined as "Shape" and a method defined as :
Shape * CreateConcreteShape();
Now, I have a class, called ShapeFactory as following:
class ShapeFactory
{
public:
static ShapeFactory * Instance();
protected:
typedef Shape * (*CreateShapeCallback) ();
// Returns true if registeration was successful
typedef std::map <int, createshapecallback=""> CallbackMap;
ShapeFactory();
ShapeFactory(const ShapeFactory & );
ShapeFactory& operator=(const ShapeFactory&);
bool RegisterShape (int ShapeId, CreateShapeCallback CreateFn);
bool UnregisterShape(int ShapeId);
Shape * CreateShape(int ShapeId);
CallbackMap callbacks_;
private:
static ShapeFactory * m_pInstance;
~ShapeFactory(); // the destructor should not be called from outside
};
Now, I have a class Line that inherits from Shape and it contains the following:
class Line : public Shape
{
public:
Line();
virtual ~Line();
virtual Shape * CreateLine();
virtual void Draw() const;
virtual void Rotate(double angle);
virtual void Zoom (double zoomFactor) ;
private:
static ShapeFactory TheFactory;
};
When I try adding the CreateLine method of the Line class to the ObjectFactory as shown below, I get the following compile-time error:
Line::Line()
{
ShapeFactory * pShapeFactory = ShapeFactory::Instance();
if(pShapeFactory != 0)
pShapeFactory->RegisterShape(1, CreateLine());
}
Error:
error C2664: 'RegisterShape' : cannot convert parameter 2 from 'class Shape *' to 'class Shape *(__cdecl *)(void)'
There is no context in which this conversion is possible
How do I fix this problem?
thanks
|
|
|
|
|
Hold on - the second parameter of RegisterShape(1, CreateLine()); is defined as "CreateShapeCallback CreateFn", not Shape* so what is happening is the compiler is unable to convert from a pointer to Shape class returned by CreatLine() to a pointer to the actual function itself. Squarepeg -> round hole. So if you really do want to insert a pointer to the function CreateLine then you will need to remove the brackets from CreateLine in pShapeFactory->RegisterShape(1, CreateLine());, so instead of executing the fn you can just take it's pointer.
*¨¨`)
¸¸.·´ ¸.·*¨¨`)
(¸¸.·* ¸ .·*
¸¸.·*
(¸¸.~~> Joel Holdsworth.
|
|
|
|
|
hi , i m searching for a class or a function that detect if an user is connected to the internet or not,
Please Help,
Thanks,
Bye
|
|
|
|
|
I have never used this but have a look at:
BOOL InternetGetConnectedState(
LPDWORD lpdwFlags,
DWORD dwReserved
);
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
I know it's going to be simple, but can anyone please tell me how can I get current tab position or ID in a dialog box?
|
|
|
|
|
send TCM_GETCURSEL message to the control
int nIndex = static_cast<int>(::SendMessage(GetDlgItem(hMyDlg, ID_MYTABCTL), TCM_GETCURSEL, 0, 0));
|
|
|
|
|
If you're talking about the currently activated tab in a tab control, then the message above is correct.
If you want to find which control is active, then use GetFocus() .
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Thanks for your help, Alex and Ryan. Send TCM_GETCURSEL message is all I needed.
|
|
|
|
|
skinnyreptile wrote:
Thanks for your help
You're welcome
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I am trying to pass a vector to a function, but something is wrong.
I think I am declairing the prototype and function incorrectly
this is what I have
in my *.h file
int static parseData(vector<double> v);
in my *.cpp file
<br />
RFMAccess::someFunction(){<br />
<br />
\\do some stuff here and pass the vector<br />
parseData(data);<br />
}<br />
<br />
<br />
int RFMAccess::parseData(vector<double> v){<br />
<br />
\\do some stuff with the vector here<br />
<br />
return 0;<br />
}<br />
I actually need to pass the vector to another function in another class, but this is the idea I am trying to do.
I would pass-by-reference but, as mentioned the function is in another class.
thanks,
Steven
|
|
|
|
|
vector is not a type, it is a template.
|
|
|
|
|
I didn't realize that the code left off the <double>
The function looked more like
RFMAccess::parseData(vector<double> v)
does this look corret?
steven
|
|
|
|
|
I think you meant to do something like
RFMAccess::parseData(vector<int>& v)
|
|
|
|
|
or
RFMAccess::parseData(const vector<int>& v)
|
|
|
|
|
I tried 2x to get the greater than and less than symbols in the message but they kept getting left off.
I just realized that they were at the bottom
RFMAccess::parseData(vector<int> &v)
is this the correct notation?
steven
|
|
|
|
|
I understood that. What I was implying is that you might want to pass your vector by reference(or constant reference). You might not want to create a copy of the array/vector every time you call the function(unless it was your intent;)).
|
|
|
|
|
|
I didn't realize that the code left off the <double>
The function looked more like
RFMAccess::parseData(vector<double> v)
does this look corret?
steven
|
|
|
|
|
I got my hands on a Xerox copy of some notes, which says that AfxWinTerm() is called *after* ExitInstance() in an MFC application.
MSDN doesn't even have an entry for AfxWinTerm() . MSDN search and Google weren't very helpful.
I'm beginning to suspect these notes I have are very old and refer to outdated content. Am I right?
Vikram.
-----------------------------
KI klike KDE kand kuse kit, kbut KI kmust kadmit, kstarting kall knames kwith K kis ksilly. KI khope kthey kwill kgive kup kthis kwhole kscheme ksoon kand kcome kup kwith kreal knames.
pI vThink aHungarian nNotation vIs iA aWonderful nThing cAnd pEveryone avShould vUse pIt aAll dThe nTime, adNo nMatter pWhat dThe nContext, adEven adWhen vSpeaking.
|
|
|
|
|
Was just poking around CP and found this article..
http://www.codeproject.com/cpp/mfcprogflow.asp
Quote from the article..
Once WM_QUIT is received Run returns and control returns to AfxWinMain which performs clean-up and lastly calls AfxWinTerm which deletes all the global application structures that were created.
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I wanted to know how Could i Send email in an Visual C++ App. Is there any API to do that ?
|
|
|
|
|
Several. Look at:
CDocument::OnFileSendMail()
(Extended) MAPI
SMTP
CDO
|
|
|
|
|