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")); } }
BOOL CALLBACK TBCIAWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { BOOL res = 0; std::map<HWND, WNDPROC>::iterator iter = g_windowInfoMap.find( hwnd ); //DEBUG_INFO("hwnd 0x%x message 0x%x wparam 0x%x lparam 0x%x\n",hwnd,message,wParam,lParam); if( iter != g_windowInfoMap.end() ) { if (message == WM_PAINT) { ShowWindow( hwnd, SW_HIDE ); } else if( message == LVM_SETITEMTEXT ) // TODO 安装细节显示 等找到消息再写 { ; } else if( message == PBM_SETPOS ) { CProgressUI* pProgress = static_cast<CProgressUI*>(g_pFrame->GetPaintManager().FindControl( g_tempParam )); pProgress->SetMaxValue( 30000 ); if( pProgress == NULL ) return 0; pProgress->SetValue( (int)wParam); if( pProgress->GetValue() == 30000 ) { CTabLayoutUI* pTab = NULL; int currentIndex; pTab = static_cast<CTabLayoutUI*>(g_pFrame->GetPaintManager().FindControl( g_installPageTabName )); if( pTab == NULL ) return -1; currentIndex = pTab->GetCurSel(); pTab->SelectItem( currentIndex + 1 ); } } else { res = CallWindowProc( iter->second, hwnd, message, wParam, lParam); } } return res; }
//创建list item BOOL CMainDlg::create_ListItem(tag_Donwload_File_Ini_Data tag_File_Data) { //获取list指针 CListUI *cList_Item = static_cast<CListUI*>(m_pm.FindControl(_T("down_list_tab"))); if(NULL == cList_Item) { return FALSE; } //创建list item节点指针 CListContainerElementUI *new_node = new CListContainerElementUI; new_node->ApplyAttributeList(_T("height=\"60\"")); //创建一个界面布局器 横向布局 高度 60 CVerticalLayoutUI *new_v_lay = new CVerticalLayoutUI; new_v_lay->ApplyAttributeList(_T("height=\"60\"")); ////////////////////////////////////////////////////////////////////////// //创建各种控件 CButtonUI *cBtn_Ico = new CButtonUI; cBtn_Ico->ApplyAttributeList( _T("name=\"ico\" float=\"true\" pos=\"5,10,0,0\" width=\"48\" height=\"38\" tooltip=\"图标..\" bkimage=\"file='exe_file.png'\"") ); CTextUI *cText_file = new CTextUI; cText_file->ApplyAttributeList( _T("name=\"file\" float=\"true\" pos=\"55,15,0,0\" width=\"300\" height=\"20\" tooltip=\"文件名..\" font=\"0\" textcolor=\"#ffffffff\"") ); cText_file->SetText(tag_File_Data.strFileName.c_str()); CTextUI *cText_Print = new CTextUI; cText_Print->ApplyAttributeList( _T("name=\"print\" float=\"true\" pos=\"55,35,0,0\" width=\"300\" height=\"20\" text=\"正在准备下载..\" tooltip=\"进度提示..\" font=\"0\" textcolor=\"#ffddd333\"") ); cText_Print->SetText(tag_File_Data.strDataPrint.c_str()); CTextUI *cText_jdtbk = new CTextUI; cText_jdtbk->ApplyAttributeList( _T("name=\"jdtbk\" float=\"true\" pos=\"300,15,0,0\" width=\"210\" height=\"7\" bkimage=\"file='progress_back.png'\"") ); CProgressUI *cProgress = new CProgressUI; cProgress->ApplyAttributeList( _T("name=\"jdt\" float=\"true\" pos=\"300,15,0,0\" width=\"210\" height=\"7\" foreimage=\"file='progress_fore.png'\"") ); cProgress->SetMaxValue(tag_File_Data.n64FileSize); cProgress->SetMinValue(0); cProgress->SetValue(tag_File_Data.n64ProgRessPos); CButtonUI *cBtn_Stop = new CButtonUI; cBtn_Stop->ApplyAttributeList( _T("name=\"stop\" float=\"true\" pos=\"400,25,0,0\" width=\"30\" height=\"30\" tooltip=\"暂停下载..\" normalimage=\"file='stop.png'\"") ); CButtonUI *cBtn_Down = new CButtonUI; cBtn_Down->ApplyAttributeList( _T("name=\"down\" float=\"true\" pos=\"440,25,0,0\" width=\"30\" height=\"30\" tooltip=\"开始下载..\" normalimage=\"file='go.png'\"") ); CButtonUI *cBtn_Open = new CButtonUI; cBtn_Open->ApplyAttributeList( _T("name=\"open\" float=\"true\" pos=\"480,25,0,0\" width=\"30\" height=\"30\" tooltip=\"打开文件..\" normalimage=\"file='ok.png'\"") ); CButtonUI *cBtn_Dele = new CButtonUI; cBtn_Dele->ApplyAttributeList( _T("name=\"dele\" float=\"true\" pos=\"520,5,0,0\" width=\"20\" height=\"20\" tooltip=\"删除任务..\" normalimage=\"file='close.png'\"") ); ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// //将创建好的控件添加到界面布局器中 new_v_lay->Add(cBtn_Ico); new_v_lay->Add(cText_file); new_v_lay->Add(cText_Print); new_v_lay->Add(cText_jdtbk); new_v_lay->Add(cProgress); new_v_lay->Add(cBtn_Stop); new_v_lay->Add(cBtn_Down); new_v_lay->Add(cBtn_Open); new_v_lay->Add(cBtn_Dele); //将界面布局器添加到list item节点中 new_node->Add(new_v_lay); //最后把list节点插入到list中 cList_Item->Add(new_node); _Nv_Download_Ex *Nv_Task_ = new _Nv_Download_Ex; Nv_Task_->m_pList = cList_Item; Nv_Task_->m_pListElement = new_node; Nv_Task_->m_pVerticalLayout = new_v_lay; Nv_Task_->m_pBtnIco = cBtn_Ico; Nv_Task_->m_pTextFile = cText_file; Nv_Task_->m_pTextPrint = cText_Print; Nv_Task_->m_pTextJdtBk = cText_jdtbk; Nv_Task_->m_pProgRess = cProgress; Nv_Task_->m_pBtnStop = cBtn_Stop; Nv_Task_->m_pBtnGo = cBtn_Down; Nv_Task_->m_pBtnOK = cBtn_Open; Nv_Task_->m_pBtnClose = cBtn_Dele; Nv_Task_->get_WndPtr(this); //数据获取 Nv_Task_->m_strUrl = tag_File_Data.strUrl; Nv_Task_->m_strFileSavePath = tag_File_Data.strPath; Nv_Task_->m_bOpenFile = tag_File_Data.bOpenFile; Nv_Task_->m_strCoolie = tag_File_Data.strCoolie; //vector<_Nv_Download_Ex*>::iterator it; //it = m_vt_Nv_Download.begin(); //m_vt_Nv_Download.insert(it, Nv_Task_); m_vt_Nv_Download.push_back(Nv_Task_); return TRUE; }