STDMETHODIMP CActiveXCtrl::OnInPlaceActivateEx(BOOL* pfNoRedraw, DWORD dwFlags) { TRACE(_T("AX: CActiveXCtrl::OnInPlaceActivateEx")); ASSERT(m_pInPlaceObject==NULL); if( m_pOwner == NULL ) return E_UNEXPECTED; if( m_pOwner->m_pUnk == NULL ) return E_UNEXPECTED; ::OleLockRunning(m_pOwner->m_pUnk, TRUE, FALSE); HWND hWndFrame = m_pOwner->GetManager()->GetPaintWindow(); HRESULT Hr = E_FAIL; if( (dwFlags & ACTIVATE_WINDOWLESS) != 0 ) { m_bWindowless = true; Hr = m_pOwner->m_pUnk->QueryInterface(IID_IOleInPlaceObjectWindowless, (LPVOID*) &m_pInPlaceObject); m_pOwner->m_hwndHost = hWndFrame; m_pOwner->GetManager()->AddMessageFilter(m_pOwner); } if( FAILED(Hr) ) { m_bWindowless = false; Hr = CreateActiveXWnd(); if( FAILED(Hr) ) return Hr; Hr = m_pOwner->m_pUnk->QueryInterface(IID_IOleInPlaceObject, (LPVOID*) &m_pInPlaceObject); } if( m_pInPlaceObject != NULL ) { CRect rcItem = m_pOwner->m_rcItem; if( !m_bWindowless ) rcItem.ResetOffset(); m_pInPlaceObject->SetObjectRects(&rcItem, &rcItem); } m_bInPlaceActive = SUCCEEDED(Hr); return Hr; }
void Notify(TNotifyUI& msg) { // name = flashUI 控件在UI布局中默认注释掉,查看效果需修改xml CFlashUI* pFlashUI = static_cast<CFlashUI*>(m_pm.FindControl(_T("flashUI"))); if( msg.sType == _T("click") ) { if( msg.pSender->GetName() == _T("closebtn") || msg.pSender->GetName() == _T("closebtn2") ) { PostQuitMessage(0); return; } } else if ( msg.sType == _T("windowinit")) { if ( pFlashUI) { pFlashUI->m_pFlash->put_WMode(_bstr_t(_T("Transparent") )); // FlashUI没有实现特定接口,需要完善才能支持 pFlashUI->m_pFlash->put_Movie( _bstr_t(CPaintManagerUI::GetInstancePath() + _T("\\skin\\FlashRes\\test.swf")) ); pFlashUI->m_pFlash->DisableLocalSecurity(); pFlashUI->m_pFlash->put_AllowScriptAccess(L"always"); BSTR request,response; request = SysAllocString(L"<invoke name=\"setButtonText\" returntype=\"xml\"><arguments><string>Click me!</string></arguments></invoke>"); response = SysAllocString(L""); pFlashUI->m_pFlash->CallFunction(request, &response); SysFreeString(request); SysFreeString(response); } } else if( msg.sType == _T("showactivex") ) { if( msg.pSender->GetName() == _T("flashActiveX") ) { IShockwaveFlash* pFlash = NULL; CActiveXUI* pActiveX = static_cast<CActiveXUI*>(msg.pSender); pActiveX->GetControl(IID_IUnknown, (void**)&pFlash); if( pFlash != NULL ) { pFlash->put_WMode( _bstr_t(_T("Transparent") ) ); pFlash->put_Movie( _bstr_t(CPaintManagerUI::GetInstancePath() + _T("\\skin\\FlashRes\\test.swf")) ); pFlash->DisableLocalSecurity(); pFlash->put_AllowScriptAccess(L"always"); BSTR request,response; request = SysAllocString(L"<invoke name=\"setButtonText\" returntype=\"xml\"><arguments><string>Click me!</string></arguments></invoke>"); response = SysAllocString(L""); pFlashUI->m_pFlash->CallFunction(request, &response); SysFreeString(request); SysFreeString(response); } } } }
void RedisHelpUI::Initialize() { CActiveXUI* pActiveXUI = static_cast<CActiveXUI*>(GetPaintMgr()->FindControl(_T("ie"))); if( pActiveXUI ) { IWebBrowser2* pWebBrowser = NULL; pActiveXUI->GetControl(IID_IWebBrowser2, (void**)&pWebBrowser); // 忽略js错误 pWebBrowser->put_Silent(true); if( pWebBrowser != NULL ) { pWebBrowser->Navigate(L"http://redis.io/commands",NULL,NULL,NULL,NULL); //pWebBrowser->Navigate(L"about:blank",NULL,NULL,NULL,NULL); pWebBrowser->Release(); } } }
HRESULT CActiveXCtrl::CreateActiveXWnd() { if( m_pWindow != NULL ) return S_OK; m_pWindow = new CActiveXWnd; if( m_pWindow == NULL ) return E_OUTOFMEMORY; m_pOwner->m_hwndHost = m_pWindow->Init(this, m_pOwner->GetManager()->GetPaintWindow()); return S_OK; }
STDMETHODIMP CActiveXCtrl::SetFocus(BOOL fFocus) { TRACE(_T("AX: CActiveXCtrl::SetFocus")); if( m_pOwner == NULL ) return E_UNEXPECTED; if( fFocus ) m_pOwner->SetFocus(); m_bFocused = (fFocus == TRUE); return S_OK; }
void CFrameWnd::InitWindow() { // SetIcon(IDR_MAINFRAME); // 设置任务栏图标 CenterWindow(); // 初始化CActiveXUI控件 CActiveXUI* pActiveXUI = static_cast<CActiveXUI*>(m_PaintManager.FindControl(_T("ActiveXDemo1"))); if( pActiveXUI ) { IWebBrowser2* pWebBrowser = NULL; pActiveXUI->SetDelayCreate(false); // 相当于界面设计器里的DelayCreate属性改为FALSE,在duilib自带的FlashDemo里可以看到此属性为TRUE pActiveXUI->CreateControl(CLSID_WebBrowser); // 相当于界面设计器里的Clsid属性里填入{8856F961-340A-11D0-A96B-00C04FD705A2},建议用CLSID_WebBrowser,如果想看相应的值,请见<ExDisp.h> pActiveXUI->GetControl(IID_IWebBrowser2, (void**)&pWebBrowser); if( pWebBrowser != NULL ) { //pWebBrowser->Navigate(L"https://code.google.com/p/duilib/",NULL,NULL,NULL,NULL); pWebBrowser->Navigate(L"about:blank", NULL, NULL, NULL, NULL); pWebBrowser->Navigate(L"http://www.baidu.com/", NULL, NULL, NULL, NULL); // 由于谷歌时不时被墙,所以换成反应快的网站 pWebBrowser->Release(); } } // 初始化CProgressUI控件 CProgressUI* pProgress = static_cast<CProgressUI*>(m_PaintManager.FindControl(_T("ProgressDemo1"))); pProgress->SetValue(50); // 初始化CListUI控件 CDuiString str; CListUI* pList = static_cast<CListUI*>(m_PaintManager.FindControl(_T("ListDemo1"))); for (int i = 0; i < 100; i++) { CListTextElementUI* pListElement = new CListTextElementUI; pListElement->SetTag(i); pList->Add(pListElement); str.Format(_T("%d"), i); pListElement->SetText(0, str); pListElement->SetText(1, _T("haha")); } }
STDMETHODIMP CActiveXCtrl::GetDC(LPCRECT pRect, DWORD grfFlags, HDC* phDC) { TRACE(_T("AX: CActiveXCtrl::GetDC")); if( phDC == NULL ) return E_POINTER; if( m_pOwner == NULL ) return E_UNEXPECTED; *phDC = ::GetDC(m_pOwner->m_hwndHost); if( (grfFlags & OLEDC_PAINTBKGND) != 0 ) { CRect rcItem = m_pOwner->GetPos(); if( !m_bWindowless ) rcItem.ResetOffset(); ::FillRect(*phDC, &rcItem, (HBRUSH) (COLOR_WINDOW + 1)); } return S_OK; }
void Notify(TNotifyUI& msg) { if( msg.sType == _T("click") ) { if( msg.pSender->GetName() == _T("closebtn") || msg.pSender->GetName() == _T("closebtn2") ) { PostQuitMessage(0); return; } } else if( msg.sType == _T("showactivex") ) { if( msg.pSender->GetName() != _T("flash") ) return; IShockwaveFlash* pFlash = NULL; CActiveXUI* pActiveX = static_cast<CActiveXUI*>(msg.pSender); pActiveX->GetControl(IID_IUnknown, (void**)&pFlash); if( pFlash != NULL ) { pFlash->put_WMode( _bstr_t(_T("Transparent") ) ); pFlash->put_Movie( _bstr_t(CPaintManagerUI::GetInstancePath() + _T("\\skin\\FlashRes\\test.swf")) ); pFlash->DisableLocalSecurity(); pFlash->put_AllowScriptAccess(L"always"); BSTR response; pFlash->CallFunction(L"<invoke name=\"setButtonText\" returntype=\"xml\"><arguments><string>Click me!</string></arguments></invoke>", &response); pFlash->Release(); } } }
STDMETHODIMP CActiveXCtrl::GetWindowContext(IOleInPlaceFrame** ppFrame, IOleInPlaceUIWindow** ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo) { TRACE(_T("AX: CActiveXCtrl::GetWindowContext")); if( ppDoc == NULL ) return E_POINTER; if( ppFrame == NULL ) return E_POINTER; if( lprcPosRect == NULL ) return E_POINTER; if( lprcClipRect == NULL ) return E_POINTER; *ppFrame = new CActiveXFrameWnd(m_pOwner); *ppDoc = NULL; ACCEL ac = { 0 }; HACCEL hac = ::CreateAcceleratorTable(&ac, 1); lpFrameInfo->cb = sizeof(OLEINPLACEFRAMEINFO); lpFrameInfo->fMDIApp = FALSE; lpFrameInfo->hwndFrame = m_pOwner->GetManager()->GetPaintWindow(); lpFrameInfo->haccel = hac; lpFrameInfo->cAccelEntries = 1; return S_OK; }
// IOleWindow STDMETHOD(GetWindow)(HWND* phwnd) { if( m_pOwner == NULL ) return E_UNEXPECTED; *phwnd = m_pOwner->GetManager()->GetPaintWindow(); return S_OK; }
void CMainDialog::OnClick( CControlUI* pSender) { if (pSender->GetName() == TEXT ("btnExit")) { PostQuitMessage(0); return; } else if (pSender->GetName() == _T ("btnTip")) { CControlUI* pbtnTip = static_cast <CControlUI*> (m_pm.FindControl(_T ("btnTip"))); if (pbtnTip) { pbtnTip->SetVisible(false); } CEditUI* peditSearch = static_cast <CEditUI*> (m_pm.FindControl(_T ("editSearch"))); if (peditSearch != NULL) { peditSearch->SetFocus(); } } else if (pSender->GetName() == _T ("lstDelButton")) { int iIndex = 0; CMyList* pParent = static_cast <CMyList*> (pSender->GetParent()->GetParent()); if (pParent) { iIndex = pParent->GetItemIndex(pSender->GetParent()); } CDuiString str; str.Format(_T ("您要删除 %d 项"), iIndex); if (IDNO == MessageBox (GetHWND (), str, NULL, MB_OK | MB_YESNO)) return; CMyList* pList = static_cast <CMyList*> (m_pm.FindControl(_T ("lstControl"))); ASSERT(pList); if (pList) { pList->RemoveAt(iIndex); CControlUI* pItem = pList->GetItemAt(iIndex+5); if (pItem) { const RECT& rc = pItem->GetPos(); SIZE sz = {0, rc.top}; pList->SetScrollPos(sz); } } } else if (pSender->GetName() == _T ("btnAddComboItem")) { CComboUI* pcbx = static_cast <CComboUI*> (m_pm.FindControl(_T ("combo1"))); assert (pcbx); if (pcbx) { CListLabelElementUI* pItem = new CListLabelElementUI (); pItem->SetText(_T ("{b}{i}新加项{/i}{/b}")); pcbx->Add(pItem); } AddComboboxItem(); CComboUI* pcbx2 = static_cast <CComboUI*> (m_pm.FindControl(_T ("combo2"))); } else if (pSender->GetName() == _T ("btnGoIe")) { CActiveXUI* pActiveXUI = static_cast<CActiveXUI*>(m_pm.FindControl(_T("ie"))); if( pActiveXUI ) { IWebBrowser2* pWebBrowser = NULL; pActiveXUI->GetControl(IID_IWebBrowser2, (void**)&pWebBrowser); if( pWebBrowser != NULL ) { CEditUI* pEdit = static_cast <CEditUI*> (m_pm.FindControl(_T ("editIePath"))); ASSERT (pEdit); CDuiString strIePath = _T ("www.baidu.com"); if (pEdit) { strIePath = pEdit->GetText(); } WCHAR szPath [1024] = {0}; #if defined(_UNICODE) || defined(UNICODE) lstrcpyW (szPath, strIePath); #else ::MultiByteToWideChar(CP_ACP, 0, strIePath, -1, szPath, 1023); #endif pWebBrowser->Navigate(szPath,NULL,NULL,NULL,NULL); pWebBrowser->Release(); } } } }
void CQuizWnd::InitWindow() { assert(m_songInfo); CenterWindow(); auto& quizInfo = m_songInfo->GetQuizInfo(); // show title CTextUI* title = static_cast<CTextUI*>(m_PaintManager.FindControl(L"title")); if (!title) return; title->SetText(quizInfo.get_title().c_str()); // show questoins button CHorizontalLayoutUI* questions_btn = static_cast<CHorizontalLayoutUI*>(m_PaintManager.FindControl(L"questions_btn")); if (!questions_btn) return; wchar_t ndx[3] = L"1"; auto cnt = quizInfo.get_quiz_count(); static const int FIXED_LENGTH = 64; SIZE sz = { 1,1 }; for (auto i = 0; i < cnt; i++) { CButtonUI* btn = new CButtonUI(); btn->SetName(((wstring)BTN_QUESTION_PREFIX + ndx).c_str()); btn->SetFloat(); btn->SetFixedXY(sz); btn->SetFixedHeight(FIXED_LENGTH); btn->SetFixedWidth(FIXED_LENGTH); btn->SetNormalImage(((wstring)NORMAL_PREFIX + ndx + POSTFIX_PNG).c_str()); btn->SetFocusedImage(((wstring)NORMAL_PREFIX + ndx + POSTFIX_PNG).c_str()); btn->SetHotImage(((wstring)HOT_PREFIX + ndx + POSTFIX_PNG).c_str()); btn->SetPushedImage(((wstring)HOT_PREFIX + ndx + POSTFIX_PNG).c_str()); questions_btn->Add(btn); ndx[0]++; sz.cx += FIXED_LENGTH + 1; if (ndx[0] == 58) { ndx[0] = L'1'; ndx[1] = L'0'; } } // show doen button if (cnt > 0) { CButtonUI* btn = new CButtonUI(); btn->SetName(((wstring)BTN_QUESTION_PREFIX + DONE).c_str()); btn->SetFloat(); btn->SetFixedXY(sz); btn->SetFixedHeight(FIXED_LENGTH); btn->SetFixedWidth(FIXED_LENGTH); btn->SetNormalImage(((wstring)NORMAL_PREFIX + DONE + POSTFIX_PNG).c_str()); btn->SetFocusedImage(((wstring)NORMAL_PREFIX + DONE + POSTFIX_PNG).c_str()); btn->SetHotImage(((wstring)HOT_PREFIX + DONE + POSTFIX_PNG).c_str()); btn->SetPushedImage(((wstring)HOT_PREFIX + DONE + POSTFIX_PNG).c_str()); questions_btn->Add(btn); } // init question container CActiveXUI* question = static_cast<CActiveXUI*>(m_PaintManager.FindControl(_T("question"))); if (!question) return; question->SetDelayCreate(false); // 相当于界面设计器里的DelayCreate属性改为FALSE,在duilib自带的FlashDemo里可以看到此属性为TRUE question->CreateControl(CLSID_WebBrowser); // 相当于界面设计器里的Clsid属性里填入{8856F961-340A-11D0-A96B-00C04FD705A2},建议用CLSID_WebBrowser,如果想看相应的值,请见<ExDisp.h> question->GetControl(IID_IWebBrowser2, (void**)&m_question); assert(m_question); // show 1st question ShowQuiz(1); }
void CQuizWnd::ShowQuiz(int ndx) { assert(m_songInfo); assert(m_question); auto& quizInfo = m_songInfo->GetQuizInfo(); auto quiz = quizInfo.get_quiz(ndx - 1); if (!quiz) return; // show question std::wstring html_path = m_songInfo->get_tmp_path() + L"\\" + m_songInfo->get_id() + L"\\question.html"; std::wofstream out(html_path); if (!out.is_open())return; std::wstringstream ss; ss << L"<HTML>" L"<head>" L"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" L"<title>lyric</title>" L"</head>" L"<BODY SCROLL=NO bgcolor='#FFFFBF' topmargin='2' leftmargin='2'>" L"<h3 align='LEFT'>" L"<font size='5' color=#000000>" << quiz->get_question() << L"</font>" L"</h3>" L"</BODY>" L"</HTML>"; std::wstring w = ss.str(); std::string u; utf8::utf16to8(w.begin(), w.end(), std::back_inserter(u)); out << u.c_str(); out.close(); m_question->Navigate(const_cast<wchar_t*>(html_path.c_str()), nullptr, nullptr, nullptr, nullptr); // show options CVerticalLayoutUI* options = static_cast<CVerticalLayoutUI*>(m_PaintManager.FindControl(L"options")); if (!options)return; options->RemoveAll(); std::list<song::Mp3Info::QuizInfo::Quiz::OptionAndContent> list; quiz->get_questions(list); for (auto option_and_content : list) { // add container CHorizontalLayoutUI* container = new CHorizontalLayoutUI(); container->SetFixedHeight(50); options->Add(container); // add option CButtonUI* btn_option = new CButtonUI(); btn_option->SetFixedWidth(50); btn_option->SetFixedWidth(50); std::wstring option = option_and_content.first; btn_option->SetName((BTN_OPTION_PREFIX + option).c_str()); btn_option->SetNormalImage((NORMAL_OPTION_PREFIX + option + POSTFIX_PNG).c_str()); btn_option->SetFocusedImage((NORMAL_OPTION_PREFIX + option + POSTFIX_PNG).c_str()); btn_option->SetHotImage((HOT_OPTION_PREFIX + option + POSTFIX_PNG).c_str()); btn_option->SetPushedImage((HOT_OPTION_PREFIX + option + POSTFIX_PNG).c_str()); container->Add(btn_option); // add content CActiveXUI* content = new CActiveXUI(); container->Add(content); IWebBrowser2* pWebBrwser = nullptr; content->SetDelayCreate(false); // 相当于界面设计器里的DelayCreate属性改为FALSE,在duilib自带的FlashDemo里可以看到此属性为TRUE content->CreateControl(CLSID_WebBrowser); // 相当于界面设计器里的Clsid属性里填入{8856F961-340A-11D0-A96B-00C04FD705A2},建议用CLSID_WebBrowser,如果想看相应的值,请见<ExDisp.h> content->GetControl(IID_IWebBrowser2, (void**)&pWebBrwser); assert(pWebBrwser); if (!pWebBrwser)return; ss.str(L""); ss.clear(); ss << L"<HTML>" L"<head>" L"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" L"<title>lyric</title>" L"</head>" L"<BODY SCROLL=NO bgcolor='#FFFFBF' topmargin='2' leftmargin='2'>" L"<TABLE WIDTH=100% HEIGHT=100%><TR WIDTH=100% HEIGHT=100%><TD style=\"font-family:微软雅黑; font-size:20px; \">" L"<font size='3' color=#000000>" << option_and_content.second << L"</font>" L"</TD></TR></TABLE>" L"</BODY>" L"</HTML>"; std::wstring w = ss.str(); std::string u; utf8::utf16to8(w.begin(), w.end(), std::back_inserter(u)); std::wstring html_path = m_songInfo->get_tmp_path() + L"\\" + m_songInfo->get_id() + L"\\content_" + option + L".html"; std::wofstream out(html_path); if (!out.is_open())return; out << u.c_str(); out.close(); pWebBrwser->Navigate(const_cast<wchar_t*>(html_path.c_str()), nullptr, nullptr, nullptr, nullptr); pWebBrwser->Release(); // add line gap CHorizontalLayoutUI* line_gap = new CHorizontalLayoutUI(); line_gap->SetFixedHeight(50); options->Add(line_gap); } // if user had chosen an answer before, show it. auto user_answer = quiz->get_user_answer(); if (!user_answer.empty()) { std::wstring option_btn_name = BTN_OPTION_PREFIX + user_answer; CButtonUI* btn = static_cast<CButtonUI*>(m_PaintManager.FindControl(option_btn_name.c_str())); if (btn) { g_prev_clicked_button_option = nullptr; UpdateButtonUi2(btn, user_answer); } } g_cur_quiz_info = quiz; ss.str(L""); ss.clear(); ss << ndx; std::wstring question_ndx = ss.str(); std::wstring question_btn_name = BTN_QUESTION_PREFIX + ss.str(); CButtonUI* question_btn = static_cast<CButtonUI*>(m_PaintManager.FindControl(question_btn_name.c_str())); if (question_btn) { g_prev_clicked_button = nullptr; UpdateButtonUi(question_btn, question_ndx); } }
void CDuiFrameWnd::Notify( TNotifyUI& msg ) { if (msg.sType == DUI_MSGTYPE_SELECTCHANGED) { CTreeViewUI* pTree = static_cast<CTreeViewUI*>(m_PaintManager.FindControl(_T("treePlaylist"))); if(pTree && -1 != pTree->GetItemIndex(msg.pSender) && U_TAG_PLAYLIST == msg.pSender->GetTag()) { m_iPlaylistIndex = pTree->GetItemIndex(msg.pSender); Play(m_cPlayList.GetPlaylist(GetPlaylistIndex(m_iPlaylistIndex)).szFileName); //(static_cast<CTreeNodeUI*> (msg.pSender))->GetItemText(); } } else if(msg.sType == DUI_MSGTYPE_SELECTCHANGED) { CDuiString strName = msg.pSender->GetName(); CTabLayoutUI* pTab = static_cast<CTabLayoutUI*>(m_PaintManager.FindControl(_T("tabCaption"))); std::vector<CDuiString> vctString; vctString.push_back(_T("tabPlay")); vctString.push_back(_T("tabLib")); vctString.push_back(_T("tabFind")); vctString.push_back(_T("tabMine")); vctString.push_back(_T("tabCloud")); std::vector<CDuiString>::iterator it = std::find(vctString.begin(), vctString.end(), strName); if (vctString.end() != it) { int iIndex = it - vctString.begin(); pTab->SelectItem(iIndex); // 加载网页 // 由于加载网页会耗很多内存,所以这里选择动态加载 if (iIndex > 0) { std::vector<CDuiString> vctName, vctURL; CActiveXUI* pActiveXUI; vctName.push_back(_T("ActiveXLib")); vctName.push_back(_T("ActiveXFind")); vctName.push_back(_T("ActiveXMine")); vctName.push_back(_T("ActiveXCloud")); vctURL.push_back(_T("http://pianku.xmp.kankan.com/moviestore_index.html")); vctURL.push_back(_T("http://search.xmp.kankan.com/index4xmp.shtml")); vctURL.push_back(_T("http://pianku.xmp.kankan.com/xmpguess/host.html")); vctURL.push_back(_T("http://vod.xunlei.com/page/xmp/home/home.html?init=1")); iIndex--; pActiveXUI = static_cast<CActiveXUI*>(m_PaintManager.FindControl(vctName[iIndex])); if(pActiveXUI) { IWebBrowser2* pWebBrowser = NULL; pActiveXUI->GetControl(IID_IWebBrowser2, (void**)&pWebBrowser); if(pWebBrowser) { _bstr_t bstrTmp; BSTR bstr; pWebBrowser->get_LocationURL(&bstr); bstrTmp.Attach(bstr); if (! bstrTmp.length()) { pWebBrowser->Navigate(_bstr_t(vctURL[iIndex]), NULL,NULL,NULL,NULL); pWebBrowser->Release(); } } } } } } else if(msg.sType == DUI_MSGTYPE_ITEMCLICK) { CDuiString strName = msg.pSender->GetName(); if (strName == _T("menuSequence")) { m_emPlayMode = EM_PLAY_MODE_SEQUENCE; } else if (strName == _T("menuRandom")) { m_emPlayMode = EM_PLAY_MODE_RANDOM; } else if (strName == _T("menuSingleCircle")) { m_emPlayMode = EM_PLAY_MODE_SINGLE_CIRCLE; } } else if( msg.sType == DUI_MSGTYPE_DBCLICK ) { if (IsInStaticControl(msg.pSender)) { // 这里会传进来很多次双击消息,所以只获取祖先控件的消息 if (! msg.pSender->GetParent()) { FullScreen(! m_bFullScreenMode); } } } __super::Notify(msg); }
void CDuiFrameWnd::InitWindow() { SetIcon(IDI_ICON1); // 根据分辨率自动调节窗口大小 MONITORINFO oMonitor = {}; oMonitor.cbSize = sizeof(oMonitor); ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTONEAREST), &oMonitor); AdaptWindowSize(oMonitor.rcMonitor.right - oMonitor.rcMonitor.left); ::GetWindowPlacement(*this, &m_OldWndPlacement); // 初始化CActiveXUI控件 std::vector<CDuiString> vctName; CActiveXUI* pActiveXUI; vctName.push_back(_T("ActiveXLib")); vctName.push_back(_T("ActiveXFind")); vctName.push_back(_T("ActiveXMine")); vctName.push_back(_T("ActiveXCloud")); for (UINT i = 0; i < vctName.size(); i++) { pActiveXUI = static_cast<CActiveXUI*>(m_PaintManager.FindControl(vctName[i])); if(pActiveXUI) { pActiveXUI->SetDelayCreate(false); pActiveXUI->CreateControl(CLSID_WebBrowser); } } // 几个常用控件做为成员变量 CSliderUI* pSilderVol = static_cast<CSliderUI*>(m_PaintManager.FindControl(_T("sliderVol"))); m_pSliderPlay = static_cast<CSliderUI*>(m_PaintManager.FindControl(_T("sliderPlay"))); m_pLabelTime = static_cast<CLabelUI*>(m_PaintManager.FindControl(_T("labelPlayTime"))); if (! pSilderVol || ! m_pSliderPlay || ! m_pLabelTime) { return; } pSilderVol->OnNotify += MakeDelegate(this, &CDuiFrameWnd::OnVolumeChanged); m_pSliderPlay->OnNotify += MakeDelegate(this, &CDuiFrameWnd::OnPosChanged); // 设置播放器的窗口句柄和回调函数 CWndUI *pWnd = static_cast<CWndUI*>(m_PaintManager.FindControl(_T("wndMedia"))); if (pWnd) { m_cAVPlayer.SetHWND(pWnd->GetHWND()); m_cAVPlayer.SetCallbackPlaying(CallbackPlaying); m_cAVPlayer.SetCallbackPosChanged(CallbackPosChanged); m_cAVPlayer.SetCallbackEndReached(CallbackEndReached); } // 加载m3u播放列表 AddFiles(m_cPlayList.GetPlaylist(), true); // 选中上一次播放文件的位置 CTreeViewUI *pTree = static_cast<CTreeViewUI*>(m_PaintManager.FindControl(_T("treePlaylist"))); if (pTree) { pTree->SelectItem(m_iPlaylistIndex, true); } }