I would like to display a local file in html format. I can simply do:
void CMyhtmlView::OnInitialUpdate()
{
CHtmlView::OnInitialUpdate();
CMyhtml开发者_如何学CDoc * pDoc = (CMyhtmlDoc *) GetDocument();
Navigate2 (pDoc->GetPathName() ,NULL,NULL);
}
and this displays an ascii file in the view but my real file is not ascii and it has to be decrepted first, plus obviously I want more control and display data in tables rather than plain text. Can I do that?
Assume a simple case where we multiply 10 numbers by 2 and display the results.
int num[10] = {1,2,3,4,5,6,7,8,9,10};
int multiplyBy = 2;
int result[10] = {0};
for (int i = 0; i < 10; i++)
{
result[i] = num[i] * multiplyBy;
}
// now display the results in html view
column1(number) Column2(multiplayBy) results(result)
1 2 2
2 2 4
3 2 6
//and so on
Can this be done? Even if your example doesn't use tables, can we display dynamic data like this in htmlview and if so how? I am thinking the data is loaded by document and we can manipulate it already but it is a matter of displaying it. Thanks.
Yes you can. What you need to do:
- Go to this article http://www.codeproject.com/KB/MFC/dhtmldialog.aspx
- Generate your html table
- Use
IHTMLElement->put_outerHTML(_bstr_t("<table>.. my table data ..</table>"))
to put your html in some element with specified id
All you need its get IHTMLElement than you can do everything with your page.
精彩评论