//
LRESULT TestWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
//
HRESULT CMyHtmlShow::RegisterTestClass(HINSTANCE hInstance)
{
WNDCLASS wc = { 0 };
HRESULT hrResult;
if(!GetClassInfo(hInstance, WC_HTMLCONTAINER, &wc))
{
wc.style = CS_HREDRAW | CS_VREDRAW | CS_IME;//CS_IME
wc.lpfnWndProc = TestWndProc;
wc.hInstance = hInstance;
wc.lpszClassName = WC_HTMLCONTAINER;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
hrResult = (RegisterClass(&wc) ? S_OK : E_FAIL);
}
else
{
hrResult = S_OK;
}
return hrResult;
}
//
int CMyHtmlShow::CreateMyHtmlWindow(CString strHtml)
{
HWND hwndParent;
HWND hwndHTML;
//
VERIFY(SUCCEEDED(RegisterTestClass(hInstance)));
//parent window
hwndParent = CreateWindow(WC_HTMLCONTAINER,
L"窗口标题",
WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
0);
RECT rc;
GetWindowRect(hwndParent, &rc);
SHFullScreen(hwndParent, SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON | SHFS_SHOWSTARTICON);
//SHFullScreen(hwndParent, SHFS_SHOWSIPBUTTON | SHFS_SHOWSTARTICON);
//new position of parent window
MoveWindow( hwndParent,
rc.left,
rc.top - (MENU_HEIGHT + 5),
rc.right,
rc.bottom - MENU_HEIGHT + 5 + 10,
TRUE);
VERIFY(InitHTMLControl(hInstance));
//HTML window
hwndHTML = CreateWindow(WC_HTML,
NULL,
//WS_CHILD | WS_BORDER | WS_VISIBLE,
WS_BORDER | WS_VISIBLE,
5,
35,
(rc.right - rc.left) - 10,
(rc.bottom - rc.top) - 33,
hwndParent,
NULL,
hInstance,
NULL);
//
//SetActiveWindow(hwndParent);
//
if (hwndHTML != NULL)
{
BSTR bstrURL = SysAllocString(strHtml);
SendMessage(hwndHTML, DTM_NAVIGATE,0,(LPARAM)bstrURL);//0 turn to 1,DTM_INTEGRALPAGING DTM_NAVIGATE
SysFreeString(bstrURL);
MSG msg;
while (GetMessage(&msg,NULL,0,0)) //0,0
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}
/****************************************************************************
* *
* FUNCTION : HandleCreate ( hwnd ) *
* *
* PURPOSE : Creates a new (empty) menu and appends to it the "State" *
* menu items. It sets up the user-defined checkmarks for the *
* menu. It then inserts this menu into the main menu bar. *
* *
****************************************************************************/
VOID APIENTRY HandleCreate(
HWND hwnd
)
{
#if _WIN32_WCE > 211 //Pocket PC devices
//Create a MenuBar for WCE devices
SHMENUBARINFO info;
info.cbSize = sizeof(info);
info.hwndParent = hwnd;
info.dwFlags = SHCMBF_HMENU;
info.nToolBarId = IDR_MENU_HTML;
info.hInstRes = ::AfxGetInstanceHandle();
info.nBmpId = 0;
info.cBmpImages = 0;
SHCreateMenuBar(&info);
if (FALSE == SHCreateMenuBar(&info))
{
MessageBox(hwnd, L"Create MenuBar Failed", L"Error", MB_OK);
}
g_hWndCB = info.hwndMB;
#else
g_hWndCB = CommandBar_Create(g_hInst, hwnd, 1);
CommandBar_InsertMenubar(g_hWndCB, g_hInst, IDM_MAIN_MENU, 0);
CommandBar_AddAdornments(g_hWndCB, 0, 0);
#endif
return;
}
//
HRESULT ProcessMainMenu(HWND hDlg, WORD wLo)
{
HRESULT hr = S_OK;
WCHAR pszSubject[MAX_LOADSTRING];
IItem * pItem = NULL;
long lOID = 0;
switch(wLo)
{
case ID_MYOK:
{
DestroyWindow(hDlg);
PostQuitMessage(0);
break;
}
}
return hr;
}
//
LRESULT TestWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult = 0;
switch (uMsg)
{
//MENU
case WM_CREATE:
{
// Create the menu
HandleCreate(hwnd);//
break;
}
case WM_COMMAND:
{
ProcessMainMenu(hwnd, LOWORD(wParam));
break;
}
case WM_CANCELMODE:
{
DestroyWindow(hwnd);
PostQuitMessage(0);
break;
}
/*case WM_TIMER:
{
DestroyWindow(hwnd);
PostQuitMessage(0);
break;
}*/
default:
{
lResult = DefWindowProc(hwnd, uMsg, wParam, lParam);
break;
}
}
return lResult;
}