|
Hello,
INTRODUCTION
As I use Paul DiLascia's HTMLCtrl (it's completely the same than CHTMLView but it can be placed in dialogs) I've spent some days trying to send directly HTML code to the control in order not to need to write a file each time the information to show changes.
Finally I got it...
But as it is based in getting the HTMLDocument and at the beggining it doesn't exist, I've used the "about:" protocol in order to force the creation of a document. (I know that it must be another way of doing it...)
but the fact is that it works almost well.
QUESTION
I "reload" (I should say re-send) the HTML each time the user changes his/her selection in a ListCtrl and everything goes OK except the first time, that nothing is shown.
Here's the code used:
-----------------------------------------------------------------
In the OnInitDialog and in order to force a document...
-----------------------------------------------------------------
<br />
this->m_HTMLCtrl.Navigate("about:<html><body bgcolor=\"7AA1E6\" leftmargin=\"0\" topmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" oncontextmenu=\"return false\"></html>");
-----------------------------------------------------------------
-----------------------------------------------------------------
In the HTML refresh function...
-----------------------------------------------------------------
<br />
IHTMLDocument2* pHTMLDocument2;<br />
LPDISPATCH lpDispatch;<br />
IHTMLElement* pBody;<br />
BSTR bstr;<br />
HRESULT hr;<br />
<br />
lpDispatch = this->m_HTMLCtrl.GetHtmlDocument();<br />
<br />
if (lpDispatch)<br />
{<br />
hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&pHTMLDocument2);<br />
lpDispatch->Release();<br />
<br />
hr = pHTMLDocument2->get_body(&pBody);<br />
<br />
bstr = csCodiHTML.AllocSysString();<br />
<br />
if (pBody)<br />
{<br />
pBody->put_innerHTML(bstr);<br />
pBody->Release();<br />
} <br />
<br />
SysFreeString(bstr);<br />
}<br /> -----------------------------------------------------------------
Could you tell me what is happening here?
Why it works OK the second time and not the first one?
Thank you in advance
|
|
|
|
|
I've also started using the "about:" trick someone recently mentioned on CP. It works fine for me the first time. Here's how I use the HTML control:
CString strUrl = "about:<html><body> ... </body></html>";
m_htmlCtrl.SetSilent (FALSE);
m_htmlCtrl.Navigate (strUrl, navNoReadFromCache);
Hope this helps!
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Yes, it also worked for me...
but my problem is that the web page that I show to the user has a lot of text, and I can't use "about:" protocol because it has a limitation and my page exceeds it...
Then I've searched in order to write as many information (without chars limitation) to the HTMLCtrl.
In order to do that I've done what's in my previous post...
And it works fine... (almost)...
I need a HTMLDocument pointer in order to write data to it, but my function is not capable to get that pointer the first time, the other ones it works perfectly... I'm wondering if I'm trying to select the document before it has been able to be created...
And I would like to get the way to create and only create a HTMLDocument into a CHtmlView. Because I think that the "about:" protocol must not be the right solution...
thank you for your interest!
|
|
|
|
|
Ah. How about first seeding the control with "about:blank" and then getting the (valid) HTMLDocument pointer? It would be great if that works!
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Yes, it works always, but not the first time... And I don't know why...
I'm doing the same the first and the second and all times... but the document seems to be created only the second time...
You can try it, it's so easy...
All the code used is what I've posted in the first post...
And if you want you can download Paul Di Lascia's HTML Ctrl from this link:
http://www.microsoft.com/msj/0100/c++/c++0100.asp[^]
|
|
|
|
|
I don't understand why I must send (in the about clause) the margins that I'll use in the web page because if I don't do it sending HTML directly don't gets placed in the right position even if the directives (margins...) are written.
Then I'm passing to the "about:" the margins and the background color only...
and I must only know how to get that document created the first time...
|
|
|
|
|
Hello everybody:
Everytime that I call the function CFileDialog::DoModal I'm getting an Assert error. This is what I have in my code:
<br />
if (lastFileOpenPath.GetLength() > 0)<br />
{<br />
openDlg.m_ofn.lpstrInitialDir = lastFileOpenPath;<br />
}<br />
<br />
int nResult = openDlg.DoModal();
Is there something that I'm missing? Is any of you guys had this problem before? Any answer is more than welcome.
Have a good day!!!
Luis E. Cuadrado
)
|
|
|
|
|
are u sure it is getting into the if loop..if so, is lastFileOpenPath pointing to a existing directory on the machine ??
There are no failures; there are only extended learning opportunities.
|
|
|
|
|
By the if...loop you mean the following?
if (lastFileOpenPath.GetLength() > 0)
{
openDlg.m_ofn.lpstrInitialDir = lastFileOpenPath;
}
If so, yes. I did a step over and I was able to see it being executed. After it comes out of the if then the DoModal function throws and assert error.
About lastFileOpenPath, yes is pointing to a directory in the machine. I'm able to open the file selected by the open file dialog. But I have to click Ignore when I get the assert error.
Thanks,
Luis E. Cuadrado
)
|
|
|
|
|
wait a minute ! u r assigning a CString to a LPCTSTR (openDlg.m_ofn.lpstrInitialDir = lastFileOpenPath)..i guess u have to do a casting to do that ??
There are no failures; there are only extended learning opportunities.
|
|
|
|
|
What is it ASSERTing on?
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
It is ASSERTing in the DoModal function in the DLGFILE.CPP. The ASSERT comes out after selecting a file from the Open Dialog.
This is where is ASSERTing on in the DLGFILE.CPP:
if (nResult)
ASSERT(pThreadState->m_pAlternateWndInit == NULL); <-- HERE
pThreadState->m_pAlternateWndInit = NULL;
when I check the Developer Studio's call stack, it's comming from here:
if (lastFileOpenPath.GetLength() > 0)<br />
{<br />
openDlg.m_ofn.lpstrInitialDir = lastFileOpenPath;<br />
}
int nResult = openDlg.DoModal(); <--- HERE
I hope this helps.
Thanks,
Luis E. Cuadrado
)
|
|
|
|
|
This is probably a dumb request, but can you post the declaration of the openDlg variable?
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
No problem. This is pretty much how the source file looks like:
CFileDialog openDlg;<br />
.<br />
.<br />
.<br />
if (lastFileOpenPath.GetLength() > 0)<br />
{<br />
openDlg.m_ofn.lpstrInitialDir = (LPCTSTR)lastFileOpenPath;<br />
}<br />
int nResult = openDlg.DoModal();
Thanks,
Luis E. Cuadrado
)
|
|
|
|
|
I'm not familiar with the code that's failing the assertion but I read through it a bit and it seems like pThreadState->m_pAlternateWndInit is not NULL whenever the OFN_EXPLORER flag is set in the m_ofn member. Are you setting that flag yourself, by any chance? If so, try not setting it and see if it makes a difference.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
I checked and I found out that the person that wrote the code, was setting the OFN_EXPLORER tag. I commented that part out and it doesn't make a diference. It still fails the assertion.
Thanks for your help!!
Best regards,
Luis E. Cuadrado
)
|
|
|
|
|
OK, here's one last stab at this issue.
Is the dialog box being created in a separate thread? If so, is it using a parent window which was created in a different thread? This may be the problem. MFC does not support related windows being created accross different threads -- I forgot exactly why, but someone here may shed some light.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Hi All !
I have this piece of code working fine on NT but drwas nothing on Windows 2000, any idea. Basically, it draws a rectangle on a dialog.
<br />
CClientDC dc (dlg);
dlg->GetClientRect (&rect);
CBrush brush (RGB (192,192,192));<br />
dc.SelectObject(&brush);<br />
<br />
dc.Rectangle(x_base+(d*20),y_base+(c*30),x_base+20+(<br />
|
|
|
|
|
i just ran that piece of code on Win2k and works fine..i tested with coordinates (0,0,100,100)..
just check ur co-ordinates ie [dc.Rectangle(x_base+(d*20),y_base+(c*30),x_base+20+(]
may the co-ordinates are just not "inside" the dialog..
There are no failures; there are only extended learning opportunities.
|
|
|
|
|
They are inside because when I run the same code on NT, I see them, so this is funny...
Thank you anyways !
|
|
|
|
|
wait a minute ! hope i am not confusing u here..its been a long time since i had worked on such stuff..
could it be due to screen resolution..because of things like screen co-ordinates or client co-ordinates..ohhhh i am so forgetful...
There are no failures; there are only extended learning opportunities.
|
|
|
|
|
In that case using ScreenToClient() should solve it.
Regards,
Griffith
Everything you say will be misquoted, ripped out of context and used against you.
|
|
|
|
|
I wrote this dialog app and after it runs for awhile it just stops updating all the objects on the screen. What I mean by not updating is that some of the object just stop appearing or are only drawn partially. I have many pages in this dialog and they mostly just have large buttons on them. I'm not calling wm_paint or messing with any of the draw functions, I have just let Windows handle that.
Also, I noticed that some of the drop downs instead of having a down arrow it will display a "6".
Any idea on how I can make sure that everything gets drawn on the screen?
|
|
|
|
|
i am not really sure of the answer..just a guess..
Could you check if ur app is leaking memory..could u check the taskmanager to see ur app's mem utilization ?
There are no failures; there are only extended learning opportunities.
|
|
|
|
|
Make sure that the application is not storing huge amount of data in memory and continue adding more data. The program could have memory leaks.
Check task manager and make sure the size of the process in more is consistant and does not increase dramatically.
Kuphryn
|
|
|
|