//--------------------------------------------------------------------------- void TLinkLabelEx::CMTextChanged(TMessage &Message) { TWinControl::Dispatch(&Message); AdjustBounds(); Invalidate(); if(!CheckWin32Version(5, 1) || !IsLinkLabelSupported()) { String Parsed = ParseLinks(); if(Parsed != Caption) Caption = Parsed; } }
//--------------------------------------------------------------------------- void TLinkLabelEx::AdjustBounds() { if(!ComponentState.Contains(csLoading) && AutoSize) { if(CheckWin32Version(6) && IsLinkLabelSupported()) { if(HandleAllocated()) { TSize TextSize; SendMessage(Handle, LM_GETIDEALSIZE, WordWrap ? Width : MaxInt, reinterpret_cast<LONG>(&TextSize)); SetBounds(Left, Top, WordWrap ? Width : TextSize.cx, WordWrap ? TextSize.cy : Height); } } else { HDC DC = GetDC(0); try { HFONT SaveFont = reinterpret_cast<HFONT>(SelectObject(DC, Font->Handle)); try { String Parsed = ParseLinks(); if(FWordWrap) { TRect Rect(0, 0, Width, Height); DrawText(DC, Parsed.c_str(), Parsed.Length(), &Rect, DT_WORDBREAK | DT_NOCLIP | DT_CALCRECT | DT_NOPREFIX); Height = Rect.Height(); } else { TSize TextSize; GetTextExtentPoint32(DC, Parsed.c_str(), Parsed.Length(), &TextSize); SetBounds(Left, Top, TextSize.cx, TextSize.cy); } } __finally { SelectObject(DC, SaveFont); } } __finally { ReleaseDC(0, DC); } } } }
// a: \path\to\file line 300 void PipedProcessCtrl::SyncOutput(int maxchars) { if(!m_proc) return; bool oneshot=true; if(maxchars<=0) { maxchars=20000; oneshot=false; } int lineno=m_textctrl->GetLineCount()-1; while(m_proc->IsInputAvailable()) { char buf0[maxchars+1]; for(int i=0;i<maxchars+1;i++) buf0[i]=0; m_istream->Read(buf0,maxchars); wxString m_latest=wxString::FromAscii(buf0); long start,end; start=m_textctrl->GetSelectionStart(); end=m_textctrl->GetSelectionEnd(); int pos=start>end?start:end; bool move_caret=(pos>=m_textctrl->PositionFromLine(m_textctrl->GetLineCount())&& (start==end)); m_textctrl->AppendText(m_latest); if(move_caret) { m_textctrl->GotoLine(m_textctrl->GetLineCount()); // m_textctrl->SetSelectionStart(-1); // m_textctrl->SetSelectionEnd(-1); } if(oneshot) break; } if(m_proc->IsErrorAvailable()) { while(m_proc->IsErrorAvailable()) { char buf0[maxchars+1]; for(int i=0;i<maxchars+1;i++) buf0[i]=0; m_estream->Read(buf0,maxchars); wxString m_latest=wxString::FromAscii(buf0); long start,end; start=m_textctrl->GetSelectionStart(); end=m_textctrl->GetSelectionEnd(); int pos=start>end?start:end; bool move_caret=(pos>=m_textctrl->PositionFromLine(m_textctrl->GetLineCount())&& (start==end)); int style_start=m_textctrl->PositionFromLine(m_textctrl->GetLineCount()); m_textctrl->AppendText(m_latest); if(move_caret) { m_textctrl->GotoLine(m_textctrl->GetLineCount()); // m_textctrl->SetSelectionStart(-1); // m_textctrl->SetSelectionEnd(-1); } m_textctrl->StartStyling(style_start,0x1F); m_textctrl->SetStyling(m_textctrl->PositionFromLine(m_textctrl->GetLineCount())-style_start,PP_ERROR_STYLE); if(oneshot) break; } } if(m_parselinks) ParseLinks(lineno,m_textctrl->GetLineCount()); }