Setting BGColor to a WebBrowser Control [modified]
-
Hi! How to set the Background color and BackGround Image to a CExplorer control in MFC?
modified on Thursday, May 5, 2011 7:42 AM
-
Hi! How to set the Background color and BackGround Image to a CExplorer control in MFC?
modified on Thursday, May 5, 2011 7:42 AM
What is CExplorer?
-
What is CExplorer?
Html Browser control.
-
Html Browser control.
-
I've added a Html Browser control to a Dialog in MFC. Initially it is displayed with white background. I want ot change to some other color. How to do this?
-
Hi! How to set the Background color and BackGround Image to a CExplorer control in MFC?
modified on Thursday, May 5, 2011 7:42 AM
Don't you need to do this via HTML ?
Watched code never compiles.
-
Don't you need to do this via HTML ?
Watched code never compiles.
No. Through C++/MFC code.
-
No. Through C++/MFC code.
maximilien is right; the window doesn't belong to you, you've given it to the web browser you can either embed an html resource in your own exe/dll and Navigate2 to it using the res:// namespace (see http://msdn.microsoft.com/en-us/library/aa767740.aspx[^]) or you can dynamically build an HTMLDocument2 and use IPersistStream to get it into the web browser I'd choose the res protocol - much simpler
-
No. Through C++/MFC code.
well, if u insist on it, subclass your web browser control. I think the CExplorer class (generated from web browser activeX) would be derived from CWnd. Handle WM_PAINT or ON_WM_ERASEBKGND messages in it. do your background painting there. hopefully this may work.
// Explorer .h
DECLARE_MESSAGE_MAP()
afx_msg BOOL OnEraseBkgnd(CDC* pDC);BEGIN_MESSAGE_MAP(CExplorer, CWnd)
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()BOOL CExplorer1::OnEraseBkgnd(CDC* pDC)
{
CRect rc;
GetClientRect(&rc);
pDC->FillSolidRect(&rc, RGB(255, 0, 0));return TRUE;
}*****But this lives only till you load your first web page in browser control. :)
-
well, if u insist on it, subclass your web browser control. I think the CExplorer class (generated from web browser activeX) would be derived from CWnd. Handle WM_PAINT or ON_WM_ERASEBKGND messages in it. do your background painting there. hopefully this may work.
// Explorer .h
DECLARE_MESSAGE_MAP()
afx_msg BOOL OnEraseBkgnd(CDC* pDC);BEGIN_MESSAGE_MAP(CExplorer, CWnd)
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()BOOL CExplorer1::OnEraseBkgnd(CDC* pDC)
{
CRect rc;
GetClientRect(&rc);
pDC->FillSolidRect(&rc, RGB(255, 0, 0));return TRUE;
}*****But this lives only till you load your first web page in browser control. :)
Yes it has to work since CExplorer1 is also Derived From CWnd. and mark your comment as answer.My 5.