int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdline, int nCmdShow) { CoInitialize(NULL); InitCommonControls(); CMyDialog dlg; dlg.DoModal(); return 0; }
BOOL CMyThread::InitInstance() { // TODO: perform and per-thread initialization here CMyDialog dlg; m_pMainWnd=&dlg; dlg.DoModal(); return TRUE; }
LRESULT CMyScrollBar::OnHScroll(WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); // Get a pointer to the MyDialog object CMyDialog* pMyDialog = GetDialogApp()->GetDialog(); GetScrollInfo(&m_si); switch (LOWORD (wParam)) { // user clicked left arrow case SB_LINELEFT: m_si.nPos -= 1; break; // user clicked right arrow case SB_LINERIGHT: m_si.nPos += 1; break; // user clicked the scroll bar shaft left of the scroll box case SB_PAGELEFT: m_si.nPos -= m_si.nPage; break; // user clicked the scroll bar shaft right of the scroll box case SB_PAGERIGHT: m_si.nPos += m_si.nPage; break; // user dragged the scroll box case SB_THUMBTRACK: m_si.nPos = m_si.nTrackPos; break; default : break; } pMyDialog->SetScroll(m_si.nPos); // Set the scroll bar position pMyDialog->SetSlider(m_si.nPos); // Set the slider position pMyDialog->SetProgress(m_si.nPos); // Set the progress bar position pMyDialog->SetStatic(FALSE, m_si.nPos); // Set the static text return 0L; }
LRESULT CMySlider::OnMessageReflect(UINT uMsg, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(wParam); UNREFERENCED_PARAMETER(lParam); switch (uMsg) { case WM_HSCROLL: { // Get the slider bar position int nPos = GetPos(); // Get a pointer to the MyDialog object CMyDialog* pMyDialog = GetDialogApp()->GetDialog(); pMyDialog->SetProgress(nPos); // Set the progress bar position pMyDialog->SetScroll(nPos); // Set the scroll bar position pMyDialog->SetStatic(TRUE, nPos); // Set the static text break; } } return 0; }
HRESULT InitIEStuff (WebShellInitContext * initContext) { HRESULT hr; HWND m_hWndClient; RECT rect; CMyDialog *bObj = initContext->browserObject; HRESULT hRes = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); ATLASSERT(SUCCEEDED(hRes)); /*if (_WIN32_IE >= 0x0300) INITCOMMONCONTROLSEX iccx; iccx.dwSize = sizeof(iccx); iccx.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES; BOOL bRet = ::InitCommonControlsEx(&iccx); bRet; ATLASSERT(bRet); #else */ // ::InitCommonControls(); //#endif GetClientRect(initContext->parentHWnd, &rect); HINSTANCE newInst = GetModuleHandleA(NULL); hRes = _Module.Init(NULL, newInst); ATLASSERT(SUCCEEDED(hRes)); AtlAxWinInit(); m_hWndClient = bObj->Create(initContext->parentHWnd, rect, _T("about:blank"), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL, WS_EX_CLIENTEDGE, ID_WEBBROWSER); hr = bObj->QueryControl(&(initContext->browserObject->m_pWB)); if FAILED(hr) { ATLTRACE(_T("Couldn't retrieve webbrowser")); return (-1); } if SUCCEEDED(hr) { ATLTRACE(_T("Browser successfully retrieved")); } initContext->browserHost = m_hWndClient; if (!bObj->spUnk) { hr = bObj->QueryControl(&(bObj->spUnk)); hr = bObj->DispEventAdvise(bObj->spUnk); } if FAILED(hr) { ATLTRACE(_T("Couldn't establish connection points")); return -1; } hr = bObj->m_pWB->QueryInterface(IID_IServiceProvider, (void**)&(bObj->m_pISP)); if (FAILED(hr) || (bObj->m_pISP == NULL)) { ATLTRACE(_T("Couldn't obtain COM IServiceProvider")); return -1; } hr = bObj->m_pISP->QueryService(SID_STravelLogCursor, IID_ITravelLogStg, (void**)&(bObj->m_pTLStg)); if (FAILED(hr) || (bObj->m_pTLStg == NULL)) { ATLTRACE(_T("Couldn't obtain ITravelLog interface")); return -1; } processEventLoop(initContext); return 0; }