void CDuiFrameWnd::AddFiles( const std::vector<PlayFileInfo> &vctString, bool bInit ) { COptionUI *pOptionTmp; CVerticalLayoutUI* pLayout = NULL; CDuiString strTmp; TCHAR szName[_MAX_FNAME]; TCHAR szExt[_MAX_EXT]; unsigned i, uWantedCount; pLayout = static_cast<CVerticalLayoutUI*>(m_PaintManager.FindControl(_T("playlist"))); if (! pLayout) { return; } for(i = 0, uWantedCount = 0; i < vctString.size(); i++) { if (IsWantedFile(vctString[i].szFileName)) { _tsplitpath_s(vctString[i].szFileName, NULL, 0, NULL, 0, szName, _MAX_FNAME, szExt, _MAX_EXT); strTmp.Format(_T("%s%s"), szName, szExt); // 文件名 pOptionTmp = new COptionUI; pOptionTmp->SetTextColor(0xFFC8C6CB); pOptionTmp->SetHotTextColor(0xFFC8C6CB); pOptionTmp->SetSelectedTextColor(0xFFC8C6CB); pOptionTmp->SetTag(U_TAG_PLAYLIST); pOptionTmp->SetText(strTmp); pOptionTmp->SetAttribute(_T("height"), _T("22")); pOptionTmp->SetAttribute(_T("inset"), _T("7,0,0,0")); pOptionTmp->SetAttribute(_T("align"), _T("center")); pOptionTmp->SetAttribute(_T("font"),_T("4")); pOptionTmp->SetUserData(vctString[i].szFileName); pOptionTmp->SetName(vctString[i].szFileName); pOptionTmp->SetSelectedImage(_T("file='btn_bk.png'")); pLayout->Add(pOptionTmp); uWantedCount++; if (! bInit) { m_cPlayList.Add(vctString[i]); // 完整路径 } } } Rand(m_queRand, uWantedCount); ShowPlaylist(true); }
void CMainWnd::InitWindow() { // 初始化数据管理器 m_Data.Init(m_hWnd); // 创建分类按钮 CHorizontalLayoutUI* pTabBar = (CHorizontalLayoutUI*)m_PaintManager.FindControl(_T("tabbar")); if(pTabBar) { TABBTN aTypes[] = { {_T("8009|1003|1004|1007|1002|1005|1006|1001|1008"), _T("精选")}, {_T("1003"), _T("风景")}, {_T("1004"), _T("美女")}, {_T("1007"), _T("小清新")}, {_T("1002"), _T("动漫")}, {_T("1005"), _T("萌宠")}, {_T("1006"), _T("明星")}, {_T("1001"), _T("创意")}, {_T("1008"), _T("汽车")}, {_T("8009"), _T("颜色")}, }; COptionUI* pFirst = NULL; for(int i = 0; i < sizeof(aTypes) / sizeof(TABBTN); ++i) { TABBTN Tab = aTypes[i]; COptionUI* pOption = new COptionUI(); pOption->SetName(_T("wp_tabbtn")); pOption->SetText(Tab.sText); pOption->SetUserData(Tab.sType); pOption->SetGroup(_T("tabbar")); pOption->SetFixedHeight(25); pOption->SetFixedWidth(65); pOption->SetHotImage(_T("file='main/224.bmp' corner='4,4,4,4'")); pOption->SetSelectedImage(_T("file='main/224.bmp' corner='4,4,4,4'")); pOption->OnNotify += MakeDelegate(this, &CMainWnd::OnNotify1); pOption->OnNotify += MakeDelegate(this, &CMainWnd::OnNotify2); pTabBar->Add(pOption); if(pFirst == NULL) pFirst = pOption; } if(pFirst != NULL) pFirst->Selected(true); } m_Data.LoadBizhi(_T("8009|1003|1004|1007|1002|1005|1006|1001|1008"), 1, 10); }
void MainFrame::EnumInstalledDriver() { // 清空界面中list中显示的打印机列表 CContainerUI* pDriverList = static_cast<CContainerUI*>(paint_manager_.FindControl(_T("driver_list"))); if (pDriverList != NULL) pDriverList->RemoveAll(); // 枚举本地计算机上所有安装的打印机驱动(实际使用时可以只枚举自家的打印机驱动) LPBYTE lpBuffer = NULL; DWORD dwNeeded = 0,dwReturned = 0; EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 1, NULL, 0, &dwNeeded, &dwReturned); if (dwNeeded == 0) return; lpBuffer = (LPBYTE)malloc(dwNeeded); if (lpBuffer == NULL) return; EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 1, lpBuffer, dwNeeded, &dwNeeded, &dwReturned); for (DWORD dwIndex = 0; (dwIndex < dwReturned) && (pDriverList != NULL); dwIndex++) { COptionUI* pDriver = new COptionUI(); if (pDriver != NULL) { pDriver->ApplyAttributeList(_T("padding=\"15,0,0,0\" height=\"35\" textpadding=\"20,0,0,0\" align=\"left\" normalimage=\"res='124' restype='png' dest='0,10,15,25'\" hotimage=\"res='125' restype='png' dest='0,10,15,25'\" selectedimage=\"res='126' restype='png' dest='0,10,15,25'\"")); pDriver->SetText(((PRINTER_INFO_1*)lpBuffer + dwIndex)->pName); pDriverList->Add(pDriver); } } LPTSTR lpDefaultPrinter; GetDefaultPrinter(NULL, &dwNeeded); lpDefaultPrinter = (LPTSTR)malloc(dwNeeded * sizeof(TCHAR)); GetDefaultPrinter((LPTSTR)lpDefaultPrinter, &dwNeeded); free(lpDefaultPrinter); free(lpBuffer); }
void CMainDlg::Notify(TNotifyUI& msg) { //throw std::exception("The method or operation is not implemented."); //单击事件 if(msg.sType == DUI_MSGTYPE_CLICK) { //点击关闭按钮 if(msg.pSender->GetName() == _T("sys_close_btn")) //退出 Close(0); //点击添加按钮 else if(msg.pSender->GetName() == _T("add_option")) { //新建一个option按钮 CDialogBuilder builder; COptionUI * p = static_cast<COptionUI *>(builder.Create(_T("option.xml"),0,NULL,&m_pm)); if(NULL == p) return; CContainerUI * pContainer = static_cast<CContainerUI *>(m_pm.FindControl(_T("main_option_layout"))); int nCount = pContainer->GetCount(); static int i = 1; CDuiString str1; str1.Format(_T("新增按钮%d"), i); p->SetText(str1); pContainer->AddAt(p, nCount - 1); CTabLayoutUI * pTab = static_cast<CTabLayoutUI *>(m_pm.FindControl(_T("main_tab"))); if(NULL != pTab) { CDuiString str2; str2.Format(_T("新增界面%d"), i); //增加一个界面,这里可以像上边option一样使用xml创建 CButtonUI * pButton = new CButtonUI; pButton->SetTextColor(0xffffffff); pButton->SetText(str2); pTab->Add(pButton); p->SetTag(pTab->GetCount() - 1); } i++; } } //切换选项卡按钮时根据不同的按钮,选中不同的界面 else if(msg.sType == DUI_MSGTYPE_SELECTCHANGED) { if(msg.pSender->GetName() == _T("option_1")) { CTabLayoutUI * pTab = static_cast<CTabLayoutUI *>(m_pm.FindControl(_T("main_tab"))); if(NULL != pTab) { CControlUI * pControl = pTab->FindSubControl(_T("tab_01")); if(NULL != pControl) pTab->SelectItem(pControl); } } else if(msg.pSender->GetName() == _T("option_2")) { CTabLayoutUI * pTab = static_cast<CTabLayoutUI *>(m_pm.FindControl(_T("main_tab"))); if(NULL != pTab) { CControlUI * pControl = pTab->FindSubControl(_T("tab_02")); if(NULL != pControl) pTab->SelectItem(pControl); } } else if(msg.pSender->GetName() == _T("option")) { CTabLayoutUI * pTab = static_cast<CTabLayoutUI *>(m_pm.FindControl(_T("main_tab"))); pTab->SelectItem(msg.pSender->GetTag()); } } }