138 lines
3.1 KiB
C++
138 lines
3.1 KiB
C++
////////////////////////////////////////////////////////////////
|
||
// If this code works, it was written by Paul DiLascia.
|
||
// If not, I don't know who wrote it.
|
||
// Compiles with Visual C++ 6.0, runs on Windows 98 and probably NT too.
|
||
//
|
||
#include "StdAfx.h"
|
||
#include "MmsHtmlCtrl.h"
|
||
|
||
#ifdef _DEBUG
|
||
#define new DEBUG_NEW
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[] = __FILE__;
|
||
#endif
|
||
|
||
void CMmsHtmlCtrl::OnAppCmd(LPCTSTR lpszWhere)
|
||
{
|
||
if (_tcsicmp(lpszWhere,_T("ok"))==0) {
|
||
GetParent()->SendMessage(WM_COMMAND,IDOK);
|
||
}
|
||
}
|
||
|
||
void CMmsHtmlCtrl::OnDocumentComplete(LPCTSTR lpszURL)
|
||
{
|
||
|
||
CHtmlView::OnDocumentComplete(lpszURL);
|
||
|
||
Show_Scroll();
|
||
}
|
||
|
||
|
||
void CMmsHtmlCtrl::OnNavigateComplete2(LPCTSTR strURL)
|
||
{
|
||
CHtmlView::OnNavigateComplete2(strURL);
|
||
|
||
}
|
||
BOOL CMmsHtmlCtrl::Show_Scroll()
|
||
{
|
||
HRESULT hr;
|
||
IHTMLDocument2* pDoc = (IHTMLDocument2*)GetHtmlDocument();
|
||
if ( !pDoc )
|
||
{
|
||
return false;
|
||
}
|
||
/*
|
||
IHTMLDocument3 *piDoc3 = NULL;
|
||
IHTMLElement *piDocElement = NULL;
|
||
IHTMLElement2 *piDocElement2 = NULL;
|
||
pDoc->QueryInterface(__uuidof(IHTMLDocument3), (void**) &piDoc3);
|
||
piDoc3->get_documentElement(&piDocElement);
|
||
piDocElement->QueryInterface(__uuidof(IHTMLElement2), (void**) &piDocElement2);
|
||
long l=0;
|
||
piDocElement2->get_clientHeight(&l);
|
||
*/
|
||
|
||
IHTMLElement *phtmlElement = NULL;
|
||
pDoc->get_body(&phtmlElement);
|
||
pDoc->Release();
|
||
if ( !phtmlElement )
|
||
{
|
||
return false;
|
||
}
|
||
IHTMLElement2 *phtmlElement2 = NULL;
|
||
hr = phtmlElement->QueryInterface(IID_IHTMLElement2, (void**)&phtmlElement2);
|
||
if(FAILED(hr))
|
||
{
|
||
phtmlElement->Release();
|
||
return false;
|
||
}
|
||
if ( !phtmlElement2)
|
||
{
|
||
phtmlElement->Release();
|
||
return false;
|
||
}
|
||
|
||
long lHeight=0;
|
||
long lHeight4=0;
|
||
phtmlElement2->get_clientHeight(&lHeight);
|
||
phtmlElement2->get_scrollHeight(&lHeight4);
|
||
phtmlElement2->Release();
|
||
/*
|
||
long lHeight2=0;
|
||
CRect rect;
|
||
m_Html.GetWindowRect(&rect);
|
||
lHeight2=rect.Height();
|
||
*/
|
||
|
||
|
||
IHTMLBodyElement *phtmlbody = NULL;
|
||
phtmlElement->QueryInterface(IID_IHTMLBodyElement, (void**)&phtmlbody);
|
||
if(phtmlbody != NULL)
|
||
{
|
||
if (lHeight<lHeight4)
|
||
phtmlbody->put_scroll(L"yes");
|
||
else
|
||
phtmlbody->put_scroll(L"no");
|
||
phtmlbody->Release();
|
||
phtmlElement->Release();
|
||
}
|
||
phtmlElement->Release();
|
||
|
||
return true;
|
||
}
|
||
BOOL CMmsHtmlCtrl::PreTranslateMessage(MSG* pMsg)
|
||
{
|
||
if ((pMsg->message == WM_RBUTTONDOWN)||(pMsg->message == WM_RBUTTONDBLCLK))
|
||
{
|
||
CPoint point(pMsg->pt);
|
||
ScreenToClient(&point);
|
||
/*
|
||
IHTMLDocument2* pdoc2=NULL;
|
||
IHTMLElement* pElement=NULL;
|
||
IDispatch* pDisp=NULL;
|
||
pDisp=GetHtmlDocument();
|
||
pDisp->QueryInterface(IID_IHTMLDocument2,(void**)&pdoc2);
|
||
pDisp->Release();
|
||
|
||
pdoc2->elementFromPoint(point.x,point.y,&pElement);
|
||
pdoc2->Release();
|
||
if(pElement){
|
||
BSTR ID;
|
||
pElement->get_id(&ID);
|
||
pElement->Release();
|
||
CString str=(LPCTSTR)(_bstr_t)ID;
|
||
if(str=="Layer1"){
|
||
CMenu menu;
|
||
menu.LoadMenu(IDR_MENU1 );
|
||
CMenu* pmenu=menu.GetSubMenu(0);
|
||
pmenu->TrackPopupMenu(0,pMsg->pt.x,pMsg->pt.y,this);
|
||
}
|
||
}
|
||
*/
|
||
return TRUE;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD>ε<EFBFBD>,<2C><><EFBFBD><EFBFBD>ʾ<EFBFBD>κβ˵<CEB2>,ֱ<>ӷ<EFBFBD><D3B7><EFBFBD>TRUE<55><45><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ô<EFBFBD><C3B4>html<6D><6C><EFBFBD>ض<EFBFBD>ID<49><44>Ԫ<EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>Ҫ<EFBFBD><D2AA>ʾ<EFBFBD>IJ˵<C4B2>
|
||
}
|
||
else
|
||
{
|
||
return CHtmlView::PreTranslateMessage(pMsg);
|
||
}
|
||
} |