|
Thanks for your answer Andy, it's exactly what you say.
Today I have found a solution. I can get a IHTMLDocument pointer. So I have access to the HTML code.
But that leads me to another question. How can I insert an image into the HTML code which is in memory and not on HD.
Must I save the image to a file in order to insert it into the HTML document or is there an other way?
|
|
|
|
|
Hi,
Yes indeed IHTMLDocumentPtr is the starting point into the DOM.
One thing that will help in the long run is to import the HTML type library - thus getting Visual Studio to generate wrappers around the numerous interfaces and methods. It wraps using smart pointers - so no QueryInterface/Releases to take care of.
e.g. insert the following into either your header/implementation file
#import "C:\Windows\system32\mshtml.tlb" no_auto_exclude
This will generate two files, mshtml.tlh and mshtml.tli, in your project directory. The first is a header file, the next the implementation. With this done, here is a simple DHTML process from within MFC to get an element from the page...
void CWebDlg::OnDocumentCompleteExplorer1(LPDISPATCH pDisp, VARIANT FAR* URL)
{
USES_CONVERSION;
MSHTML::IHTMLDocument2Ptr spDoc(m_ctlWeb1.GetDocument());
if (spDoc)
{
MSHTML::IHTMLDocument3Ptr spDoc3 = spDoc;
if (spDoc3)
{
MSHTML::IHTMLElementPtr spElem2 = spDoc3->getElementById(_bstr_t("idSpan1"));
if (spElem2)
{
CString strText = W2T(spElem2->innerText);
spElem2->innerText = _bstr_t("Hello There");
}
}
}
}
See how we can easily get the different interfaces of the object. The wrapper is doing the QI under the covers when we do a simple assignment. Plus the smart pointer will release that reference once the object goes out of scope.
You can also easily create elements at will, e.g. here we create a BGSOUND element and append it to the DOM document.
MSHTML::IHTMLDocument2Ptr spDoc(m_ctlWeb1.GetDocument());
if (spDoc)
{
MSHTML::IHTMLElementPtr spElem = spDoc->createElement(_T("BGSOUND"));
if (spElem)
{
MSHTML::IHTMLBGsoundPtr spBG = spElem;
if (spBG)
{
CString strURL = _T("http://xyzxyz/snd/newalert.wav");
spBG->put_src((bstr_t)strURL);
MSHTML::IHTMLDOMNodePtr spBody = spDoc->body;
MSHTML::IHTMLDOMNodePtr spNode2Add = spBG;
spBody->appendChild(spNode2Add);
}
}
}
To answer your question about inserting an image - I not too sure, something at the back of my mind does ring a bell about embedding IMG data in an HTML page. I'll see if I can find out. But for now I would think about saving the image to the file-system and then referencing the IMG src tag to the location.
If you have any questions about DHTML or using MFC to generate DHTML I'll be happy to answer them.
Hope this helps,
Andy
|
|
|
|
|
Thanks for the detailed answer. I think now I have the starting point I need.
But do I need the wrappers if I don't add new HTML elements? My plan is to change existing HTML elements only.
So If I get a pointer like IHTMLElement and change the properties of the object that should be no problem?
The MSHTML documentation in the MSDN library seems also to be very good.
Thanks for your help.
|
|
|
|
|
Hi,
I would always use the wrappers as it will ease the time and readablity of your code. As an example, here is some code without the use of the wrappers:
IUnknown* lpUnk = m_pSite->GetObjectUnknown();
if ( lpUnk != NULL )
{
HRESULT hr;
IHTMLDocument2* pHTMLDocument2;
hr = lpUnk->QueryInterface(IID_IHTMLDocument2, (void **)&pHTMLDocument2);
if ( SUCCEEDED( hr ) )
{
BSTR bstrColor = SysAllocString( buff );
VARIANT varColor;
varColor.vt = VT_BSTR;
varColor.bstrVal = bstrColor;
hr = pHTMLDocument2-> put_bgColor( varColor );
pHTMLDocument2->Release();
}
}
and now the same code with the use of the wrappers:
MSHTML::IHTMLDocument2Ptr spDoc(m_pSite->GetObjectUnknown());
if (spDoc)
{
spDoc->bgColor = bstr_t("#ffffff");
}
As you can see it is substantially cleaner. And this was a simple example.
You can also call any Javascript functions (from MFC) that are in the HTML page (I can show you how if you need to)
And also, you can implement an event handler at the MFC side such that, for example, an onclick HTML event will cause the web browser control to call into your application.
Hope this helps,
Andy
|
|
|
|
|
Thanks again
I will try the wrappers. Since I only want to do some basic things I will not use JavaScript.
The simple browser wrapper for the MS Web Browser control which I use is very good. It already offers message handlers. So this should be easy.
You helped me a lot.
|
|
|
|
|
I'm a newb.... & would like to know a way to run web apps outside the default web container location of tomcat 5.0 in windows 2000....running IIS...
|
|
|
|
|
I have two tables in MSSQL, say a,b , now I am creating a report in crystal with ado having two aliases as ado,ado_1, now ado fields are tagged in report header and ado_1 fields are tagged in details, there is a common field in both ado and ado_1 whic is used for linking, now when i link from ado to ado_1 I can see all the fields of ado, but not of ado_1 in detail, and if i change the link from ado_1 to ado i can see all the fields of ado_1 but not of ado, no complex struc exist, it a plain report
kindly help
vikash
|
|
|
|
|
Hi, I have question to ask all of you. Do you have any method to know all of an e-mail address of each person around the world?
Roath Kanel
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Is this a serious question? Why do you want this information anyway?
The only reason I could think that anyone would want this information is to spam lots of people (well, everybody by the looks of it). SPAM is one of the major irritations of the internet and its perpetuation should be strongly discouraged at every level.
To answer your question: No, you cannot know the "e-mail address of each person around the world". Many people go to great lengths to guard their address and maintain their privacy. You should respect that.
|
|
|
|
|
The reason that I want to know about e-mail address because most of my friend when finish the university are go to work in a difference places without let me know even their telephone number. We ask the university many time but it seem no result. I just want to know if their is a software or webpage when I type my friend name, it will display an e-mail address to contact them (if they register the name ex: hotmail, yahoo).
I know that personal privacy must be respect, but I don't want to know the other personal privacy even my friend. I just want to know the way to contact them.
Roath Kanel
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Unless they have registered somewhere then no. Also, if they have not given you their contact details I would question their level of commitment as friends.
Google for your friend's name, they may have posted their email address somewhere, or have some other way of contacting them. Websites like friends reunited (not available yet in Norway or Cambodia) allow people to post details of where they went to school and for a nominal fee you can contact each other through the site.
|
|
|
|
|
Thank you very much, I have some idea about it. I use google to search but there is no result. All of us are best freind, I need to wait from the university if there are any result.
Roath Kanel
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Not unless your Professor Xavier and you know how to work that cerybro mind reading machine
How do I print my voice mail?
|
|
|
|
|
|
Hi all,
i dont want a horizontal bar in my html page i dont have any frame in my page but i want to remove horizontal bar is there any code for that. i am using tables which width = 100% but it show me a bar is there any solution for that. please give me any code.
thanking you
|
|
|
|
|
Anonymous wrote:
i am using tables which width = 100%
Ummm.... try 90%
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Hi all,
I working on a site which is maid in pure HTML. I want to send a mail throug my site. but i dont know how to send it. may i have use any service like SMTP or there is any other way to send mail by pure html. Do u have any source code?
please give me reply as early as possible
Thank you
|
|
|
|
|
Anonymous wrote:
there is any other way to send mail by pure html
No there is not
Anonymous wrote:
may i have use any service like SMTP
Yes you must use SMTP and you would have to do that from the web server not the browser [in most cases] for security restrictions.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Hi,
the only way to send emails by >only< HTML is to setup a link like:
Email me!
Jups, another way is to use CGI's such as PHP, Perl etc.
There is a library called (PHP-)AFuX - it is for PHP and includes two classes for sendind and receiving emails.
Just have a look at:
http://soc8.ath.cx/cgi-bin/sws/cgi_main_products_phpafux.php
Bye so far
|
|
|
|
|
Can anyone help me.
I need a horizontal scroll bar in list box in ASP
The overflow property of CSS doesnt work
ITs very urgent
Thanks for ur support
CarmelChocos
|
|
|
|
|
Hello,
I have problem with ActiveX server included in MS Internet Explorer 5.5.
The aplication changes several pages in circle and all events are handling by Javascript.
After som time IExplorer shows message, like : "script on this page is causing internet explorer to run slowly".
I found this IExplorer bug in MSDN and I Set Timeout Period for Script by creating a new value in registry "MaxScriptStatements"=dword:ffffffff.
But after some time of running aplication, IExplorer shows this message again.
Have you any other idea how to fix this problem? (e.g. where IE saves total number of tracks of executed script statements ?)
Please help me.
Thanks.
|
|
|
|
|
how to set input type file field value
Hi all..
i am not able to set the default value for by giving the value.
is there any way to achieve the purpose?
function callme()
{
document.form1.t.value="textdsfdsfdsfdsf";
document.form1.file.value="c:\php.exe";
}
Harinath
Cybernet software systems pvt. ltd.
3, Bishop wallers avenue east,
mylapore
chennai
India-600004
|
|
|
|
|
You can't do this.
This is designed as such for security reasons.
If you could dynamically set the value of the file input object, anyone would be able to steal files from your hard disk.
theJazzyBrain
Excellence is not an act, but a habit! Aristotle
|
|
|
|
|
Hi All,
I wish someone can help me out with this. When a file is downloaded from the IE browser, the file download dialog opens. Is there any way to know if the user clicked on the open,save or cancel button. I need to use this information in a program.
Dipeka.A.J
|
|
|
|
|
Can I prevent a window from closing unless he is logged out of the web page through java script. Please explain How?
Regards,
Rahul
|
|
|
|