Where->Lines->Append(String);
while (Where->Lines->Count >= Where->Height/(abs(Where->Font->Height)+3))
Where->Lines->Delete(0);
works as a way to get a resizeable TMemo to scroll and change the number of
lines to match the size of the window (the +3 is the number of pixels added
between the lines -- for Courier New fonts anyway). But as the length of
the window is increased a "jitter" of everything in the window gets worse
and worse. It looks like all of the text jumps up two lines and then back
down one when a line is appended. I tried many things with swapping around
the order of everything, but I couldn't get rid of it. Is there a way to
freeze the window (like turn off updating) until the above is finished? I'd
be a Windows API-thing, huh? Maybe that would help. ???
Thanks for everyone's suggestions (I tried SelStart's, WM_VSCROLL's,
EM_SCROLLCARET's, ListBoxes... :-)
Bob
the false means it won't redraw, set to true when your done
(this is an api question)
Bob Greschke <bgre...@nrao.edu> wrote in message
news:7eoa8e$78...@forums.borland.com...
>SendMessage(Where->Handle, WM_SETREDRAW, false, 0);
>
>the false means it won't redraw, set to true when your done
>(this is an api question)
Much better:
Memo1->Lines->BeginUpdate;
try { ... }
__finally
{
Memo1->Lines->EndUpdate;
}
--
Stefan Hoffmeister (TeamB) http://www.econos.de/
Please do apply judgement when sending email.
(Don't you guys have anything better to do on a Saturday?? :-)
Bob
Stefan Hoffmeister (TeamB) <Stefan.Ho...@Econos.de> wrote in message
news:3719c132...@forums.inprise.com...
> I'm writing a client for displaying engineering data and
>messages HAVE to be color-coded according to how badly things are going
>wrong. So as of this minute everything is in the garbage...
No. Just replace TMemo with TRichEdit.
Stefan Hoffmeister (TeamB) <Stefan.Ho...@Econos.de> wrote in message
news:371bc4ed...@forums.inprise.com...
void __fastcall writeMsg(TRichEdit *Where, String Attrib, String String)
{
Where->SelStart = Where->Text.Length();
if (Attrib == "L")
Where->SelAttributes->Color = clLime;
else if (Attrib == "Y")
Where->SelAttributes->Color = clYellow;
else if (Attrib == "R")
Where->SelAttributes->Color = clRed;
else if (Attrib == "A")
Where->SelAttributes->Color = clAqua;
Where->Lines->Append(String);
while (Where->Lines->Count >= Where->Height/(abs(Where->Font->Height)+3))
Where->Lines->Delete(0);
Where->SelAttributes->Color = clWhite;
Where->Font->Style.Clear();
}
I haven't stuck in the anti-"jitter" stuff yet. And the
"Where->SelStart..." has to go before the "Where->SelAttributes...". I had
it just before the "...Appends(..." statement, but all of the stuff that was
supposed to be in color was not printing out AFTER the window filled up and
'scrolling' began. Maybe it was printing at the very top and then scrolling
off. ??
> > Stefan Hoffmeister (TeamB) http://www.econos.de/
> > Please do apply judgement when sending email.
THANKS A BUNCH!! I couldn't have done it without you! Let's all give
Stefan a round of applause! :-)
Bob
PS - Tomorrow it's static/character-based/VT100-like displays. :-)
RichEdit1->SelStart=0;
RichEdit1->Perform(EM_SCROLLCARET,0,0);
RichEdit1->SetFocus();
> Much better:
>
> Memo1->Lines->BeginUpdate;
> try { ... }
> __finally
> {
> Memo1->Lines->EndUpdate;
> }
Oh, the old Delphi way of doing things, but you're writing C++ now
Stefan : Ź )
Long ago I wrote a simple C++ class,
class CStringsUpdate
{
private:
TStrings* m_strings;
public:
CStringsUpdate( TStrings* strings ) : m_strings( strings )
{
strings->BeginUpdate();
}
~CStringsUpdate( void )
{
m_strings->EndUpdate();
}
};
now any time I want to lock a stringlist, I just declare
void DoStuff( void )
{
CStringUpdate( Memo1->Lines );
DoStuffHere...
}
Much easier now, once the class is written (and put into a utilities
header file).
If fact, I have update classes for most the controls that support
begin/end update. This is one of the big selling points of BCB over
Delphi for me!
AlisdairM
>now any time I want to lock a stringlist, I just declare
>
>void DoStuff( void )
>{
> CStringUpdate( Memo1->Lines );
> DoStuffHere...
>}
You realize that this is not equivalent to Begin/EndUpdate? Your
EndUpdate lock is released only when CStringUpdate goes out of
scope...
To be fully equivalent, you'd have to use
void DoStuff( void )
{
{ CStringUpdate( Memo1->Lines ); }
DoStuffHere...
}
Urgh. <g>
--
> You realize that this is not equivalent to Begin/EndUpdate?
erm, no, still not got it...
> EndUpdate lock is released only when CStringUpdate goes out of
> scope...
Yes, that's the point isn't it?
> To be fully equivalent, you'd have to use
> void DoStuff( void )
> {
> { CStringUpdate( Memo1->Lines ); }
> DoStuffHere...
> }
Actually, that releases the lock BEFORE I do my stuff.
The time this does get annoying is when I (v. rarely) need to code
void DoStuff( void )
{
{
CStringUpdate( Memo1->Lines );
DoStuffHere...
} // Release the lock
DoStuffAfterRepaint...
}
But most times, I want to lock updates within a method, and just
declaring a lock or two at the top looks a lot tidier than all those
try/finallys I used to have to do in Delphi.
AlisdairM