المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Problem getting element from CDHtmlDialog when loading the HTML from a file using Nav



C++ Programming
03-30-2009, 11:50 AM
Hi there,
I'm having problems getting an HTML element from a CDHtmlDialog.
Here is my scenario:
I need to create a Dialog in which to display a HTML page with some textareas. These textareas need to be filled dynamically from my code. The purpose of this Dialog is somewhat resembling a preview dialog. I need to show the end user how a pdf will look like and allow the user to modify some data just before creating the pdf.
So, I used CDHtmlDialog, I loaded the page using Navigate(fileURL)(please be aware that I cannot store the htmls as resources because I will need to load a relatively large number of them, so I would prefer loading them straight from the disk), and now I want to populate the textareas .
To do that, I used this chunk of code that I found browsing the web:

IHTMLElement* pLinkElement = NULL;

if (GetElement(_T("text_id"), &pLinkElement) == S_OK && pLinkElement != NULL)
{
pLinkElement->put_innerText(text_value);
}

The problem is that GetElement returns an E_NOINTERFACE error message.
This happens when I'm using this code on the OnInitDialog() method, right after using Navigate().

I also intercepted some OnClick messages for a few buttons in my HTML (using the DHTML_EVENT_MAP). If I use the code above on one of those OnClickButton() methods, the code works fine.

Does anyone have an ideea why this would happen?

Thanks in advance,
Paul.