?
Solved

autocommit text in RichEdit

Posted on 2005-03-23
18
Medium Priority
?
278 Views
Last Modified: 2013-11-22
Hi Expert,

I wonder how it would be possible to make sure that text entered by the user, is committed to memory even when he forgets to leave the edit eara (I always use TAB, is there another way?) and clicks something else. The text is 'entered' just into the control, not into memory. It can be hard for endusers to understand that text isn't really entered then, not comparable to, say, typing on a typewriter.

I have been looking at functions like flush, endundo, commit etc but these seem not applicable to RichEdit controls.

Any ideas?

Thank you,
Ron dW
0
Comment
Question by:Ron_de_Weijze
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
  • 3
  • +1
18 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 13619426
Hi,

Do you mean 'saving RichEdit contents to hard disk or database' when you're talking about autocommit? If yes then you may use two events to write your RichEdit down - RichEdit.OnExit event and/or Form.OnClose event. RichEdit.OnExit is fired when the user moves the focus to another control on the same form (i.e. clicks somewhere else on the form or presses TAB). Form.OnClose is fired when the user (or something else) closes the form.

procedure TForm1.RichEdit1Exit(Sender: TObject);
begin
  RichEdit1.Lines.SaveToFile('c:\re.rtf');
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  RichEdit1.Lines.SaveToFile('c:\re.rtf');
end;

Regards, Geo
0
 

Author Comment

by:Ron_de_Weijze
ID: 13619470
I forgot to mention that I tried the OnExit and even tested (just to make sure) OnMouseMove, but neither picks up the event of clicking another control. Also, that the commit is not to file (yet) but to working memory, using TAB. Do you know what command commits text entered into the RichEdit, to working memory?

Thanks,
Ron dW
0
 
LVL 17

Expert Comment

by:geobul
ID: 13619551
OnExit works when you click to another control on the same form. Drop a richedit and a button on a form. Add the following event:

procedure TForm1.RichEdit1Exit(Sender: TObject);
begin
  ShowMessage('RichEdit.Exit');
end;

Run the project, write something in the edit and then click the button with mouse. You'll see the message box 'RichEdit.Exit' before the button gets the focus.

I don't quite understand what you have in mind saying 'working memory'. The whole control (including its contents) is already in memory. Are you talking about saving the text into MemoryStream or something?

Regards, Geo
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Ron_de_Weijze
ID: 13624925
Hi Geo,

Sorry for the delay. I am trying to understand the code I am working on. It seems that form-instances, holding rich edits, are dynamically created on a canvas. Therefore, you are either in (the RichEdit on) or out of, one form-instance at a time, there being no possibility to click elsewhere on the same form-instance.

Still studying though...

Thanks,
Ron
0
 

Author Comment

by:Ron_de_Weijze
ID: 13624974
By 'working memory' I mean the cache: that memory that is used before contents is committed to file on disk. So my question is how to commit text content to cache memory before committing it to disk memory, preventing it to get lost by clicking a different form-instance. By the way, the TAB moves the cursor to buttons for the RichEdit: that is what commits right now, but that is also what is easily forgotten by the enduser - thus losing what he just typed down.
0
 
LVL 34

Expert Comment

by:Slick812
ID: 13627970
???
from your comments, you seem to have something that does not use the "normal" edit Control (RichEdit in your case) methods, as a RichEdit will have the text you type into it, until the text is changed by the user or changed by program code, (the text is maintained in the system memory for the RichEdit Control)  I do not think ther is any separate  "working memory" set up for a normal TRichEdit. . .  I have some difficulty understanding you comments about your Set up for showing the various RichEdits (or maybe ther's just one Rich edit), you seem to suggest that if the user Leaves one "Form" that has a RichEdit on it, that "Form" is destroyed, and goes to another text edit Form, , then another "Form" is created with another RichEdit on it. . . In that case, you will need to get the "Form" on Close Event and then Write the RichEdit Text to whatever there is to store the text, I guess it's the "Working Memory", but  I have not heard of any "Standard" for "Working Memory", I would guess it's a TMemoryStream. . I Think a TRichEdit  Lines has a WriteToStream method?
Seems like I need more information to say any more?
0
 

Author Comment

by:Ron_de_Weijze
ID: 13629832
Hi Slick, there certainly is a separate section (of memory) that holds the text maintained in the system memory for the RichEdit Control. The program works like this (viewpoint enduser) : text is entered into the RE and is kept there as long as typing is going on. Then edit controls can be used to send the text to printer, change format, underline etc. So each time a little editor is wrapped around the RE, when a note on the canvas is opened (clicked). Clicking a different note opens the text in the RE of that note, *not saving the text of the previous one*, unless tab is used to move out of the RE into its editor controls wrapper on the same form. So I figure that form-*instances* holding an RE and an editor/wrapper are created each time a note on the canvas is clicked.
0
 

Author Comment

by:Ron_de_Weijze
ID: 13629842
I will try the form's onClose event as you suggested and let you know..
Thanks,
Ron dW
0
 
LVL 34

Expert Comment

by:Slick812
ID: 13634397
??
You have described what the "Clicking" does visually, but I do not know how the code methods for that work. . . . You also say something about  the  "Tab is Used to move out", but I also do not know anything about the code methods it might use to do that? ? By information I requested, I did not mean so much about clicking or Tab use (yes it was good to know), but about the   CODE   that these events call. . . .
0
 
LVL 34

Expert Comment

by:Slick812
ID: 13634409
can you show the code in the Tab press event (or whatever event that the Tab Key press would fire)?
0
 

Author Comment

by:Ron_de_Weijze
ID: 13636057
The code in the Tab press event is hard to find.
There is no response to KeyDown if Key=9 (Tab), while there is a response and a possibility to break on all other keys pressed down.

To give you some idea:

type                              
  TPropertyFrm = class(TForm)                              
  public                              
    function  DataExchange(fromControl : Boolean) : Boolean; virtual;            
...

type                              
  TNotePrp = class(TPropertyFrm)                              
  private                              
    { Private declarations }                              
    m_Container : TContainer;                              
    RichEditURL1: TRichEditURL;                              
...

type                              
  TDrawSheet = class(TForm)                              
    procedure PB_SheetDblClick(Sender: TObject);
  private                              
    { Note Property Form }                              
    m_NoteProp : TNotePrp;      
    { Visuality Items }
    m_VCanvas   : TVCanvas;
    m_VCanvasVisible : TVCanvas;
    m_BackBuffer : TBitmap;
    m_SheetView : TSheetView;
                              
procedure TDrawSheet.PB_SheetDblClick(Sender: TObject);                  
var                              
   HitNote : TNoteItem;                              
begin                              
   with m_SheetView do                              
   begin                              
      HitNote := NoteAt(m_MovLastPoint.X, m_MovLastPoint.Y); // note on canvas                                    
      if HitNote <> nil then                              
      begin                              
            { Apply Changes in Navigator }
            Main.ApplyChanges;
            ...
            m_NoteProp.Show;
         end

         m_JustShowedProps := TRUE;
         UpdateSheet(TRUE);
      end
      ...

0
 
LVL 34

Accepted Solution

by:
Slick812 earned 1000 total points
ID: 13636776
OK, , I read your code post above,
Sorry, but  I can not determine whst that code may be doing?
The ONLY thing in the above code that even has anything in it that MIGHT have something to do with s TRichEdit is the code line

 RichEditURL1: TRichEditURL;

But I am not familar with the  TRichEditURL  control, I can only guess from it's name that it is a Decendent from TRichEdit , , But what this  RichEditURL1  might do in the code methods for   TNotePrp  is unknown to me. . . . .
 I will also guess that there is a reason why this RichEdit you ask about in your Question, does not automaticly store any text the user types into it in this mysterious  "working memory", I would guess that somehow it allows the user to do several changes to the text, until they get it right, and then when it is acceptable, some button or control or Key is clicked or pressed to set the current text of the RichEdit into the working memory

since there is no Tab Key event, I will guess that there is an  "OnExit"  event for the RichEdit. . .or an "OnEnter" event for the control that the Tab key moves the focus to? ?

??????
Do I have to guess at what your app does?
0
 
LVL 34

Expert Comment

by:Slick812
ID: 13636788
would the code for

procedure  ApplyChanges

in the line

Main.ApplyChanges;

be where the update of this working memory happens?
0
 
LVL 4

Expert Comment

by:arnismit
ID: 13642510
ron,

i have been away for a while
so i just tuned in.
anything i can still do for you in here ?

greetings
arni
0
 

Author Comment

by:Ron_de_Weijze
ID: 13662502
Apologies Slick,

OnExit dòes indeed work with Tab, in spite of my earlier assessments that it didn't.
So now I can call the system events that save the text and force saving.

Arni, thanks for offering but this call is closed.

Ron dW
0
 
LVL 17

Expert Comment

by:geobul
ID: 13669360
I was talking about that event from the very beginning :-(
0
 

Author Comment

by:Ron_de_Weijze
ID: 13669663
That is right Geo

But so was I ("I forgot to mention that I tried the OnExit and even tested OnMouseMove, but neither picks up the event of clicking another control"). After that, Slick insisted that that had to be the case even though I said that it couldn't be.

Yet I should have split the points.
Sorry for that.

0
 

Author Comment

by:Ron_de_Weijze
ID: 13955559
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month12 days, 12 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question