|
I've already done, that don't works.
is there another way to do it?
thx
Martin
|
|
|
|
|
And what is wrong? Let us look at your PICTUREDISP constructors/destructor. Also, what is a OCArray class?
With best wishes,
Vita
|
|
|
|
|
The OCArray is a faster CArray class (you can find it on this page).
The variable pPic is a LPPICTUREDISP an is passed by a function called from a VisualBasic application. (It is only a temporary variable).
It should work like that:
1. pPic is passed to the function
2. the function inserts the pPic into the array
3. and calls a function that updates the thumbnail view.
The point is that you can only insert two pic's, if you'll insert a third one the ocx crashes. Furthermore all pictures become the last inserted picture.
The declaration of LPPICTUREDISP is the standard MFC declaration.
The two files of my PICTUREDISP class can you find on:
http://www.martin.krellmann.net/PICTUREDISP.h.txt
http://www.martin.krellmann.net/PICTUREDISP.cpp.txt
|
|
|
|
|
Well. I have a look at your files.
PICTUREDISP(IPictureDisp* lpDisp)
{
if (this != NULL)
this->Release();
if ((lpDisp != NULL) &&
SUCCEEDED(lpDisp->QueryInterface(IID_IPictureDisp, (LPVOID*)this)))
{
ASSERT(this != NULL);
}
}
ULONG STDMETHODCALLTYPE PICTUREDISP::Release()
{
return this->Release();
}
Why have you decide to call the Release() in the constructor? You must get the endless loop, IMHO.
virtual ~PICTUREDISP();
You should not use the virtual destructor. Your vtable will not correspond to the vtable of a class PICTUREDISP during a destructor call (QueryInterface will replace this vtable).
To avoid the AddRef/Release problem you must also realize the operator of copying with your technique.
PICTUREDISP& operator=(const PICTUREDISP& src)
{
...
}
In summary I would like to tell you that your technique is very doubtful and is fraught with mistakes. Though it may have the right on life. Be attentive! And often use Debug Session!
With best wishes,
Vita
|
|
|
|
|
I think that is to difficult for me. Maybe you could modify my source-files an mail them to me: martin2002@web.de.
Is there a better technique to relaize the view. Well pherhaps it is a good way in VB, but maybe not in C++? So you could figure out that I'm quite a good VB programmer, but these MFC/COM/ATL thing are to difficult for me yet. But it is very necessary to realize the thumb view.
Please help me ...
|
|
|
|
|
I wrote an ActiveX. It is included in an HTML page with a codebase information used to install the ActiveX on the user machine.
When the user has an administrator account (WinNT and Win2000) or an account with rights, it works. Else, the ActiveX is not instanciate in the HTML page.
Does anybody know how to force the install of an ActiveX with a standard Windows user account ?
|
|
|
|
|
Hi,
I get a linker error when I try to compile this class that contains a sink object in my ATL COM project.
"error LNK2005: "struct ATL::_ATL_FUNC_INFO OnNewUpdateInfo" (...) already defined in EventClient.obj"
Here is the listing of the Header file that conatians the sink object.
// EventClient.h: interface for the EventClient class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_EVENTCLIENT_H__062FDEBD_52F0_11D6_97B4_0002A5A9B5AA__INCLUDED_)
#define AFX_EVENTCLIENT_H__062FDEBD_52F0_11D6_97B4_0002A5A9B5AA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#import "D:\TreeServer\TreeServer.tlb" no_namespace, named_guids, raw_interfaces_only, raw_native_types
//#include "D:\TreeServer\TreeServer.h"
//#include "D:\TreeServer\TreeServer_i.c"
#include <windows.h>
#include <atlbase.h>
#include <atlcom.h>
/************************************************************/
// Info for the events handler.
ATL::_ATL_FUNC_INFO OnNewUpdateInfo = {CC_STDCALL, VT_EMPTY, 1, {VT_BSTR}};
class CEventClient
: public IDispEventSimpleImpl<1, CEventClient, &DIID__ITreeUpdateEvents>
{
public:
CEventClient(ITreeUpdate *pITreeUpdate);
virtual ~CEventClient();
// The sink method.
void __stdcall OnNewUpdate(BSTR msg)
{
USES_CONVERSION;
m_bstrInMsg = msg;
SysFreeString(msg);
}
BEGIN_SINK_MAP(CEventClient)
SINK_ENTRY_INFO(1, DIID__ITreeUpdateEvents, 1, OnNewUpdate, &OnNewUpdateInfo)
END_SINK_MAP()
private:
ITreeUpdate *m_pITreeUpdate;
BSTR m_bstrInMsg;
};
#endif // !defined(AFX_EVENTCLIENT_H__062FDEBD_52F0_11D6_97B4_0002A5A9B5AA__INCLUDED_)
Any help would be great. I've been trying to track down this error for days now. ;(
Thanks in advance.
Ken
|
|
|
|
|
You variable is in the H file, thus being declared twice. Place an extern in the H file and the actual variable in a CPP.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hi!
I am a developer and I work with DCOM on Windows98. The question is: is there any problem to use a CComPtr object as a class member?
Thanks.
Gian.
|
|
|
|
|
Nope, not at all. I use it all the time.
The only problem I have ever seen with CComPtr is that it doesn't work in STL collections. But there is a CAdapt class that helps with this problem.
Instead of std::vector <ccomptr <isomething=""> >, you have std::vector <cadapt <ccomptr="" <isomething=""> > >.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hi everybody,
I'm a complete COM beginner and I'm wrestling with my first project using MSVC.
Using the ATL wizard I can successfully create a simple DLL (add simple ATL object, AddMethod).
My problem is how can I return a value from my method ? I DO NOT want to pass pointers, which I then manipulate within the method but I want to be able to return the value "directly" (retVal = obj.mymethod()). I'm sure this can be done, but it seems the return type of COM methods is always HRESULT !??
Can I do this using properties (AddProperty) ?
A few lines of example code would be great.
Many thanks,
Axel
|
|
|
|
|
It is completely possible to create a COM interface function that returns the value directly like this:
DWORD GetCount();
However, I would only recommend doing this if you are only writing this object for use in your programs, and you will be using the object as an INPROC_SERVER.
If you want to write COM objects that are truely binary compatible, and can be used by other languages than C++, like VB, then you will need to alway return HRESULT. The reason why is for programs that perfrom network or interprocess communication through COM objects. Whenever you expand the boundaries of your program, there are certain situations that can occur that are out of your control, like the user disconnects their computer from the network. The other libraries that COM depends on will use the HRESULT to indicate this to your program or the program that is using your object.
If you do not use pointers to return values to the user, it becomes more difficult to marshal your data across process boundaries and computers.
Here is a simple prototype for a Get procedure:
HRESULT __stdcall GetCount(DWORD *dwCound);
You want to use the stdcall calling convention for all of your functions in COM, because this is the convention that all programs expect when dealing with a COM interface. _cdecl is the default for VC++.
The bool Essential COM,/i> by Don Box is very insightful for learning COM.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
If you want to get a retval from an ATL/COM function, you have to declare the variable that stores the retval as [out, retval] in the ATL Interface.
Example:
interface IExampleClass : IDispatch
{
[id(1), helpstring("Method ExampleFunc")] HRESULT ExampleFunc([in] int nParam1, [in] int nParam2, [out, retval] int* nRet);
}
|
|
|
|
|
Hi
Iwant to develop service in which I need to create a thread.
How can I implement a thread in a service?.I am using ATL com Wizard to create the service.
Thanks
Pathi
|
|
|
|
|
Dear all:
I made a Internet download component(such as a.cab).Then I execute the following command:
1.Makecert -sk test1 -r -ss test1
2.SignCode -s test1 a.cab
However the command output is:
"This file is signed,but not timestamped."
How can I make a timestamped digital certification.
Could you give me some advice.
thanks a lot.
liuage
|
|
|
|
|
-t http://timestamp.verisign.net/scripts/timstamp.dll
Todd Smith
|
|
|
|
|
Is there a class just as MFC's CTime in ATL/WTL?i am waitin for you answer!
|
|
|
|
|
I exercise the pure c++(No supported by MFC and ATL,even IDisptch interface) to write:
1.proxy/stub DLL;
2.out proc server EXE;
3.client EXE.
Then I run the program.When the client call function of connectable object in the server through interface,
All work well;But if the server call function of the sink in the client even like QueryInterface(.....) ,
A strange thing raises.For example,I test the command below:
//the pUnk is passed from client by Advise(......)
HRESULT hResult=pUnk->QueryInterface(IID_IUnknown,(void**)(&pIUnknown));
Now I make use of FormatMessage(.....) to check the value of hResult,
the string is "The operation completed successfully";
Whereas QueryInterface(.....) does not implement!(I add MessageBox(....) topside to prompt me),
I want to known the reason,who can help me?thanks a lot!
//A slice of my source code
//MyCom.idl
import "unknwn.idl" ;
import "OCIDL.IDL" ;
//IMyEventSink interface,CMyEventSink object do the realization
[
object,
uuid(5A76E364-92E6-4d90-B575-31C0497FD174),
helpstring("IMyEventSink Interface"),
pointer_default(unique)
]
interface IMyEventSink : IUnknown
{
HRESULT Test([in] DWORD dwShowNum) ;
};
//the rest omits
..............
C/C++ code fans
|
|
|
|
|
The problem had been resolved,I forgot to call QueryInterface(...)in the Advise(...),It is said in MSDN that calling the function is necessary!
Thank all of you!
C/C++ code fans
|
|
|
|
|
My application is created using MFC / VC6.0. I host a webbrowser control within my dialog. When I display a HTML page within the control & click on the url links I have provided, I'm able to capture them in BeforeNavigate2 event successfully. This I use it to display different functionality when I'm offline. But I have a problem when I host Flash Ads within my WebBrowser.
How can I trap the events like clicking on a hyperlink provided in Flash Ad & communicate it back to my application.I do know there are events like OnMouseup, OnMouseDown etc in Flash. I'm more particularly interested in my application intercepting the clicked event of the Flash, processing & redirecting it back to be opened up in the browser control
anandhi
|
|
|
|
|
i want to use WRL::CString ,but once i add #include <atlmisc.h> to the stdafx.h,the compiler will notify me with the following:
error C2664: '_LoadString' : cannot convert parameter 2 from 'class WTL::CString' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
who can help me?
i am coming quietly just as i am leaving quietly.
|
|
|
|
|
Try explicitly casting the CString variable (Parameter 2 of the LoadString function that is failing) to a LPCTSTR. This should for the compiler to use the cast operator that is declared for the WTL::CString.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I created a object and used it in ASP. All the things were fine for the first time. But after that I found when I built the com again, it report that LINK : fatal error LNK1104: cannot open file "Debug/StudentManager.dll".
I thought it because StudentManager.dll is still used by asp. But when I close asp or even logoff the computer, it didn't work yet. I can not use Release method in ASP as in client program to release object.
So if anyone has such experience, please tell me.
|
|
|
|
|
Yet another wonder of some Win32 components. It's most probably still locked by some other "component" such as the Transaction Manager or the ... You get the picture. You're basically left to wait until some timeout of some "nice" service that holds this interface for you, in case you'd need it again, is released.
Another way to fix it is to use plain RPC or CORBA.
Microsoft=sh*t? No. Not always, but often.
|
|
|
|
|
what are good books for learning atl ?
i've got "beginning atl com programming" by Gimes Stockton Reily and Templeton
but its pretty much unreadble
any suggestions?
bryce
|
|
|
|