HTMLGFX: Add a default HTML page that mimics the screen saver bouncing BOINC logo.

HTMLGFX: Remove attempt at using the 'window.external' DOM extension, it was requiring a typelib.
This commit is contained in:
Rom Walton 2014-12-24 01:59:37 -05:00
parent ad9616e143
commit 24ef08bbb6
11 changed files with 152 additions and 46 deletions

View File

@ -1,10 +1,9 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by vboxhtmlgfx_win.rc
// Used by browser_win.rc
//
#define IDD_BROWSER 101
#define IDC_IE 1000
#define IDI_ICON 100
// Next default values for new objects
//

View File

@ -27,6 +27,22 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON ICON "res\\boinc.ico"
/////////////////////////////////////////////////////////////////////////////
//
// HTML
//
default_win.htm HTML "res\\default_win.htm"
boinc.png HTML "res\\boinc.png"
virtualbox.png HTML "res\\virtualbox.png"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
/////////////////////////////////////////////////////////////////////////////
//
@ -58,7 +74,7 @@ BEGIN
VALUE "FileDescription", "BOINC HTML Graphics"
VALUE "FileVersion", VER_TOSTR(BOINC_MAJOR_VERSION, BOINC_MINOR_VERSION, WRAPPER_RELEASE)
VALUE "InternalName", "htmlgfx"
VALUE "LegalCopyright", "© 2011-2014 University of California"
VALUE "LegalCopyright", "© 2011-2015 University of California"
VALUE "OriginalFilename", "htmlgfx.exe"
VALUE "ProductName", "BOINC HTML Graphics"
VALUE "ProductVersion", VER_TOSTR(BOINC_MAJOR_VERSION, BOINC_MINOR_VERSION, WRAPPER_RELEASE)
@ -70,11 +86,6 @@ BEGIN
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
/////////////////////////////////////////////////////////////////////////////
//
// String Table

View File

@ -50,8 +50,6 @@ CWndClassInfo& CHTMLBrowserHost::GetWndClassInfo()
HWND CHTMLBrowserHost::Create(
HWND hWndParent, _U_RECT rect, LPCTSTR szWindowName, DWORD dwStyle, DWORD dwExStyle, _U_MENUorID MenuOrID, LPVOID lpCreateParam
){
HWND hWnd;
ATOM atom = GetWndClassInfo().Register(&m_pfnSuperWindowProc);
if (!atom)
return NULL;
@ -76,28 +74,15 @@ HWND CHTMLBrowserHost::Create(
}
// create window
hWnd = CWindow::Create((LPCTSTR)atom, hWndParent, rect, szWindowName, dwStyle, dwExStyle, MenuOrID, lpCreateParam);
// register external dispatch
SetExternalDispatch((IHTMLBrowserHostUI*)this);
return hWnd;
return CWindow::Create((LPCTSTR)atom, hWndParent, rect, szWindowName, dwStyle, dwExStyle, MenuOrID, lpCreateParam);
}
void CHTMLBrowserHost::FinalRelease()
{
SetExternalDispatch(NULL);
ReleaseAll();
}
STDMETHODIMP CHTMLBrowserHost::Log(
VARIANT* pvaLog
){
browserlog_msg("%S", pvaLog->bstrVal);
return S_OK;
}
STDMETHODIMP CHTMLBrowserHost::ShowMessage(
HWND hwnd, LPOLESTR lpstrText, LPOLESTR lpstrCaption, DWORD dwType, LPOLESTR lpstrHelpFile, DWORD dwHelpContext, LRESULT *plResult
){

View File

@ -18,24 +18,13 @@
#ifndef _BROWSERCTRL_WIN_H_
#define _BROWSERCTRL_WIN_H_
/////////////////////////////////////////////////////////////////////////////
// IBrowserHostUI interface
MIDL_INTERFACE("A7275E6E-DE3D-4107-B34F-C4C28411A6F0")
IHTMLBrowserHostUI : public IDispatch
{
public:
virtual HRESULT STDMETHODCALLTYPE Log(VARIANT* pvaLog) = 0;
};
/////////////////////////////////////////////////////////////////////////////
// CHTMLBrowserHost class
class ATL_NO_VTABLE CHTMLBrowserHost :
public CAxHostWindow,
public IDocHostShowUI,
public IOleCommandTarget,
public IDispatchImpl<IHTMLBrowserHostUI>
public IOleCommandTarget
{
public:
DECLARE_NO_REGISTRY()
@ -44,7 +33,6 @@ public:
DECLARE_GET_CONTROLLING_UNKNOWN()
BEGIN_COM_MAP(CHTMLBrowserHost)
COM_INTERFACE_ENTRY(IHTMLBrowserHostUI)
COM_INTERFACE_ENTRY(IDocHostShowUI)
COM_INTERFACE_ENTRY(IOleCommandTarget)
COM_INTERFACE_ENTRY_CHAIN(CAxHostWindow)
@ -58,12 +46,6 @@ public:
void FinalRelease();
// COM Interface - IHTMLBrowserHostUI
// Provide a basic set of services to HTML based applications
//
STDMETHOD(Log)(VARIANT* pvaLog);
// COM Interface - IDocHostShowUI
// http://msdn.microsoft.com/en-us/library/aa770041(v=vs.85).aspx
//
@ -76,7 +58,6 @@ public:
//
STDMETHOD(QueryStatus)(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText);
STDMETHOD(Exec)(const GUID* pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG* pvaIn, VARIANTARG* pvaOut);
};
#endif

View File

@ -26,6 +26,7 @@
#include <AtlTypes.h>
#include <exdisp.h>
#include <exdispid.h>
#include <stdlib.h>
#include <string>
#include "win_util.h"
#include "version.h"
@ -38,22 +39,61 @@
#include "browserwnd_win.h"
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
CHTMLBrowserWnd::CHTMLBrowserWnd()
{
m_pBrowserHost = NULL;
m_hIcon = NULL;
m_hIconSmall = NULL;
}
CHTMLBrowserWnd::~CHTMLBrowserWnd()
{
if(m_hIcon)
{
::DestroyIcon(m_hIcon);
m_hIcon = NULL;
}
if(m_hIconSmall)
{
::DestroyIcon(m_hIconSmall);
m_hIconSmall = NULL;
}
}
LRESULT CHTMLBrowserWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
HRESULT hr;
RECT rcClient;
TCHAR szExecutable[MAX_PATH];
CComPtr<IUnknown> pCtrl;
CComVariant v;
// Load Icon Resources
m_hIcon = (HICON)::LoadImage(
_AtlBaseModule.GetResourceInstance(),
MAKEINTRESOURCE(IDI_ICON),
IMAGE_ICON,
0, 0,
LR_DEFAULTSIZE | LR_DEFAULTCOLOR);
ATLASSERT(m_hIcon);
m_hIconSmall = (HICON)::LoadImage(
_AtlBaseModule.GetResourceInstance(),
MAKEINTRESOURCE(IDI_ICON),
IMAGE_ICON,
::GetSystemMetrics(SM_CXSMICON),
::GetSystemMetrics(SM_CYSMICON),
LR_DEFAULTCOLOR);
ATLASSERT(m_hIconSmall);
SetIcon(m_hIcon);
SetIcon(m_hIconSmall, FALSE);
// Create Control Host
hr = CComObject<CHTMLBrowserHost>::CreateInstance(&m_pBrowserHost);
@ -78,7 +118,15 @@ LRESULT CHTMLBrowserWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
m_pBrowserCtrl = pCtrl;
if (m_pBrowserCtrl) {
m_pBrowserCtrl->Navigate(CComBSTR("http://www.romwnet.org/"), &v, &v, &v, &v);
GetModuleFileName(NULL, szExecutable, sizeof(szExecutable));
// Construct Windows resource reference
//
m_strDefaultURL += "res://";
m_strDefaultURL += szExecutable;
m_strDefaultURL += "/default_win.htm";
m_pBrowserCtrl->Navigate(m_strDefaultURL, &v, &v, &v, &v);
}
bHandled = TRUE;

View File

@ -52,8 +52,12 @@ public:
CComObject<CHTMLBrowserHost>* m_pBrowserHost;
CComQIPtr<IWebBrowser2> m_pBrowserCtrl;
CComBSTR m_strDefaultURL;
bool m_bScreensaverMode;
HICON m_hIcon;
HICON m_hIconSmall;
};
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -0,0 +1,73 @@
<html>
<head>
<title></title>
</head>
<body style="background-color:Black">
<div align="center" id="content" style="position:absolute;">
<table>
<tr>
<td>
<img src="boinc.png">
</td>
<td valign="top" style="width:250px;height:64px">
<p style="color:White">Loading...</p>
</td>
</tr>
</table>
</div>
<script language="JavaScript" type="text/javascript">
var interval;
var step = 5;
var delay = 1000;
var height = 0;
var Hoffset = 0;
var Woffset = 0;
var yon = 0;
var xon = 0;
var xPos = 20;
var yPos = document.body.clientHeight;
interval = setInterval('refresh()', delay);
function refresh() {
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = content.offsetHeight;
Woffset = content.offsetWidth;
content.style.left = xPos + document.body.scrollLeft;
content.style.top = yPos + document.body.scrollTop;
if (yon) {
yPos = yPos + step;
}
else {
yPos = yPos - step;
}
if (yPos < 0) {
yon = 1;
yPos = 0;
}
if (yPos >= (height - Hoffset)) {
yon = 0;
yPos = (height - Hoffset);
}
if (xon) {
xPos = xPos + step;
}
else {
xPos = xPos - step;
}
if (xPos < 0) {
xon = 1;
xPos = 0;
}
if (xPos >= (width - Woffset)) {
xon = 0;
xPos = (width - Woffset);
}
}
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -326,6 +326,11 @@
<ItemGroup>
<ResourceCompile Include="..\samples\gfx_html\browser_win.rc" />
</ItemGroup>
<ItemGroup>
<None Include="..\samples\gfx_html\res\default_win.htm">
<DeploymentContent>true</DeploymentContent>
</None>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>