Example #1
0
const CComplex& CComplex::operator=(LPCSTR szNum)
{
	while (szNum[0]==' ') szNum++;
	int nIndex=FirstCharIndex(szNum+1,'+')+1;
	if (nIndex==0) nIndex=FirstCharIndex(szNum+1,'-')+1;
	if (nIndex==0)
	{
		nIndex=FirstCharIndex(szNum,'i');
		if (nIndex==-1) nIndex=FirstCharIndex(szNum,'j');
		if (nIndex==-1)
		{
			Re=szNum;
			Im=0;
		}
		else
		{
			Re=0;
			CString im(szNum,nIndex);
			if (im.IsEmpty())
				Im=1;
			else if (im.Compare("-")==0)
				Im=-1;
			else
				Im=szNum;
		}
	}
	else
	{
		CString re(szNum,nIndex);
		CString im;
		Re=re;
		while (szNum[nIndex]==' ') nIndex++;
		if (szNum[nIndex]=='+')
			nIndex++;
		else if (szNum[nIndex]=='-')
		{
			nIndex++;
			im='-';
		}
		while (szNum[nIndex]>='0' && szNum[nIndex]<='9')
		{
			im << szNum[nIndex];
			nIndex++;
		}
		if (szNum[nIndex]=='i' || szNum[nIndex]=='j')
		{
			if (im.IsEmpty())
				Im=1;
			else if (im.Compare("-")==0)
				Im=-1;
			else
				Im=im;
		}
		else
			Im=0;
	}
	return *this;
}
Example #2
0
const CReal& CReal::operator=(LPCSTR szNum)
{
	if (FirstCharIndex(szNum,'.')!=-1)
	{
		nIrrational=atof(szNum);
		if (nIrrational==int(nIrrational))
		{
			isRational=TRUE;
			nRational.nNumerator=int(nIrrational);
			nRational.nDenominator=1;
		}
		else
			isRational=FALSE;
		return *this;
	}
	LONG_PTR nIndex=FirstCharIndex(szNum,'/');
	if (nIndex!=-1)
	{
		int nMultipler=(int)FirstCharIndex(szNum,' ');
		if (nMultipler>0 && nMultipler<nIndex)
		{
			char* sz=new char[nMultipler+1];
			fMemCopy(sz,szNum,nMultipler);
			sz[nMultipler]='\0';
			szNum+=nMultipler+1;
			nIndex-=nMultipler+1;
			nMultipler=atoi(sz);
			delete[] sz;
		}
		else
			nMultipler=0;
		char* sz=new char[nIndex+1];
		fMemCopy(sz,szNum,nIndex);
		sz[nIndex]='\0';
		isRational=TRUE;
		nRational.nNumerator=atoi(sz);
		nRational.nDenominator=atoi(szNum+nIndex+1);
		if (nRational.nDenominator==0)
			nRational.nDenominator=1;
		delete[] sz;
		if (nMultipler>=0)
			nRational.nNumerator+=nRational.nDenominator*nMultipler;
		else
		{
			nRational.nNumerator=-nRational.nNumerator;
			nRational.nNumerator-=nRational.nDenominator*nMultipler;
		}
		return *this;
	}
	isRational=TRUE;
	nRational.nNumerator=atoi(szNum);
	nRational.nDenominator=1;
	return *this;
}
Example #3
0
HWND CWnd::HtmlHelp(UINT uCommand,DWORD_PTR dwData,LPCWSTR szHelpFile)
{
	if (szHelpFile==NULL)
		szHelpFile=GetApp()->m_szHelpFile;

	if (szHelpFile!=NULL)
	{	
		if (FirstCharIndex(szHelpFile,L'\\')!=-1)
		{
			if (IsUnicodeSystem())
				return HtmlHelpW(m_hWnd,szHelpFile,uCommand,dwData);
			else
				return HtmlHelpA(m_hWnd,W2A(szHelpFile),uCommand,dwData);
		}



		// Insert path
		if (IsUnicodeSystem())
		{
			CStringW sExeName=GetApp()->GetExeNameW();
			return HtmlHelpW(*this,sExeName.Left(sExeName.FindLast(L'\\')+1)+szHelpFile,
				uCommand,dwData);
		}
	
		CString sExeName=GetApp()->GetExeName();
		return HtmlHelpA(*this,sExeName.Left(sExeName.FindLast(L'\\')+1)+szHelpFile,
			uCommand,dwData);
	}



	if (IsUnicodeSystem())
	{
		CStringW sExeName=GetApp()->GetExeNameW();
		return HtmlHelpW(*this,sExeName.Left(sExeName.FindLast(L'.')+1)+L"chm",
			uCommand,dwData);
	}

	CString sExeName=GetApp()->GetExeName();
	return HtmlHelpA(*this,sExeName.Left(sExeName.FindLast(L'.')+1)+"chm",
		uCommand,dwData);
}
Example #4
0
void CSubAction::DoMisc()
{
	if (m_nMisc==ExecuteCommandMisc)
	{
		if (m_szCommand!=NULL)
			CLocateDlg::ExecuteCommand(m_szCommand);
		return;
	}
	else if (m_nMisc==InsertAsterisks)
	{
		CLocateDlg* pLocateDlg=GetLocateDlg();
		if (pLocateDlg==NULL)
			return;

		CStringW Text;
		pLocateDlg->m_NameDlg.m_Name.GetText(Text);
		DWORD dwSelStart=pLocateDlg->m_NameDlg.m_Name.GetEditSel();
		WORD wSelEnd=HIWORD(dwSelStart);
		dwSelStart&=0xFFFF;

		// If asterisks are already at the beginning and the end, replace spaces
		if (Text[0]==L'*' && Text.LastChar()==L'*')
			Text.ReplaceChars(L' ',L'*');
		else 
		{
			if (Text[0]!=L'*')
			{
				Text.InsChar(0,L'*');
				
				// Update selection
				if (dwSelStart==wSelEnd)
				{
					dwSelStart++;
					wSelEnd++;
				}
				else 
				{
					if (dwSelStart>0)
						dwSelStart++;
					wSelEnd++;
				}
			}
			
			if (Text.LastChar()!=L'*')
			{
				// Update selection first
				if (wSelEnd==Text.GetLength())
				{
					if (dwSelStart==wSelEnd)
						dwSelStart++;
					wSelEnd++; 
				}

				Text.Append(L'*');
			}
		}

		pLocateDlg->m_NameDlg.m_Name.SetText(Text);
		pLocateDlg->m_NameDlg.m_Name.SetEditSel(dwSelStart,wSelEnd);
		pLocateDlg->OnFieldChange(CLocateDlg::isNameChanged);
		return;
	}
	

	// Send/Post Message

	BOOL bFreeWParam=FALSE,bFreeLParam=FALSE;
	
	HWND hWnd=NULL;
	WPARAM wParam=NULL,lParam=NULL;

	if (m_pSendMessage->szWindow[0]=='0')
	{
		if (m_pSendMessage->szWindow[1]=='x' || 
			m_pSendMessage->szWindow[1]=='X')
		{
			// Hex value
			LPWSTR szTemp;
			hWnd=(HWND)wcstoul(m_pSendMessage->szWindow+2,&szTemp,16);
		}
	}
	else if (strcasecmp(m_pSendMessage->szWindow,L"HWND_BROADCAST")==0)
		hWnd=HWND_BROADCAST;
	else if (GetLocateDlg()!=NULL && strcasecmp(m_pSendMessage->szWindow,L"LOCATEDLG")==0)
		hWnd=*GetLocateDlg();
	else if (strcasecmp(m_pSendMessage->szWindow,L"LOCATEST")==0)
		hWnd=*GetTrayIconWnd();
	else if (wcsncmp(m_pSendMessage->szWindow,L"Find",4)==0)
	{
		int nIndex=(int)FirstCharIndex(m_pSendMessage->szWindow,L'(');
		if (nIndex!=-1)
		{
			LPCWSTR pText=m_pSendMessage->szWindow+nIndex+1;
			LPWSTR pClassAndWindow[3]={NULL,NULL,NULL};
			
			nIndex=(int)FirstCharIndex(pText,L',');
			if (nIndex==-1)
			{
				nIndex=(int)FirstCharIndex(pText,L')');
				if (nIndex==-1)
					pClassAndWindow[0]=alloccopy(pText);
				else
					pClassAndWindow[0]=alloccopy(pText,nIndex);
			}
			else
			{
				pClassAndWindow[0]=alloccopy(pText,nIndex);
				pText+=nIndex+1;

				nIndex=(int)FirstCharIndex(pText,L')');
				pClassAndWindow[1]=alloccopy(pText,nIndex);
			}

			EnumWindows(WindowEnumProc,LPARAM(pClassAndWindow));

			// Third cell is handle to window
			hWnd=(HWND)pClassAndWindow[2];

			delete[] pClassAndWindow[0];
			if (pClassAndWindow[1])
				delete[] pClassAndWindow[1];
		}
	}
	


	// Parse wParam
	if (m_pSendMessage->szWParam!=NULL)
	{
		if (m_pSendMessage->szWParam[0]=='0')
		{
			if (m_pSendMessage->szWParam[1]=='x' || 
				m_pSendMessage->szWParam[1]=='X')
			{
				// Hex value
				LPWSTR szTemp;
				wParam=(WPARAM)wcstoul(m_pSendMessage->szWParam+2,&szTemp,16);
			}
			else if (m_pSendMessage->szWParam[1]!='\0')
			{
				DWORD dwLength;
				wParam=(WPARAM)dataparser(m_pSendMessage->szWParam,istrlen(m_pSendMessage->szWParam),gmalloc,&dwLength);
				*((BYTE*)wParam+dwLength)=0;
				bFreeWParam=TRUE;
			}
		}
		else if ((wParam=_wtoi(m_pSendMessage->szWParam))==0)
		{
			DWORD dwLength;
			wParam=(WPARAM)dataparser(m_pSendMessage->szWParam,istrlen(m_pSendMessage->szWParam),gmalloc,&dwLength);
			*((BYTE*)wParam+dwLength)=0;
			bFreeWParam=TRUE;
		}
	}

	// Parse lParam
	if (m_pSendMessage->szLParam!=NULL)
	{
		if (m_pSendMessage->szLParam[0]=='0')
		{
			if (m_pSendMessage->szLParam[1]=='x' || 
				m_pSendMessage->szLParam[1]=='X')
			{
				// Hex value
				LPWSTR szTemp;
				lParam=(WPARAM)wcstoul(m_pSendMessage->szLParam+2,&szTemp,16);
			}
			else if (m_pSendMessage->szLParam[1]!='\0')
			{
				DWORD dwLength;
				lParam=(WPARAM)dataparser(m_pSendMessage->szLParam,istrlen(m_pSendMessage->szLParam),gmalloc,&dwLength);
				*((BYTE*)lParam+dwLength)=0;
				bFreeLParam=TRUE;
			}
		}
		else if ((lParam=_wtoi(m_pSendMessage->szLParam))==0)
		{
			DWORD dwLength;
			lParam=(WPARAM)dataparser(m_pSendMessage->szLParam,istrlen(m_pSendMessage->szLParam),gmalloc,&dwLength);
			*((BYTE*)lParam+dwLength)=0;
            bFreeLParam=TRUE;
		}
	}

	if (hWnd!=NULL)
	{
		if (m_nMisc==PostMessage)
			::PostMessage(hWnd,m_pSendMessage->nMessage,wParam,lParam);
		else
			::SendMessage(hWnd,m_pSendMessage->nMessage,wParam,lParam);
	}

	if (bFreeWParam)
		GlobalFree((HANDLE)wParam);
	if (bFreeLParam)
		GlobalFree((HANDLE)lParam);

}