Board index » delphi » limited Tmemo, someone?

limited Tmemo, someone?

Quote
Jimmy wrote:
> What i need is a Tmemo with 8 lines that will not allow more lines and won't
> scroll.

In the OnChange event, put this:

begin
  if (Memo1.Lines.Count > 8) then
    SendMessage(Memo1.Handle, EM_UNDO, 0, 0);
  SendMessage(Memo1.Handle, EM_EMPTYUNDOBUFFER, 0, 0);
end;

HTH,
Glenn

 

Re:limited Tmemo, someone?


Help on limited Tmemo...

I've asked this before but never got a reply that fully solved this problem.

What i need is a Tmemo with 8 lines that will not allow more lines and won't
scroll. Have tried Tmemo.perform functions and lines.delete etc but it never
gets perfect. I would really be happy if someone could send me sourcecode of
such a method.
Please reply to my email. thx in advance...

/Jimmy
j...@mbox300.swipnet.se

Re:limited Tmemo, someone?


This may sound stupid but couldn't you just set the MaxLength property of the
TMemo to whatever size you need it to be?

********************************
Michael Glatz
glatzfa...@aol.com
mgl...@briefcase.com

Re:limited Tmemo, someone?


In article <1PcQ1.4808$777.4293...@nntpserver.swip.net>, "Jimmy"

Quote
<j...@mbox300.swipnet.se> writes:
>Help on limited Tmemo...

>I've asked this before but never got a reply that fully solved this problem.

>What i need is a Tmemo with 8 lines that will not allow more lines and won't
>scroll. Have tried Tmemo.perform functions and lines.delete etc but it never
>gets perfect. I would really be happy if someone could send me sourcecode of
>such a method.
>Please reply to my email. thx in advance...

>/Jimmy

Hi Jimmy,

              It might help if you tell us how and what you are using it for.
Does it need to receive keyboard input. Do you need to cut, paste and insert
etc. Depending on what your requirements are you could use 8 edit boxes set to
'flat' on a white panel, not very sophisticated but it could be made to work.
Or, depending on your requirements, you could 'roll your own' using a TImage
quite easily.

Gordon Whittam

___________________
http://members.aol.com/gwhit41980/

Re:limited Tmemo, someone?


Quote
ad...@jennisoft.com wrote:

> Jimmy wrote:

> > What i need is a Tmemo with 8 lines that will not allow more lines and won't
> > scroll.

> In the OnChange event, put this:

> begin
>   if (Memo1.Lines.Count > 8) then
>     SendMessage(Memo1.Handle, EM_UNDO, 0, 0);
>   SendMessage(Memo1.Handle, EM_EMPTYUNDOBUFFER, 0, 0);
> end;

where does one find a list of these messages?
would be real handy

steam and wind

--
       David Forsyth                 DAFkite A-T Iwr.Ru.Ac.Za
Keeper of the listserver for South African Railways fans       _|_ His
Part time gricer, kiter, photographer, father etc etc           |  Way
http://www.ru.ac.za/departments/iwr/staff/daf/welcome.html      |  Up
For reduction of advertising mail, my return address is invalid.
Read the address above and figure it out please.

Re:limited Tmemo, someone?


In article <1PcQ1.4808$777.4293...@nntpserver.swip.net>, "Jimmy"

Quote
<j...@mbox300.swipnet.se> writes:
>Help on limited Tmemo...

>I've asked this before but never got a reply that fully solved this problem.

>What i need is a Tmemo with 8 lines that will not allow more lines and won't
>scroll. Have tried Tmemo.perform functions and lines.delete etc but it never
>gets perfect. I would really be happy if someone could send me sourcecode of
>such a method.

I have a feeling in my bones that this is a bit "kludgy" - but it does not seem
easy <g>

procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
var
  LineCount, MemoChPos, XYPosn, XPosn,  LineLen : integer;
begin
  LineCount := Memo1.Perform(EM_GETLINECOUNT, 0, 0); // total lines
  if not (Key = Char(VK_BACK)) then
    if not ((Key = Char(VK_RETURN)) and (LineCount < 8)) then begin
      MemoChPos := Memo1.SelStart - 1;
      XYPosn := Memo1.Perform(EM_POSFROMCHAR, MemoChPos, 0);
      XPosn := Lo(XYPosn); // X pixel posn in Memo
      LineLen := Memo1.Perform(EM_LINELENGTH, MemoChPos+1, 0);
      if ((LineLen > 2) and (XPosn > Memo1.Width - 30)) or
         (LineCount > 8) then
        Key := #0;
    end; {if not (return key and total lines < 8))
  {end; if not backspace key}
end;

This seems to do most thing, except that it does not stop you entering
additional characters to exceed the line length in a previously entered line.

Alan Lloyd
alangll...@aol.com

Re:limited Tmemo, someone?


In article <36123581.2...@iwr.ru.ac.za>, David Forsyth <DAFk...@iwr.ru.ac.za>
writes:

Quote
>where does one find a list of these messages?
>would be real handy

Win32.hlp - but you have to do a Index | Find, get the word-list loaded and
then enter the words to find (EM_ in this case) and then troll through then
looking for useful possibilities.

BUT -BUT - BUT the descriptions given are almost perversely confusing and
obtuse, as though MS does not want you to know about them. I foind it almost
impossible to find an answer to a problem, I just spend some time each week
idly looking and trying to remember what might be useful.

When you've found something, you may get some hints by looking at the
windows.pas (or whatever other Delphi file has the Delphi headers in them).

Alan Lloyd
alangll...@aol.com

Re:limited Tmemo, someone?


in the delphi\source\rtl\win\messages.pas file

Other Threads