Ejemplo n.º 1
0
	IMPL_LUA_FUNC(LuaCTreeNodeUI, AddChildNode)
	{
		try
		{
			CTreeNodeUI* self;
			self = static_cast<CTreeNodeUI*>(LuaStatic::CheckUserData(l, 1));
			CTreeNodeUI* pTreeNodeUI;
			pTreeNodeUI = static_cast<CTreeNodeUI*>(LuaStatic::CheckUserData(l, 2));
			if(self->AddChildNode(pTreeNodeUI))
				lua_pushboolean(l,1);
			else
				lua_pushboolean(l,0);
			return 1;
		}
		catch (...)
		{
			DuiException(_T("LuaCTreeNodeUI::AddChildNode"));
			return 0;
		}
	}
Ejemplo n.º 2
0
void CLoginDlg::OnPrepare(TNotifyUI& msg)
{
	__super::OnPrepare(msg);
	CControlUI* pControl = m_PaintManager.FindControl("maxbtn");
	if(pControl) pControl->SetVisible(false);
	
	CCheckBoxUI* pCheckBox = (CCheckBoxUI*)m_PaintManager.FindControl("autologin");
	//pCheckBox->SetCheck(true);
	
	static CMyBrowserEventHandler eventhandle;
	CWebBrowserUI* m_pbrowserSpList = static_cast<CWebBrowserUI*>(m_PaintManager.FindControl(_T("ie")));
	if (m_pbrowserSpList)
	{
		
		m_pbrowserSpList->SetWebBrowserEventHandler(&eventhandle);
		m_pbrowserSpList->Navigate2("about:blank");
		PostMessage(WM_MSG_SET_FOCUS);
	//	m_pbrowserSpList->Navigate2("http://www.baidu.com");
	}
	CWebBrowserUI* m_pbrowserSpList1 = static_cast<CWebBrowserUI*>(m_PaintManager.FindControl(_T("ie2")));
	if (m_pbrowserSpList1)
	{

		m_pbrowserSpList1->SetWebBrowserEventHandler(&eventhandle);
		m_pbrowserSpList1->Navigate2("http://www.baidu.com");
	}

	CListUI *list = static_cast<CListUI*>(m_PaintManager.FindControl(_T("listex"))); 
	list->SetKeyboardEnabled(false);
	//³õʼ»¯Ê÷µÄÏÔʾ 
	CTreeViewUI* pTree = static_cast<CTreeViewUI*>(m_PaintManager.FindControl(_T("tree")));
	if (!pTree)
	{
		return;
	}
	pControl = m_PaintManager.FindControl(_T("drag"));
	pTree->m_pDragingCtrl = pControl;

	CTreeNodeUI* pNodeRoot = new CTreeNodeUI;
	pNodeRoot->SetAttribute(_T("folderattr"),_T("padding=\"0,1,0,0\" width=\"36\" height=\"16\" normalimage=\"file='treeview_b.png' source='0,0,36,16'\" hotimage=\"file='treeview_b.png' source='36,0,72,16'\" selectedimage=\"file='treeview_a.png' source='0,0,36,16' selectedhotimage=\"file='treeview_a.png' source='36,0,72,16'\""));
	pTree->Add(pNodeRoot);
	CDuiString strNode = "";
	strNode.Format("Ö÷»úÁбí");
	pNodeRoot->SetItemText(strNode);
	pNodeRoot->SetExpand(true);
	//m_pNodeRoot = pNodeRoot;
	for (int i = 1; i < 17; i++)
	{
		int nn = pNodeRoot->GetCountChild();
		CTreeNodeUI* pNodeParent = new CTreeNodeUI;
		pNodeRoot->AddChildNode(pNodeParent);
		pNodeParent->SetName(strNode);
		pNodeParent->SetAttribute(_T("folderattr"),_T("padding=\"0,1,0,0\" width=\"36\" height=\"16\" normalimage=\"file='treeview_b.png' source='0,0,36,16'\" hotimage=\"file='treeview_b.png' source='36,0,72,16'\" selectedimage=\"file='treeview_a.png' source='0,0,36,16' selectedhotimage=\"file='treeview_a.png' source='36,0,72,16'\""));
		CDuiString strNode = "";
		strNode.Format("Ŀ¼%d", i);
		pNodeParent->SetItemText(strNode);
		pNodeParent->SetName(strNode);
		if (i % 4 == 0)
		{
			pNodeParent->SetExpand(true);
		}
		for (int j = 1; j< 7; j++)
		{
			CTreeNodeUI* pNodeChild = new CTreeNodeUI(true);	//±íʾÊÇÒ¶×Ó½Úµã 
			CDuiString strNode = "";
			strNode.Format("%d_%d", i, j);
			pNodeChild->SetItemText(strNode);
			pNodeChild->SetName(strNode);
			pNodeParent->AddChildNode(pNodeChild);
		}
	}
}
Ejemplo n.º 3
0
void MainDialog::Notify(TNotifyUI& msg)
{
	if( msg.sType == _T("windowinit") ) 
		OnPrepare(msg);
	else if( msg.sType == _T("click") ) 
	{
		if( msg.pSender == m_pCloseBtn ) 
		{
			PostQuitMessage(0);
			return; 
		}
		else if( msg.pSender == m_pMinBtn ) 
		{ 
			SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
			return; 
		}
		else if( msg.pSender == m_pMaxBtn ) 
		{ 
			SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); return; 
		}
		else if( msg.pSender == m_pRestoreBtn ) 
		{ 
			SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); return; 
		}
		else if (msg.pSender->GetName() == _T("upload"))
		{
			
			
		}
		else if (msg.pSender == m_pClose)
		{
			
		}
	}

	else if(msg.sType==_T("setfocus"))
	{
		
	}
	else if( msg.sType == _T("itemexpand") ) 
	{
		CTreeNodeUI* pNowNode = static_cast<CTreeNodeUI*>(msg.pSender);
		pNowNode->Select(true);
		
		CTreeViewUI* pTree = static_cast<CTreeViewUI*>(m_pm.FindControl(_T("tree")));
		CListUI* pList = static_cast<CListUI*>(m_pm.FindControl(_T("file_list")));
		g_bUpdateDir = false;
		if (!pNowNode->IsHasChild())
		{
			g_bUpdateDir = true;
		}

		pList->RemoveAll();
	
		WIN32_FIND_DATA FindFileData;
		HANDLE hListFile;
		TCHAR szFilePath[MAX_PATH];



		lstrcpy(szFilePath,pNowNode->GetUserData());
		lstrcat(szFilePath, _T("\\*"));

		hListFile = FindFirstFile(szFilePath,&FindFileData);

		if(hListFile==INVALID_HANDLE_VALUE)
		{
			return;
		}
		else
		{        
			do
			{
				if(lstrcmp(FindFileData.cFileName,TEXT("."))==0||
					lstrcmp(FindFileData.cFileName,TEXT(".."))==0)
				{
					continue;
				}
	


				SYSTEMTIME  st;
				FileTimeToSystemTime(&FindFileData.ftLastWriteTime,&st);
				DWORDLONG dwlSize = (DWORDLONG)(FindFileData.nFileSizeHigh * (MAXDWORD+1)) + FindFileData.nFileSizeLow;
				DWORD dwSize = (DWORD)(dwlSize / 1024);

				if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
				{	
					if (g_bUpdateDir)
					{
						CTreeNodeUI* pNode = new CTreeNodeUI;
						pNode->SetAttribute(_T("folderattr"),_T("padding=\"0,1,0,0\" width=\"36\" height=\"16\" normalimage=\"file='treeview_b.png' source='0,0,36,16'\" hotimage=\"file='treeview_b.png' source='36,0,72,16'\" selectedimage=\"file='treeview_a.png' source='0,0,36,16' selectedhotimage=\"file='treeview_a.png' source='36,0,72,16'\""));
						pNowNode->AddChildNode(pNode);
						pNode->SetItemText(FindFileData.cFileName);
						CDuiString szUserData = pNowNode->GetUserData() + _T("\\") + pNode->GetItemText();
						pNode->SetUserData(szUserData);
					}
					
				}
				else
				{
					CListTextElementUI* pLine = new CListTextElementUI;
					pList->Add(pLine);
					CDuiString szNewName(FindFileData.cFileName);
					
					int pos = szNewName.ReverseFind('.');
					CDuiString szExt = szNewName.Right(szNewName.GetLength() - pos);
					SHFILEINFO shfi;
					memset(&shfi,0,sizeof(shfi));
					SHGetFileInfo(szExt,
						FILE_ATTRIBUTE_NORMAL,
						&shfi,
						sizeof(shfi),
						SHGFI_ICON|SHGFI_USEFILEATTRIBUTES);

					pLine->SetIcon(0,shfi.hIcon);
				
					pLine->SetText(0,szNewName);

					SYSTEMTIME  st;
					FileTimeToSystemTime(&FindFileData.ftLastWriteTime,&st);
					CDuiString szTime;
					szTime.Format(_T("%04d/%02d/%02d %02d:%02d:%02d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
					pLine->SetText(1,szTime);

					DWORDLONG dwlSize = (DWORDLONG)(FindFileData.nFileSizeHigh * (MAXDWORD+1)) + FindFileData.nFileSizeLow;
					CDuiString szSize;
					if (dwlSize <1024)
					{
						szSize.Format(_T("%ldB"),dwlSize);
					}
					else
					{
						szSize.Format(_T("%ldK"),dwlSize/1024);
					}

					pLine->SetText(2,szSize);

					CDuiString szArrtib;
					szArrtib.Format(_T("%d"),FindFileData.dwFileAttributes);
					pLine->SetText(3,szArrtib);
					
				}
			}
			while(FindNextFile(hListFile, &FindFileData));
		
		}			
	

	}
	
}