Delphi Caret Position Tedit
Once in a while you want to set the caret position (aka cursor position) in a TMemo to a given line and character in that line. If you google for it you will find lots of hits that tell you to do the following:
Problem/Question/Abstract: How to determine the caret position in a TMemo. Answer: You can use the Windows API messages EMLINEFROMCHAR and EMLINEINDEX to determine the current line and offset within that line (starting from SelStart). LineNum: longint. Delphi – Indy idTCPServer and idTCPClient. This is a simple example for usign Nevrona Indy components in Delphi to create a small server application using TCP/IP protocol. TO simplify we can build an example where there is a Server Application that recive a string from a Client App. And then return that string to the Client, but we use. Any one have any idea on how to select an area of text in a TEdit and have the cursor at the beginning of the selection. Eg: TEdit.Text:= 'Delphi Rules'; TEdit.SelStart:= 7; TEdit.SelLength:= 5; TEdit should now display 'Delphi Rules' with the last word selected (or something close to that) and the cursor at the end of the text.
or without the ugly with statement
But that looks to be at least pre-Delphi 2007 because there already is a TMemo.CaretPos property that does the same:
This is a lot easier to understand than the above. Note that you can’t just assign only x or y like this:
This won’t work, because accessing CaretPos calls a getter method that returns a TPoint value. Changing this value does not change the CaretPos property, you must write the actual CaretPos property.
Unfortunately, while this works fine in general, Borland has introduced a bug in TCustomGrid.Paint that breaks this (both) code. If you have got a TCustomGrid descendant (TStringGrid and friends) on the form or a different form, you might find that the caret of the memo shows at the position where it would be on the grid. See QC 25702 for a description and workaround.
Warning:
The workaround requires you to modify the VCL unit Grids.pas. To do that you should copy it from the Delphi installation to your project’s source code, add it to your project and only then modify it. Otherwise you might end up with a Delphi update overwriting it or even worse, failing to install.
Caret Position How do I get the coordinates of the caret position (system wide) ? thanks for help tom |
Re:Caret PositionQuote> How do I get the coordinates of the caret position (system wide) ? |
Re:Caret PositionThe GetCursorPos function retrieves the cursor's position (mouse position), in screen coordinates. What I want is a function GetCaretPos that retrieves the caret's position in screen coordinates.(in any application) Ok ? thanks for help tom Quote> > How do I get the coordinates of the caret position (system wide) ? |
Re:Caret PositionQuoteThomas wrote: GetCaretPos(..) |
Re:Caret PositionQuote> The GetCursorPos function retrieves the cursor's position (mouse position), there is only one caret in the system. Generally, each window that accepts keyboard input must create the caret when it receives the keyboard focus and destroy the caret when it loses the keyboard focus. The caret is a shared resource; there is only one caret in the system. A window You cannot assume the currently active window has a caret. You must find the |
Re:Caret PositionHow can I pass it to GetCaretPos ?? That function doesn't use a handle ! QuoteTopprolmc <Toppro...@Starpower.net> wrote in message Quote
|
Re:Caret PositionStill, my problem is to get the Caret Position (System wide !!) The GetCaretPos(..) only works in my application but not in others. thanks for further help tom Quote> > The GetCursorPos function retrieves the cursor's position (mouse |
Delphi Tedit Get Caret Position
Re:Caret PositionQuoteIn article <8j7uqj$...@bornews.borland.com>, Thomas wrote: Peter Below (TeamB) 100113.1...@compuserve.com) |
Re:Caret PositionThomas, May be, what you want to know is the Mouse Coordinates system wide, which is very diferent than the Caret Position. The caret, as you may know, is the Blinking cursor used in TEdit and TMemo among others controls. rgs, jos Thomas <thomas...@gmx.ch> escribi en el mensaje de noticias Quote> How do I get the coordinates of the caret position (system wide) ? |
Re:Caret PositionAnyone can tell me where i can find some docs about winapi |
Re:Caret PositionQuote'Jos Nazario' <jnaza...@infordesporto.pt> wrote in message Quote> Anyone can tell me where i can find some docs about winapi files (including API) are on the start menu. Otherwise, try: http://msdn.microsoft.com/library/psdk/portals/win32start_1n6t.htm Best regards |
Re:Caret Position |
Re:Caret PositionQuote'Marius Bunescu' <a...@crinsoft.ro> wrote in message Hence the MSDN link I quoted! ;) Cheers |
Re:Caret Position |
1. Caret position to correct pixel position
2. Get Caret Position from Mouse Location?
3. Inserting text a caret position in a memo
Delphi Tedit Caret Position
4. Caret Position in TRichEdit
5. Caret position in TMemo
6. Richedit caret position on backward selection
Delphi Cursor Position In Tedit
7. Caret Position in a Memo or Rich Edit
8. richedit problem (adding text on current caret position)
9. RichEdit (D3) - setting/getting desired caret position
10. TMemo caret position