devxlogo

Dynamic Buffer

Dynamic Buffer

Question:
I’m using Delphi to do a client-server application in which all the lines I get from a socket I send to a TMemo in my form. I want that Tmemo to have a 200 lines buffer so that if it has more than 200 lines I delete the first line. How can I prevent the Tmemo from jumping up and down, focusing the first and then the last line in the buffer? How can I “freeze” the Tmemo visualization? How can I prevent the scroll bar from moving?

Answer:
To “freeze” the update of the screen while you’re updating so that the usercan’t really see what’s going on, just enclose the code that you want”hidden” from the user between the following:

LockWindowUpdate(Form1.Handle);  …code that you want to hideLockWindowUpdate(0);
LockWindowUpdate is a WinAPI call that “freezes” the screen. All you do isprovide the handle of the window you want frozen, then all updates to thewindow aren’t made. LockWindowUpdate(0) resumes screen updating.

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist