对active不熟悉,只想要个现实网页,并且新打开网页在原窗口显示,还有就是处理下键盘。我网上找的代码
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
//------------mycode---------
RECT rc;
IWebBrowser2* iWebBrowser=NULL;
VARIANT varMyURL;
LPOLESTR pszName=OLESTR("shell.Explorer.2");
GetClientRect(hWnd, &rc);
//--------------------------
switch (message)
{
case WM_CREATE:
WinContainer.Create(hWnd, rc, 0,WS_CHILD |WS_VISIBLE);
WinContainer.CreateControl(pszName);
WinContainer.QueryControl(__uuidof(IWebBrowser2),(void**)&iWebBrowser);
VariantInit(&varMyURL);
varMyURL.vt = VT_BSTR;
varMyURL.bstrVal = SysAllocString(_T("http://www.sina.com.cn"));
iWebBrowser-> Navigate2(&varMyURL,0,0,0,0);
VariantClear(&varMyURL);
//iWebBrowser-> Release();
ConnectEvents();
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
能显示网页,但没有键盘消息。而且不知道怎么处理事件。
路过的大哥大姐麻烦帮帮忙。新手,代码给全点
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课