- C/C++ code
#include <atlbase.h>#include <atlwin.h>CComModule _Module;LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ static CAxWindow axWindow; switch (uMsg) { case WM_CREATE: RECT rc; GetClientRect(hWnd, &rc); axWindow.Create(hWnd, rc, 0, WS_CHILD | WS_VISIBLE); axWindow.CreateControl(OLESTR("shell.Explorer.2")); IWebBrowser2* webBrowser; axWindow.QueryControl(__uuidof(IWebBrowser2), (void**)&webBrowser); VARIANT varURL; VariantInit(&varURL); varURL.vt = VT_BSTR; varURL.bstrVal = SysAllocString(_T("http://2011.hebei.teacher.com.cn/")); webBrowser->Navigate2(&varURL, 0, 0, 0, 0); VariantClear(&varURL); webBrowser->Release(); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, uMsg, wParam, lParam);}int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, PTSTR /*pszCmdLine*/, int /*nCmdShow*/){ WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wcex.lpszMenuName = NULL; wcex.lpszClassName = _T("Windows Demo Class"); wcex.hIconSm = wcex.hIcon; if (!RegisterClassEx(&wcex)) { MessageBox(NULL, _T("RegisterClassEx failed!"), _T("Windows Demo"), MB_ICONERROR); return 0; } HWND hWnd = CreateWindowEx(WS_EX_APPWINDOW, _T("Windows Demo Class"), _T("Windows Demo"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); ShowWindow(hWnd, SW_SHOW); UpdateWindow(hWnd); MSG msg; while (GetMessage(&msg, NULL, 0, 0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int)msg.wParam;}
代码如上,如何去掉webBrowser的滚动条。
是否有现成的函数?感谢。
------解决方案--------------------------------------------------------
根据MSDN里的描述
axWindow.CreateControl的参数可以是下列之一:
A ProgID such as "MSCAL.Calendar.7"
A CLSID such as "{8E27C92B-1264-101C-8A2F-040224009C02}"
A URL such as "http://www.microsoft.com"
A reference to an Active document such as "file://\\Documents\MyDoc.doc"
A fragment of HTML such as "MSHTML:<HTML><BODY>This is a line of text</BODY></HTML>"
这里楼主可以用最后一种方法,将页面作为一个IFRAME元素嵌入到HTML页面去
MSHTML:<HTML><BODY scrolling="no"><Iframe scrolling="no" src="xxx"/></BODY></HTML>