BOOL CVersionChecker::UndertakeRequest(CString& strPost)
{
	m_pRequest.SetURL( _T("http://update.trillinux.org/version/beta.php?") + strPost );
	//Remember to set the update server for final releases.
	
	if ( ! m_pRequest.Execute( FALSE ) ) return FALSE;
	
	int nStatusCode = m_pRequest.GetStatusCode();
	if ( nStatusCode < 200 || nStatusCode > 299 ) return FALSE;
	
	CString strResponse = m_pRequest.GetResponseString();
	CString strHack = theApp.GetProfileString( _T("VersionCheck"), _T("TestResponse"), _T("") );
	if ( strHack.GetLength() ) strResponse = strHack;
	
	for ( strResponse += '&' ; strResponse.GetLength() ; )
	{
		CString strItem	= strResponse.SpanExcluding( _T("&") );
		strResponse		= strResponse.Mid( strItem.GetLength() + 1 );
		
		CString strKey = strItem.SpanExcluding( _T("=") );
		if ( strKey.GetLength() == strItem.GetLength() ) continue;
		strItem = CTransfer::URLDecode( strItem.Mid( strKey.GetLength() + 1 ) );

		strItem.TrimLeft();
		strItem.TrimRight();
		
		m_pResponse.SetAt( strKey, strItem );
	}
	
	return TRUE;
}
Example #2
0
BOOL CChatWnd::OnLocalText(const CString& sText)
{
    // Save history
    m_pHistory.Add( sText );
    if ( m_pHistory.GetSize() > EDIT_HISTORY ) m_pHistory.RemoveAt( 0 );
    m_nHistory = static_cast< int >( m_pHistory.GetSize() );

    if ( sText.GetAt( 0 ) == _T('/') )
    {
        CString strCommand = sText.SpanExcluding( _T(" \t") ).Trim();
        if ( strCommand.CompareNoCase( _T("/me") ) == 0 )
        {
            // Action text
            return OnLocalMessage( true, sText.Mid( 4 ) );
        }
        else if ( OnLocalCommand( strCommand, sText.Mid( strCommand.GetLength() + 1 ).Trim() ) )
        {
            // Handled command
            return TRUE;
        }
    }
    else if ( sText.GetAt( 0 ) == _T('*') &&
              ( sText.GetAt( 1 ) == _T(' ') || sText.GetAt( 1 ) == _T('\t') ) )
    {
        // Action text
        return OnLocalMessage( true, sText.Mid( 2 ) );
    }

    // Regular text
    return OnLocalMessage( false, sText );
}
Example #3
0
bool CPatch::Read(CStdioFile& fp)
{
	CString	s;
	int	Version;
	if (!fp.ReadString(s) || _stscanf(s, FILE_ID, &Version) != 1)
		return(FALSE);
	SetDefaults();	// in case some lines are missing
	while (fp.ReadString(s)) {
		s.TrimLeft();
		CString	Name = s.SpanExcluding(_T(" \t"));
		CString	Arg = s.Mid(Name.GetLength());
		int	i;
		for (i = 0; i < ROWS; i++) {
			if (Name == m_RowData[i].Name) {
				ROW	*r = &m_Row[i];
				_stscanf(Arg, _T("%lf %d %lf %lf %lf"),
					&r->Val, &r->Wave, &r->Amp, &r->Freq, &r->PW);
				break;
			}
		}
		if (i >= ROWS) {	// not a parm row, assume it's a state member
			for (i = 0; m_LineInfo[i].Name != NULL; i++) {
				if (Name == m_LineInfo[i].Name) {
					CFormatIO::StrToVal(m_LineInfo[i].Type, Arg,
						((char *)this) + m_LineInfo[i].Offset);
					break;
				}
			}
		}
	}
	return(TRUE);
}
Example #4
0
INT_PTR CRemoteWnd::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
{
	if ( CmdButton* pButton = HitTestButtons( point ) )
	{
		CString strTip;

		if ( LoadString( strTip, pButton->m_nID ) )
		{
			if ( LPCTSTR pszBreak = _tcschr( strTip, '\n' ) )
			{
				pTI->lpszText = _tcsdup( pszBreak + 1 );
			}
			else
			{
				strTip = strTip.SpanExcluding( L"." );
				pTI->lpszText = _tcsdup( strTip );
			}
		}

		pTI->hwnd		= GetSafeHwnd();
		pTI->uId		= pButton->m_nID;
		pTI->uFlags		= pTI->uFlags & ~TTF_IDISHWND;
		pTI->rect		= pButton->m_rc;

		return pTI->uId;
	}

	return CWnd::OnToolHitTest( point, pTI );
}
Example #5
0
void CSubmountsDlg::OnDelete()
{
	HOURGLASS hourglass;

	int nIndex = m_SubmtList.GetCurSel();
	ASSERT(nIndex >= 0);

	CString strSubmt;
	CString strShareName;
	m_SubmtList.GetText(nIndex, strSubmt);

	ASSERT(!strSubmt.IsEmpty());

	strShareName = strSubmt.SpanExcluding(_T("="));

	if (ShowMessageBox(IDS_REALLY_DELETE_SUBMT, MB_YESNO | MB_ICONQUESTION, IDS_REALLY_DELETE_SUBMT, strShareName) != IDYES)
		return;

	m_SubmtList.DeleteString(nIndex);

	if (m_SubmtList.GetCount() == 0) {
		m_Delete.EnableWindow(FALSE);
		m_Change.EnableWindow(FALSE);
	}

	CSubmountInfo *pInfo = new CSubmountInfo();
	pInfo->SetShareName(strShareName);
	pInfo->SetStatus(SIS_DELETED);
	AddWork(pInfo);
}
Example #6
0
void CDlgDialbox::OnBnClickedDialboxConnect()
{
	CString sComPort = "";
	const int iItem = m_ComPort.GetCurSel();
	if (iItem < 0) return;
	m_ComPort.GetLBText(iItem, sComPort);
	if (sComPort.IsEmpty()) return;
	int err = OpenDialboxBluetoothSPP("\\\\.\\" + sComPort.SpanExcluding(" "));
	if (err) {
		AfxMessageBox( 
			"Error on connecting the device.\r\n1. Is the selected device placed near your PC? Is it turned on?\r\n"
			"2. If this error repeatedly occurs even when the correct device is selected, "
			"go to the Bluetooth config window and remove the device and do pairing again."
		);
	}
	EnableCtrl();
}
Example #7
0
void CSubmountsDlg::OnChange()
{
	CAddSubmtDlg dlg;

	HOURGLASS hourglass;

	dlg.SetAddMode(FALSE);

	int nIndex = m_SubmtList.GetCurSel();
	ASSERT(nIndex >= 0);

	CString strSubmt;
	CString strShareName;
	m_SubmtList.GetText(nIndex, strSubmt);

	ASSERT(!strSubmt.IsEmpty());

	strShareName = strSubmt.SpanExcluding(_T("="));

	CSubmountInfo *pInfo = FindWork(strShareName);
	if (pInfo != 0)
		// Make a copy we can free below
		pInfo = new CSubmountInfo(*pInfo);
	else
		pInfo = ReadSubmtInfo(strShareName);

	if (!pInfo) {
		ShowMessageBox(IDS_GET_SUBMT_INFO_ERROR, MB_ICONEXCLAMATION, IDS_GET_SUBMT_INFO_ERROR, strShareName);
		return;
	}

	dlg.SetSubmtInfo(pInfo);

	delete pInfo;

	if (dlg.DoModal() != IDOK)
		return;

	pInfo = dlg.GetSubmtInfo();

	m_SubmtList.DeleteString(nIndex);
	m_SubmtList.InsertString(nIndex,
		pInfo->GetShareName() + "=" + pInfo->GetPathName());

	AddWork(pInfo);
}
Example #8
0
BOOL CSecureRule::FromGnucleusString(CString& str)
{
	int x[4] = {};

	int nPos = str.Find( L':' );
	if ( nPos < 1 ) return FALSE;

	CString strAddress = str.Left( nPos );
	str = str.Mid( nPos + 1 );

	if ( _stscanf( strAddress, L"%i.%i.%i.%i", &x[0], &x[1], &x[2], &x[3] ) != 4 )
		return FALSE;

	m_nIP[0] = (BYTE)x[0]; m_nIP[1] = (BYTE)x[1];
	m_nIP[2] = (BYTE)x[2]; m_nIP[3] = (BYTE)x[3];

	nPos = strAddress.Find( L'-' );

	if ( nPos >= 0 )
	{
		strAddress = strAddress.Mid( nPos + 1 );

		if ( _stscanf( strAddress, L"%i.%i.%i.%i", &x[0], &x[1], &x[2], &x[3] ) != 4 )
			return FALSE;

		for ( int nByte = 0; nByte < 4; nByte++ )
		{
			BYTE nTop = (BYTE)x[ nByte ], nBase = (BYTE)x[ nByte ];

			for ( BYTE nValue = m_nIP[ nByte ]; nValue < nTop; nValue++ )
			{
				m_nMask[ nByte ] &= ~( nValue ^ nBase );
			}
		}
	}

	m_nType		= srAddress;
	m_nAction	= srDeny;
	m_nExpire	= srIndefinite;
	m_sComment	= str.SpanExcluding( L":" );

	MaskFix();

	return TRUE;
}
Example #9
0
BOOL CCallerChannel::IsNotUserTime()
{
	CRegistry pRegistry;
	
	if ( ! pRegistry.GetInt( "Caller", "NoUser" ) ) return FALSE;
	
	CString strValue = pRegistry.GetString( "Caller", "UserTime" );
	
	CString str	= strValue.SpanExcluding( _T("-") );
	WORD nLTime = _ttoi( str );
	
	strValue	= strValue.Mid( str.GetLength() + 1 );
	WORD nHTime = _ttoi( strValue );
	
	CTime tNow = CTime::GetCurrentTime();
	WORD nNowTime = tNow.GetHour()* 100 + tNow.GetMinute();
	
	return nNowTime < nLTime || nNowTime > nHTime;
}
Example #10
0
BOOL CCallerChannel::PutForwardRing(CXMLElement* pXML, CChannel*& pChannel)
{
	CString strValue = pXML->GetAttributeValue( "Forward" );
	
	for ( strValue += '|' ; strValue.GetLength() ; )
	{
		CString str	= strValue.SpanExcluding( _T("|;,") );
		strValue	= strValue.Mid( str.GetLength() + 1 );
		
		if ( pChannel = Network.LookOutPhs( (LPCTSTR)str ) )
		{
			CDialPacket* pPacket = new CDialPacket;
			pPacket->SetLocalId( "96031" ); pPacket->SetRemoteId( str );
			pPacket->SetCallerId( pXML->GetAttributeValue( "ID" ) );
			pPacket->SetFeeNumber( pXML->GetAttributeValue( "ID" ) );
			
			pChannel->OnDialPacket( pPacket ); pPacket->Release();
			SetLinker( pChannel->m_nChan );
		}
		break;
	}
	return TRUE;
}
void CVersionChecker::ProcessResponse()
{
	int nDays = VERSIONCHECKER_FREQUENCY;
	CString strValue;
	
	if ( m_pResponse.Lookup( _T("Message"), strValue ) || m_pResponse.Lookup( _T("MessageBox"), strValue ) )
	{
		m_sMessage = strValue;
	}
	
	if ( m_pResponse.Lookup( _T("Quote"), strValue ) )
	{
		m_sQuote = strValue;
		theApp.WriteProfileString( _T("VersionCheck"), _T("Quote"), m_sQuote );
	}
	
	if ( m_pResponse.Lookup( _T("SystemMsg"), strValue ) )
	{
		for ( strValue += '\n' ; strValue.GetLength() ; )
		{
			CString strLine	= strValue.SpanExcluding( _T("\r\n") );
			strValue		= strValue.Mid( strLine.GetLength() + 1 );
			if ( strLine.GetLength() ) theApp.Message( MSG_SYSTEM, strLine );
		}
	}
	
	if ( m_pResponse.Lookup( _T("UpgradePrompt"), strValue ) )
	{
		m_sUpgradePrompt = strValue;
		
		m_pResponse.Lookup( _T("UpgradeFile"), m_sUpgradeFile );
		m_pResponse.Lookup( _T("UpgradeSHA1"), m_sUpgradeSHA1 );
		m_pResponse.Lookup( _T("UpgradeTiger"), m_sUpgradeTiger );
		m_pResponse.Lookup( _T("UpgradeSize"), m_sUpgradeSize );
		m_pResponse.Lookup( _T("UpgradeSources"), m_sUpgradeSources );
		m_pResponse.Lookup( _T("UpgradeVersion"), m_sUpgradeVersion );

		// Old name
		if ( ! m_sUpgradeSHA1.GetLength() )
			m_pResponse.Lookup( _T("UpgradeHash"), m_sUpgradeSHA1 );
		
		theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradePrompt"), m_sUpgradePrompt );
		theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradeFile"), m_sUpgradeFile );
		theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradeSHA1"), m_sUpgradeSHA1 );
		theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradeTiger"), m_sUpgradeTiger);
		theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradeSize"), m_sUpgradeSize );
		theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradeSources"), m_sUpgradeSources );
		theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradeVersion"), m_sUpgradeVersion );
		
		m_bUpgrade = TRUE;
	}
	else
	{
		theApp.WriteProfileString( _T("VersionCheck"), _T("UpgradePrompt"), _T("") );
		m_bUpgrade = FALSE;
	}
	
	if ( m_pResponse.Lookup( _T("AddDiscovery"), strValue ) )
	{
		strValue.TrimLeft();
		strValue.TrimRight();
		DiscoveryServices.Add( strValue, CDiscoveryService::dsWebCache );
	}
	
	if ( m_pResponse.Lookup( _T("NextCheck"), strValue ) )
	{
		_stscanf( strValue, _T("%lu"), &nDays );
	}
	
	SetNextCheck( nDays );
	
	PostMessage( m_hWndNotify, WM_VERSIONCHECK, 0, 0 );
}
Example #12
0
void COutWnd::OnDbClick()
{
    INT nSelectIndex;
    CString omStrSelectedItem;
    nSelectIndex = m_omListBox.GetCurSel();
    if(nSelectIndex!=LB_ERR )
    {
        CString omStrLineNumber = "";
        INT     nIndex          = 0;
        UINT    unLineNumber    = 0;
        char*   pcStopStr       = nullptr;

        m_omListBox.GetText(nSelectIndex,omStrSelectedItem);
        CString omStrFilePath;
        CString omStrFileName;
        omStrFilePath=omStrSelectedItem;
        while(!(nSelectIndex==0||omStrFilePath==defSTR_BUILD_TRACE_LINE_MARK))
        {
            --nSelectIndex;
            m_omListBox.GetText(nSelectIndex,omStrFilePath);
        }
        if(omStrFilePath==defSTR_BUILD_TRACE_LINE_MARK)
        {
            ++nSelectIndex;
            m_omListBox.GetText(nSelectIndex,omStrFilePath);
            int nNameIndex = omStrFilePath.ReverseFind('\\');
            if(nNameIndex != -1)
            {
                //pGetBusSpecificFunctionEditorDoc(omStrFilePath);
                CFunctionEditorDoc* pDoc = m_pGlobalObj->pGetDocPtrOfFile(omStrFilePath);
                if (pDoc != nullptr)
                {
                    //If file is opened then get its frame and activate it
                    {
                        POSITION pos = pDoc->GetFirstViewPosition();
                        if (pos)
                        {
                            pDoc->GetNextView(pos)->GetParentFrame()->ActivateFrame();
                        }
                    }
                }
                else
                {
                    //If file is not opened then open it
                    if ( !m_pGlobalObj->bOpenFunctioneditorfile(omStrFilePath) )
                    {
                        AfxMessageBox("Specified filename not found!",
                                      MB_OK|MB_ICONINFORMATION);
                    }
                }

                // Find the ':' to get the number after second ':'
                nIndex = omStrSelectedItem.Find(":");
                if(nIndex!=-1)
                {

                    omStrLineNumber = omStrSelectedItem.Right(
                                          omStrSelectedItem.GetLength()-nIndex-1);
                    nIndex          = omStrLineNumber.Find(":");
                    omStrLineNumber = omStrLineNumber.Right(
                                          omStrLineNumber.GetLength()-nIndex-1);

                    omStrLineNumber.TrimLeft();
                    omStrLineNumber.TrimRight();
                    omStrLineNumber = omStrLineNumber.SpanExcluding(":");
                    unLineNumber    = _tcstol((LPCTSTR)omStrLineNumber,
                                              &pcStopStr,10);
                    // Call this function only if the  line number is valid
                    if(unLineNumber!=0)
                    {
                        CFileView* pFileView = m_pGlobalObj->podGetFileViewPtr();
                        if(pFileView != nullptr)
                        {
                            pFileView->vDisplayWarningLineNumber(OUTWND,unLineNumber);
                        }
                    }
                }
                else
                {
                    nIndex = omStrSelectedItem.Find(":");
                    if(nIndex!=-1)
                    {
                        nIndex          = omStrSelectedItem.Find(":");
                        omStrLineNumber = omStrSelectedItem.Right(
                                              omStrSelectedItem.GetLength()-nIndex-1);

                        omStrLineNumber.TrimLeft();
                        omStrLineNumber.TrimRight();
                        omStrLineNumber = omStrLineNumber.
                                          SpanExcluding("\t ");
                        unLineNumber    = _tcstol((LPCTSTR)omStrLineNumber,
                                                  &pcStopStr,
                                                  10);
                        if(unLineNumber!=0)
                        {
                            CFileView* pFileView = m_pGlobalObj->podGetFileViewPtr();

                            if(nullptr != pFileView)
                            {
                                pFileView->vDisplayWarningLineNumber(OUTWND,
                                                                     unLineNumber);
                            }
                        }
                    }
                }
            }
        }
    }
}
/*** Will be called before the first display of the dialog *******************/
BOOL CCalendarDlg2::OnInitDialog()
{
    m_mcMonthCal.SetHolidaysFromFile(_T("HOLIDAYS.INI"));
    m_mcMonthCal.pDelegates=this;
    CResizeableDialog::OnInitDialog();
    // ֿאנסטל פאיכ
    CString sContent;
    ReadFile(sMainFile,sContent);
    sContent.Replace("\r\n","\n");
    sContent=CString("\n")+sContent+"\n";
    while(sContent!="") {
        CString sLine=sContent.SpanExcluding("\n");
        if(sLine!="") {
            aItems.Add(sLine);
            if(sContent.GetLength()>sLine.GetLength()) {
                sContent=sContent.Mid(sLine.GetLength()+1);
            } else {
                sContent="";
            }
        }
        sContent.TrimLeft();
    }
    LRESULT lRes=0;
    NMDAYSTATE pDayState;
    SYSTEMTIME stMinRange, stMaxRange;
    memset(&pDayState,0,sizeof(pDayState));
    m_mcMonthCal.GetMonthRange(&stMinRange, &stMaxRange, GMR_DAYSTATE);
    pDayState.cDayState=(stMaxRange.wYear - stMinRange.wYear) * 12 + stMaxRange.wMonth - stMinRange.wMonth + 1;
    memcpy(&pDayState.stStart,&stMinRange,sizeof(SYSTEMTIME));
    OnGetdaystate((NMHDR*)&pDayState,&lRes);
    //pDayState.prgDayState[0]=0xffff;
    //memset(pDayState.prgDayState,555,5*sizeof(MONTHDAYSTATE));
    m_mcMonthCal.SetDayState(pDayState.cDayState,pDayState.prgDayState);
    m_mcMonthCal.Invalidate();

    //-----------------------------------
    // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE);			// Set big icon
    SetIcon(m_hIcon, FALSE);		// Set small icon
    GetDlgItem(IDC_STATIC1)->SetWindowText(_l(sStatic1));
    GetDlgItem(IDC_STATIC2)->SetWindowText(_l(sStatic2));
    SetWindowText(_l(sTitle));
    GetDlgItem(IDOK)->SetWindowText(_l(sButton));
    GetDlgItem(IDCLEAR)->SetWindowText(_l("Clear field"));
    // Register resizable controls
    RegisterControl(IDC_STATIC1, ATTACH_TO_TOP_EDGE | ATTACH_TO_VERTICAL_EDGES);
    RegisterControl(IDC_MONTHCALENDAR1, ATTACH_TO_TOP_EDGE | ATTACH_TO_VERTICAL_EDGES);
    RegisterControl(IDC_STATIC2, ATTACH_TO_TOP_EDGE | ATTACH_TO_VERTICAL_EDGES);
    RegisterControl(IDC_EDIT_TXT, ATTACH_TO_TOP_EDGE | ATTACH_TO_VERTICAL_EDGES);
    RegisterControl(IDC_STATIC3, ATTACH_TO_BOTTOM_EDGE | ATTACH_TO_LEFT_EDGE);
    RegisterControl(IDCLEAR, ATTACH_TO_BOTTOM_EDGE | ATTACH_TO_LEFT_EDGE);
    RegisterControl(IDOK, ATTACH_TO_BOTTOM_EDGE | ATTACH_TO_RIGHT_EDGE);
    // Calculate minimum and maximum size of calendar window
    CRect rect;
    m_mcMonthCal.GetClientRect(rect);
    int nWidth  = rect.Width();
    int nHeight = rect.Height();

    if (m_mcMonthCal.GetMinReqRect(rect))
    {
        int   nMinWidth   = rect.Width();
        int   nMinHeight  = rect.Height();
        int   nDiffWidth  = nMinWidth  - nWidth;
        int   nDiffHeight = nMinHeight - nHeight;
        CRect rectOffset(nDiffWidth/2, nDiffHeight/2, nDiffWidth/2 + nDiffWidth%2,
                         nDiffHeight/2 + nDiffHeight%2);

        GetWindowRect(rect);
        rect += rectOffset;
        MoveWindow(rect);
        ThisSizeIsMinSize();

        int nMaxWidth  = nMinWidth  * 2 +  6*(3-1);
        int nMaxHeight = nMinHeight * 2 + 13*(4-1);

        nDiffWidth  = nMaxWidth  - nWidth;
        nDiffHeight = nMaxHeight - nHeight;
        rectOffset  = CRect(nDiffWidth/2, nDiffHeight/2,
                            nDiffWidth/2 + nDiffWidth%2,
                            nDiffHeight/2 + nDiffHeight%2);

        GetWindowRect(rect);
        rect += rectOffset;

        int nScreenWidth  = GetSystemMetrics(SM_CXSCREEN);
        int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
        if (rect.Width() > nScreenWidth)
        {
            rect.left  = 0;
            rect.right = nScreenWidth-1;
        }
        if (rect.Height() > nScreenHeight)
        {
            rect.top    = 0;
            rect.bottom = nScreenHeight-1;
        }
        m_nMaxWidth  = m_nMinWidth*2;
        m_nMaxHeight = m_nMinHeight;
        /*
        MoveWindow(rect);
        ThisSizeIsMaxSize();

        CRect rtBegin(rect);
        MoveWindow(rtBegin);
        */
    }
    SYSTEMTIME sysTime;
    GetSystemTime(&sysTime);
    BOOL bResult = (BOOL)::SendMessage(m_mcMonthCal, MCM_SETCURSEL, 0, (LPARAM) &sysTime);
    SetTextForDay(&sysTime);
    return TRUE;  // return TRUE  unless you set the focus to a control
}
Example #14
0
BOOL CChatWnd::PreTranslateMessage(MSG* pMsg)
{
    if ( pMsg->message == WM_KEYDOWN )
    {
        if ( pMsg->wParam == VK_RETURN )
        {
            CString sCurrent;
            m_wndEdit.GetWindowText( sCurrent );

            for ( ; sCurrent.GetLength(); sCurrent = sCurrent.Mid( 1 ) )
            {
                CString strLine = sCurrent.SpanExcluding( _T("\r\n") );
                if ( strLine.GetLength() )
                {
                    if ( ! OnLocalText( strLine ) )
                        // Leave rest of string in edit box
                        break;
                    sCurrent = sCurrent.Mid( strLine.GetLength() );
                }
            }

            m_wndEdit.SetWindowText( sCurrent );
            return TRUE;
        }
        else if ( pMsg->wParam == VK_ESCAPE )
        {
            m_wndEdit.SetWindowText( _T("") );
            m_nHistory = static_cast< int >( m_pHistory.GetSize() );
            return TRUE;
        }
        else if ( pMsg->wParam == VK_UP )
        {
            MoveHistory( -1 );
            return TRUE;
        }
        else if ( pMsg->wParam == VK_DOWN )
        {
            MoveHistory( 1 );
            return TRUE;
        }
        else if ( pMsg->wParam == VK_PRIOR )
        {
            m_wndView.PostMessage( WM_VSCROLL, MAKELONG( SB_PAGEUP, 0 ), NULL );
            return TRUE;
        }
        else if ( pMsg->wParam == VK_NEXT )
        {
            m_wndView.PostMessage( WM_VSCROLL, MAKELONG( SB_PAGEDOWN, 0 ), NULL );
            return TRUE;
        }
        else if ( pMsg->wParam == VK_HOME && ( GetAsyncKeyState( VK_CONTROL ) & 0x8000 ) )
        {
            m_wndView.PostMessage( WM_VSCROLL, MAKELONG( SB_TOP, 0 ), NULL );
            return TRUE;
        }
        else if ( pMsg->wParam == VK_END && ( GetAsyncKeyState( VK_CONTROL ) & 0x8000 ) )
        {
            m_wndView.PostMessage( WM_VSCROLL, MAKELONG( SB_BOTTOM, 0 ), NULL );
            return TRUE;
        }
        else if ( pMsg->wParam == 'B' && ( GetAsyncKeyState( VK_CONTROL ) & 0x8000 ) )
        {
            OnChatBold();
            return TRUE;
        }
        else if ( pMsg->wParam == 'I' && ( GetAsyncKeyState( VK_CONTROL ) & 0x8000 ) )
        {
            OnChatItalic();
            return TRUE;
        }
        else if ( pMsg->wParam == 'U' && ( GetAsyncKeyState( VK_CONTROL ) & 0x8000 ) )
        {
            OnChatUnderline();
            return TRUE;
        }
        else if ( pMsg->wParam == 'K' && ( GetAsyncKeyState( VK_CONTROL ) & 0x8000 ) )
        {
            OnChatColour();
            return TRUE;
        }
    }

    return CPanelWnd::PreTranslateMessage( pMsg );
}
int ParseLine(CString sLine, CString& sBody, CString& sResOut, int& iFrom, double dSpeed, WKCallbackInterface* pCallback)
{
	if(rtDesktop.bottom==0 && rtDesktop.right==0){
		GetWindowRect(GetDesktopWindow(),&rtDesktop);
	}
	CString sParams;
	sParams=CDataXMLSaver::GetInstringPartGreedly("('","')",sLine);
	if(sParams==""){
		sParams=CDataXMLSaver::GetInstringPartGreedly("(",")",sLine);
		if(sParams!=""){
			sLine=sLine.SpanExcluding("(");
		}
	}else{
		sLine=sLine.SpanExcluding("('");
	}
	if(sParams==""){
		sParams=CDataXMLSaver::GetInstringPartGreedly("\"","\"",sLine);
		if(sParams!=""){
			sLine=sLine.SpanExcluding("\"");
		}
	}
	if(sParams==""){
		sParams=CDataXMLSaver::GetInstringPartGreedly("'","'",sLine);
		if(sParams!=""){
			sLine=sLine.SpanExcluding("'");
		}
	}
	sLine.TrimLeft();
	sLine.TrimRight();
	sLine.MakeUpper();
	if(sLine!=""){
		if(sLine=="RETURN"){
			sResOut=sParams;
			sResOut.TrimLeft(" \"'\t");
			sResOut.TrimRight(" \"'\t");
			iFrom=-1;
			return 1;
		}
		if(sLine=="IF"){
			int iDelPos=sParams.Find("==");
			if(iDelPos!=-1){
				CString sLeft=sParams.Left(iDelPos);
				if(sLeft.Find("unescape")==0){
					sLeft=CDataXMLSaver::GetInstringPart("(",")",sLeft);
					sLeft=UnescapeString(sLeft);
				}
				CString sRight=sParams.Mid(iDelPos+2);
				if(sLeft!=sRight){
					iFrom=sBody.Find('}',iFrom);
				}
			}
		}
		if(sLine=="SET_SPEED"){
			double dSpeed=atof(sParams);
			if(dSpeed<0.1){
				dSpeed=1;
			}
		}
		if(sLine=="CALLACTION"){
			if(pCallback){
				pCallback->CallWKAction(atol(sParams));
			}
		}
		if(sLine=="CALLMACRO"){
			if(pCallback){
				pCallback->StartQuickRunByName(sParams,"");
			}
		}
		if(sLine=="WAIT"){
			Sleep(DWORD(atof(sParams)*1000*dSpeed));
		}
		if(sLine=="ACTIVATEWINDOW"){
			sParams.TrimLeft();
			sParams.TrimRight();
			sParams.TrimLeft("\"");
			sParams.TrimRight("\"");
			HWND hActivate=::FindWindow(NULL,sParams);
			if(hActivate){
				::SetForegroundWindow(hActivate);
				::SendMessage(::GetDesktopWindow(), WM_SYSCOMMAND, (WPARAM) SC_HOTKEY, (LPARAM)hActivate);
			}
		}
		if(sLine=="ALERT"){
			AfxMessageBox(sParams);
		}
		if(sLine=="WAITWHILEALLKEYSARERELEASED"){
			if(pCallback){
				pCallback->WaitWhileAllKeysAreReleased();
			}
		}
		if(sLine=="COMMAND"){
			HWND hCur=GetForegroundWindow();
#ifdef _DEBUG
			char szDebugTitle[128]={0};
			GetWindowText(hCur,szDebugTitle,128);
#endif
			CString sTargetByClass=CDataXMLSaver::GetInstringPart("targetByClass=[","]",sParams);
			CString sTargetByTitle=CDataXMLSaver::GetInstringPart("targetByTitle=[","]",sParams);
			if(sTargetByClass!="" || sTargetByTitle!=""){
				hCur=0;// Слать куда попало предназначенные спецклассу мессаги нельзя!
				// Walton Dell <WDELL@altera.com>
				HWND hTarget=::FindWindow((sTargetByClass!="")?LPCSTR(sTargetByClass):NULL,(sTargetByTitle!="")?LPCSTR(sTargetByTitle):NULL);
				if(hTarget){
					hCur=hTarget;
				}else{
					BOOL bInvis=atol(CDataXMLSaver::GetInstringPart("evenInvisible=[","]",sParams));
					if(bInvis){
						sSearchClass=sTargetByClass;
						sSearchTitle=sTargetByTitle;
						::EnumWindows(EnumFindWndBox,LPARAM(&hTarget));
						if(hTarget){
							hCur=hTarget;
						}
					}
				}
			}
			BOOL bUsedChildWindows=0;
			if(hCur){
				CString sCTargetByID=CDataXMLSaver::GetInstringPart("childTargetByID=[","]",sParams);
				if(sCTargetByID!=""){
					HWND hTarget=::GetDlgItem(hCur,atolx(sCTargetByID));
					if(hTarget){
						bUsedChildWindows=1;
						hCur=hTarget;
					}
				}
				CString sCTargetByClass=CDataXMLSaver::GetInstringPart("childTargetByClass=[","]",sParams);
				CString sCTargetByTitle=CDataXMLSaver::GetInstringPart("childTargetByTitle=[","]",sParams);
				if(sCTargetByClass!="" || sCTargetByClass!=""){
					HWND hTarget=::FindWindowEx(hCur,0,(sCTargetByClass!="")?LPCSTR(sCTargetByClass):NULL,(sCTargetByTitle!="")?LPCSTR(sCTargetByTitle):NULL);
					if(hTarget){
						bUsedChildWindows=1;
						hCur=hTarget;
					}
				}
			}
			{// Выбираем тип и выполняем код
				if(hCur && sParams.Find("activate::")!=-1){
					SwitchToWindow(hCur,TRUE);
				}
				if(sParams.Find("wnd::")!=-1){
					CString sX=CDataXMLSaver::GetInstringPart("x=[","]",sParams);
					long lX=atolx(sX);
					if(sX=="SCREEN_R"){
						lX=rtDesktop.right;
					}
					if(sX=="SCREEN_L"){
						lX=rtDesktop.left;
					}
					CString sY=CDataXMLSaver::GetInstringPart("y=[","]",sParams);
					long lY=atolx(sY);
					if(sY=="SCREEN_B"){
						lY=rtDesktop.bottom;
					}
					if(sY=="SCREEN_T"){
						lY=rtDesktop.top;
					}
					CString sRel=(CDataXMLSaver::GetInstringPart("rel=[","]",sParams));
					long lRel=atolx(sRel);
					sRel.MakeUpper();
					long lSz=atolx(CDataXMLSaver::GetInstringPart("savesize=[","]",sParams));
					long lRb=atolx(CDataXMLSaver::GetInstringPart("rightbottom=[","]",sParams));
					long lCn=atolx(CDataXMLSaver::GetInstringPart("center=[","]",sParams));
					if(hCur){
						HWND hOrif=hCur;
						CRect rt;
						if(!bUsedChildWindows){
							GetWindowTopParent(hCur);
							GetWindowRect(hCur,&rt);
						}else{
							GetClientRect(hCur,&rt);
						}
						CSize sz=rt.Size();
						if(sY=="NOCHANGE_B"){
							lY=rt.bottom;
						}
						if(sY=="NOCHANGE_T"){
							lY=rt.top;
						}
						if(sX=="NOCHANGE_L"){
							lX=rt.left;
						}
						if(sX=="NOCHANGE_R"){
							lX=rt.right;
						}
						/*if(sRel=="CURSOR"){
						CPoint pt;
						GetCursorPos(&pt);
						rt.OffsetRect(lX,lY);
					}*/
						if(lRel || sRel=="RELATIVE"){
							rt.OffsetRect(lX,lY);
						}else if(lSz){
							if(lCn){
								rt.left=(lX-sz.cx)/2;
								rt.top=(lY-sz.cy)/2;
								rt.right=rt.left+sz.cx;
								rt.bottom=rt.top+sz.cy;
							}else if(lRb){
								rt.OffsetRect(lX-rt.right,lY-rt.bottom);
							}else{
								rt.OffsetRect(lX-rt.left,lY-rt.top);
							}
						}else if(lRb){
							rt.right=lX;
							rt.bottom=lY;
						}else{
							rt.left=lX;
							rt.top=lY;
						}
						MoveWindow(hCur,rt.left,rt.top,rt.Width(),rt.Height(),TRUE);
					}
				}
				if(hCur && sParams.Find("cmd::")!=-1){
					DWORD dwMsg=atolx(CDataXMLSaver::GetInstringPart("msg=[","]",sParams));
					LPARAM lPar=atolx(CDataXMLSaver::GetInstringPart("l=[","]",sParams));
					WPARAM wPar=atolx(CDataXMLSaver::GetInstringPart("h=[","]",sParams));
					if(hCur){
						HWND hOrif=hCur;
						if(!bUsedChildWindows){
							GetWindowTopParent(hCur);
						}
						BOOL bRes=0; 
						bRes=::SendMessage(hOrif,dwMsg,wPar,lPar);
					}
				}
				if(sParams.Find("key::")!=-1){
					DWORD dwMsg=atolx(CDataXMLSaver::GetInstringPart("msg=[","]",sParams));
					CString sLow=CDataXMLSaver::GetInstringPart("l=[","]",sParams);
					LPARAM lPar=0;
					if(sLow.GetLength()==9 && sLow[0]=='#'){
						lPar=(hexCode(sLow.Mid(1,2))<<(8*3))+(hexCode(sLow.Mid(3,2))<<(8*2))+(hexCode(sLow.Mid(5,2))<<8)+hexCode(sLow.Mid(7,2));
					}else{
						lPar=atolx(sLow);
					}
					BOOL bKeyDown=atolx(CDataXMLSaver::GetInstringPart("keydown=[","]",sParams));
					DWORD dwVK=LOBYTE(lPar);
					DWORD dwScan=HIBYTE(lPar);
					BOOL bExtended=atolx(CDataXMLSaver::GetInstringPart("ext=[","]",sParams));;
					::keybd_event(BYTE(dwVK), BYTE(dwScan), (bKeyDown?0:KEYEVENTF_KEYUP)|(bExtended?KEYEVENTF_EXTENDEDKEY:0), 0);
				}
				if(sParams.Find("mou::")!=-1){
					DWORD dwMsg=atolx(CDataXMLSaver::GetInstringPart("msg=[","]",sParams));
					long dwX=atolx(CDataXMLSaver::GetInstringPart("x=[","]",sParams));
					long dwY=atolx(CDataXMLSaver::GetInstringPart("y=[","]",sParams));
					// Если все относительно, то колбасим...
					CString sRel=(CDataXMLSaver::GetInstringPart("rel=[","]",sParams));
					sRel.MakeUpper();
					int dwRel=atolx(sRel);
					if(dwRel>0 || sRel=="WINDOW" || sRel=="RELATIVE"){
						if(hCur){
							CRect rt;
							GetWindowRect(hCur,&rt);
							dwX+=rt.left;
							dwY+=rt.top;
						}else{
							// Относительные клики без активного окна скипаем нахрен!
							return 0;
						}
					}
					if(dwRel<0 || sRel=="CURSOR"){
						CPoint pt;
						GetCursorPos(&pt);
						dwX+=pt.x;
						dwY+=pt.y;
					}
					dwX=long(65536*double(dwX)/double(rtDesktop.Width()));
					dwY=long(65536*double(dwY)/double(rtDesktop.Height()));
					if(dwMsg!=WM_MOUSEMOVE){// Сначала двигаем
						::mouse_event(
							MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE
							,dwX
							,dwY
							,0,0);
					}
					if(dwMsg==WM_LBUTTONDOWN){
						dwMsg=MOUSEEVENTF_LEFTDOWN;
					}else if(dwMsg==WM_LBUTTONUP){
						dwMsg=MOUSEEVENTF_LEFTUP;
					}else if(dwMsg==WM_RBUTTONDOWN){
						dwMsg=MOUSEEVENTF_RIGHTDOWN;
					}else if(dwMsg==WM_RBUTTONUP){
						dwMsg=MOUSEEVENTF_RIGHTUP;
					}else if(dwMsg==WM_MBUTTONDOWN){
						dwMsg=MOUSEEVENTF_MIDDLEDOWN;
					}else if(dwMsg==WM_MBUTTONUP){
						dwMsg=MOUSEEVENTF_MIDDLEUP;
					}else{
						dwMsg=MOUSEEVENTF_MOVE;
					}
					::mouse_event(
						MOUSEEVENTF_ABSOLUTE|dwMsg
						,dwX
						,dwY
						,0,0);
				}
			}
		}
	}
	return 0;
}