|
|
Get a copy of Essential COM if you really want to understand it.
I'd also look into ATL as it makes COM programming a lot easier. The Wrox Press ATL books are very good.
Michael
Communication is the first step towards enlightenment.
|
|
|
|
|
How can i make an IPC with my own COM component? Which type of COM server (.dll or .exe) and threading model must i use?
|
|
|
|
|
If you use ATL all of that stuff is taken care of for you. You can use any threading model that you would like, and any type of COM server. I am think that MFC will handle the marshalling for you as well, but I am not positive.
If you do not use one of these tools, then you will have to create your own mechanism to communicate to the other process, whether it is Memory mapped files, TCP/IP or some other method.
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!
|
|
|
|
|
While trying to build a ActiveX control using ATL (with MFC support) & i run into these linker error messages & the funny thing is I'm not using/referencing RichEdit control at all!
uuid.lib(cguid_i.obj) : error LNK2005: _IID_IRichEditOleCallback already defined in OrderEntryCtrl.o
uuid.lib(cguid_i.obj) : error LNK2005: _IID_IRichEditOle already defined in OrderEntryCtrl.o
Any clues?? TIA
Chen Venkataraman
|
|
|
|
|
I should add that the ActiveX control is subclassing a Edit control
Chen Venkataraman
|
|
|
|
|
Never mind - i figured out
I was using the ATLControls.h (from the MS sample atlcon) that provides wrapper methods for all the common controls.
This file also includes additional header files
#include "richedit.h"
#include "richole.h"
that relate to RichEditCtrl & i suspect these were causing the problem.
For now, i excluded them in my project by defining _ATL_NO_RICHEDIT in my project & modifying the ATLControls.h header to conditionally include them like so.
#ifndef _ATL_NO_RICHEDIT
#endif
Chen Venkataraman
|
|
|
|
|
Hi again,
In my previous post I explained my problem... there is another one dealing with they way the strings look when they enter the COM world. They have double pipes (||) where it's supposed to be newlines...
Have you had any experience with this?
/T
|
|
|
|
|
CR and LF aren't displayable characters, so when you view a string you will still the "double pipes". They still are the chr$(10), chr$(13), it's just that the string can't display them.
The string would look right if displayed in a multiline edit control. I don't think you need to worry about this.
Michael
|
|
|
|
|
Hi everybody,
I'm reading a huge selection of text from MS Word to a COM object. My objective is to translate this text.
The interface goes like this:
Word Macro calls Translate of COMobj where Selection.Text contains the text to be translated:
sub Trans
Selection.Text = COMObj->Translate(Selection.Text)
end sub
COMObj's Translate looks like this:
STDMETHODIMP CCPPTranslate::Translate(BSTR* pbstrText, BSTR* pbstrRet)
{
USES_CONVERSION;
if (m_Translator.IsOk())
{
char* pszText = m_Translator.Translate(W2A(*pbstrText));
CComBSTR ComBSTR = CComBSTR(pszText);
delete[] pszText;
*pbstrRet = ComBSTR.Detach();
return S_OK;
}
Now, what happens is that when I select more than 32767 (is that a bell ringing?) characters and run the macro, MS Word crashes. Is this because of some limitations COM have with respect to string lengths that I do not know of or is there something else I'm missing here?
All help is greatly appreciated,
/Tommy
|
|
|
|
|
As far as I know, you could have string that is 4GB in length. I think that it is more a limitation of the macros in WORD.
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!
|
|
|
|
|
read my article:
http://www.codeproject.com/useritems/BUG_in__bstr_t_amp__varia.asp
CComBSTR has the same problem
soptest
|
|
|
|
|
In Netscape Navigator my ocx in the HTML page can not be loaded and seen. What should I do with my OCX codes and Navigator setting respectively to enable OCX in Navigator?
3x
|
|
|
|
|
1) Use some kind of a wrapper control that can create and host instances of any WIndows activex control. There are a couple of such commercial and free controls available on the web.
2) rig up Netscape plugin support yourself(thru XP COM) to your activex control.
#define MOSTLY_LEAN_AND_MEAN
|
|
|
|
|
Hi,
I know i've seen this done in a few places, but what's the best way to go about adding a toolbar button to powerpoint so that it can launch an external application? I've seen an example on code project for making a COM/ATL plugin for Outlook 2000, but that seems to go way beyond what I would need - or does it?
Also, would that [outlook plugin] solution work for office 97/95? If not, is there even a way to insert functionality like that?
Cheers
Jedi
|
|
|
|
|
this would not work with Office 95/97.
#define MOSTLY_LEAN_AND_MEAN
|
|
|
|
|
As to adding toolbar buttons thru an addin to PP, this is very similar to the article on Outlook, but ofcourse with a few minor changes. If you have followed most of what my article says, (and have a little ATL COM background)you shouldn't have many problems. Just the registry keys for pp addins are different, the object model is slightly different(with regards to addin buttons) and you have to obviously import different typelibs(msppt9.olb & other dependencies). But the basic process of adding toolbar buttons, menu items, command handlers and propertypages are very similar to Outlook.
As to launching an external app,(on button click?) if the app is COM based, you would use interface based programming or ShellExec() for non-COM apps.
#define MOSTLY_LEAN_AND_MEAN
|
|
|
|
|
You were right - it only took me an hour or so to actually implement the button in powerpoint Thanks for writing such a great article..it really helped a lot.
|
|
|
|
|
I have built a COM server with c# and tested it with VB 6.0. Everything has gone well with VB. But when I tried to use it with VC++ it didn't work. I imported the type library with and without the no_namespace directive. When I compiled the project it gave these errors:
c:\MyProjects\MFC\COMClient1\Debug\COMServer1.tli(57): error C2064: term
does not evaluate to a function
c:\MyProjects\MFC\COMClient1\Debug\COMServer1.tli(53): error C2501:
'_TypePtr' : missing storage-class or type specifiers
c:\MyProjects\MFC\COMClient1\Debug\COMServer1.tli(53): error C2433:
'_TypePtr' : 'inline' not permitted on data declarations
c:\MyProjects\MFC\COMClient1\Debug\COMServer1.tli(53): error C2143:
syntax error : missing ';' before '_QuoteServer::GetType'
c:\MyProjects\MFC\COMClient1\Debug\COMServer1.tlh(86): warning C4183:
'GetType': missing return type; assumed to be a member function
returning 'int'
c:\MyProjects\MFC\COMClient1\Debug\COMServer1.tlh(86): error C2501:
'_QuoteServer::_TypePtr' : missing storage-class or type specifiers
c:\MyProjects\MFC\COMClient1\Debug\COMServer1.tlh(86): error C2146:
syntax error : missing ';' before identifier 'GetType'
my COM server has only two methods:
string GetQuote ();
int GetInt ();
There is a problem with the type library. _TypePtr is not defined anywhere. The interesting thing is that this component works very well with Visual Basic. Does anybody know what this problem might be?
Thanks,
Tunca Bergmen
|
|
|
|
|
more ofenly, when vs complied the com source to a tlb in it will have a hint like this:
// #import "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.tlb" you shoud add this to StdAfx.h before #inport youOwn.tlb
the basice property like _Type, _ObjRef will added in you project for the proto type
i think, it will solve you problem.
but the bigger problem is : after everythin done, there be some runtime errors when you call a Ptr in you program
anyone can help?
|
|
|
|
|
I have written an ATL DCOM object running as a service logged on as a local user on that server.
Can I find out who is instantiating my server object from a client.
|
|
|
|
|
I'm a begineer in COM. Please anyone help me.
I have to pass a String value(CString) from an edit box into COM Object(LPCTSTR).
ThankYou
|
|
|
|
|
You need to do something like this where your CString is called cString, and your com function is pInt->Fuction():
BSTR bstr;
bstr = ::SysAllocString(cString);
pInt->Function(bstr);
::SysFreeString(bstr);
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!
|
|
|
|
|
Just an observation:
If the requirement is only to send the contents of the
CString to the server (as in this case), then the
solution is okay. If the server changes it and the client
needs it back, a BSTR * will be required.
The IDL should have [in] BSTR bstr in the first case.
For the second type it should have [in, out] BSTR *pbstr
With best regards,
Sayan
Email:sayanmukherjee@indiatimes.com
|
|
|
|
|
Thanks for you Help. I did as you explained. But it's showing an error.
error C2664: 'SysAllocString' : cannot convert parameter 1 from 'class CString' to 'const unsigned short *'
Please explain
|
|
|
|