示例#1
0
文件: ctltree.c 项目: bencz/OrangeC
void CopyText(HWND hwnd)
{
    int len = GetClipboardText(hwnd, NULL, NULL,-2) + 1;
    char *p = malloc(len);
    if (p)
    {
        p[0] = 0;
        GetClipboardText(hwnd, NULL, p,-2);
        TextToClipBoard(hwnd, p);
        free(p);
    }
}
示例#2
0
文件: Utils.cpp 项目: Peluko/xkeymacs
BOOL CUtils::IsTOForEOF()
{
	CString text;
	GetClipboardText(text);
	return text.IsEmpty() || // for normal application
			text.GetLength() >= 3; // for VC++
}
示例#3
0
文件: wclipboard.cpp 项目: 2asoft/0ad
wchar_t* sys_clipboard_get()
{
	if(!OpenClipboard(hWndNewOwner))
		return 0;

	wchar_t* text;
	Status ret = GetClipboardText(text);

	WARN_IF_FALSE(CloseClipboard());

	return (ret == INFO::OK)? text : 0;
}
示例#4
0
文件: ctltree.c 项目: bencz/OrangeC
int GetClipboardText(HWND hwnd, HTREEITEM item, char *buf, int indent)
{
    int rv = 0;
    HTREEITEM current;
    if (item == NULL)
    {
        current = TreeView_GetRoot(hwnd);
    }
    else
    {
        rv += LoadItemText(hwnd, item, buf, indent);
        current = TreeView_GetChild(hwnd, item);
    }
    if (current)
    {
        do
            rv += GetClipboardText(hwnd, current, buf, indent + 2);
        while ((current = TreeView_GetNextSibling(hwnd, current))) ;
    }
    return rv;
}
示例#5
0
bool CEditUndoStack::OnPaste (CRichEditCtrl* pCtrl) {
  CString Buffer;
  long    StartSel;
  long    EndSel;

	/* Ignore invalid input */
  if (pCtrl == NULL) return (false);
  pCtrl->GetSel(StartSel, EndSel);

  if (EndSel - StartSel >= 1) {
    Buffer = pCtrl->GetSelText();
    CreateDeleteString(Buffer, StartSel, EndSel);
    //return (true);
  }

	/* Get the clipboard text to insert */
  if (!GetClipboardText(Buffer)) return (false);
  if (Buffer.IsEmpty()) return (false);

  CreateInsertString(Buffer, StartSel, StartSel);
  return (true);
}
示例#6
0
void CMainFrame::OnEditPaste()
{
    std::_tstring attrs;
    GetClipboardText(attrs);
    m_repositoryDlg.DoPaste(attrs);
}
示例#7
0
文件: NumericEdit.cpp 项目: ems/TMS
/**
 *	OnPaste - WM_PASTE message handler
 *	Parses a numeric value from the clipboard text, if available, and 
 *	displays it appropriately in the edit control
 *
 *	Added By Gurmeet S. Kochar (Mar 04, 2004)
 */
LRESULT CNumericEdit::OnPaste(WPARAM wParam, LPARAM lParam)
{
	UNUSED_ALWAYS(wParam);
	UNUSED_ALWAYS(lParam);

	CString	strClipBrdText,		// text available on clipboard
			strCtrlText;		// text in the edit control
	DWORD	dwSelStart = 0,		// selection range starting position
			dwSelEnd = 0;		// selection range ending position
	int		iDecimalPos[2];		// 0 = in control, 1 = in clipboard text

	strClipBrdText = GetClipboardText();
	// no (valid) clipboard data available?
	if (strClipBrdText.IsEmpty())
	{
		TRACE0("(Warning) CNumericEdit::OnPaste:"
				" Unknown clipboard data format or clipboard data unavailable.\n");
		::MessageBeep(MB_ICONEXCLAMATION);
		return (0L);
	}

	// get control's current text and selection range
	GetWindowText(strCtrlText);
	SendMessage(EM_GETSEL, (WPARAM)&dwSelStart, (LPARAM)&dwSelEnd);

	// pasting a negative value somewhere in between the current text?
	if ( (strClipBrdText[0] == DefUserLocale.chNegationSymbol) && (dwSelStart) )
	{
		::MessageBeep(MB_ICONEXCLAMATION);
		return (0L);
	}

	if (strCtrlText.GetLength() && 
		strCtrlText[0] == DefUserLocale.chNegationSymbol)
	{
		if (dwSelEnd == dwSelStart)
		{
			::MessageBeep(MB_ICONEXCLAMATION);
			return (0L);
		}
	}

	if (m_chDigitsAfterDecimal)
	{
		iDecimalPos[0] = strCtrlText.Find(DefUserLocale.chDecimalSymbol);
		iDecimalPos[1] = strClipBrdText.Find(DefUserLocale.chDecimalSymbol);
		// both control and clipboard text contain a decimal symbol and 
		// decimal symbol doesn't fall within the current selection range
		if ( (iDecimalPos[0] >= 0 && iDecimalPos[1] >= 0) && 
			 (iDecimalPos[0] < dwSelStart || iDecimalPos[0] > dwSelEnd) )
		{
			// extract only that much data from clipboard text 
			// that comes before the decimal symbol position
			strClipBrdText = strClipBrdText.Left(iDecimalPos[1]);
			
			// set iDecimalPos[1] to -1 to indicate that now 
			// there is no decimal symbol in the clipboard text!
			iDecimalPos[1] = -1;
		}
	}

	strCtrlText = strCtrlText.Left(dwSelStart) + 
					strClipBrdText + 
					strCtrlText.Mid(dwSelEnd);
	dwSelEnd = dwSelStart + strClipBrdText.GetLength();

	// if count of digits after decimal symbol exceeds the 
	// value specified by m_chDigitsAfterDecimal, then, 
	// truncate the rest of the string
	iDecimalPos[0] = strCtrlText.Find(DefUserLocale.chDecimalSymbol);
	if (iDecimalPos[0] >= 0)
	{
		if (strCtrlText.Mid(iDecimalPos[0] + 1).GetLength() > m_chDigitsAfterDecimal)
			strCtrlText = strCtrlText.Left(iDecimalPos[0] + m_chDigitsAfterDecimal + 1);
	}

	SetWindowText(strCtrlText);
	SetSel(dwSelEnd, dwSelEnd);	// position caret, scroll if necessary!

	// Do not call CEdit::Paste from within this function!!!

	return (0L);
}
示例#8
0
bool Search::ProcessKey(const Manager::Key& Key)
{
	auto LocalKey = Key;

	// для вставки воспользуемся макродвижком...
	if (LocalKey()==KEY_CTRLV || LocalKey()==KEY_RCTRLV || LocalKey()==KEY_SHIFTINS || LocalKey()==KEY_SHIFTNUMPAD0)
	{
		string ClipText;
		if (GetClipboardText(ClipText))
		{
			if (!ClipText.empty())
			{
				ProcessName(ClipText);
				ShowBorder();
			}
		}

		return true;
	}
	else if (LocalKey() == KEY_OP_XLAT)
	{
		m_FindEdit->Xlat();
		const auto strTempName = m_FindEdit->GetString();
		m_FindEdit->ClearString();
		ProcessName(strTempName);
		Redraw();
		return true;
	}
	else if (LocalKey() == KEY_OP_PLAINTEXT)
	{
		m_FindEdit->ProcessKey(LocalKey);
		const auto strTempName = m_FindEdit->GetString();
		m_FindEdit->ClearString();
		ProcessName(strTempName);
		Redraw();
		return true;
	}
	else
		LocalKey=_CorrectFastFindKbdLayout(Key.Event(),LocalKey());

	if (LocalKey()==KEY_ESC || LocalKey()==KEY_F10)
	{
		m_KeyToProcess=KEY_NONE;
		Close();
		return true;
	}

	// // _SVS(if (!FirstKey) SysLog(L"Panel::FastFind  Key=%s  %s",_FARKEY_ToName(Key),_INPUT_RECORD_Dump(&rec)));
	if (LocalKey()>=KEY_ALT_BASE+0x01 && LocalKey()<=KEY_ALT_BASE+65535)
		LocalKey=lower(static_cast<WCHAR>(LocalKey()-KEY_ALT_BASE));
	else if (LocalKey()>=KEY_RALT_BASE+0x01 && LocalKey()<=KEY_RALT_BASE+65535)
		LocalKey=lower(static_cast<WCHAR>(LocalKey()-KEY_RALT_BASE));

	if (LocalKey()>=KEY_ALTSHIFT_BASE+0x01 && LocalKey()<=KEY_ALTSHIFT_BASE+65535)
		LocalKey=lower(static_cast<WCHAR>(LocalKey()-KEY_ALTSHIFT_BASE));
	else if (LocalKey()>=KEY_RALTSHIFT_BASE+0x01 && LocalKey()<=KEY_RALTSHIFT_BASE+65535)
		LocalKey=lower(static_cast<WCHAR>(LocalKey()-KEY_RALTSHIFT_BASE));

	if (LocalKey()==KEY_MULTIPLY)
		LocalKey=L'*';

	switch (LocalKey())
	{
		case KEY_F1:
		{
			Hide();
			{
				Help::create(L"FastFind"sv);
			}
			Show();
			break;
		}
		case KEY_CTRLNUMENTER:   case KEY_RCTRLNUMENTER:
		case KEY_CTRLENTER:      case KEY_RCTRLENTER:
			m_Owner->FindPartName(m_FindEdit->GetString(), TRUE, 1);
			Redraw();
			break;
		case KEY_CTRLSHIFTNUMENTER:  case KEY_RCTRLSHIFTNUMENTER:
		case KEY_CTRLSHIFTENTER:     case KEY_RCTRLSHIFTENTER:
			m_Owner->FindPartName(m_FindEdit->GetString(), TRUE, -1);
			Redraw();
			break;
		case KEY_NONE:
		case KEY_IDLE:
			break;
		default:

			if ((LocalKey()<32 || LocalKey()>=65536) && LocalKey()!=KEY_BS && LocalKey()!=KEY_CTRLY && LocalKey()!=KEY_RCTRLY &&
			        LocalKey()!=KEY_CTRLBS && LocalKey()!=KEY_RCTRLBS && !IsModifKey(LocalKey()) &&
			        !(LocalKey()==KEY_CTRLINS||LocalKey()==KEY_CTRLNUMPAD0) && // KEY_RCTRLINS/NUMPAD0 passed to panels
			        !(LocalKey()==KEY_SHIFTINS||LocalKey()==KEY_SHIFTNUMPAD0) &&
			        !((LocalKey() == KEY_KILLFOCUS || LocalKey() == KEY_GOTFOCUS) && IsWindowsVistaOrGreater()) // Mantis #2903
			        )
			{
				m_KeyToProcess=LocalKey;
				Close();
				return true;
			}
			auto strLastName = m_FindEdit->GetString();
			if (m_FindEdit->ProcessKey(LocalKey))
			{
				auto strName = m_FindEdit->GetString();

				// уберем двойные '**'
				if (strName.size() > 1
				        && strName.back() == L'*'
				        && strName[strName.size()-2] == L'*')
				{
					strName.pop_back();
					m_FindEdit->SetString(strName);
				}

				/* $ 09.04.2001 SVS
				   проблемы с быстрым поиском.
				   Подробнее в 00573.ChangeDirCrash.txt
				*/
				if (starts_with(strName, L'"'))
				{
					strName.erase(0, 1);
					m_FindEdit->SetString(strName);
				}

				if (m_Owner->FindPartName(strName, FALSE, 1))
				{
					strLastName = strName;
				}
				else
				{
					if (Global->CtrlObject->Macro.IsExecuting())// && Global->CtrlObject->Macro.GetLevelState() > 0) // если вставка макросом...
					{
						//Global->CtrlObject->Macro.DropProcess(); // ... то дропнем макропроцесс
						//Global->CtrlObject->Macro.PopState();
						;
					}

					m_FindEdit->SetString(strLastName);
				}

				Redraw();
			}

			break;
	}
	return true;
}