March 22nd, 2002, 06:37 PM
What is a (void**)?
The title says pretty much everything I want to know. I'm trying to wrap my brain around COM, and I've never seen a cast like (void**) before. It appears in the QueryInterface method of COM objects:
HRESULT QueryInterface( REFIID iid, void** ppvObject );
I know what a void pointer is, I guess I'm just confused with the ** part. Is it just a pointer to a pointer?
March 23rd, 2002, 10:46 AM
I don't know anything about this type of programming but I believe you are correct when you say it is a pointer to a pointer. The following link states:
ppvObject - An [out] pointer to the interface pointer identified by iid.
March 23rd, 2002, 10:52 AM
imagine a list of strings that you want to pass to a function.
each string is a char*, a list is passed via its address, so the "list of strings" is a char**
the void** is just more general.
March 23rd, 2002, 05:04 PM
Thanks. Its good to be able to confirm things. I hate "going on faith," for things like this, because eventually, assuming things catches up with you-- especially if your assumption was wrong.
Now if I could just figure out how to use these darn COM interfaces... :confused:. I didn't want to learn the COM, but the project I've started pretty much demands it if I'm gonna see it to completion. I guess I'm off to the bookstore this weekend.
It was supposed to be one of those 'simple' project. *cough* The amount of times I've heard that...
March 23rd, 2002, 08:44 PM
Ok, I'm out of ideas I guess. I'm hoping someone can offer some advice. Its a pretty specific problem. I have a view derived from CHTMLView. Its pretty basic, I use a template to put an 'empty' (html) document in the view, then I'm supposed to browse the DOM and populate/retrieve the form elements with data from the actual application's document (ie: the doc data from the doc/view architecture).
Here's the catch though, I'm able to browse the dom, but I can't for the life of me figure out how to access/modify any of its attributes. Here's what I got so far.
The ErrorMessage() function is just a little shortcut to a message box to tell me exactly where the browsing failed.
// Get the document's IDispatch pointer.
IDispatch* pHtmlDoc = GetHtmlDocument();
// Obtain a pointer to the IHTMLDocument2 interface.
IHTMLDocument2* pIDocument = NULL;
hr = pHtmlDoc->QueryInterface(IID_IHTMLDocument2, (void**) &pIDocument);
// Obtain a pointer to the HTMLElements interface.
IHTMLElementCollection* pIElements = NULL;
hr = pIDocument->get_all(&pIElements);
// Obtain a pointer to all the Input elements from the collection
IHTMLElementCollection* pInputs = NULL;
hr = pIElements->tags(_variant_t("input"), (IDispatch**) &pInputs);
// For now, try to get element 0.
// Eventually will need to try to iterate over all elements.
IHTMLInputTextElement* pIThisElement = NULL;
hr = pInputs->item(_variant_t((long) 0), _variant_t((long) 0),
// How do I get element name/value?
ErrorMessage(_T("Failed at pIThisElement"));
ErrorMessage(_T("Failed at pInputs"));
ErrorMessage(_T("Failed at pIForms"));
ErrorMessage(_T("Failed at pIDocument"));
How do I use the pIThisElement interface to edit (if the app is in a load procedure), or read (if the app is in a save procedure)? I can't seem to figure out the pIThisElement->get_value() or similar functions.
March 25th, 2002, 06:42 PM
Have you tried this:
pIThisElement->get_name(&bstr); // To get the name
CString strTag = bstr;
pIThisElement->get_value(&bstr); // To get the value
pIThisElement->set_value(bstr); // To set the value
March 26th, 2002, 02:38 AM
Unfortunately, yes. I get an assertion error.
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
Funny thing is, I get this error even if I pass a plain old &BSTR to the get/put functions. Its got me stumped.