Example #1
0
void CHistoryWnd::ScrollToEnd(CRichEditCtrl& edit, int numVisibleRows)
{
	int numLines = edit.GetLineCount();
	int nFirstLine = edit.GetFirstVisibleLine();
	if (numLines > numVisibleRows) 
	{
		int nScrollCount = numLines - numVisibleRows - nFirstLine - 1;
//		int nScrollCount = numLines - numVisibleRows - nFirstLine;
		if (nScrollCount > 0)
			edit.LineScroll(nScrollCount);
	}
}
void MessagesDlg::OnTcnSelchangingTab(NMHDR *pNMHDR, LRESULT *pResult)
{
	CRichEditCtrl* richEdit = (CRichEditCtrl*)GetDlgItem(IDC_MESSAGE);
	CString str;
	int len = richEdit->GetWindowTextLength();
	LPTSTR ptr = str.GetBuffer(len);
	richEdit->GetWindowText(ptr,len+1);
	str.ReleaseBuffer();

	MessagesContact* messagesContact = GetMessageContact();
	messagesContact->message = str;
	*pResult = 0;
}
BOOL MessagesDlg::OnInitDialog()
{
	CBaseDialog::OnInitDialog();

	AutoMove(IDC_TAB,0,0,100,0);
	AutoMove(IDC_LAST_CALL,100,0,0,0);
	AutoMove(IDC_CLOSE_ALL,100,0,0,0);
	AutoMove(IDC_TRANSFER,100,0,0,0);
	AutoMove(IDC_HOLD,100,0,0,0);
	AutoMove(IDC_END,100,0,0,0);
	AutoMove(IDC_LIST,0,0,100,80);
	AutoMove(IDC_MESSAGE,0,80,100,20);

	lastCall = NULL;
	tab = &tabComponent;
	
	HICON m_hIcon = theApp.LoadIcon(IDR_MAINFRAME);
	SetIcon(m_hIcon, FALSE);
	
	TranslateDialog(this->m_hWnd);

#ifndef _GLOBAL_VIDEO
	GetDlgItem(IDC_VIDEO_CALL)->ShowWindow(SW_HIDE);
#endif

	CRichEditCtrl* richEdit = (CRichEditCtrl*)GetDlgItem(IDC_MESSAGE);
	richEdit->SetEventMask(richEdit->GetEventMask() | ENM_KEYEVENTS);

	CRichEditCtrl* richEditList = (CRichEditCtrl*)GetDlgItem(IDC_LIST);
    richEditList->SetEventMask(richEdit->GetEventMask() | ENM_MOUSEEVENTS);

	CFont* font = this->GetFont();
	LOGFONT lf;
	font->GetLogFont(&lf);
	lf.lfHeight = 16;
	_tcscpy(lf.lfFaceName, _T("Arial"));
	fontList.CreateFontIndirect(&lf);
	richEditList->SetFont(&fontList);
	lf.lfHeight = 18;
	fontMessage.CreateFontIndirect(&lf);
	richEdit->SetFont(&fontMessage);


	para.cbSize=sizeof(PARAFORMAT2);
	para.dwMask = PFM_STARTINDENT | PFM_LINESPACING | PFM_SPACEBEFORE | PFM_SPACEAFTER;
	para.dxStartIndent=100;
	para.dySpaceBefore=100;
	para.dySpaceAfter=0;
	para.bLineSpacingRule = 5;
	para.dyLineSpacing = 22;
	richEditList->SetParaFormat(para);
	return TRUE;
}
void ViewFilesDialog::NewFontSelected(bool resetBold)
{
    CRichEditCtrl* pEdit = (CRichEditCtrl*) GetDlgItem(IDC_FVIEW_EDITBOX);
    ASSERT(pEdit != NULL);

    CHARFORMAT cf;
    cf.cbSize = sizeof(CHARFORMAT);
    cf.dwMask = CFM_FACE | CFM_SIZE;
    if (resetBold) {
        cf.dwMask |= CFM_BOLD;
        cf.dwEffects = 0;
    }
    ::lstrcpy(cf.szFaceName, fTypeFace);
    cf.yHeight = fPointSize * 20;       // in twips
    pEdit->SetSel(0, -1);               // select all
    pEdit->SetSelectionCharFormat(cf);
    pEdit->SetSel(0, 0);                // unselect
}
Example #5
0
int writestream(int fhandle, CRichEditCtrl &ctrl)
{
  EDITSTREAM es;

  es.dwCookie=fhandle;
  es.dwError=0;
  es.pfnCallback=writestream_callback;
  ctrl.StreamOut(SF_TEXT,es);
  return es.dwError;
}
//-----  LogMessage()  --------------------------------------------------------
void CFormChunkMergeView::LogMessage(const CString text, const CHARFORMAT* pFormat)
{
	CRichEditCtrl*	pLogView    ((CRichEditCtrl*) GetDlgItem(IDC_RE_LOG));
	int				lineCountOld(pLogView->GetLineCount());

	//  select  nothing, set format and append new text
	pLogView->SetSel(-1, -1);
	pLogView->SetSelectionCharFormat(*((CHARFORMAT*) pFormat));
	pLogView->ReplaceSel(text);

	//  scroll to end of text
	pLogView->LineScroll(pLogView->GetLineCount() - lineCountOld);
	pLogView->SetSel(-1, -1);
}
void CScoreDialog::ScrollToBottom(CRichEditCtrl& edit) 
{
	RECT rect;
	edit.GetRect(&rect);
	int nSize = rect.bottom - rect.top;

	//
	CWindowDC dc(this);
	TEXTMETRIC tm;
	dc.GetTextMetrics(&tm);

	// scroll to bottom
	int nHeight = tm.tmHeight;
	int nVisibleRows = nSize / nHeight;
	int numLines = edit.GetLineCount();
	int nFirstLine = edit.GetFirstVisibleLine();
	if (numLines > nVisibleRows) 
	{
		int nScrollCount = numLines - nVisibleRows - nFirstLine;
		edit.LineScroll(nScrollCount);
	}

	// and set selection at the end of the text
	int nTextLength = edit.GetTextLength();
	edit.SetSel(nTextLength,nTextLength);
}
void CRTFBuilder::write(CRichEditCtrl &c)
{
	m_string += '}';

//	CRtfStringDlg d(m_string);

	EDITSTREAM es = {(DWORD)&m_string, 0, EditStreamCallBack };

	// richEd is the rich edit control
	c.StreamIn(SF_RTF | SFF_SELECTION, es);

	m_string.Empty();
}
BOOL CCheckTextControlDlg::OnInitDialog() {
	CDialog::OnInitDialog();

	CString sampleText(_T("Alice was begining to get very tired of siting by her sister on the "
	  "bank, and of having nothing to do: once or twice she had peeped into the "
	  "book her sister was reading, but it had no pitures or conversatoins in "
	  "it, \"and what is the use of a book,\" thought Alice \"without pictures or "
	  "conversation?\"\r\n\r\n"
	  "So she was considerring in her own mind (as well as she could, for the "
	  "hot day made her feel very sleepy and stuppid), whether the plesure of "
	  "making a daisy-chain would be worth the trouble of getting up and "
	  "picking the daisys, when sudenly a White Rabbit with pink eyes ran "
	  "close by her."));

	CEdit *editCtrl = (CEdit *)GetDlgItem(IDC_EDIT1);
	editCtrl->SetWindowText(sampleText);
	editCtrl->SetSel(0, 0);

	// Load the contents of the rich-text control from a file.
	CRichEditCtrl *richEditCtrl = (CRichEditCtrl *)GetDlgItem(IDC_RICHEDIT1);
	richEditCtrl->LimitText(0xfffffff);
	CFile inFile;
	// alice.rtf is located in ssce\sdk\examples; current directory
	// should be ssce\sdk\examples\mfc\mfcexample
	if (inFile.Open(_T("..\\alice.rtf"), CFile::modeRead)) {
		EDITSTREAM es;
		es.dwCookie = (DWORD)&inFile;
		es.dwError = 0;
		es.pfnCallback = streamInCb;
		richEditCtrl->StreamIn(SF_RTF, es);
		inFile.Close();
	}
	else {
		richEditCtrl->SetWindowText(sampleText);
	}
	return (TRUE);
}
void MessagesDlg::OnChangeTab(pjsua_call_info *p_call_info)
{
	tab->HighlightItem(tab->GetCurSel(),FALSE);

	MessagesContact* messagesContact = GetMessageContact();
	SetWindowText(messagesContact->name);

	if (messagesContact->callId != -1) {
		pjsua_call_info call_info;
		if (!p_call_info) {
			pjsua_call_get_info(messagesContact->callId, &call_info);
			p_call_info = &call_info;
		}
		UpdateCallButton(TRUE, p_call_info);
		if (accountSettings.singleMode
			&&(p_call_info->role==PJSIP_ROLE_UAC ||
				(p_call_info->role==PJSIP_ROLE_UAS &&
				(p_call_info->state == PJSIP_INV_STATE_CONFIRMED
				|| p_call_info->state == PJSIP_INV_STATE_CONNECTING)
				))
			) {
			SIPURI sipuri;
			ParseSIPURI(messagesContact->number, &sipuri);
#ifndef _GLOBAL_ACCOUNT_MINI
			microsipDlg->pageDialer->SetNumber(!sipuri.user.IsEmpty() && sipuri.domain == accountSettings.account.domain ? sipuri.user : messagesContact->number);
#else
			microsipDlg->pageDialer->SetNumber(!sipuri.user.IsEmpty() ? sipuri.user : messagesContact->number);
#endif
		}
	} else {
		UpdateCallButton();
		if (accountSettings.singleMode) {
			microsipDlg->pageDialer->Clear();
		}
	}

	CRichEditCtrl* richEditList = (CRichEditCtrl*)GetDlgItem(IDC_LIST);
	CRichEditCtrl* richEdit = (CRichEditCtrl*)GetDlgItem(IDC_MESSAGE);

	CString messages = messagesContact->messages;
	EDITSTREAM es;
	es.dwCookie = (DWORD) &messages;
	es.pfnCallback = MEditStreamInCallback; 
	richEditList->StreamIn(SF_RTF, es);

	richEditList->PostMessage(WM_VSCROLL, SB_BOTTOM, 0);
	richEdit->SetWindowText(messagesContact->message);

	int nEnd = richEdit->GetTextLengthEx(GTL_NUMCHARS);
	richEdit->SetSel(nEnd, nEnd);
}
Example #11
0
BOOL helper::WriteFormattedStr(CRichEditCtrl& rec, LPCTSTR pszText, CHARFORMAT& cf)
{
	long nSelStart, nSelEnd;
	// 得到选择区并替换
	rec.GetSel(nSelStart, nSelEnd);
	rec.ReplaceSel(pszText);
	//
	nSelEnd = nSelStart + (long)_tcslen(pszText);
	rec.SetSel(nSelStart, nSelEnd);
	rec.SetSelectionCharFormat(cf);

	rec.SetSel(nSelEnd, nSelEnd);
	rec.UpdateWindow();

	return TRUE;
}
Example #12
0
void SampleContextMenu(CWindow wnd, CRichEditCtrl& ctrl, CPoint pt)
{
	CHARRANGE selRange;
	ctrl.GetSel(selRange);
	if (pt == CPoint(-1, -1))
		pt = ctrl.PosFromChar(selRange.cpMin);
	else
		ctrl.ScreenToClient(&pt);

	CRect rect;
	ctrl.GetClientRect(&rect);
	if (!rect.PtInRect(pt))
		return;

	if (selRange.cpMin == selRange.cpMax)
		ctrl.SetSel(0, -1);
	CMenu menuContext;
	menuContext.LoadMenu(IDR_SAMPLE_CONTEXTMENU);
	CMenuHandle menuPopup(menuContext.GetSubMenu(0));
	ctrl.ClientToScreen(&pt);
	menuPopup.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, wnd);
}
Example #13
0
void CProgressDlg::ParserCmdOutput(CRichEditCtrl &log,CProgressCtrl &progressctrl,HWND m_hWnd,CComPtr<ITaskbarList3> m_pTaskbarList,CStringA &oneline, char ch, CWnd *CurrentWork)
{
	//TRACE(_T("%c"),ch);
	if( ch == ('\r') || ch == ('\n'))
	{
		CString str;

//		TRACE(_T("End Char %s \r\n"),ch==_T('\r')?_T("lf"):_T(""));
//		TRACE(_T("End Char %s \r\n"),ch==_T('\n')?_T("cr"):_T(""));

		if(ClearESC(oneline))
		{
			ch = ('\r');
		}

		int lines = log.GetLineCount();
		g_Git.StringAppend(&str,(BYTE*)oneline.GetBuffer(),CP_ACP);
		str.Trim();
//		TRACE(_T("%s"), str);

		if(ch == ('\r'))
		{
			int start=log.LineIndex(lines-1);
			log.SetSel(start, log.GetTextLength());
			log.ReplaceSel(str);
		}
		else
		{
			int length = log.GetWindowTextLength();
			log.SetSel(length, length);
			if (length > 0)
				log.ReplaceSel(_T("\r\n") + str);
			else
				log.ReplaceSel(str);
		}

		if (lines > 500) //limited log length
		{
			int end=log.LineIndex(1);
			log.SetSel(0,end);
			log.ReplaceSel(_T(""));
		}
		log.LineScroll(log.GetLineCount() - log.GetFirstVisibleLine() - 4);

		int s1=oneline.ReverseFind(_T(':'));
		int s2=oneline.Find(_T('%'));
		if (s1 > 0 && s2 > 0)
		{
			if(CurrentWork)
				CurrentWork->SetWindowTextW(str.Left(s1));

			int pos=FindPercentage(str);
			TRACE(_T("Pos %d\r\n"),pos);
			if(pos>0)
			{
				progressctrl.SetPos(pos);
				if (m_pTaskbarList)
				{
					m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
					m_pTaskbarList->SetProgressValue(m_hWnd, pos, 100);
				}
			}
		}

		oneline="";

	}
	else
	{
		oneline+=ch;
	}
}
Example #14
0
void CResultDialog::OnCopySelectionToClipboard() 
{
	CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
	pEd->Copy( );
}
Example #15
0
void CResultDialog::SetText(LPCSTR aText)
{
  CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
	CString aCStr(aText);
  pEd->SetWindowText(aCStr);
}
Example #16
0
void CResultDialog::Empty()
{
  CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
  pEd->Clear();
}
Example #17
0
/*
 * Rearrange the DiskEdit dialog (which defaults to SectorEdit mode) to
 * accommodate block editing.
 */
BOOL BlockEditDialog::OnInitDialog(void)
{
    /*
     * Get rid of the "sector" input item, and change the "track" input
     * item to accept blocks instead.
     */
    CWnd* pWnd;

    pWnd = GetDlgItem(IDC_STEXT_SECTOR);
    pWnd->DestroyWindow();
    pWnd = GetDlgItem(IDC_DISKEDIT_SECTOR);
    pWnd->DestroyWindow();
    pWnd = GetDlgItem(IDC_DISKEDIT_SECTORSPIN);
    pWnd->DestroyWindow();

    CString blockStr;
    //blockStr.LoadString(IDS_BLOCK);
    blockStr.Format(L"Block (%d):", fpDiskFS->GetDiskImg()->GetNumBlocks());
    pWnd = GetDlgItem(IDC_STEXT_TRACK);
    ASSERT(pWnd != NULL);
    pWnd->SetWindowText(blockStr);

    /*
     * Increase the size of the window to accommodate the larger block size.
     */
    const int kStretchHeight = 250;
    CRect rect;

    GetWindowRect(&rect);
    rect.bottom += kStretchHeight;
    MoveWindow(&rect);

    CRichEditCtrl* pEdit = (CRichEditCtrl*)GetDlgItem(IDC_DISKEDIT_EDIT);
    ASSERT(pEdit != NULL);
    CRect inner;
    pEdit->GetRect(&inner);
    inner.bottom += kStretchHeight;
    pEdit->GetWindowRect(&rect);
    ScreenToClient(&rect);
    rect.bottom += kStretchHeight;
    pEdit->MoveWindow(&rect);
    pEdit->SetRect(&inner);

    MoveControl(this, IDC_DISKEDIT_DONE, 0, kStretchHeight);
    MoveControl(this, IDC_DISKEDIT_OPENFILE, 0, kStretchHeight);
    MoveControl(this, IDC_DISKEDIT_SUBVOLUME, 0, kStretchHeight);
    MoveControl(this, IDHELP, 0, kStretchHeight);
    MoveControl(this, IDC_DISKEDIT_NIBBLE_PARMS, 0, kStretchHeight);

    /*
     * Do base-class construction.
     */
    DiskEditDialog::OnInitDialog();

    /*
     * Configure the spin button.  We use the "track" spin button for blocks.
     */
    MySpinCtrl* pSpin;
    pSpin = (MySpinCtrl*)GetDlgItem(IDC_DISKEDIT_TRACKSPIN);
    ASSERT(pSpin != NULL);
    pSpin->SetRange32(0, fpDiskFS->GetDiskImg()->GetNumBlocks()-1);
    pSpin->SetPos(0);

    /* give us something to look at */
    if (LoadData() != 0) {
        LOGI("WHOOPS: LoadData() failed, but we're in OnInitDialog");
    }

    return TRUE;
}
Example #18
0
BOOL DiskEditDialog::OnInitDialog(void)
{
    ASSERT(!fFileName.IsEmpty());
    ASSERT(fpDiskFS != NULL);

    /*
     * Disable the write button.
     */
    if (fReadOnly) {
        CButton* pButton = (CButton*) GetDlgItem(IDC_DISKEDIT_DOWRITE);
        ASSERT(pButton != NULL);
        pButton->EnableWindow(FALSE);
    }

    /*
     * Use modified spin controls so we're not limited to 16 bits.
     */
    ReplaceSpinCtrl(&fTrackSpinner, IDC_DISKEDIT_TRACKSPIN,
        IDC_DISKEDIT_TRACK);
    ReplaceSpinCtrl(&fSectorSpinner, IDC_DISKEDIT_SECTORSPIN,
        IDC_DISKEDIT_SECTOR);



    /*
     * Configure the RichEdit control.
     */
    CRichEditCtrl* pEdit = (CRichEditCtrl*) GetDlgItem(IDC_DISKEDIT_EDIT);
    ASSERT(pEdit != NULL);

    /* set the font to 10-point Courier New */
    CHARFORMAT cf;
    cf.cbSize = sizeof(CHARFORMAT);
    cf.dwMask = CFM_FACE | CFM_SIZE;
    wcscpy(cf.szFaceName, L"Courier New");
    cf.yHeight = 10 * 20;       // point size in twips
    BOOL cc = pEdit->SetDefaultCharFormat(cf);
    if (cc == FALSE) {
        LOGI("SetDefaultCharFormat failed?");
        ASSERT(FALSE);
    }

    /* set to read-only */
    pEdit->SetReadOnly();
    /* retain the selection even if we lose focus [can't do this in OnInit] */
    pEdit->SetOptions(ECOOP_OR, ECO_SAVESEL);

    /*
     * Disable the sub-volume and/or file open buttons if the DiskFS doesn't
     * have the appropriate stuff inside.
     */
    if (fpDiskFS->GetNextFile(NULL) == NULL) {
        CWnd* pWnd = GetDlgItem(IDC_DISKEDIT_OPENFILE);
        pWnd->EnableWindow(FALSE);
    }
    if (fpDiskFS->GetNextSubVolume(NULL) == NULL) {
        CWnd* pWnd = GetDlgItem(IDC_DISKEDIT_SUBVOLUME);
        pWnd->EnableWindow(FALSE);
    }

    /*
     * Configure the nibble parm drop-list in an appropriate fashion.
     */
    InitNibbleParmList();

    /*
     * If this is a sub-volume edit window, pop us up slightly offset from the
     * parent window so the user can see that there's more than one thing
     * open.
     */
    if (fPositionShift != 0) {
        CRect rect;
        GetWindowRect(&rect);
        rect.top += fPositionShift;
        rect.left += fPositionShift;
        rect.bottom += fPositionShift;
        rect.right += fPositionShift;
        MoveWindow(&rect);
    }

    /*
     * Set the window title.
     */
    CString title("Disk Viewer - ");
    title += fFileName;
    if (fpDiskFS->GetVolumeID() != NULL) {
        title += " (";
        title += fpDiskFS->GetVolumeID();
        title += ")";
    }
    SetWindowText(title);

    return TRUE;
}
Example #19
0
void ViewFilesDialog::DisplayText(const WCHAR* fileName)
{
    CWaitCursor wait;   // streaming of big files can take a little while
    bool errFlg;
    bool emptyFlg = false;
    bool editHadFocus = false;
    
    ASSERT(fpOutput != NULL);
    ASSERT(fileName != NULL);

    errFlg = fpOutput->GetOutputKind() == ReformatOutput::kOutputErrorMsg;

    ASSERT(fpOutput->GetOutputKind() != ReformatOutput::kOutputUnknown);

    CRichEditCtrl* pEdit = (CRichEditCtrl*) GetDlgItem(IDC_FVIEW_EDITBOX);
    ASSERT(pEdit != NULL);

    /* retain the selection even if we lose focus [can't do this in OnInit] */
    pEdit->SetOptions(ECOOP_OR, ECO_SAVESEL);

#if 0
    /*
     * Start by trashing anything that's there.  Not strictly necessary,
     * but it prevents the control from trying to maintain the old stuff
     * in an undo buffer.  (Not entirely sure if a stream-in operation is
     * undoable, but it costs very little to be certain.)
     *
     * UPDATE: I turned this off because it was dinging the speaker (?!).
     * Might be doing that because it's in read-only mode.
     */
    pEdit->SetSel(0, -1);
    pEdit->Clear();
    pEdit->EmptyUndoBuffer();
#endif

    /*
     * There's a redraw flash that goes away if you change the input
     * focus to something other than the edit ctrl.  (Move between large
     * files; it looks like you can see the text being selected and
     * hightlighted.  The control doesn't have an "always highlight" flag
     * set, so if the focus is on a different control it doesn't light up.)
     *
     * Since we're currently forcing the focus to be on the edit ctrl later
     * on, we just jam it to something else here.  If nothing has the focus,
     * as can happen if we click on "resource fork" and then Alt-N to a
     * file without a resource fork, we force the focus to return to the
     * edit window.
     *
     * NOTE: this would look a little better if we used the Prev/Next
     * buttons to hold the temporary focus, but we need to know which key
     * the user hit.  We could also create a bogus control, move it into
     * negative space where it will be invisible, and use that as a "focus
     * holder".
     */
    CWnd* pFocusWnd = GetFocus();
    if (pFocusWnd == NULL || pFocusWnd->m_hWnd == pEdit->m_hWnd) {
        editHadFocus = true;
        GetDlgItem(IDOK)->SetFocus();
    }

    /*
     * The text color isn't getting reset when we reload the control.  I
     * can't find a "set default text color" call, so I'm reformatting
     * part of the buffer.
     *
     * Here's the weird part: it doesn't seem to matter what color I
     * set it to under Win2K.  It reverts to black so long as I do anything
     * here.  Under Win98, it uses the new color.
     */
    //if (0)
    {
        CHARFORMAT cf;
        cf.cbSize = sizeof(CHARFORMAT);
        cf.dwMask = CFM_COLOR;
        cf.crTextColor = RGB(0, 0, 0);
        pEdit->SetSel(0, 1);    // must select at least one char
        pEdit->SetSelectionCharFormat(cf);
    }

    /*
     * Add the appropriate data.  If the "bitmap" flag is set, use the
     * MyDIBitmap pointer instead.
     */
    if (fpOutput->GetOutputKind() == ReformatOutput::kOutputBitmap) {
        CClientDC dcScreen(this);
        HBITMAP hBitmap;

        if (fpRichEditOle == NULL) {
            /* can't do this in OnInitDialog -- m_pWnd isn't initialized */
            fpRichEditOle = pEdit->GetIRichEditOle();
            ASSERT(fpRichEditOle != NULL);
        }

        //FILE* fp = fopen("C:/test/output.bmp", "wb");
        //if (fp != NULL) {
        //  pDib->WriteToFile(fp);
        //  fclose(fp);
        //}
        
        hBitmap = fpOutput->GetDIB()->ConvertToDDB(dcScreen.m_hDC);
        if (hBitmap == NULL) {
            LOGI("ConvertToDDB failed!");
            pEdit->SetWindowText(L"Internal error.");
            errFlg = true;
        } else {
            //DumpBitmapInfo(hBitmap);
            //DumpBitmapInfo(pDib->GetHandle());

            LOGI("Inserting bitmap");
            pEdit->SetWindowText(L"");
            CImageDataObject::InsertBitmap(fpRichEditOle, hBitmap);

            /* RichEditCtrl has it now */
            ::DeleteObject(hBitmap);
        }
    } else {
        /*
         * Stream the data in, using the appropriate format.  Since we don't
         * have the "replace selection" flag set, this replaces everything
         * that's currently in there.
         *
         * We can't use SetWindowText() unless we're willing to forgo viewing
         * of binary files in "raw" form.  There doesn't seem to be any other
         * difference between the two approaches.
         */
        const char* textBuf;
        long textLen;
        int streamFormat;

        textBuf = fpOutput->GetTextBuf();
        textLen = fpOutput->GetTextLen();
        streamFormat = SF_TEXT;
        if (fpOutput->GetOutputKind() == ReformatOutput::kOutputRTF)
            streamFormat = SF_RTF;
        if (fpOutput->GetTextLen() == 0) {
            textBuf = "(file is empty)";
            textLen = strlen(textBuf);
            emptyFlg = true;
            EnableFormatSelection(FALSE);
        }
        if (fpOutput->GetOutputKind() == ReformatOutput::kOutputErrorMsg)
            EnableFormatSelection(FALSE);

        /* make sure the control will hold everything we throw at it */
        pEdit->LimitText(textLen+1);
        LOGI("Streaming %ld bytes (kind=%d)",
            textLen, fpOutput->GetOutputKind());

        /* clear this early to avoid loading onto yellow */
        if (errFlg)
            pEdit->SetBackgroundColor(FALSE, RGB(255, 255, 0));
        else if (emptyFlg)
            pEdit->SetBackgroundColor(FALSE, RGB(192, 192, 192));
        else
            pEdit->SetBackgroundColor(TRUE, 0);

        RichEditXfer xfer(textBuf, textLen);
        EDITSTREAM es;
        es.dwCookie = (DWORD) &xfer;
        es.dwError = 0;
        es.pfnCallback = RichEditXfer::EditStreamCallback;
        long count;
        count = pEdit->StreamIn(streamFormat, es);
        LOGI("StreamIn returned count=%ld dwError=%d", count, es.dwError);

        if (es.dwError != 0) {
            /* a -16 error can happen if the type is RTF but contents are not */
            char errorText[256];

            sprintf(errorText,
                "ERROR: failed while loading data (err=0x%08lx)\n"
                "(File contents might be too big for Windows to display)\n",
                es.dwError);
            RichEditXfer errXfer(errorText, strlen(errorText));
            es.dwCookie = (DWORD) &errXfer;
            es.dwError = 0;

            count = pEdit->StreamIn(SF_TEXT, es);
            LOGI("Error StreamIn returned count=%ld dwError=%d", count, es.dwError);

            errFlg = true;
        }

        //pEdit->SetSel(0, 0);
    }

    /* move us back to the top */
    pEdit->LineScroll(-pEdit->GetFirstVisibleLine());

    /* just in case it's trying to hold on to something */
    pEdit->EmptyUndoBuffer();

    /* work around bug that creates unnecessary scroll bars */
    pEdit->SetScrollRange(SB_VERT, 0, 0, TRUE);
    pEdit->SetScrollRange(SB_HORZ, 0, 0, TRUE);

    /* display the entire message in the user's selected font */
    if (!fpOutput->GetMultipleFontsFlag()) {
        // adjust the font, stripping default boldness from SF_TEXT
        NewFontSelected(fpOutput->GetOutputKind() != ReformatOutput::kOutputRTF);
    }

    /* enable/disable the scroll bars */
    //pEdit->EnableScrollBar(SB_BOTH, ESB_DISABLE_BOTH);

    if (errFlg)
        pEdit->SetBackgroundColor(FALSE, RGB(255, 255, 0));
    else if (emptyFlg)
        pEdit->SetBackgroundColor(FALSE, RGB(192, 192, 192));
    else
        pEdit->SetBackgroundColor(TRUE, 0);

    /*
     * Work around a Windows bug that prevents the scroll bars from
     * being displayed immediately.  This makes them appear, but the
     * vertical scroll bar comes out funky on short files (fixed with
     * the SetScrollRange call above).
     *
     * Best guess: when the edit box is resized, it chooses the scroll bar
     * configuration based on the currently-loaded data.  If you resize it
     * and *then* add data, you're stuck with the previous scroll bar
     * values.  This doesn't quite make sense though...
     *
     * This works:
     *  - Set up dialog.
     *  - Load data.
     *  - Do minor twiddling.
     *  - Resize box significantly.
     *
     * This works:
     *  - (box already has data in it)
     *  - Load new data.
     *  - Do minor twiddling.
     *
     * This doesn't:
     *  - Set up dialog
     *  - Resize box significantly.
     *  - Load data.
     *  - Do minor twiddling.
     *
     * There might be some first-time setup issues in here.  Hard to say.
     * Anything related to RichEdit controls is extremely fragile, and must
     * be tested with a variety of inputs, preference settings, and under
     * at least Win98 and Win2K (which are *very* different).
     */
    if (fFirstResize) {
        /* adjust the size of the window to match the last size used */
        const Preferences* pPreferences = GET_PREFERENCES();
        long width = pPreferences->GetPrefLong(kPrFileViewerWidth);
        long height = pPreferences->GetPrefLong(kPrFileViewerHeight);
        CRect fullRect;
        GetWindowRect(&fullRect);
        //LOGI(" VFD pre-size %dx%d", fullRect.Width(), fullRect.Height());
        fullRect.right = fullRect.left + width;
        fullRect.bottom = fullRect.top + height;
        MoveWindow(fullRect, TRUE);

        editHadFocus = true;    // force focus on edit box

        fFirstResize = false;
    } else {
        /* this should be enough */
        ShiftControls(0, 0);
    }
        
    if (fpOutput->GetOutputKind() == ReformatOutput::kOutputBitmap) {
        /* get the cursor off of the image */
        pEdit->SetSel(-1, -1);
    }

    /*
     * We want the focus to be on the text window so keyboard selection
     * commands work.  However, it's also nice to be able to arrow through
     * the format selection box.
     */
    if (editHadFocus)
        pEdit->SetFocus();

    fTitle = fileName;
    //if (fpOutput->GetOutputKind() == ReformatOutput::kOutputText ||
    //  fpOutput->GetOutputKind() == ReformatOutput::kOutputRTF ||
    //  fpOutput->GetOutputKind() == ReformatOutput::kOutputCSV ||
    //  fpOutput->GetOutputKind() == ReformatOutput::kOutputBitmap ||
    //  fpOutput->GetOutputKind() == ReformatOutput::kOutputRaw)
    //{
        // not for error messages
        fTitle += _T(" [");
        fTitle += fpOutput->GetFormatDescr();
        fTitle += _T("]");
    //} else if (fpOutput->GetOutputKind() == ReformatOutput::kOutputRaw) {
    //  fTitle += _T(" [Raw]");
    //}

    CString winTitle = _T("File Viewer - ");
    winTitle += fTitle;
    SetWindowText(winTitle);

    /*
     * Enable or disable the next/prev buttons.
     */
    CButton* pButton;
    pButton = (CButton*) GetDlgItem(IDC_FVIEW_PREV);
    pButton->EnableWindow(fpSelSet->IterHasPrev());
    pButton = (CButton*) GetDlgItem(IDC_FVIEW_NEXT);
    pButton->EnableWindow(fpSelSet->IterHasNext());
}
Example #20
0
void DiskEditDialog::DisplayData(const uint8_t* srcBuf, int size)
{
    WCHAR textBuf[80 * 16 * 2];
    WCHAR* cp;
    int i, j;

    ASSERT(srcBuf != NULL);
    ASSERT(size == kSectorSize || size == kBlockSize);

    CRichEditCtrl* pEdit = (CRichEditCtrl*)GetDlgItem(IDC_DISKEDIT_EDIT);
    ASSERT(pEdit != NULL);

    /*
     * If we have an alert message, show that instead.
     */
    if (!fAlertMsg.IsEmpty()) {
        const int kWidth = 72;
        int indent = (kWidth/2) - (fAlertMsg.GetLength() / 2);
        if (indent < 0)
            indent = 0;

        CString msg = L"                                    "
                      L"                                    ";
        ASSERT(msg.GetLength() == kWidth);
        msg = msg.Left(indent);
        msg += fAlertMsg;
        for (i = 0; i < (size / 16)-2; i += 2) {
            textBuf[i] = '\r';
            textBuf[i+1] = '\n';
        }
        wcscpy(&textBuf[i], msg);
        pEdit->SetWindowText(textBuf);

        return;
    }

    /*
     * No alert, do the usual thing.
     */
    cp = textBuf;
    for (i = 0; i < size/16; i++) {
        if (size == kSectorSize) {
            /* two-nybble addr */
            wsprintf(cp, L" %02x: %02x %02x %02x %02x %02x %02x %02x %02x "
                         L"%02x %02x %02x %02x %02x %02x %02x %02x  ",
                i * 16,
                srcBuf[0], srcBuf[1], srcBuf[2], srcBuf[3],
                srcBuf[4], srcBuf[5], srcBuf[6], srcBuf[7],
                srcBuf[8], srcBuf[9], srcBuf[10], srcBuf[11],
                srcBuf[12], srcBuf[13], srcBuf[14], srcBuf[15]);
        } else {
            /* three-nybble addr */
            wsprintf(cp, L"%03x: %02x %02x %02x %02x %02x %02x %02x %02x "
                         L"%02x %02x %02x %02x %02x %02x %02x %02x  ",
                i * 16,
                srcBuf[0], srcBuf[1], srcBuf[2], srcBuf[3],
                srcBuf[4], srcBuf[5], srcBuf[6], srcBuf[7],
                srcBuf[8], srcBuf[9], srcBuf[10], srcBuf[11],
                srcBuf[12], srcBuf[13], srcBuf[14], srcBuf[15]);
        }
        ASSERT(wcslen(cp) == 54);
        cp += 54;       // strlen(cp)
        for (j = 0; j < 16; j++)
            *cp++ = PrintableChar(srcBuf[j]);

        *cp++ = '\r';
        *cp++ = '\n';

        srcBuf += 16;
    }
    /* kill the last EOL, so the cursor doesn't move past that line */
    cp--;
    *cp = '\0';

    pEdit->SetWindowText(textBuf);
}
Example #21
0
BOOL NibbleEditDialog::OnInitDialog(void)
{
    /*
     * Get rid of the "sector" input item.
     */
    CWnd* pWnd;

    pWnd = GetDlgItem(IDC_STEXT_SECTOR);
    pWnd->DestroyWindow();
    pWnd = GetDlgItem(IDC_DISKEDIT_SECTOR);
    pWnd->DestroyWindow();
    pWnd = GetDlgItem(IDC_DISKEDIT_SECTORSPIN);
    pWnd->DestroyWindow();

    CString trackStr;
    trackStr.Format(L"Track (%d):", fpDiskFS->GetDiskImg()->GetNumTracks());
    pWnd = GetDlgItem(IDC_STEXT_TRACK);
    ASSERT(pWnd != NULL);
    pWnd->SetWindowText(trackStr);

    /*
     * Increase the size of the window so it's the same height as blocks.
     *
     * NOTE: using a pixel constant is probably bad.  We want to use something
     * like GetTextMetrics, but I'm not sure how to get that without a
     * device context.
     */
    CRichEditCtrl* pEdit = (CRichEditCtrl*)GetDlgItem(IDC_DISKEDIT_EDIT);
    ASSERT(pEdit != NULL);
    const int kStretchHeight = 249;
    CRect rect;

    GetWindowRect(&rect);
    rect.bottom += kStretchHeight;
    MoveWindow(&rect);

    /*
     * Must postpone resize of edit ctrl until after data has been loaded, or
     * scroll bars fail to appear under Win98.  Makes no sense whatsoever, but
     * that's Windows for you.
     */
#if 0
    CRect inner;
    pEdit->GetRect(&inner);
    inner.bottom += kStretchHeight;
    pEdit->GetWindowRect(&rect);
    ScreenToClient(&rect);
    rect.bottom += kStretchHeight;
    pEdit->MoveWindow(&rect);
    pEdit->SetRect(&inner);
#endif

    /* show the scroll bar */
    pEdit->ShowScrollBar(SB_VERT);

    MoveControl(this, IDC_DISKEDIT_DONE, 0, kStretchHeight);
    MoveControl(this, IDC_DISKEDIT_OPENFILE, 0, kStretchHeight);
    MoveControl(this, IDC_DISKEDIT_SUBVOLUME, 0, kStretchHeight);
    MoveControl(this, IDHELP, 0, kStretchHeight);
    MoveControl(this, IDC_DISKEDIT_NIBBLE_PARMS, 0, kStretchHeight);

    /* disable opening of files and sub-volumes */
    pWnd = GetDlgItem(IDC_DISKEDIT_OPENFILE);
    pWnd->EnableWindow(FALSE);
    pWnd = GetDlgItem(IDC_DISKEDIT_SUBVOLUME);
    pWnd->EnableWindow(FALSE);

    /*
     * Do base-class construction.
     */
    DiskEditDialog::OnInitDialog();

    /*
     * This currently has no effect on the nibble editor.  Someday we may
     * want to highlight and/or decode address fields.
     */
    pWnd = GetDlgItem(IDC_DISKEDIT_NIBBLE_PARMS);
    pWnd->EnableWindow(FALSE);

    /*
     * Configure the track spin button.
     */
    MySpinCtrl* pSpin;
    pSpin = (MySpinCtrl*)GetDlgItem(IDC_DISKEDIT_TRACKSPIN);
    ASSERT(pSpin != NULL);
    pSpin->SetRange32(0, fpDiskFS->GetDiskImg()->GetNumTracks()-1);
    pSpin->SetPos(0);

    /* give us something to look at */
    LoadData();

    return TRUE;
}
void MessagesDlg::OnSelectAll()
{
	CRichEditCtrl* richEditList = (CRichEditCtrl*)GetDlgItem(IDC_LIST);
	richEditList->SetSel(0,-1);
}
void MessagesDlg::OnCopy()
{
	CRichEditCtrl* richEditList = (CRichEditCtrl*)GetDlgItem(IDC_LIST);
	richEditList->Copy();
}
Example #24
0
DWORD SetRichEditData(CRichEditCtrl& ctrl, DWORD format, const BYTE* pData, size_t len)
{
	RichEditStream stream(pData, len);
	EDITSTREAM es = { reinterpret_cast<DWORD_PTR>(&stream), 0, &EditStreamCallback };
	return ctrl.StreamIn(SF_RTF, es);
}
void MessagesDlg::AddMessage(MessagesContact* messagesContact, CString message, int type, BOOL blockForeground)
{
	CTime tm = CTime::GetCurrentTime();

	if (type == MSIP_MESSAGE_TYPE_SYSTEM) {
		if ( messagesContact->lastSystemMessage == message && messagesContact->lastSystemMessageTime > tm.GetTime()-2) {
			messagesContact->lastSystemMessageTime = tm;
			return;
		}
		messagesContact->lastSystemMessage = message;
		messagesContact->lastSystemMessageTime = tm;
	} else if (!messagesContact->lastSystemMessage.IsEmpty()) {
		messagesContact->lastSystemMessage = _T("");
	}

	if (IsWindowVisible() && !blockForeground) {
		SetForegroundWindow();
	}
	CRichEditCtrl richEdit;
	MessagesContact* messagesContactSelected = GetMessageContact();

	CRichEditCtrl *richEditList = (CRichEditCtrl *)GetDlgItem(IDC_LIST);
	if (messagesContactSelected != messagesContact) {
		CRect rect;
		rect.left = 0;
		rect.top = 0;
		rect.right = 300;
		rect.bottom = 300;
		richEdit.Create(ES_MULTILINE | ES_READONLY | ES_NUMBER | WS_VSCROLL, rect, this, NULL);
		richEdit.SetFont(&fontList);
		richEdit.SetParaFormat(para);	

		CString messages = messagesContact->messages;
		EDITSTREAM es;
		es.dwCookie = (DWORD) &messages;
		es.pfnCallback = MEditStreamInCallback; 
		richEdit.StreamIn(SF_RTF, es);

		richEditList = &richEdit;
	}

	COLORREF color;
	CString name;
	if (type==MSIP_MESSAGE_TYPE_LOCAL) {
		color = RGB (0,0,0);
		if (!accountSettings.account.displayName.IsEmpty()) {
			name = accountSettings.account.displayName;
		}
	} else if (type==MSIP_MESSAGE_TYPE_REMOTE) {
		color = RGB (21,101,206);
		name = messagesContact->name;
		int pos = name.Find(_T(" ("));
		if (pos==-1) {
			pos = name.Find(_T("@"));
		}
		if (pos!=-1) {
			name = name.Mid(0,pos);
		}
	}

	int nBegin;
	CHARFORMAT cf;
	CString str;

	CString time = tm.Format(_T("%X"));

	nBegin = richEditList->GetTextLengthEx(GTL_NUMCHARS);
	richEditList->SetSel(nBegin, nBegin);
	str.Format(_T("[%s]  "),time);
	richEditList->ReplaceSel( str );
	cf.dwMask = CFM_BOLD | CFM_COLOR | CFM_SIZE;
	cf.crTextColor = RGB (131,131,131);
	cf.dwEffects = 0;
	cf.yHeight = 160;
	richEditList->SetSel(nBegin,-1);
	richEditList->SetSelectionCharFormat(cf);

	if (type != MSIP_MESSAGE_TYPE_SYSTEM) {
		cf.yHeight = 200;
	}
	if (name.GetLength()) {
		nBegin = richEditList->GetTextLengthEx(GTL_NUMCHARS);
		richEditList->SetSel(nBegin, nBegin);
		richEditList->ReplaceSel( name + _T(": "));
		cf.dwMask = CFM_BOLD | CFM_COLOR | CFM_SIZE;
		cf.crTextColor = color;
		cf.dwEffects = CFE_BOLD;
		richEditList->SetSel(nBegin,-1);
		richEditList->SetSelectionCharFormat(cf);
	}

	nBegin = richEditList->GetTextLengthEx(GTL_NUMCHARS);
	richEditList->SetSel(nBegin, nBegin);
	richEditList->ReplaceSel(message+_T("\r\n"));
	cf.dwMask = CFM_BOLD | CFM_COLOR | CFM_SIZE;

	cf.crTextColor = type == MSIP_MESSAGE_TYPE_SYSTEM ? RGB (131, 131, 131) : color;
	cf.dwEffects = 0;

	richEditList->SetSel(nBegin,-1);
	richEditList->SetSelectionCharFormat(cf);

	if (messagesContactSelected == messagesContact)	{
		richEditList->PostMessage(WM_VSCROLL, SB_BOTTOM, 0);
	} else {
		for (int i = 0; i < tab->GetItemCount(); i++) {
			if (messagesContact == GetMessageContact(i))
			{
				tab->HighlightItem(i, TRUE);
				break;
			}
		}
	}

	str=_T("");
	EDITSTREAM es;
	es.dwCookie = (DWORD) &str;
	es.pfnCallback = MEditStreamOutCallback; 
	richEditList->StreamOut(SF_RTF, es);
	messagesContact->messages=str;
}
Example #26
0
void CProgressDlg::InsertColorText(CRichEditCtrl &edit,CString text,COLORREF rgb)
{
	CHARFORMAT old,cf;
	edit.GetDefaultCharFormat(cf);
	old=cf;
	cf.dwMask|=CFM_COLOR;
	cf.crTextColor=rgb;
	cf.dwEffects|=CFE_BOLD;
	cf.dwEffects &= ~CFE_AUTOCOLOR ;
	edit.SetSel(edit.GetTextLength()-1,edit.GetTextLength());
	edit.ReplaceSel(text);
	edit.SetSel(edit.LineIndex(edit.GetLineCount()-2),edit.GetTextLength());
	edit.SetSelectionCharFormat(cf);
	edit.SetSel(edit.GetTextLength(),edit.GetTextLength());
	edit.SetDefaultCharFormat(old);
	edit.LineScroll(edit.GetLineCount() - edit.GetFirstVisibleLine() - 4);
}
Example #27
0
void DiskEditDialog::DisplayNibbleData(const unsigned char* srcBuf, int size)
{
    ASSERT(srcBuf != NULL);
    ASSERT(size > 0);
    ASSERT(fAlertMsg.IsEmpty());

    int bufSize = ((size+15) / 16) * 80;
    WCHAR* textBuf = new WCHAR[bufSize];
    WCHAR* cp;
    int i;

    if (textBuf == NULL)
        return;

    cp = textBuf;
    for (i = 0; size > 0; i++) {
        if (size >= 16) {
            wsprintf(cp, L"%04x: %02x %02x %02x %02x %02x %02x %02x %02x "
                         L"%02x %02x %02x %02x %02x %02x %02x %02x",
                i * 16,
                srcBuf[0], srcBuf[1], srcBuf[2], srcBuf[3],
                srcBuf[4], srcBuf[5], srcBuf[6], srcBuf[7],
                srcBuf[8], srcBuf[9], srcBuf[10], srcBuf[11],
                srcBuf[12], srcBuf[13], srcBuf[14], srcBuf[15]);
            ASSERT(wcslen(cp) == 53);
            cp += 53;       // strlen(cp)
        } else {
            wsprintf(cp, L"%04x:", i * 16);
            cp += 5;
            for (int j = 0; j < size; j++) {
                wsprintf(cp, L" %02x", srcBuf[j]);
                cp += 3;
            }
        }

        *cp++ = '\r';
        *cp++ = '\n';

        srcBuf += 16;
        size -= 16;
    }
    /* kill the last EOL, so the cursor doesn't move past that line */
    cp--;
    *cp = '\0';

    CRichEditCtrl* pEdit = (CRichEditCtrl*)GetDlgItem(IDC_DISKEDIT_EDIT);
    ASSERT(pEdit != NULL);
    pEdit->SetWindowText(textBuf);

    /*
     * Handle resize of edit box.  We have to do this late or the scroll bar
     * won't appear under Win98.  (Whatever.)
     */
    if (fFirstResize) {
        fFirstResize = false;

        const int kStretchHeight = 249;
        CRect rect;

        GetWindowRect(&rect);

        CRect inner;
        pEdit->GetRect(&inner);
        inner.bottom += kStretchHeight;
        pEdit->GetWindowRect(&rect);
        ScreenToClient(&rect);
        rect.bottom += kStretchHeight;
        pEdit->MoveWindow(&rect);
        pEdit->SetRect(&inner);
    }

    delete[] textBuf;
}
// id 0 is the basestream
void CInputDocView::addPanel(CResultStream* pStream, int id)
{
	CRect r;//(0,0, 100, 100);
	GetClientRect(&r);
	r.top = 25;
	r.right -= 5;
	r.bottom -= 5;
	CRichEditCtrl* pEC = new CRichEditCtrl;//CPanelRichEditCtrl;//
//	CEdit* pEC = new CEdit;
	m_pEditCtrls.Add(pEC);



	DWORD dwFlags = ECO_SAVESEL | ES_AUTOVSCROLL | ES_MULTILINE |
				ES_NOHIDESEL   | WS_BORDER | WS_VSCROLL | WS_CHILD | WS_VISIBLE | ES_WANTRETURN;

#ifndef jdhhab621
	// a hack to get a scrollbar for pc-patr.  This could be generalized or put in the user's
	// control, but not without work that seems unjustified if it's just for pcpatr.

	if (pStream->getDescriptor()->getTabLabel().Find("PATR") != -1)
		dwFlags |= WS_HSCROLL | ES_AUTOHSCROLL;
#endif // jdhhab261

	pEC->Create(dwFlags,
				(RECT&)r,
				&m_tabCtrl,
				id);

	CFont* test = pStream->getFont();
	pEC->SetFont(test);

	// NOTE: I'm not clear on whether StreamIn is done with the stream when it returns;
	// it doesn't seem to delete it, but you'd think it would need
	// to keep it around so it can get at large files when the user
	// scrolls down; maybe not.  Why it matters is, what if the cwCOOKIE
	// member points to a CResultsStream that I've deleted?
	// For now, I'm going to go on the assumption that the whole
	// file is read right here.
	pEC->StreamIn(SF_TEXT, pStream->getEditStreamIn()); // icon may be set in here
	// Set editing flags and limit

	CInputDoc* pDoc = (CInputDoc*) GetDocument();
	if(id==kBasePanelID && pDoc->m_bBaseIsEditable)
	{
		pEC->SetReadOnly(FALSE);
		const long kMaxAddableChars = 2000;
		long l = pEC->GetTextLength() + kMaxAddableChars;
		pEC->LimitText(l);
		pEC->SetEventMask( ENM_KEYEVENTS| ENM_CHANGE );// want to know when the user changes something
	}
	else
		pEC->SetReadOnly(TRUE);


/*	ALL THIS WAS FOR CEDIT, NOT CRICHEDIT
	EDITSTREAM es =  pStream->getEditStreamIn();
	long sz = pEC->GetLimitText()-10;
	char* buff = new char [sz+1];
	ASSERTX(buff);
	long actual;
	(es.pfnCallback)((DWORD)(pStream), (unsigned char*)buff, sz, &actual);
	buff[actual] = '\0';
	CString sOverflowMsg = pStream->getOverflowMsg();
	if(actual > sz - sOverflowMsg.GetLength())
	{
		buff[sz-sOverflowMsg.GetLength()] = '\0';
		CString s = buff;
		s += sOverflowMsg;
		pEC->SetWindowText(s);
	}
	else
		pEC->SetWindowText(buff);


	// make it close
	(es.pfnCallback)((DWORD)(pStream), (unsigned char*)buff, 0, &actual);
	delete buff;
*/

	// make the tab for this item
	TC_ITEM tie;
	tie.mask = TCIF_TEXT |TCIF_PARAM ;
	tie.lParam = (LPARAM)pStream;
	tie.pszText = (char*)  LPCTSTR(pStream->getDescriptor()->getTabLabel());
	int iconEnum = pStream->getTabIconEnum();
	if(iconEnum>=0)
	{
		tie.mask |= TCIF_IMAGE;
		tie.iImage = iconEnum;
	}

	if (-1 == m_tabCtrl.InsertItem(99, &tie ))
	{
		ASSERTX(FALSE);
	}
	else
	{
		//CToolTipCtrl* pTip = new CToolTipCtrl;
		//pTip->Create(this); // <--- or should it be the tab bar?
		//pTip->
		CToolTipCtrl* pTip = m_tabCtrl.GetToolTips();
		ASSERT(pTip);
		CRect r;
		m_tabCtrl.GetItemRect(m_tabCtrl.GetItemCount()-1, &r);
		CString s;
		s.Format("%s", pStream->getToolTipText());
		pTip->AddTool(&m_tabCtrl, s, &r, id);
	}
}