本文整理汇总了C++中CActiveXUI::GetControl方法的典型用法代码示例。如果您正苦于以下问题:C++ CActiveXUI::GetControl方法的具体用法?C++ CActiveXUI::GetControl怎么用?C++ CActiveXUI::GetControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveXUI
的用法示例。
在下文中一共展示了CActiveXUI::GetControl方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Notify
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);
}
}
}
}
示例2: Initialize
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();
}
}
}
示例3: 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"));
}
}
示例4: Notify
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();
}
}
}
示例5: OnClick
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();
}
}
}
}
示例6: 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);
}
示例7: 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);
//.........这里部分代码省略.........
示例8: Notify
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);
}
}
//.........这里部分代码省略.........