void DumpWaveformat(WAVEFORMATEX *pWave) { AtlTrace("WAVEFORMATEX Structure:\n"); AtlTrace("\tChannels: %d\n", pWave->nChannels); AtlTrace("\tSamples/Sec: %f kHz\n", (double)pWave->nSamplesPerSec / 1000); AtlTrace("\tBits/Sample: %d\n", pWave->wBitsPerSample); }
HRESULT CDelay::InternalAllocateStreamingResources() { AtlTrace("InternalAllocateStreamingResources()\n"); _ASSERTE(InputType(0)->formattype == FORMAT_WaveFormatEx); _ASSERTE(m_dwDelay > 0); m_pWave = (WAVEFORMATEX*)InputType(0)->pbFormat; // Allocate the buffer that holds the delayed samples m_cbDelayBuffer = (m_dwDelay * m_pWave->nSamplesPerSec * m_pWave->nBlockAlign) / 1000; m_pbDelayBuffer = (BYTE*)CoTaskMemAlloc(m_cbDelayBuffer); if (m_pbDelayBuffer == NULL) { return E_OUTOFMEMORY; } FillBufferWithSilence(); m_pbDelayPtr = m_pbDelayBuffer; AtlTrace("\tAllocated %d byte buffer.\n", m_cbDelayBuffer); DumpWaveformat(m_pWave); return S_OK; }
STDMETHODIMP CPlayer::Start() { MCIERROR err = 0; if (!IsOpen()) { err = ::mciSendString(CMD_OPEN + L" \"" + path + L"\"", NULL, 0, 0); devId = ::mciGetDeviceID(path); AtlTrace("Device id =%d\n", devId); put_Volume(volume); } else { ::mciSendString(CMD_SEEK + L" \"" + path + L"\" to start", NULL, 0, 0); } if (err == 0) err = ::mciSendString(CMD_PLAY + L" \"" + path + L"\" notify", NULL, 0, m_hWnd); #ifdef _DEBUG if (err != 0) { char buf[129]; ::mciGetErrorString(err, buf, 129); AtlTrace("MCI error: %s\n", buf); } #endif return S_OK; }
void CProxySetting::readProxy(){ INTERNET_PER_CONN_OPTION_LIST List; INTERNET_PER_CONN_OPTION Option[5]; unsigned long nSize = sizeof(INTERNET_PER_CONN_OPTION_LIST); Option[0].dwOption = INTERNET_PER_CONN_AUTOCONFIG_URL; Option[1].dwOption = INTERNET_PER_CONN_AUTODISCOVERY_FLAGS; Option[2].dwOption = INTERNET_PER_CONN_FLAGS; Option[3].dwOption = INTERNET_PER_CONN_PROXY_BYPASS; Option[4].dwOption = INTERNET_PER_CONN_PROXY_SERVER; List.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST); List.pszConnection = NULL; List.dwOptionCount = 5; List.dwOptionError = 0; List.pOptions = Option; if(!InternetQueryOption(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &List, &nSize)) printf("InternetQueryOption failed! (%d)\n", GetLastError()); if(Option[0].Value.pszValue != NULL) AtlTrace("%s\n", Option[0].Value.pszValue); if((Option[2].Value.dwValue & PROXY_TYPE_AUTO_PROXY_URL) == PROXY_TYPE_AUTO_PROXY_URL) AtlTrace("PROXY_TYPE_AUTO_PROXY_URL\n"); if((Option[2].Value.dwValue & PROXY_TYPE_AUTO_DETECT) == PROXY_TYPE_AUTO_DETECT) AtlTrace("PROXY_TYPE_AUTO_DETECT\n"); INTERNET_VERSION_INFO Version; nSize = sizeof(INTERNET_VERSION_INFO); InternetQueryOption(NULL, INTERNET_OPTION_VERSION, &Version, &nSize); if(Option[0].Value.pszValue != NULL) GlobalFree(Option[0].Value.pszValue); if(Option[3].Value.pszValue != NULL) GlobalFree(Option[3].Value.pszValue); if(Option[4].Value.pszValue != NULL) GlobalFree(Option[4].Value.pszValue); INTERNET_PROXY_INFO proxyInfo; proxyInfo.dwAccessType = INTERNET_OPEN_TYPE_PRECONFIG; proxyInfo.lpszProxy = NULL; proxyInfo.lpszProxyBypass = NULL; HRESULT hr =UrlMkSetSessionOption(INTERNET_OPTION_PROXY,&proxyInfo,sizeof(proxyInfo),0); }
DWORD CDropTargetController::getEffect(DWORD dwKeys, DWORD *pEffect) { DWORD selEffect = effect & *pEffect & 0x7; DWORD pEff = DROPEFFECT_NONE; byte bc = bitCount[selEffect]; AtlTrace("selEffect=0x%x, bc=0x%x\n", selEffect, bc); if (bc == 0) pEff = DROPEFFECT_NONE; else if (bc == 1) pEff = selEffect; else { pEff = DROPEFFECT_MOVE; if ((dwKeys & 0x4) && (selEffect & DROPEFFECT_MOVE)) pEff = DROPEFFECT_MOVE; if ((dwKeys & 0x8) && (selEffect & DROPEFFECT_COPY)) pEff = DROPEFFECT_COPY; if ((dwKeys & 0x20) && (selEffect & DROPEFFECT_LINK)) pEff = DROPEFFECT_LINK; } return pEff; }
/** *\fn HRESULT GetAllWindow(LIST_STR &lstWindow) *\brief 得到所有窗体 *\param[out] LIST_STR & lstWindow *\return HRESULT 0成功,其它失败 */ HRESULT CAddinProcess::GetAllWindow(LIST_STR &lstWindow) { long nCount = 0; BSTR bstrName; CComPtr<Window> pWindow; HRESULT hr = m_pWindows->get_Count((long*)&nCount); for (int i = 1; i <= nCount; i++) { pWindow = NULL; hr = GetWindow(i, &pWindow); if (FAILED(hr)) continue; pWindow->get_Caption(&bstrName); std::string name = BstrToStr(bstrName); lstWindow.push_back(name); AtlTrace("%d %s\n", i, name.c_str()); } return hr; }
/** *\fn HRESULT GetAllCommand(LIST_STR &lstCommand) *\brief 得到所有命令 *\param[out] LIST_STR & lstCommand *\return HRESULT 0成功,其它失败 */ HRESULT CAddinProcess::GetAllCommand(LIST_STR &lstCommand) { long nCount = 0; BSTR bstrName; CComPtr<Command> pCommand; HRESULT hr = m_pCommands2->get_Count((long*)&nCount); for (int i = 1; i <= nCount; i++) { pCommand = NULL; hr = GetCommand(i, &pCommand); if (NULL == pCommand) continue; pCommand->get_Name(&bstrName); std::string name = BstrToStr(bstrName); lstCommand.push_back(name); AtlTrace("%d %s\n", i, name.c_str()); } return hr; }
/** *\fn HRESULT GetAllCommandBar(LIST_STR &lstCommandBar) *\brief 得到所有命令栏 *\param[out] LIST_STR & lstCommandBar *\return HRESULT 0成功,其它失败 */ HRESULT CAddinProcess::GetAllCommandBar(LIST_STR &lstCommandBar) { int nCount = 0; BSTR bstrName; CComPtr<CommandBar> pCommandBar; HRESULT hr = m_pCommandBars->get_Count(&nCount); for (int i = 1; i <= nCount; i++) { pCommandBar = NULL; hr = GetCommandBar(i, &pCommandBar); if (NULL == pCommandBar) continue; hr = pCommandBar->get_Name(&bstrName); std::string name = BstrToStr(bstrName); lstCommandBar.push_back(name); AtlTrace("%d %s\n", i, name.c_str()); } return hr; }
/** *\fn HRESULT GetAllControl(CommandBarControls *pControls, LIST_STR &lstControl) *\brief 得到菜单的所有菜单项 *\param[in] CommandBarControls * pControls *\param[in] LIST_STR & lstControl *\return HRESULT 0成功,其它失败 */ HRESULT CAddinProcess::GetAllControl(CommandBarControls *pControls, LIST_STR &lstControl) { if (NULL == pControls) return E_INVALIDARG; int nCount = 0; HRESULT hr = pControls->get_Count(&nCount); for (int i = 1; i <= nCount; i++) { CComPtr<CommandBarControl> pControl; // 菜单Item VARIANT varIndex; VariantInit(&varIndex); varIndex.vt = VT_I4; varIndex.lVal = i; hr = pControls->get_Item(varIndex, &pControl); if (NULL == pControl) continue; BSTR bstrName; hr = pControl->get_Caption(&bstrName); std::string name = BstrToStr(bstrName); lstControl.push_back(name); AtlTrace("Control: %d %s\n", i, name.c_str()); /* // 得到子菜单 long nc = 0; hr = pControl->get_accChildCount(&nc); for (int j = 1; j <= nc; j++) { VARIANT varIndex; VariantInit(&varIndex); varIndex.vt = VT_I4; varIndex.lVal = j; BSTR bstrName1; hr = pControl->get_accName(varIndex, &bstrName1); CComPtr<IDispatch> pDisp; hr = pControl->get_accChild(varIndex, &pDisp); CComPtr<CommandBarControl> pSubControl; pSubControl = pDisp; if (NULL != pSubControl) { hr = pSubControl->get_Caption(&bstrName1); std::string name = BstrToStr(bstrName1); AtlTrace("Control:Child %d %s\n", i, name.c_str()); } } */ } return hr; }
BOOL ActiveScriptImpl::AddScriptItem(BSTR namedItem, LPUNKNOWN lpUnknown, DWORD dwFlags) { // Add Top-level Global Named Item if (scriptPtr == NULL || lpUnknown == NULL) return false; HRESULT hr; if (namedItems.contains(namedItem)) return true; // This item has already been added // Need to save the item so that GetItemInfo() will work. AtlTrace(L"Adding named item called %s\n", namedItem); namedItems.put(namedItem, lpUnknown); if (dwFlags & MY_SCRIPTITEM_WEAK) { int *pInt = new int[1]; *pInt = 0; weakItems.put(namedItem, pInt); } hr = scriptPtr->AddNamedItem(namedItem, dwFlags & SCRIPTITEM_ALL_FLAGS); if (!SUCCEEDED(hr)) { namedItems.remove(namedItem); weakItems.remove(namedItem); return false; } // Connected to object sink-interface. if (dwFlags & SCRIPTITEM_ISSOURCE) needToConnect = true; return true; }
PSDash::_void CLoginDlg::OnCreateSessionResult( _dword dwCode ) { if(GetFramework()->GetLocalPSUID().IDType() == PSUID_GameServer) { return; } if(dwCode != E_SP_SUCCESS) { AtlMessageBox(m_hWnd,(LPCTSTR)GetFramework()->GetError(dwCode)); } else { BSTR Username = NULL, Password = NULL; GetDlgItemText(IDC_USERNAME, Username); GetDlgItemText(IDC_PASSWORD, Password); if(Username == NULL) Username = L""; if(Password == NULL) Password = L""; m_cfg.Set(L"Config", L"UserName",Username); m_cfg.Set(L"Config", L"Password",Password); GetLogWindow().SetParent(NULL); DestroyWindow(); AtlTrace(L"[LOGINDLG] Post Quit MSG 1\n"); ::PostQuitMessage(1); } }
void CConfigureDialog::ShowChild(int number) { AtlTrace("Showing tab %d\n", number); // Validate the parameter if ((number >= 0) && (number < numTabs)) { // Hide every window except for the chosen one for (int count = 0; count < numTabs; count++) { if (count != number) { dialogs[count]->ShowWindow(SW_HIDE); } else if (count == number) { #ifdef notdef // Show the chosen window and set it's location dialogs[count]->SetWindowPos(&wndTop, m_rSettingsRect.left, m_rSettingsRect.top, m_rSettingsRect.right, m_rSettingsRect.bottom, SWP_SHOWWINDOW); #endif // Show the chosen window and set it's location dialogs[count]->ShowWindow(SW_SHOW); // Select tab zero SendDlgItemMessage(IDC_TAB, TCM_SETCURSEL, (WPARAM)number, 0); } } } }
LRESULT CHilighterManageDlg::OnNMCustomdrawList(int /*idCtrl*/, LPNMHDR pNMHDR, BOOL& /*bHandled*/) { LPNMLVCUSTOMDRAW pNMCD = reinterpret_cast<LPNMLVCUSTOMDRAW>(pNMHDR); AtlTrace(L"drawstage: %u\n", pNMCD->nmcd.dwDrawStage); if (pNMCD->nmcd.dwDrawStage == CDDS_PREPAINT) { return CDRF_NOTIFYITEMDRAW; } if (pNMCD->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) { return CDRF_NOTIFYSUBITEMDRAW; } if (pNMCD->nmcd.dwDrawStage == (CDDS_ITEMPREPAINT | CDDS_SUBITEM)) { if (pNMCD->iSubItem == 1) { int index = static_cast<int>(pNMCD->nmcd.dwItemSpec); if (index < m_list.GetItemCount()) { hilighter& hl = GetHilighter(index); pNMCD->clrText = hl.d.color; pNMCD->clrTextBk = hl.d.bkcolor; } } } return CDRF_DODEFAULT; }
LRESULT PickList<C>::getValue(C *out, C def) { int data = -1; LRESULT res = SendDlgItemMessage(hDlg,wId,CB_GETCURSEL,0,0); if (res != CB_ERR) { data = SendDlgItemMessage(hDlg,wId,CB_GETITEMDATA,(WPARAM)res,0); try { wchar_t buf[MAX_PATH]; ::_snwprintf(buf, MAX_PATH, L"item[%d]/value", data); *out = valueSet->selectSingleNode(buf)->nodeTypedValue; } catch (...) { AtlTrace("Excepton tying to retrieve picklist value from XML fragment\n"); } } else if (!fixed) { char s[MAX_PATH]; GetDlgItemText(hDlg,wId, s, sizeof(s)); (*pFromStr)(out, s); } else *out = def; return 1; }
STDMETHODIMP QueueTimerService::SetTimerClient(ITimerClient *pClient) { TimerData *data = clients.get(pClient); double time; pClient->get_TimerInterval(&time); if (time == 0.0 && data != 0) RemoveTimerClient(pClient); else { if (!data) { data = new TimerData(hWnd, NULL, pClient); clients.put(pClient, data); } else ::DeleteTimerQueueTimer(hQueue, data->hTimer, NULL); AtlTrace("Setting timer to %ld\n", (long)(time * 1000)); ::CreateTimerQueueTimer(&data->hTimer, hQueue, QTS_Handler, (PVOID)data, (long)(time * 1000), (long)(time * 10000), WT_EXECUTEINTIMERTHREAD); } return S_OK; }
BOOL CScriptMeterImpl::AddDefaultScriptItem() { HRESULT hr; hr = scriptPtr->AddTypeLib(LIBID_COMMETERSLib, 1, 0, 0); if (!SUCCEEDED(hr)) return false; BOOL ret = AddScriptItem(ACTIVESCRIPT_HOST_NAME, (IMeter*)this); #ifdef CONNECTABLE IDispatch *pDispatch; scriptPtr->GetScriptDispatch(NULL, &pDispatch); pDispatch->Release(); pUtils->put_Script(pDispatch); pUtils->put_ScriptHost(this); AddScriptItem(UTILS_NAME, pUtils, SCRIPTITEM_ISVISIBLE); #endif IClientModel *_model = 0; get_Model(&_model); if (_model) { ret = AddScriptItem(MODEL_NAME, _model, SCRIPTITEM_ISVISIBLE | MY_SCRIPTITEM_WEAK); model->Release(); } else AtlTrace("Model is not set in ScriptMeterImpl\n"); return ret; }
DWORD WINAPI SkypeProcess (LPVOID lpSkypeMessageQueue) { // CoInitialize(NULL); CSkypeMessageQueue * pQueue = (CSkypeMessageQueue *) lpSkypeMessageQueue; pQueue->CreateMessageWindow(); MSG msg; int iCtr = 0; for(;;) { if(iCtr++ < 5) { if(PeekMessage(& msg, 0, 0, 0, PM_REMOVE)) { AtlTrace("Message: %d, WPARAM: %d, LPARAM: %d\n", msg.message, msg.wParam, msg.lParam); if(msg.message == WM_QUIT) { PostQuitMessage(0); //11.02.26 paak break; } TranslateMessage(& msg); DispatchMessage(& msg); } } else { iCtr = 0; } pQueue->ProcessQueue(); Sleep(1); }; pQueue->DeleteMessageWindow(); return 0; }
STDMETHODIMP CompositeOverlayImpl<B>::put_Overlays(LPSAFEARRAY newVal) { ClearAndDestroy(); long lb = 0; long ub = 0; if( !(newVal->fFeatures & FADF_DISPATCH) ) return E_INVALIDARG; HRESULT hr = ::SafeArrayGetUBound(newVal, 1, &ub); hr = ::SafeArrayGetLBound(newVal, 1, &lb); IDispatch *pDisp; IOverlay *pOverlay; long indices[1]; for (int i=lb; i<=ub; i++) { indices[0] = i; pDisp = 0; ::SafeArrayGetElement(newVal, indices, &pDisp); if (pDisp) { if (SUCCEEDED(pDisp->QueryInterface(__uuidof(IOverlay), (void**)&pOverlay))) { AtlTrace("Added overlay to composite\n"); Add(pOverlay); pOverlay->Release(); } pDisp->Release(); } } return S_OK; }
void MTConnectStreamsParser::DumpData(DataDictionary data) { for(DataDictionary::iterator it = data.begin(); it!=data.end(); it++) { AtlTrace("%s = %s\n", (*it).first.c_str(), (*it).second.c_str()); } }
STDMETHODIMP CPlayer::PutValue(BSTR sel, BSTR value) { AtlTrace(L"CPlayer::PutValue(%s, %s)\n",sel, value); if (::wcscmp(sel, SEL_CONTROL) == 0) { // A set of simplified commands if (::wcscmp(value, CMD_PLAY) == 0) { Start(); } else if (::wcscmp(value, CMD_STOP) == 0) { Stop(); } else if (::wcscmp(value, CMD_PAUSE) == 0) { Pause(); } else if (::wcscmp(value, CMD_RESUME) == 0) { Resume(); } } else if (::wcscmp(sel, SEL_CMD) == 0) { ::mciSendString(_bstr_t(value), NULL, 0 , NULL); } else if (::wcscmp(sel, SEL_CONFIG) == 0) { Configure(NULL, (long)m_hWnd); } else if (::wcscmp(sel, SEL_PATH) == 0) { put_Path(value); } return S_OK; }
HRESULT CHtmlTableSnapshots::SetDocumentText(CComPtr<IWebBrowser2> pWebBrowser, std::string cstr) { _bstr_t tbstr(cstr.c_str()); //HRESULT_EXCEPTION hr = S_OK; HRESULT hr = S_OK; VARIANT *param; SAFEARRAY *sfArray; CComPtr<IHTMLDocument2> document; BSTR bstr= tbstr.Detach(); try { // Creates a new one-dimensional array sfArray = SafeArrayCreateVector(VT_VARIANT, 0, 1); document=GetDocument(pWebBrowser); if (sfArray == NULL || document == NULL) throw std::exception("CMainDlg::SetDocumentText) Failed IHTMLDocument2\n"); hr = SafeArrayAccessData(sfArray,(LPVOID*) & param); param->vt = VT_BSTR; param->bstrVal = bstr; hr = SafeArrayUnaccessData(sfArray); hr = document->write(sfArray); } catch(std::exception e) { AtlTrace(e.what()); throw e; } catch(HRESULT hResult) { std::string errmsg =(LPCSTR)( "CMainDlg::SetDocumentText Failed: %s\n" + ErrorFormatMessage(hResult)); AtlTrace("CMainDlg::SetDocumentText Failed: %s\n", (LPCSTR) ErrorFormatMessage(hResult)); throw std::exception(errmsg.c_str()); } catch(...) { AtlTrace("CMainDlg::OpenIE() Failed\n"); throw std::exception("CMainDlg::OpenIE() Failed\n"); } if (sfArray != NULL) SafeArrayDestroy(sfArray); return S_OK; }
ScriptThread::~ScriptThread() { AtlTrace("Destroying script thread"); if (pScript) { pScript->Release(); pScript = NULL; } }
HRESULT AgentConfigurationEx::CResetThread::Execute (DWORD_PTR dwParam, HANDLE hObject) { static char name[] = "CResetThread::Execute"; AgentConfigurationEx *agent = (AgentConfigurationEx *) dwParam; CancelWaitableTimer(hObject); // DebugBreak(); try { PROCESS_INFORMATION pi; ZeroMemory(&pi, sizeof( pi ) ); STARTUPINFO si; ZeroMemory(&si, sizeof( si ) ); si.cb = sizeof( si ); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE; // set the window display to HIDE // SCM reset command of this service #ifndef RESETTEST std::string cmd = StdStringFormat("cmd /c net stop \"%s\" & net start \"%s\"", Globals.ServerName.c_str( ), Globals.ServerName.c_str( ) ); // Command line #else // This works when you run in from a command console as NikonAgent.exe debug, it will restart in the current DOS console. TCHAR buf[1000]; GetModuleFileName(NULL, buf, 1000); std::string exepath = File.ExeDirectory(); std::string exe = ExtractFilename(std::string(buf)); //GLogger.Fatal(StdStringFormat("start Agent /d \"%s\" /b \"%s\" debug\n", exepath.c_str(), buf ) ); std::string cmd = StdStringFormat("cmd /c taskkill /IM \"%s\" & \"%s\" debug", exe.c_str(), buf ); // Command line #endif if ( !::CreateProcess(NULL, // No module name (use command line) const_cast<char *>( cmd.c_str( ) ), NULL, // Process handle not inheritable NULL, // Thread handle not inheritable FALSE, // Set handle inheritance to FALSE 0, // No creation flags NULL, // Use parent's environment block NULL, // Use parent's starting directory &si, // Pointer to STARTUPINFO structure &pi) ) // Pointer to PROCESS_INFORMATION structure { AtlTrace("CreateProcess FAIL "); } ::Sleep(5000); // make sure process has spawned before killing thread } catch ( ... ) { agent->AbortMsg("Exception - ResetAtMidnightThread(void *oObject"); } return S_OK; }
STDMETHODIMP ArrayPtrVariant<I, B>::Add(I* item) { if (item == NULL) AtlTrace("Trying to add NULL to arrayptrvariant\n"); checkCapacity(); coll[_count++] = item; item->AddRef(); return S_OK; }
/* * Called when we need to persist our state. */ void Appearance::save(char *szIni, char *szIniGroup, BOOL bIsForExport, char *prefix) { char iBuf[32]; AtlTrace("Writing label to %s\n", szIni); WritePrivateProfileString(szIniGroup, LABEL_FORMAT, labelFormat, szIni); WritePrivateProfileString(szIniGroup, LABEL_SELECTOR, labelSelector, szIni); WritePrivateProfileString(szIniGroup, LABEL_METER, itoa(getLabelMeterIndex(), iBuf, 10), szIni); }
CDropTargetController::~CDropTargetController() { AtlTrace("DropTargetController destroyed\n"); if (pTargetImpl) { // if (FAILED(pTargetImpl->RevokeDragDrop())) pTargetImpl->Release(); } }
BOOL CLitSingleLock::Lock(DWORD dwTimeOut) { ATLASSERT(m_pObject != NULL || m_hObject != NULL); ATLASSERT(!m_bAcquired); #ifdef _ENABLE_DEBUG_LOCK if(!m_strLockFunction.IsEmpty()) AtlTrace(_T("begin to lock for %s at %s with object %08X\n"), m_strLockFunction,COleDateTime::GetCurrentTime().Format(_T("%M:%S")),this); #endif m_bAcquired = m_pObject->Lock(dwTimeOut); return m_bAcquired; }
static void Callback_Download( t_DownloadNotifyPara *pDownloadNotifyPara, WPARAM wParam ) { if( !pDownloadNotifyPara ) return; if(wParam != DOWNLOAD_WPARAM) return; if(!updatedlg) return; int index = pDownloadNotifyPara->nIndex; switch ( pDownloadNotifyPara->nNotityType ) { case NOTIFY_TYPE_GOT_REMOTE_FILENAME: { break; } case NOTIFY_TYPE_GOT_REMOTE_FILESIZE: { //PostMessage(updatedlg->m_hWnd, WM_MSG_DOWNLOADER_FILESIZE, wParam, (LPARAM)pDownloadNotifyPara->lpNotifyData); updatedlg->m_filesize = (int)pDownloadNotifyPara->lpNotifyData; AtlTrace("Remote file size is : %d bytes\n", (int)pDownloadNotifyPara->lpNotifyData); break; } case NOTIFY_TYPE_START_DOWNLOAD: { AtlTrace(L"Downloading Start"); break; } case NOTIFY_TYPE_END_DOWNLOAD: { ENUM_DOWNLOAD_RESULT eDownloadResult = (ENUM_DOWNLOAD_RESULT)(int)pDownloadNotifyPara->lpNotifyData; if ( eDownloadResult == ENUM_DOWNLOAD_RESULT_SUCCESS ) { PostMessage(updatedlg->m_hWnd, WM_MSG_DOWNLOADER_FINISHED, wParam, 1); AtlTrace(L"Download successfully.\n"); } else if ( eDownloadResult == ENUM_DOWNLOAD_RESULT_FAILED ) { PostMessage(updatedlg->m_hWnd, WM_MSG_DOWNLOADER_FINISHED, wParam, 0); AtlTrace(L"Download failed.\n"); } else if ( eDownloadResult == ENUM_DOWNLOAD_RESULT_CANCEL ) AtlTrace(L"User cancel download.\n"); else { PostMessage(updatedlg->m_hWnd, WM_MSG_DOWNLOADER_FINISHED, wParam, 0); AtlTrace(L"Unknow Download Finished.\n"); } break; } case NOTIFY_TYPE_THREAD_DOWNLOADED_SIZE: { PostMessage(updatedlg->m_hWnd, WM_MSG_DOWNLOADER_DOWNSIZE, wParam, (LPARAM)pDownloadNotifyPara->lpNotifyData); AtlTrace(L"Downloaded size is : %d bytes\n", (int)pDownloadNotifyPara->lpNotifyData); break; } } }
//static void DoEvents( HWND hWnd_i ) //{ // MSG stMsg = { 0 }; // while( PeekMessage( &stMsg, hWnd_i, 0, 0, PM_REMOVE )) // { // TranslateMessage( &stMsg ); // DispatchMessage( &stMsg ); // } //} void CMainDlg::Close(int nVal) { AtlTrace("CMainDlg::Close"); ShowWindow(SW_HIDE); // pretend going away RemoveIcon(); KillTimer(1); //Don't forget to revoke after you are done: HRESULT hr = pGIT->RevokeInterfaceFromGlobal( dwWebBrowserCookie ); PostThreadMessage((DWORD)dlgMainThead,WM_QUIT,0,0); //??? AtlTrace("CMainDlg::Close PostQuitMessage"); ::Sleep(100); MSG msg = { 0 }; while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { AtlTrace("CEchoService::stop()) PeekMessage"); TranslateMessage(&msg); DispatchMessage(&msg); ::Sleep(100); } }
LRESULT CMainDlg::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { AtlTrace("CMainDlg::OnDestroy"); // unregister message filtering and idle updates //CMessageLoop* pLoop = _Module.GetMessageLoop(); CMessageLoop* pLoop = _thread->GetMessageLoop(); //if(pLoop == NULL) // return 0; pLoop->RemoveMessageFilter(this); pLoop->RemoveIdleHandler(this); return 0; }