|
|
I am currently trying to work with COM and make a container to hold a Word document. What is happening is that I create the frame window, then insert the Word document, and it does what it should, it brings up the doc, puts the Word toolbars and menus on the window, etc. But one thing it does that is strange is that it has several of the toolbar buttons disabled. The Open, New, and Save buttons are disabled. Also, the Print button is enabled but when I click on it, it doesn't do anything. Other buttons, such as the spell check work fine. Everything seems to work fine when using the menus. Does anyone know why these buttons are disabled? How to enable these buttons? Anything about this issue?
I looked through several articles, such as the Using MS Office in an MFC Application but that doesn't ever mention anything like this....
|
|
|
|
|
Have you checked the properties for the control. There might be property settings that will allow you to view the toolbars. If you are importing the Word DLL then look at the TLH file. There must be some property setting. I will look into it myself when I get the time and see if I can find something.
|
|
|
|
|
Hey everyone!
I'm working on an application that suppose to send a WAP configuration from a PC to a mobile via SMS, the mobile that i'm using to send the SMS is Nokia 6110. I'm using a specific SDK (SDK Nokia Connectivity) based on COM objects,I managed to send the SMS using the functions described in the SDK but i can't receive the SMS on the destination mobile.
If anyone has already used this SDK for sending SMS, plz reply to me
Bebe Harhour
|
|
|
|
|
Hi:
I know microsoft word support automation,I can use the fillow two method access word object:
#import .....
IApplicationPtr pApp;
(1)
// Start up existing word, if available
HRESULT hr = pApp.GetActiveObject(L"Word.Application");
(2)
// Start up fresh instance of word
HRESULT hr = pApp.CreateInstance("Word.Application", NULL,LSCTX_LOCAL_SERVER);
I wonder how to implement it in my application. I use Windows API RegisterActiveObject to register my application interface,but it can only use the first method to access my object.Can someone help me? Thanks!
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
For CreateInstance() to work, you need to register your class factory with a CoRegisterClassObject() call.
(RegisterActiveObject() is only for existing app instances).
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site. Support for development will ship at the same time as the Windows XP Service Pack 1 (SP1) release.
|
|
|
|
|
Thanks very much!
BTW,if I want use build both method in my application,should I use both RegisterActiveObject and CoRegisterClassObject?
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
|
Thanks very much!!!
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
Could someone post a link or explain the difference between Single Threaded Apartment and Multi Threaded Apartment? Is the use of one or the other determined by whether the application makes use of any multi threading? Does it make sense that calls to OleInit made on some threads use STA as the mode, but other calls on other threads use MTA.
Thanks for any insights.
Chris Meech
|
|
|
|
|
|
|
Thanks for the link. Jeff's work is always so good.
Chris
|
|
|
|
|
have a COM dll and I am using the libs from Office 2000. When the user hits a button, I open Word. When I open word, sometimes there is text that the user wants to edit so I put the text in a file, then put this filename in the CreateProcess function call so that Word will open this file. But I am having on irritating issue. Every time I do this with Office 2000, I keep getting the messagebox "Do you want to revert to the saved document" right when Word opens. I have tried several things and nothing seems to work so that this message box doesn't appear and Word just goes ahead and opens the file like I want it to. Does anyone have any idea how I can stop this messagebox, do you think there is something wrong with the way I am opening Word, or perhaps is there something wrong with the way I am saving the word document??????
|
|
|
|
|
Hy everybody, Please help me with an ideea. The problem is simple, but the solution...
In fact, i need to have only one permanent instance of an ATL COM+ object (or more but only persistent public data members), and 3 or more clients who must connect at this COM object to get and put data. The clients are C++ who connect with CreateInstance and ASP who use CreateObject.
The problem is at each new CreateInstance of a new client, in COM+ appear a new instance of my COM+ object, even i use DECLARE_CLASSFACTORY_SINGLETON.
Even if i use the both threading model, in any apartments, the public data look to be the same only to C++ clients, a new ASP instance will create a new object with new different public memebers !!!
Adrian Bacaianu
|
|
|
|
|
sounds like a security problem : every single instance per launching user and winstation : check out DCOMCNFG
|
|
|
|
|
It looks like you want a system-wide singleton (accross process boundaries). You would indeed get funny results with this approach:
- different processes (in your example: IIS and the C++-application) instanciating your component would get a singleton *per process*.
- any static data you maintain dies when your dll goes out of memory: this happens if all interfaces are released: DLLCanUnload is called on a regular basis, and when it returns true (default ATL-implementation: when all reference counts are zero), the dll is unloaded.
You can solve this problem by leaving the COM-singleton for what it is,
designing your component as a multiply instantiatable component
and using either static data in a persistent, out-of-process server (take a look at ATL-service) or simply persist your data in a database.
|
|
|
|
|
Hello,
I'm writing a browser helper object (BHO). It seems that I cannot do this :
<br />
IGlobalInterfaceTable *g_pGIT = NULL;<br />
<br />
void CALLBACK TimerProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)<br />
{<br />
HRESULT hr;<br />
IDOMPeek* pIDOMPeek = NULL;<br />
hr = g_pGIT->GetInterfaceFromGlobal( <br />
dwUser, <br />
IID_IDOMPeek, <br />
(void**)&pIDOMPeek);<br />
<br />
I get hr == 0x800401f0
Why and how should i do it ?
Does I have to use ITimer, ITimerService, ... But i cannot find samples how to use that.
Thanks.
|
|
|
|
|
Oops, i forgot to call:
CoInitializeEx(0, COINIT_APARTMENTTHREADED);
Next time i'll read the docs more deeply.
|
|
|
|
|
Hi,
I have been trying to get a result here for a couple of days and am now loosing hair at a rate which I am unable to sustain any longer
I have been experimenting with the VC demo ATLDRAW which includes a ATL DCOM server an ATL DCOM client and an ATL DOM Client as an ActiveX control.
I am trying to reduce the required Authorization such that someone can use it who is not a member of the same domain, so long as they have a login name and password on the client which matches the server. (I have seen this done with Windows Media Services remote management).
All is fine with the normal Client as I can use -
<br />
CoInitializeSecurity(NULL, -1, NULL, NULL,RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IDENTIFY, NULL, EOAC_NONE, NULL);<br />
However in the ActiveX control you can not call CoInitializeSecurity as you are too late. I have tried using CoSetProxyBlanket on m_pDrawServ but it has no effect. I have found some stuff at -
http://www.microsoft.com/msj/defaultframe.asp?page=/msj/1198/security/security1198.htm&nav=/msj/1198/newnav.htm[^]
Which says I need to call CoSetProxyBlanket on my interfaces but I don't see how to do it.
Has anyone ever managed to reduce the Authorization Level in a DCOM ATL ActiveX control and if so how.
Cheers
|
|
|
|
|
I am having some trouble with something that is probably very simple. I have a COM project (exe) and it does not use any ATL. It is fairly simple, a dialog box opens with 2 buttons, the first is to run MS Word. When pressed, word opens up and the user can enter some text. After a lot of research and trial-and-error, I was able to put a button on the Word toolbar. But I do not know how to know when the button has been pressed. This is my class:
/*----------------------------------------------------------------------------*/
const IID IID_IWordAppEventSink = __uuidof(Word::ApplicationEvents);
const IID IID_IWordDocEventSink = __uuidof(Word::DocumentEvents);
const IID IID_ISpecialSaveExit = __uuidof(Office::CommandBarButton);
/*----------------------------------------------------------------------------*/
class CWordEventSink : public CCmdTarget
{
DECLARE_DYNCREATE(CWordEventSink)
public:
CWordEventSink();
virtual ~CWordEventSink();
BOOL Advise(IUnknown* pSource, REFIID iid);
BOOL Unadvise(REFIID iid);
void SetLauncher(CTestDlg* pWordLauncher);
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWordEventSink)
public:
virtual void OnFinalRelease();
//}}AFX_VIRTUAL
protected:
// Generated message map functions
//{{AFX_MSG(CWordEventSink)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
// Generated OLE dispatch map functions
//{{AFX_DISPATCH(CWordEventSink)
afx_msg void OnAppStartup();
afx_msg void OnAppQuit();
afx_msg void OnAppDocumentChange();
afx_msg void OnDocNew();
afx_msg void OnDocOpen();
afx_msg void OnDocClose();
afx_msg void PSISaveAndExit();
//}}AFX_DISPATCH
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
private:
CConnectionAdvisor m_AppEventsAdvisor;
CConnectionAdvisor m_DocEventsAdvisor;
CConnectionAdvisor m_BarEventsAdvisor;
CTestDlg* m_pWordLauncher;
};
I kind of cheated by using an example article written by Christian Staffe called Automating and Eventing in Word. But it never mentioned what to do to capture when the button has been pressed. Does anyone have any thoughts or suggestions? Examples would be great to, I am still trying to learn all this COM stuff..........
|
|
|
|
|
Please check out htis article :http://www.codeproject.com/com/outlookaddin.asp. Although this uses ATL, the basics still hold true.
You should use ConnectionPoints semantics to Advise and Unadvise to ICommandBarButtonEvents dispinterface which has a single method Click(dispid 0x00000001). Thus in your implementation of Invoke in your class, when the dispid = 1, check if the passed CommandBarButton* is the button you created and write the code for the handler.
First ofcourse somewhere in OnConnection() you must advise to ICommandBarButtonEvents like.
CComPtr<iconnectionpoint> spConPt;
hr = spMyButton->FindConnectionPoint(
DIID__CommandBarButtonEvents,
&spConPt);
DWORD dwCookie;
if (FAILED(hr))
return hr;
hr = spConPt->Advise(reinterpret_cast <idispatch*>(this),
&dwCookie4);
if (FAILED(hr))
return hr;
.......
similarly you should also Unadvise() when the connection is no longer needed.
'My capacity for happiness', he added, 'you could fit into a matchbox without taking out the matches first'.
- Marvin, the robot.
Amit Dey
sonork: 100:18407
msn: visualcdev
|
|
|
|
|
I posted this on the Visual C++ board and the only response I got was "import them both". I am hoping that maybe someone in the COM board can help me with a little more info. I cannot import them both, it will not compile!
I was hoping someone could help me with a little problem I am having. I am new to COM and after a lot of research and helpful articles, I was finally able to write my first COM dll. One of the most suggested articles is the one about creating an outlook dll for office 2000. So I structed my dll around this. I used the #import for the type libs and was actually able to create my own button. I am not doing this for outlook but instead of word and excel. What I was wondering is if there is a way to know, programatically, what version of office the machine has? The #import statements are located in the stdafx.h. But is there a way to check if Office XP, then use the #import statements for Office XP and if not, use the ones for office 2000 libs? I have looked through a lot of code and I found a complete of alot ideas but with the way the dll is put together, since I am not using the msword.h and such, they don't work for me. Can anyone give me any suggestions!!!!!!
|
|
|
|
|
I have a bad answer for you, and then a question.
I have seen this type of question many other places and I have never seen an answer. My suggestion would be to simply use more than one version of your .dll. It would be nice to be able to use only one .dll for any system, but, as an example, check out the Microsoft Internet Explorer update page... there are different d/ls for different versions of windows. I think you have the same type of situation. It ain't pretty, but it may be the only solution. Hopefully someone can jump in and give a better answer...
And now my question: I was wondering what resources you used for your project, besides the article you referenced in your post. Specifically, I am getting ready to start a project using COM to automate Word and I am looking for a resource on this, objects, functions, etc. More specifically I want to be able to select document properties, search for and open templates, write text to the document, and print. I have gotten lost on wild goose chases in MSDN docs and I just need a nudge in the right direction.
Please let me know if you can help.
Thanks,
tym!
|
|
|
|
|
I am not sure if I am the best person to answer this. I tried to use MSDN and they have a wealth of information. Unfortunately, I understood about 1% of all the information. There are many articles out there, the one I reference in the above posting written by Amit Dey, there is another written by Christian Staffe, both are on this website. Plus, between this website and CodeGuru.com, you can pick up a lot of information. The bad thing is that it is not all straight forward, unless you are an experience COM/ATL programmer. Another bad thing is that many examples are written with ATL and many others are NOT. So it is a bad mix. If you keep digging, you can find a lot. If you are wanting to select document properties, open templates, print, etc, you can find basic functions/info on these websites. If you are wanting to add a button/toolbar/menu, that is a whole 'nother ballgame!
|
|
|
|
|