|
Hi,
I am currently using Visual Studio version 6.0 for C++/MFC development and I want to move to the new IDE Visual Studio .NET and continue learning COM and ATL C++ developlment.
QUESTION
Can I develop regular COM/ATL C++ code using the new VS.NET? I should say that I am new to COM programming so I don't want to make things more difficult.
So my question is really - I would like to continue the same C++/MFC/COM/ATL coding but using the new compiler and IDE. Is that possible, without too much grief?
Thanks
Mike
|
|
|
|
|
|
any 1 can help me what and when __uuidof is used in com
when i used it with _CommandBarButtonEvents when creating an add in for outlook 2000 it generated error "this class have no uuid associated with it" . but in ole object viewer i can see its uuid.
|
|
|
|
|
can u write those lines of code whih u r using to get __uuidof ur event interface.
Abhishek Srivastava
Software Engineer (VC++)
India ,Noida
Mobile no 9891492921
|
|
|
|
|
__uuidof keyword extract guid assigned to an object via "uuid" attribute ((__declspec(uuid"...")). It's not always assigned. Usually headers generated by midl or "import" statement have such attibutes attached to the objects (interfaces, enums)
Check your header file that has a declaration of _CommandBarButtonEvents
Edward
|
|
|
|
|
Got a problem, exhausted all of my ideas:
I have an MFC / ATL-com-server project. Upon final release, I want the COM object to wait for a timer to fire one last time and run it's thread to completion before unloading itself. Here are some attempts:
1) AddRef() in the com object and then once the timer thread has fired it's last time, Release() from that thread. This causes a crash in the main window of the app in CWnd::DestrowWindow function with this code:
if (pWnd != NULL)
{
#ifdef _DEBUG
ASSERT(pMap->LookupPermanent(hWndOrig) == NULL);
#endif
}
2) In the CSSLogCOM::InternalRelease() function (which I've overridden), wait for a flag to be set when the timer thread fires and completes with while(bWait) Sleep(1000); . This doesn't work because the timer won't fire once we're in this function! ???
3) I would try to post a WM_QUIT message to the main window, but the ATL server can host many copies of the same COM object in a single instance and if one of them posts the quit message, other running instances will be stopped early.
Anyone have any idea how I can "delay" the final release of a COM object from closing the ATL server until my worker thread has completed?
Thanks
~Steve
|
|
|
|
|
How about using CreateEvent/SetEvent/WaitForSingleObject/SignalObjectAndWait?
Create two events before the worker starts, one called "StopNow" and "DidStop". Let the worker thread do it's thing, periodically checking the "StopNow" event with WaitForSingleObject. When your server is about to terminate, make it use the function SignalObjectAndWait. This'll set the "StopNow" event, thus triggering the worker thread. It'll also make the server wait for the "DidStop" event. Meanwhile, the thread exits gracefully, but before finally quitting, it sets the event "DidStop", which will give the main thread clearance to continue termination.
void OnTerminate() {
SignalObjectAndWait(hStopNow, hDidStop, INFINITE, FALSE);
...
}
void ThreadProc() {
while(...) {
...
if(WaitForSingleObject(hStopNow, 0)) {
SetEvent(hDidStop);
}
}
}
--
Seraphim Shock. Gold for your ears.
|
|
|
|
|
Thanks for the tip, and the example code. Looks promising, I'll give it a go...
~Steve
|
|
|
|
|
I want to convert HTML to TEXT from some string
It good works in VB code like this:
Dim body As String
Dim hd As HTMLDocument
Dim str As String
Set hd = New HTMLDocument
Open "c:\test\a.html" For Input As #1
body = Input(4188, #1)
hd.body.innerHTML = body
Debug.Print hd.body.outerText
I try do it with VC++ so:
IHTMLDocument2 *pHtmlDoc = NULL;
HRESULT hr;
hr = CoCreateInstance(CLSID_HTMLDocument,
NULL,
CLSCTX_INPROC_SERVER,
IID_IHTMLDocument2,
(LPVOID *) &pHtmlDoc);
IHTMLElement *pBody;
hr = pHtmlDoc->createElement(CComBSTR("BODY"), &pBody);
CComBSTR bsText;
hr = pBody->get_outerHTML(&bsText); // OK, we have ""
CComBSTR SomeText("Some Text);
hr = pBody->put_outerHTML((BSTR)SomeText); // ;-( falls
It falls down while "put_outerHTML"
Who know right solution?
PS
Set hd = New HTMLDocument
creates an object with html code with base document structure (5 tags: html, body, head, title, p).
CoCreateInstance creates absolutely empty object.
Why?
================================
My products are here
|
|
|
|
|
Sorry don't have time to check it myself, but should work: you can try to query for IPersistStreamInit, and then call IPersistStreamInit::InitNew, that should initialize the html document object
Edward
|
|
|
|
|
Does anybody know how to fill the fields of IE's web page
from within VB or C++ ? What if the page is secure? Of
course, there is no problem to fill all the fields by
hand. The question is how to do it automatically, by
running .exe or .dll.
|
|
|
|
|
|
Hello,
I am confused about the Marshalling. When is it needed actulaly ??.....(when we want to run an out of procees server)... thats what i know. But cant we like run an Exe server without the marshalling support. I think i have seen some source code which makes an exe server (nothing else i mean no proxy/stub implementation is there ... no DLL). And you can invoke it from the client. This suggests that u can make an Exe server without Marhalling support is that true ? kindly clear me about this ...
Thank you
|
|
|
|
|
Marshalling is always required when calling between different execution contexts. This can include calling between components in a single-threaded apartment and a multi-threaded apartment (e.g. if the calling thread in the executable called CoInitialize , OleInitialize or CoInitializeEx with the COINIT_APARTMENTTHREADED flag, and the component in the DLL is registered with ThreadingModel = Free). Marshalling is always required on a cross-process or cross-machine call.
Marshalling is the process of converting the call parameters into a suitable in-memory or network representation in order for the RPC library to transfer the call across the execution boundary. When received on the other side, unmarshalling is the process of converting back from the in-memory or network representation into a procedure call. The return value and any output parameters are then marshalled back to the caller.
COM looks in the registry on a per-IID basis to locate proxy/stub implementations. You can find them under HKEY_CLASSES_ROOT\Interface\{IID}\ProxyStubClsid32.
There are two cases in which you don't need to supply a proxy/stub implementation. The first is where you're only using standard interfaces, or interfaces defined by a third party. These should already be registered. If you only use IDispatch (Object in VB 6), you don't need a marshaller.
The second is where you're using only Automation-compatible types. For these, you can use the Automation marshaller, which uses the type library to marshal parameters. You must register the type library for this to work, by calling RegisterTypeLib .
The Automation marshaller goes by the name of PSOAInterface, and has a CLSID of {00020424-0000-0000-C000-000000000046}.
|
|
|
|
|
Hmmm Great Reply,
No wonder i was getting interface not supported when i tried to RUN my Exe Server, while the exapmle code that i saw worked(as it supported the standard interfaces ..and therfore had no proxy/stub implementation) ..... Thanks that was a great reply...it helped me a lot. Code Project is great ... i have learnt a lot from these forms specially.
One thing more. To my knowledge using midl tool u can do marshalling easily for custom interfaces ....... i have made the interface in MIDL and compiled it, it gives me a lot of files .... I guess u have to get a dll out of it somehow ........ which u have to register under the proxy/stub in registery...plz correct me if i am wrong
Thank you
|
|
|
|
|
Usually (depend on midl options) you'll need xx_p.c file (proxy stup), xx_i.c (interface defs), dlldata.c
If you use atl/com wizard it generates makefile for proxy stub: dllxxx.mk
Edward
|
|
|
|
|
hi there people..
i lost my cd which came along Inside Ole (MS press) by Kraig BrockSchmidt...any body with a copy...
or any link?
many thanks
|
|
|
|
|
Hi, I am new to using COM, this is the first time I have tried, I have an MFC application that creates merge data for Word and I was wanting to create a Word document within the application add relevant merge fields and automatically attach the created data then save the document away, can anyone point me in the direction of some good tutorials, or useful information for the aspects of the Word COM I am looking for, thanks.
Ben.
|
|
|
|
|
|
Thanks for that, I have actually seen the first one of those before and have tried to take it apart and get what I need, as I said this is the first time I have tried using any sort of Component Object Model so I have found it hard trying to identify useless and useful code, the comments help a little but I was hoping for something that actually explained the different parts of the code rather than just saying what the parts do.
Thanks again,
Ben.
|
|
|
|
|
I have written an object supporting IPersistStreamInit.
Now I want to save/load it in/from ordinary (not structured file).
How to get IStream on ordinary file ? Or I must add an IPersistFile to my object ?
Thanks in advance,
Valery
|
|
|
|
|
You'll have to implement it yourself. Not very hard as IStream methods map pretty much 1:1 to the Win32 API.
--
I am perpetual, I keep the country clean.
|
|
|
|
|
Thank you for the reply, I'd rather implement IPersistFile on my object
|
|
|
|
|
Of course you should, but still - you need that IStream, and if you don't want to use structured storage, you'd have to implement your own class CFileStream : public IStream .
--
I am perpetual, I keep the country clean.
|
|
|
|
|
It seems Microsoft intentionally don't provide IStream on ordinary files, but I don't know why.
|
|
|
|