Ejemplo n.º 1
0
LRESULT CStockBuyUI::OnOrderReq(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	ASSERT(wParam);
	int i = static_cast<int>(lParam);

	CListTextElementUI* pElem = reinterpret_cast<CListTextElementUI*>(wParam);
	std::string sContractNumber = Base::CharacterSet::UnicodeToANSI(pElem->GetText(9));		
	//iterOrderNumber iter = std::find(vecOrderNumber.begin(), vecOrderNumber.end(), sContractNumber);
	//ASSERT(iter);
	//vecOrderNumber.erase(iter);

	DUITRACE(_T("new a order bussiness request, send to sdk."));
	return 0;
}
Ejemplo n.º 2
0
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"));
    }
}
Ejemplo n.º 3
0
    static DWORD WINAPI Search(LPVOID lpParameter)
    {
        try
        {
            struct Prama* prama = (struct Prama *)lpParameter;
            CListUI* pList = prama->pList;
            CButtonUI* pSearch = prama->pSearch;
            CStdString tDomain = prama->tDomain;
            //-------------------------------------
            /*
            * 添加数据循环
            */
            for(int i=0; i<100; i++)
            {
                std::stringstream ss;
                ss << "www." << i << ".com";
                domain.push_back(ss.str());
                ss.clear();
                ss << "it's " << i;
                desc.push_back(ss.str());
                CListTextElementUI* pListElement = new CListTextElementUI;
                pListElement->SetTag(i);
                if (pListElement != NULL)
                {
                    ::PostMessage(prama->hWnd, WM_ADDLISTITEM, 0L, (LPARAM)pListElement);
                }
                /*
                *	Sleep 为了展示添加的动态效果,故放慢了添加速度,同时可以看到添加过程中界面仍然可以响应
                */
                ::Sleep(100);
            }
            //------------------------------------------
            delete prama;

            pSearch->SetEnabled(true);
            return 0;
        }
        catch(...)
        {
            return 0;
        }
    }
Ejemplo n.º 4
0
bool ConnInfoUI::LoadConfig( const std::string& path )
{
    m_pListUI->RemoveAll();
    /// 设置利用回调填充数据
    m_pListUI->SetTextCallback(this);//[1]
    m_dicServerInfo.clear();
    
    FILE* fp = fopen(kConfigFilePath, "r");
    if (!fp) return false;

    FileStream is(fp);
    Document document;    /// Default template parameter uses UTF8 and MemoryPoolAllocator.
    if (document.ParseStream<0>(is).HasParseError())
    {
        UserMessageBox(GetHWND(), 10014, Base::CharacterSet::ANSIToUnicode(document.GetParseError()).c_str(), MB_ICONERROR);
        fclose(fp);
        return false;
    }

    const Value& serverConfig = document["Server"];
    int idx = 0;
    for (Value::ConstValueIterator itr = serverConfig.Begin(); itr != serverConfig.End(); ++itr)
    {
        const Value& subConfig = *itr;
        CDuiString name = Base::CharacterSet::UTF8ToUnicode(subConfig["name"].GetString()).c_str();
        m_dicServerInfo[kServerNameIndex].push_back(Base::CharacterSet::UnicodeToANSI(name.GetData()));
        m_dicServerInfo[kServerIpIndex].push_back(subConfig["ip"].GetString());
        std::ostringstream os;
        os<<subConfig["port"].GetInt();
        m_dicServerInfo[kServerPortIndex].push_back(os.str());
        m_dicServerInfo[kServerAuthIndex].push_back(subConfig["auth"].GetString());

        CListTextElementUI* pListElement = new CListTextElementUI;
        pListElement->SetTag(idx++);
        /// 设置工具提示
        pListElement->SetToolTip(m_pListUI->GetToolTip());
        m_pListUI->Add(pListElement);
    }
    fclose(fp);

    return true;
}
Ejemplo n.º 5
0
void CStockBuyUI::OnItemActive(TNotifyUI& msg)
{
	if (OrderList != m_iCurList)
	{
		return;
	}

	int iSelect = m_pStockOrderList->GetCurSel();
	CListTextElementUI *pNewElem = new CListTextElementUI;
	CListTextElementUI *pOldElem = static_cast<CListTextElementUI* >(m_pStockOrderList->GetItemAt(iSelect));

	m_pStockOrderList->RemoveAt(iSelect);
	
	pNewElem->SetTag(m_pStockOrderList->GetCount());
	m_pStockOrderList->AddAt(pNewElem, 0);	
	CDuiString strTime = Base::CTimeKit::GetCurDateTime(TIME_FORMAT);
	
	pNewElem->SetText(0, pOldElem->GetText(0));
	pNewElem->SetText(1, pOldElem->GetText(1));	
	pNewElem->SetText(2, pOldElem->GetText(2));
	pNewElem->SetText(3, pOldElem->GetText(3));
	pNewElem->SetText(4, pOldElem->GetText(4));
	pNewElem->SetText(5, _T(""));	
	pNewElem->SetText(6, _T("撤单"));
	pNewElem->SetText(7, strTime.Mid(0, 6));
	pNewElem->SetText(8, strTime.Mid(6,-1));
	pNewElem->SetText(9, _T("123456789"));
	pNewElem->SetText(10, pOldElem->GetText(10));
	
	//send to sdk
	//::PostMessage(GetHWND(), WM_USER_STOCK_ORDER_REQ, (WPARAM)pNewElem, 0L);
	
	OnOrderReq(GetHWND(), (WPARAM)(pNewElem), (LPARAM)(OrderBuy));
}
Ejemplo n.º 6
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));
		
		}			
	

	}
	
}