Example #1
0
CString CTreePropSheet::SplitPageTreePath(CString &strRest)
{
	int	nSeperatorPos = 0;
	while (TRUE)
	{
		nSeperatorPos = strRest.Find(_T("::"), nSeperatorPos);
		if (nSeperatorPos == -1)
		{
			CString	strItem(strRest);
			strRest.Empty();
			return strItem;
		}
		else if (nSeperatorPos>0)
		{
			// if there is an odd number of backslashes infront of the
			// seperator, than do not interpret it as separator
			int	nBackslashCount = 0;
			for (int nPos = nSeperatorPos-1; nPos >= 0 && strRest[nPos]==_T('\\'); --nPos, ++nBackslashCount);
			if (nBackslashCount%2 == 0)
				break;
			else
				++nSeperatorPos;
		}
	}

	CString	strItem(strRest.Left(nSeperatorPos));
	strItem.Replace(_T("\\::"), _T("::"));
	strItem.Replace(_T("\\\\"), _T("\\"));
	strRest = strRest.Mid(nSeperatorPos+2);
	return strItem;
}
int CXTPShortcutListBox::GetTextHeight(LPCTSTR lspzItem) const
{
    CWindowDC dc(NULL);

    CString strItem(lspzItem);

    // get the height for a single line text item.
    CFont* pOldFont = dc.SelectObject(GetFont());
    CSize size = dc.GetTextExtent(strItem);
    dc.SelectObject(pOldFont);

    // set the height of the item with single line text.
    int iTextHeight = size.cy;

    // for each newline character we need to adjust the height.
    for (int i = 0; i < strItem.GetLength(); ++i)
    {
        if (strItem[i] == _T('\n'))
        {
            iTextHeight += size.cy;
        }
    }

    return iTextHeight;
}
QWidget *SpreadSheetDelegate::createEditor(QWidget *parent,
                                          const QStyleOptionViewItem &,
                                          const QModelIndex &index) const
{
    if (index.column() == 1) {
        QDateTimeEdit *editor = new QDateTimeEdit(parent);
        editor->setDisplayFormat("dd/M/yyyy");
        editor->setCalendarPopup(true);
        return editor;
    }

    QLineEdit *editor = new QLineEdit(parent);

    // create a completer with the strings in the column as model
    QStringList allStrings;
    for (int i = 1; i<index.model()->rowCount(); i++) {
        QString strItem(index.model()->data(index.sibling(i, index.column()),
            Qt::EditRole).toString());

        if (!allStrings.contains(strItem))
            allStrings.append(strItem);
    }

    QCompleter *autoComplete = new QCompleter(allStrings);
    editor->setCompleter(autoComplete);
    connect(editor, &QLineEdit::editingFinished, this, &SpreadSheetDelegate::commitAndCloseEditor);
    return editor;
}
Example #4
0
BOOL COXCsvFile::WriteColumn(int nColumn, LPCTSTR lpszText, BOOL bQuote)
{
	CString	strSpecialChars;	// the field and string delimiters, and line break characters

	strSpecialChars=m_tcFieldDelim;
	strSpecialChars+=m_tcStringDelim;
	strSpecialChars+=_T("\r\n");

	SetError(errNone);
	
	if(nColumn<0 || nColumn>=m_nColumns)
	{
		SetError(errBadColumnIndex);
		return FALSE;
	}

	//
	// Important: The string needs to be quoted if one of the following conditions 
	// is met:
	//	1. The string contains one of the following characters:
	//		a. the field delimiter character
	//		b. the string delimiter character
	//		c. carraige return
	//		d. line feed
	//	2. The string begins with a whitespace character
	//	3. The string ends with a whitespace character
	//
	if(!bQuote
		&& _tcscspn(lpszText,strSpecialChars)>=_tcslen(lpszText)
		&& !_istspace(lpszText[0])
		&& !_istspace(lpszText[_tcslen(lpszText)-1]))
	{
		m_arrColumns[nColumn].m_strData=lpszText;
	}
	else
	{
		CString	strItem(m_tcStringDelim);
		for(int nIndex=0; lpszText[nIndex]!=tcNulc; ++nIndex)
		{
			if(lpszText[nIndex]==m_tcStringDelim)
			{
				strItem+=m_tcStringDelim;
				strItem+=m_tcStringDelim;
			}
			else
			{
				strItem+=lpszText[nIndex];
			}
		}
		strItem+=m_tcStringDelim;
		
		m_arrColumns[nColumn].m_strData=strItem;
		m_arrColumns[nColumn].m_nType=tString;
	}

	return TRUE;
}
Example #5
0
void CRegisterExport::ShellImportRegister(LPCTSTR lpImportFile)
{
	CString strItem(lpImportFile);
	CString strParameters;

	strParameters = _T("/s \"") + strItem + _T("\"");
	ShellExecute(NULL, _T("open"), _T("regedit.exe"),
		strParameters,NULL,SW_HIDE);
}
Example #6
0
void CRegisterExport::ShellExportRegister(LPCTSTR lpExportStr,LPCTSTR lpExportFile)
{
	CString strItem(lpExportStr);
	CString strFileName(lpExportFile);
	CString strFilePath;
	CString strParameters;
	int nIndex = 0;

	strParameters = _T("/e \"") + strFileName + _T("\" \"") + strItem + _T("\"");
	ShellExecute(0, _T("open"), _T("regedit.exe"),
		strParameters, NULL	, SW_SHOWNORMAL);
}
// Hook handler
long CCppWindowsHookDlg::OnHookKeyboard(WPARAM wParam, LPARAM lParam)
{
	CString str;
	GetKeyNameText(lParam, str.GetBuffer(80), 80);
	str.ReleaseBuffer();

	CString strItem(L"User strike:" + str + L"\r\n");

	// Add key data into the editing box
	CString strEdit;
	GetDlgItem(IDC_MSG)->GetWindowText(strEdit);
	GetDlgItem(IDC_MSG)->SetWindowText(strItem + strEdit);

	return 0;
}
QWidget *PhysObjectPropDelegate::createEditor(QWidget *pParent, const QStyleOptionViewItem &viewItem, const QModelIndex &index) const {
    //qDebug("PhysObjectPropDelegate::createEditor()");
    QLineEdit *pEdit = new QLineEdit(pParent);

    // create a completer with the strings in the column as model
    QStringList allStrings;
    for (int i = 1; i < index.model() -> rowCount(); i++) {
        QString strItem(index.model() -> data(index.sibling(i, index.column()), Qt::EditRole).toString());
        if (!allStrings.contains(strItem))
            allStrings.append(strItem);
    }
    QCompleter *pAutoComplete = new QCompleter(allStrings);
    pEdit -> setCompleter(pAutoComplete);
    connect(pEdit, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
    return pEdit;
}
Example #9
0
BOOL CMDXMaterialPage::IsMinMoldTemperature( CDataExchange *pDX ) 
{ 
	CString strItem("");
	GetDlgItem(IDC_EDIT_MIN_MOLD_TEMPERATURE)->GetWindowText(strItem);
    
	if( !IsRealParse( pDX, IDC_EDIT_MIN_MOLD_TEMPERATURE, strItem ) )
    {
        return FALSE;
    }

	if( !CheckInputValue( pDX, IDC_EDIT_MIN_MOLD_TEMPERATURE, atof(strItem)))
	{
		return FALSE;
	}

	SetMinMoldTemperature(atof(strItem));
	return TRUE;
}
Example #10
0
		int32 FindString(FArrayHelper* arrayHelper, const TCHAR* item)
		{
			// FString
			if (arrayHelper->GetElementProperty()->IsA<UStrProperty>())
			{
				FString strItem(item);
				return arrayHelper->Find(&strItem);
			}
			// FName
			if (arrayHelper->GetElementProperty()->IsA<UNameProperty>())
			{
				FName nameItem(item);
				return arrayHelper->Find(&nameItem);
			}
			// couldn't convert the string to the array element type
			check(false);
			return INDEX_NONE;
		}
Example #11
0
void CBCGPGlobalUtils::StringAddItemQuoted (CString& strOutput, LPCTSTR pszItem, BOOL bInsertBefore, TCHAR charDelimiter, TCHAR charQuote)
{
	CString strItem(pszItem);

	TCHAR special[] = {charDelimiter, charQuote, 0};
	if (strItem.IsEmpty () || strItem.FindOneOf (special) >= 0)
	{
		TCHAR singleQuote[] = {charQuote, 0};
		TCHAR doubleQuote[] = {charQuote, charQuote, 0};
		strItem.Replace (singleQuote, doubleQuote);

		CString strTemp;
		strTemp.Format (_T("%c%s%c"), charQuote, strItem, charQuote);
		strItem = strTemp;
	}

	CString strTemp;
	if (strOutput.IsEmpty ())
	{
		if (bInsertBefore)
		{
			strTemp.Format(_T("%s%s"), strItem, strOutput);
		}
		else
		{
			strTemp.Format(_T("%s%s"), strOutput, strItem);
		}
	}
	else
	{
		if (bInsertBefore)
		{
			strTemp.Format(_T("%s%c%s"), strItem, charDelimiter, strOutput);
		}
		else
		{
			strTemp.Format(_T("%s%c%s"), strOutput, charDelimiter, strItem);
		}
	}

	strOutput = strTemp;
}
Example #12
0
// 解析微代码的子代码
// pszItem [IN]  子微代码
// Item    [OUT] 微代码数据
bool CMicroCode::ParseItem(const char *pszItem, MICROCODE_ITEM &Item)
{
    if (NULL == pszItem) return false;

    TRACE("%s ", pszItem);

    std::string strItem(pszItem);

    int nIndex = strItem.find("<-");
    if (-1 != nIndex)   // 有总线操作
    {
        std::string strLeft = strItem.substr(0, nIndex);
        std::string strRight = strItem.substr(nIndex+2);
        
        return ParseRegMemOper(strLeft, strRight, Item);
    }
    else
    {
        return ParseALUOper(pszItem, Item);
    }
}
Example #13
0
void
MenuItem::mouseReleaseEvent( QMouseEvent* e )
{
	// If use clicked on the xk-menu and released outside ignore that
	if( !m_mouseOver ) return;	

	// If this item has a sub menu, don't do anything on clicks
	if( m_sub )
	{
		QButton::mouseReleaseEvent( e );
		return;
	}

	// Hide xk-menu
	topLevelWidget()->hide();
	
	// If this is a real item created from .desktop execute it
	if( m_desktop )
	{
		KApplication::startServiceByDesktopPath( m_desktop->fileName() );
		if( m_updateRecent )
		{
    		QString strItem(m_desktop->fileName());

    		// don't add an item from root kmenu level
    		if (!strItem.contains('/'))
    		{
	        	return;
	    	}

	    	// add it into recent apps list
	    	RecentlyLaunchedApps::the().appLaunched(strItem);
	    	RecentlyLaunchedApps::the().save();
	    	RecentlyLaunchedApps::the().m_bNeedToUpdate = true;
    	}
	}
	
	// Pass the event back to QButton
	QButton::mouseReleaseEvent( e );
}
Example #14
0
BOOL CCustomAutoComplete::LoadList(LPCTSTR pszFileName)
{
	FILE* fp = _tfsopen(pszFileName, _T("rb"), _SH_DENYWR);
	if (fp == NULL)
		return FALSE;

	// verify Unicode byte-order mark 0xFEFF
	WORD wBOM = fgetwc(fp);
	if (wBOM != 0xFEFF){
		fclose(fp);
		return FALSE;
	}

	TCHAR szItem[256];
	while (_fgetts(szItem, ARRSIZE(szItem), fp) != NULL){
		CString strItem(szItem);
		strItem.Trim(_T(" \r\n"));
		AddItem(strItem, -1);
	}
	fclose(fp);
	return TRUE;
}
	BOOL CDuiAutoComplete::LoadList(LPCTSTR pszFileName)
	{
		FILE* fp = _tfsopen(pszFileName, _T("rb"), _SH_DENYWR);
		if (fp == NULL)
			return FALSE;

		// УÑé Unicode ±àÂë×Ö½ÚÐò mark 0xFEFF
		WORD wBOM = fgetwc(fp);
		if (wBOM != 0xFEFF){
			fclose(fp);
			return FALSE;
		}

		TCHAR szItem[256];
		while (_fgetts(szItem, ARRSIZE(szItem), fp) != NULL){
			CDuiString strItem(szItem);
			strItem.Replace(_T("\r"),_T(""));
			strItem.Replace(_T("\n"),_T(""));
			AddItem(strItem, -1);
		}
		fclose(fp);
		return TRUE;
	}
Example #16
0
// Hook handler(WH_KEYBOARD_LL)
// wParam specifies the virtual key code
// lParam specifies the scan code
long CCppWindowsHookDlg::OnHookLowKeyboard(WPARAM wParam, LPARAM lParam)
{	
	CString str;
	// Convert the virtual key code into a scancode (as required by GetKeyNameText).
	UINT scanCode = MapVirtualKeyEx(wParam, 0, GetKeyboardLayout(0));
    switch(wParam)
    {
		// Certain keys end up being mapped to the number pad by the above function,
		// as their virtual key can be generated by the number pad too.
		// If it's one of the known number-pad duplicates, set the extended bit:
		case VK_INSERT:
		case VK_DELETE:
		case VK_HOME:
		case VK_END:
		case VK_NEXT:  // Page down
		case VK_PRIOR: // Page up
		case VK_LEFT:
		case VK_RIGHT:
		case VK_UP:
		case VK_DOWN:
		  scanCode |= 0x100; // Add extended bit
		  break;
    }      

    // GetKeyNameText() expects the scan code to be on the same format as WM_KEYDOWN
    GetKeyNameText(scanCode << 16, str.GetBuffer(80), 80);
    str.ReleaseBuffer();

	CString strItem(L"Keyboard input:" + str + L"\r\n");

	// Add key data into the editing box
	CString strEdit;
	GetDlgItem(IDC_MSG)->GetWindowText(strEdit);
	GetDlgItem(IDC_MSG)->SetWindowText(strItem + strEdit);

	return 0;
}
void CTemplateWizardDialog::DocumentComplete(LPDISPATCH pDisp, VARIANT* URL)
{
	UNUSED_ALWAYS(pDisp);
//	ASSERT(V_VT(URL) == VT_BSTR);

	CString str(V_BSTR(URL));

	// Load in the new file...
    HRESULT       hr;
    LPUNKNOWN     pUnkContainedBrowser = NULL;
    LPUNKNOWN     pUnkDispParam = NULL;
    IStream       *pStream = NULL;
    HGLOBAL       hHTMLText;
	CComPtr<IDispatch> pDispDocument;
//	HWND shellWnd;
//	HWND ieWnd;

    // Test for valid pointers.
    if (!m_pBrowserApp || !pDisp)
        goto CleanUp;

    // To test object equality, use COM identity rules: query both 
    // pointers for IUnknown and compare them.
    hr = m_pBrowserApp->QueryInterface(IID_IUnknown, 
        (void**)&pUnkContainedBrowser);
    if (hr)
        goto CleanUp;

    // Query the passed-in IDispatch for IUnknown.
    hr = pDisp->QueryInterface(IID_IUnknown, 
        (void**)&pUnkDispParam);
    if (hr)
        goto CleanUp;

    // If they're unequal, the event is for a subframe and we're not
    // interested.
    if (pUnkContainedBrowser != pUnkDispParam)
        goto CleanUp;

    // As a further check, make sure the URL is "about:blank".
    if (str == "about:blank")
	{
		// The string is about:blank.  This means load the correct page.
		LONG len = (LONG)m_htmlFile.GetLength();
		BYTE* data = m_htmlFile.Detach();
		hHTMLText = GlobalAlloc(GPTR, len + 1);
		if (!hHTMLText)
			goto CleanUp;

		memcpy((CHAR *)hHTMLText, (char*)data, len);
		*(char*)((char*)hHTMLText + len) = 0;

		free(data);

		hr = ::CreateStreamOnHGlobal(hHTMLText, TRUE, &pStream);
		if (hr)
			goto CleanUp;

		// Call the helper function to load the WebOC from the stream.
		//
		hr = LoadWebOCFromStream(m_pBrowserApp, pStream);

		goto CleanUp;
	}
	
/*	// Set the focus to the right window.
	shellWnd = ::FindWindowEx(m_wndBrowser.GetSafeHwnd(), NULL, "Shell DocObject View", NULL);
	ieWnd = ::FindWindowEx(shellWnd, NULL, "Internet Explorer_Server", NULL);
	::SetFocus(ieWnd);
*/
	// Set to the first available input field.
	m_pBrowserApp->get_Document(&pDispDocument);

	if (pDispDocument)
	{
		CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDocument(pDispDocument);

		// Get all of the HTML elements.
		CComPtr<IHTMLElementCollection> pElements;
		pDocument->get_all(&pElements);

		CComVariant nullVariant;
		CComPtr<IDispatch> pDispFirstElement;

		// Now get the INPUT elements.
		CComPtr<IDispatch> pDispInputElements;
		pElements->tags(CComVariant("INPUT"), &pDispInputElements);
		if (pDispInputElements)
		{
			CComQIPtr<IHTMLElementCollection, &IID_IHTMLElementCollection> pInputElements(pDispInputElements);
			if (pInputElements)
			{
				long count;
				pInputElements->get_length(&count);

				for (int i = 0; i < count; i++)
				{
					// Get the element, if it exists.
					CComPtr<IDispatch> pDispElement;
					pInputElements->item(CComVariant(i), nullVariant, &pDispElement);
					if (!pDispElement)
						continue;

					CComQIPtr<IHTMLElement, &IID_IHTMLElement> pElement(pDispElement);
					if (!pElement)
						continue;		//??

					CComBSTR bstrID;
					pElement->get_id(&bstrID);

					CComQIPtr<IHTMLInputElement, &IID_IHTMLInputElement> pInputElement(pElement);
					if (!pInputElement)
						continue;		//??

					// Get the type.
					CComBSTR bstrType;
					pInputElement->get_type(&bstrType);
					CString strType(bstrType);
					
					CString id(bstrID);
					CString value;
					if (!m_params.Lookup(id, value))
					{
						value = m_code.GetEntry(id);
					}

					if (strType == "text")
					{
						value = g_wwhizTemplateManager->ParseCode(value, NULL, &m_code);
						pInputElement->put_value(CComBSTR(value));

						if (!pDispFirstElement)
							pDispFirstElement = pDispElement;
					}
					else if (strType == "checkbox")
					{
						pInputElement->put_checked(value == "1" ? VARIANT_TRUE : VARIANT_FALSE);
					}
					else if (strType == "radio")
					{
						pInputElement->put_checked(value == "1" ? VARIANT_TRUE : VARIANT_FALSE);
					}
					else if (strType == "file")
					{
						CComQIPtr<IHTMLInputFileElement,
							&IID_IHTMLInputFileElement> pInputFileElement(pElement);
						if (!pInputFileElement)
							continue;		//??

						value = g_wwhizTemplateManager->ParseCode(value, NULL, &m_code);
						pInputFileElement->put_value(CComBSTR(value));

						if (!pDispFirstElement)
							pDispFirstElement = pDispElement;
					}
				}
			}
		}

		// Now get the SELECT elements.
		CComPtr<IDispatch> pDispSelectElements;
		pElements->tags(CComVariant("SELECT"), &pDispSelectElements);
		if (pDispSelectElements)
		{
			CComQIPtr<IHTMLElementCollection, &IID_IHTMLElementCollection> pSelectElements(pDispSelectElements);
			if (pSelectElements)
			{
				long count;
				pSelectElements->get_length(&count);

				for (int i = 0; i < count; i++)
				{
					// Get the element, if it exists.
					CComPtr<IDispatch> pDispElement;
					pSelectElements->item(CComVariant(i), nullVariant, &pDispElement);
					if (!pDispElement)
						continue;

					CComQIPtr<IHTMLElement, &IID_IHTMLElement> pElement(pDispElement);
					if (!pElement)
						continue;		//??

					CComBSTR bstrID;
					pElement->get_id(&bstrID);

					CComQIPtr<IHTMLSelectElement, &IID_IHTMLSelectElement> pSelectElement(pElement);
					if (!pSelectElement)
						continue;		//??

					// Get the type.
					CComBSTR bstrType;
					pSelectElement->get_type(&bstrType);
					CString strType(bstrType);
					
					CString id(bstrID);
					CString value;
					if (!m_params.Lookup(id, value))
					{
						value = m_code.GetEntry(id);
					}

					// This is the only way I can figure out to do this!

					// Match the name.
					long optionCount;
					pSelectElement->get_length(&optionCount);
					int j;
					for (j = 0; j < optionCount; j++)
					{
						// Get the item at the index.
						CComPtr<IDispatch> pDispOptionElement;
						pSelectElement->item(CComVariant(j), nullVariant, &pDispOptionElement);
						if (pDispOptionElement)
						{
							CComQIPtr<IHTMLOptionElement, &IID_IHTMLOptionElement> pOptionElement(pDispOptionElement);

							CComBSTR bstrItem;
							pOptionElement->get_text(&bstrItem);
							CString strItem(bstrItem);
							if (value == strItem)
							{
								pSelectElement->put_selectedIndex(j);
								break;
							}
						}
					}

					if (j == optionCount)
					{
						pSelectElement->put_selectedIndex(0);
					}
				}
			}
		}

		if (pDispFirstElement)
		{
			CComQIPtr<IHTMLControlElement, &IID_IHTMLControlElement> pHtmlElement(pDispFirstElement);
			pHtmlElement->focus();
			CComQIPtr<IHTMLInputTextElement, &IID_IHTMLInputTextElement> pElement(pDispFirstElement);
			if (pElement)
			{
				pElement->select();
			}
		}
	}

CleanUp:
    if (pStream)
        pStream->Release();
    if (pUnkContainedBrowser)
        pUnkContainedBrowser->Release();
    if (pUnkDispParam)
        pUnkDispParam->Release();

	if (!m_asciiFilename.IsEmpty())
	{
		_unlink(m_asciiFilename);
		m_asciiFilename.Empty();
	}
}
Example #18
0
BOOL CConfigFrame::DisplayContextBranch()
{   TCHAR p;
    int i, iPos, iLen, iLeft, iChars=0;
    CString strCmdLine(_T("")), strContext(_T(""));
    CString strItem(_T("")), strClass(_T("")), strSubItem(_T("")); 
    HTREEITEM hTreeItem=NULL, hChildItem=NULL, hShowItem=NULL;

    // Check for command line option
    CVcbfApp *theApp = (CVcbfApp *)AfxGetApp();
    if (!theApp)
       return FALSE;

    if (theApp->m_lpCmdLine)
      strCmdLine = theApp->m_lpCmdLine;

    strCmdLine.MakeLower();
    //
    // DBCS Compliant:
    iPos = strCmdLine.Find(_T("/c=\""));
    if (iPos != -1)
    { 
      iLen = strCmdLine.GetLength();
      iLeft = iPos + 4;
      for (i=iLeft; i<iLen; i++)
      { 
        p = strCmdLine.GetAt(i);
        if (p == _T('\"'))
        { 
          break;
        }
        iChars++;
      }
      
      strContext=strCmdLine.Mid(iLeft, iChars);
    }
    else
      strContext=_T("Name Server");

    // Take the context string and divide it into Branch and Sub-Branch
    // If no subitem is specified, "(default)" is used
       
    if (strContext.IsEmpty())
       return FALSE;    

    iPos = strContext.Find(_T("\\"));
    if (iPos != -1)
    { strClass = strContext.Left(iPos);
      strSubItem = strContext.Right(strContext.GetLength() - iPos - 1);
    }
    else
    { strClass = strContext;
      strSubItem = GetLocDefConfName();
    }

    CConfLeftDlg* pLeftDlg = GetCConfLeftDlg();
	if (!pLeftDlg) 
       return FALSE;

    // Search through the first level of the tree
    hTreeItem = pLeftDlg->m_tree_ctrl.GetChildItem(pLeftDlg->m_tree_ctrl.GetRootItem());
  
    while (hTreeItem)
    { 
      strItem = pLeftDlg->m_tree_ctrl.GetItemText(hTreeItem);
	
	  if (strItem.CompareNoCase(strClass) == 0)
      { pLeftDlg->m_tree_ctrl.Expand(hTreeItem, TVE_EXPAND);
        hShowItem=hTreeItem;
        break;
      }

      hTreeItem = pLeftDlg->m_tree_ctrl.GetNextSiblingItem(hTreeItem);
    }

    // Search through child items if necessary
    hChildItem = pLeftDlg->m_tree_ctrl.GetChildItem(hTreeItem);
    
    while (hChildItem)
    { 
      strItem = pLeftDlg->m_tree_ctrl.GetItemText(hChildItem);
	
	  if (strItem.CompareNoCase(strSubItem) == 0)
      { hShowItem=hChildItem;
        break;
      }
      
      hChildItem = pLeftDlg->m_tree_ctrl.GetNextSiblingItem(hChildItem);
    }

    // Select the item that was found and display the right pane 
    if (hShowItem)
       pLeftDlg->m_tree_ctrl.Select(hShowItem,TVGN_CARET);
 
    return TRUE;
}
Example #19
0
afx_msg LRESULT CCppWindowsHookDlg::OnShellnotify(WPARAM wParam, LPARAM lParam)
{
	//GetKeyNameText(lParam, str.GetBuffer(80), 80);
	//str.ReleaseBuffer();
	//CWnd* pwnd = CWnd::FromHandle((HWND)wParam);
	//CString strName;
	//pwnd->GetWindowText(strName);
	DWORD ThreadID = -1;
	DWORD ProcessID = -1;
	ThreadID = GetWindowThreadProcessId((HWND)wParam, &ProcessID);
	//HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
	//if (hSnapshot == INVALID_HANDLE_VALUE)
	//{
	//	CloseHandle(hSnapshot);
	//	return 0;
	//}

	//CString infoStr;
	//PROCESSENTRY32 pe32;
	//DWORD id = 0;
	//pe32.dwSize = sizeof(PROCESSENTRY32);
	//if (!Process32First(hSnapshot, &pe32))
	//{	
	//	infoStr.Format(_T("Get Process Error, status(%d)"), GetLastError());
	//	CloseHandle(hSnapshot);
	//}
	//else
	//{
	//	do
	//	{
	//		if (ProcessID == pe32.th32ProcessID)
	//		{
	//			infoStr.Format(_T("Process Name is %s"), pe32.szExeFile);
	//			break;
	//		}
	//			
	//	} while (Process32Next(hSnapshot, &pe32));

	//	CloseHandle(hSnapshot);
	//}
	CString csCmdLine;
#if 0

	//Method One:
	{
		smPROCESSINFO pi;
		GetNtProcessInfoViaPid(ProcessID, &pi);
		CString csCmdLine = pi.szCmdLine;
	}
#else
	//Method Two:
	{
		HANDLE hProcess;
		UpgradeProcessPrivilege(GetCurrentProcess(), SE_DEBUG_NAME);	//提升本进程的权限
		PROCESSENTRY32 pe;
		ZeroMemory(&pe, sizeof(PROCESSENTRY32));
		pe.dwSize = sizeof(PROCESSENTRY32);

		hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcessID);	//打开进程
		if (hProcess != 0)
		{
			char *strDestCommand;
			COMMANDLINEINFO cli;
			ZeroMemory(&cli, sizeof(COMMANDLINEINFO));
			if (GetProcessCommandLineInfo(hProcess, &cli))	//获取进程的命令行信息
			{
				try
				{
					strDestCommand = new char[cli.iDestCommandLength + 1];
					ZeroMemory(strDestCommand, cli.iDestCommandLength + 1);
					//读取目标进程的命令行文本
					ReadProcessMemory(hProcess,
						(const void *)cli.dwDestCommand_addr,
						strDestCommand,
						cli.iDestCommandLength,
						NULL);
					//csCmdLine.Format(_T("%s"), strDestCommand);
					csCmdLine = strDestCommand;
					delete[]strDestCommand;
				}
				catch (...)
				{
					//cout << "发生异常!\n" << endl;
					MessageBox(_T("exception happened"));
				}
			}
			else
			{
				//cout << "程序名:" << pe.szExeFile << "\n" << endl;
				MessageBox(_T("Process Name is %s"), pe.szExeFile);
			}
			CloseHandle(hProcess);	//关闭进程句柄
		}
	}
#endif
	CString strID;
	strID.Format(_T("New Process ID(%d) created, CmdLine:  "), ProcessID);
	CString strItem(strID + csCmdLine + L"\r\n");
	// Add key data into the editing box
	CString strEdit;
	GetDlgItem(IDC_MSG)->GetWindowText(strEdit);
	GetDlgItem(IDC_MSG)->SetWindowText(strItem + strEdit);

	return 0;
}
Example #20
0
BOOL KAwardSetting::ReadAssetAwardConfigs()
{
	CHAR szLevelAwardName[_MAX_PATH];
	ITabFile* pAssetAwardFile = NULL;
	QString szFileTemp;

	ITabFile* pTabFile = g_OpenTabFile(ASSET_AWARD_FILE);
	QCONFIRM_RET_FALSE(pTabFile);

	for (INT i = 1; i < pTabFile->GetHeight(); i++)
	{
		QModuleAssetAward* pModuleAssetAward = new QModuleAssetAward();
		QCONFIRM_RET_FALSE(pModuleAssetAward);

		pTabFile->GetString(i + 1, "ModuleName", "", pModuleAssetAward->szModuleName, MAX_NAME_LEN);
		pTabFile->GetString(i + 1, "LevelAwardName", "", szLevelAwardName, _MAX_PATH);

		szFileTemp = ASSET_AWARD_FILE_FOLDER;
		szFileTemp = szFileTemp + szLevelAwardName;

		pAssetAwardFile = g_OpenTabFile(szFileTemp.CStr());
		assert(pAssetAwardFile);
		QCONFIRM_RET_FALSE(pAssetAwardFile);

		for (INT j = 2; j < pAssetAwardFile->GetHeight(); j++)
		{
			QAssetAward* pAssetAward = new QAssetAward();
			QCONFIRM_RET_FALSE(pAssetAward);

			pAssetAwardFile->GetInteger(j + 1, "Level", 0, &pAssetAward->nLevel);

			pAssetAwardFile->GetInteger(j + 1, "IsSave", 0, &pAssetAward->nSave);
			pAssetAwardFile->GetInteger(j + 1, "OverlayDay", 0, &pAssetAward->nOverlayDay);
			pAssetAwardFile->GetInteger(j + 1, "AutoGive", 0, &pAssetAward->nAutoGive);
			pAssetAwardFile->GetInteger(j + 1, "IsSync", 0, &pAssetAward->nSync);

			pAssetAwardFile->GetInteger(j + 1, "FightingSpirit", 0, &pAssetAward->nFightingSpirit);
			pAssetAwardFile->GetInteger(j + 1, "Energy", 0, &pAssetAward->nEnergy);
			pAssetAwardFile->GetInteger(j + 1, "Prestige", 0, &pAssetAward->nPrestige);
			pAssetAwardFile->GetInteger(j + 1, "Silver", 0, &pAssetAward->nSilver);
			pAssetAwardFile->GetInteger(j + 1, "Exp", 0, &pAssetAward->nExpAwardId);

			ZeroMemory(&pAssetAward->arrAwardItem, sizeof(pAssetAward->arrAwardItem));

			for(INT k = 0; k < ASSET_AWARD_MAX_ITEM_NUM; ++k)
			{
				CHAR szItem[20];
				CHAR szTabItem[10];
				CHAR szTabItemAmountMin[20];
				CHAR szTabItemAmountMax[20];
				CHAR szTabItemRate[15];
				CHAR szTabItemTimeOut[20];

				snprintf(szTabItem, sizeof(szTabItem), "Item%d", k + 1);
				snprintf(szTabItemAmountMin, sizeof(szTabItemAmountMin), "Item%dAmountMin", k + 1);
				snprintf(szTabItemAmountMax, sizeof(szTabItemAmountMax), "Item%dAmountMax", k + 1);
				snprintf(szTabItemRate, sizeof(szTabItemRate), "Item%dRate", k + 1);
				snprintf(szTabItemTimeOut, sizeof(szTabItemTimeOut), "Item%dTimeOut", k + 1);

				pAssetAwardFile->GetString(j + 1, szTabItem, "", szItem, 20);
				std::string strItem(szItem);

				if(!strItem.size())
				{
					pAssetAward->nItemNum = k;
					break;
				}

				{
					INT nIdx = 0;
					std::basic_string<char>::size_type iBegin = 0, iEnd = 0;
					while((iEnd = strItem.find(',', iBegin)) != std::string::npos)
					{
						switch(nIdx++)
						{
						case 0:
							pAssetAward->arrAwardItem[k].sIndex.nGenre = atoi((strItem.substr(iBegin, iEnd - iBegin)).c_str());
							break;
						case 1:
							pAssetAward->arrAwardItem[k].sIndex.nDetailType = atoi((strItem.substr(iBegin, iEnd - iBegin)).c_str());
							break;
						case 2:
							pAssetAward->arrAwardItem[k].sIndex.nParticular = atoi((strItem.substr(iBegin, iEnd - iBegin)).c_str());
							break;
						default:
							ASSERT(FALSE);
						}
						iBegin = iEnd + 1;
					}
					if(iBegin < strItem.size())
					{
						pAssetAward->arrAwardItem[k].sIndex.nLevel = atoi((strItem.substr(iBegin, strItem.size() - iBegin)).c_str());
					}
				}

				pAssetAwardFile->GetInteger(j + 1, szTabItemAmountMin, 0, &pAssetAward->arrAwardItem[k].nAmountMin);
				pAssetAwardFile->GetInteger(j + 1, szTabItemAmountMax, 0, &pAssetAward->arrAwardItem[k].nAmountMax);
				pAssetAwardFile->GetInteger(j + 1, szTabItemRate, 0, &pAssetAward->arrAwardItem[k].nRate);
				pAssetAwardFile->GetInteger(j + 1, szTabItemTimeOut, 0, &pAssetAward->arrAwardItem[k].nTimeOut);

			}
			pModuleAssetAward->mapAssetAwards[pAssetAward->nLevel] = pAssetAward;
		}

		m_vecModuleAssetAwards.push_back(pModuleAssetAward);
	}

	return TRUE;
}
Example #21
0
QWidget *QFRDRTableDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const {
    QVariant dat=index.data(Qt::DisplayRole);
    QString expression=index.data(QFRDRTable::TableExpressionRole).toString();
    if (expression.isEmpty()) {
        if (dat.type()==QVariant::Invalid) {
            dat=index.data(Qt::EditRole);
        }
         if ( dat.type() == QVariant::DateTime || dat.type() == QVariant::Time || dat.type() == QVariant::Date ) {
             QDateTimeEdit *editor = new QDateTimeEdit(parent);
             //editor->setDisplayFormat("dd/M/yyyy");
             editor->setCalendarPopup(true);
             return editor;
         }
         if ( !index.isValid() || dat.type() == QVariant::Double ) {
             QFDoubleEdit* editor=new QFDoubleEdit(parent);
             editor->setCheckBounds(false, false);
             editor->setShowUpDown(false);
             return editor;
         }
         if ( dat.type() == QVariant::Int || dat.type() == QVariant::LongLong ) {
             QSpinBox* editor=new QSpinBox(parent);
             editor->setRange(INT_MIN, INT_MAX);
             editor->setButtonSymbols(QAbstractSpinBox::NoButtons);
             return editor;
         }
         if ( dat.type() == QVariant::UInt || dat.type() == QVariant::ULongLong ) {
             QSpinBox* editor=new QSpinBox(parent);
             editor->setRange(0, UINT_MAX);
             editor->setButtonSymbols(QAbstractSpinBox::NoButtons);
             return editor;
         }
         if ( dat.type() == QVariant::Bool) {
             QCheckBox* editor=new QCheckBox(parent);
             return editor;
         }

         QLineEdit *editor = new QLineEdit(parent);

         // create a completer with the strings in the column as model
         QStringList allStrings;
         for (int i = 1; i<index.model()->rowCount(); i++) {
             QString strItem(index.model()->data(index.sibling(i, index.column()),
                 Qt::EditRole).toString());

             if (!allStrings.contains(strItem))
                 allStrings.append(strItem);
         }

         QCompleter *autoComplete = new QCompleter(allStrings);
         editor->setCompleter(autoComplete);
         connect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
         return editor;
    } else {
        QWidget* widExpression=new QWidget(parent);
        widExpression->setFocusPolicy(Qt::StrongFocus);
        widExpression->setAutoFillBackground(true);
        QHBoxLayout* layout=new QHBoxLayout();
        layout->setContentsMargins(0,0,0,0);
        layout->setSpacing(1);
        widExpression->setLayout(layout);
        QLabel* label=new QLabel(widExpression);
        layout->addWidget(label, 1);
        label->setTextFormat(Qt::RichText);
        label->setText(tr("<b><font color=\"blue\">&Sigma;:</font> %1</b><i>&nbsp;&nbsp;= %2</i>").arg(expression).arg(dat.toString()));
        label->setAutoFillBackground(true);
        QFont f=label->font();
        f.setPointSizeF(f.pointSizeF()*0.9);
        label->setFont(f);
        QAction* actEdtExp;        
        QToolButton* btnEdtExp=createButtonAndAction(actEdtExp, QIcon(":/table/formula.png"), tr("edit expression ..."), widExpression);
        actEdtExp->setParent(widExpression);
        connect(actEdtExp, SIGNAL(triggered()), this, SLOT(doEditExpression()));
        layout->addWidget(btnEdtExp);
        QAction* actClearExp;
        QToolButton* btnClearExp=createButtonAndAction(actClearExp, QIcon(":/table/formulaclear.png"), tr("clear expression ..."), widExpression);
        actClearExp->setParent(widExpression);
        connect(actClearExp, SIGNAL(triggered()), this, SLOT(doClearExpression()));
        layout->addWidget(btnClearExp);
        widExpression->setFocus();
        return widExpression;
    }
}