当前位置: 首页>>代码示例>>C++>>正文


C++ CActiveXUI::CreateControl方法代码示例

本文整理汇总了C++中CActiveXUI::CreateControl方法的典型用法代码示例。如果您正苦于以下问题:C++ CActiveXUI::CreateControl方法的具体用法?C++ CActiveXUI::CreateControl怎么用?C++ CActiveXUI::CreateControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CActiveXUI的用法示例。


在下文中一共展示了CActiveXUI::CreateControl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InitWindow

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"));
    }
}
开发者ID:CodeBees,项目名称:duilib-Ex-Debug,代码行数:45,代码来源:FrameWnd.cpp

示例2: InitWindow

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);
}
开发者ID:captainwong,项目名称:Player,代码行数:65,代码来源:QuizWnd.cpp

示例3: ShowQuiz

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);
//.........这里部分代码省略.........
开发者ID:captainwong,项目名称:Player,代码行数:101,代码来源:QuizWnd.cpp

示例4: InitWindow

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);
    }
}
开发者ID:jzxyouok,项目名称:libvlc-xfplay,代码行数:64,代码来源:DuiFrameWnd.cpp


注:本文中的CActiveXUI::CreateControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。