16,471
社区成员
发帖
与我相关
我的任务
分享
//头文件
#include<afxwin.h>
#include<afxext.h>
#include<afxhtml.h>
class CMyHtmlView : public CHtmlView
{
public:
};
class CMainWindow : public CFrameWnd
{
public:
DECLARE_MESSAGE_MAP()
public:
CMainWindow();
~CMainWindow();
CString strClassName;
CButton button;
CMyHtmlView* view;
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
void click();
};
//源文件
#include "CMainWindow.h"
#include<locale.h>
#include<TCHAR.H>
/*
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
*/
BEGIN_MESSAGE_MAP(CMainWindow,CFrameWnd)
ON_BN_CLICKED(100,click)
END_MESSAGE_MAP()
BOOL CMainWindow::PreCreateWindow(CREATESTRUCT& cs)
{
CFrameWnd::PreCreateWindow(cs);
cs.dwExStyle = cs.dwExStyle & (!WS_EX_CLIENTEDGE);
return TRUE;
}
CMainWindow::CMainWindow()
{
strClassName = AfxRegisterWndClass
(CS_HREDRAW | CS_VREDRAW,
(AfxGetApp()) ->LoadStandardCursor(IDC_ARROW) ,
(HBRUSH)(COLOR_3DFACE+1),
AfxGetApp() ->LoadStandardIcon(IDI_WINLOGO) );
Create(strClassName,L"",WS_OVERLAPPEDWINDOW);
CRect r;
r.left = 10;
r.top = 10;
r.right = 110;
r.bottom = 110;
button.Create(L"CButton",BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD , r,this,100);
r.top = r.bottom + 10;
r.bottom = r.top + 300;
r.right = r.left + 500;
view = new CMyHtmlView;
view->Create(NULL, NULL, WS_CHILD | WS_VISIBLE, r, this, 1);
}
void CMainWindow::click()
{
::setlocale(LC_ALL,"chs");
view->Navigate(L"http://www.baidu.com");
}
CMainWindow::~CMainWindow()
{
//原本想在这调用 delete 删除视图对象,一调用,VC2008就精神病
}