ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Special User Sections > Borland C++ Builder Contest

Two BCB questions: 1st: regarding EM_UPDATE, 2nd: file dragging *from* form



I am new here, how is everyone doing? :)

I am here because I need help to implement something. First question.

I am trying to implement a multiple Undo/Redo feature for a text editor I am working on. I thought, one way of doing it would be to capture the EM_UPDATE message and copy the text to a buffer before the text changes. So, I need something like a BeforeChange event. In the MS docs, here is what it says:

The EN_UPDATE notification message is sent when an edit control is about to redraw itself. This notification message is sent after the control has formatted the text, but before it displays the text. This makes it possible to resize the edit control window, if necessary. The parent window of the edit control receives this notification message through a WM_COMMAND message.

--- End quote ---

This part:

The EN_UPDATE notification message is sent when an edit control is about to redraw itself. This notification message is sent after the control has formatted the text, but before it displays the text.

I thought this would have been a BeforeChange event or something but it is not.
When I capture the message, the text is already modified. I want to capture something like BeforeChange event so I can copy the text to an array of buffers and save it. I have it working now BUT the implementation is pretty poor. I have to keep track on every key stroke typed and also I have to make sure before I paste something into the RichEdit or modify the text, I have to remember to copy the existing text before I modify the text. So is there something like BeforeChange event/message? So I can put the code that copies RichEdit->Text into the buffer in the BeforeChange event instead of doing it manually all the time.

Second question: This one, I am clue less.

I KNOW how to make my program accept file from explorer BUT how can I make ito be able to drag from my program to explorer AND also want to be able to drag elements from one position on the form, to another? I am particularly interested in dragging Tabs using the Tab Control, just like in Maxthon or other tabbed browsers, the tabs are draggable.

welcome to the site alex; those are some tricky question actually.

there is a very good free drag+drop component set that i have used in the past for advanced drag and drop stuff (in AND OUT): (see bottom, Drag & Drop Component Suite); i can help you get it working for bcb if you have trouble. [i keep meaning to write some little tutorials on tricks for compiling delphi components for bcb - sometimes there are some tricky stuff].

thought i dont think that component is going to help you - basically youll want to detect a drag begin event for the tabs, and then write some custom highlighting to detect which tab they are dragging it over in order to show a visual hint.  i really don't know how to do this but id be very interested in hearing how you do it if you figure out how.

a great place to look for solutions for stuff like this is to search google GROUPS for delphi.  (delphi solutions as you probably know are 99% same as bcb, but delphi is more likely to get you some good hits).

there have been some good articles on implemented undo/redo functionality.  your approach seems a bit strange to me.. are you sure you want to reinvent the wheel? there are some nice free bcb/delphi editor components that might implement undo/redo already (scite?).  or else if you are really implmenting your own custom editor, it seems like you might be better off catching all keypresses and handling them manually in which case you wouldnt really be needing to catch en_update, etc.  or am i wrong?

Hey mouser thanks for the warm welcome, I appreciate it

Well, to be honest, I'd rather not re-invent the wheel but I really did search for solutions and I failed to find any. I remember once I downloaded a project file for BCB, called but when I extracted it and when I launched it, didn't open up properly, missing that. missing this, failed to load this, failed to load that blah blah blah, syntax error....statement missing....I say this literally so I gave up looking at the source code.

You mentioned, there are some nice and free bcb/delphi editor components. Do you know of any names I can search for? It is really hard. I found one, called SynEdit. But the component simply does not show up on the pallete on BCB 6. I posted a message on the forums, no one replied to help me. The forum over there seem to be non active. After seeking for help without success, I you said, to re-invent the wheel. I don't have a choice. I will also have to implement syntax highlighting too but it is not a priority for now.

Another question I have that you might know is this. What I want is, when the user clicks the RichEdit with the right mouse button, I want to move the carot at that position, as if the user clicked the left mouse button. Because when the user clicks the left button, the carot moves. Well I want to move it with the right mouse button. I have been unable to implement this and I have tried a few approaches such as tracking and capturing the right mouse click and sending a left mouse click message to the RichEdit, none of them worked and I don't even know if I am playing with the right APIs. The program that I write is really good. I have implemented some very cool features but these are some of the obsticles I am facing. I don't know how to move the carot at the position where the user clicks with the right mouse button. I will have to keep experimenting and read hundreds of pages of MS documentation just to implement simple stuff like this. I am sure it's not hard to do, the problem is I don't know what to look for. It's like searching for a needle.

I will see if I can get the DragDrop component going. My knowledge in Pascal is 0% but yes, the properties and methods and behaviours are the same as BCB when comparing Delphi and BCB. I have already used some Delphi examples in BCB, I just need to convert the syntax into C++ otherwise all the same.

Scintilla is a free source code editing component. It comes with complete source code and a license that permits use in any free project or commercial product.
As well as features found in standard text editing components, Scintilla includes features especially useful when editing and debugging source code. These include support for syntax styling, error indicators, code completion and call tips. The selection margin can contain markers like those used in debuggers to indicate breakpoints and the current line. Styling choices are more open than with many editors, allowing the use of proportional fonts, bold and italics, multiple foreground and background colours and multiple fonts.
--- End quote ---

note this on the scintilla page:
The biggest problem with Richedit and other similar controls is that they treat styling changes as important persistent changes to the document so they are saved into the undo stack and set the document's dirty flag. For source code, styling should not be persisted as it can be mechanically recreated.
--- End quote ---

i know that there are delphi/bcb wrappers for scintilla.


Thank you so much for that link. I can't believe my luck. That Scintilla component is trully awesome. I already forgrot about SynEdit... :)

I found a wrapper for Delphi/C++

I have been coding like crazy all day today to transform ALL my TRichEdit calls into the Scinitlla ones. A lot of errors now lol but I am doing good I think. I have plenty of ideas for work arounds!

Thanks again for the drag/drop component link too. It appeared on my pallete but I havent tested yet. I will do that a bit later. For now, I have to eliminate all compile time AND run time errors.


[0] Message Index

Go to full version