richedit

How to implement the mouse click for URLs at rich edit control

本秂侑毒 提交于 2019-12-05 13:35:42
I added a read-only rich edit 2.0 control to my dialog (code is using C windows API, the dialog is created by using function DialogBox ) At the dialog call back, at the WM_INITDIALOG, I add the following code to enable url detection and also enable the event ENM_LINK is sent to the parent dialog instead of the rich edit control itself: LRESULT mask = SendMessage(hWndText, EM_GETEVENTMASK, 0, 0); //hWndText is rich edit control SendMessage(hWndText, EM_SETEVENTMASK, 0, mask | ENM_LINK); ::SendMessage(hWndText, EM_AUTOURLDETECT, TRUE, NULL); I had a little trouble to enable the url detection

Scrolling RichEdit without it having focus

筅森魡賤 提交于 2019-12-05 08:01:53
I need to scroll a RichEdit to the very end after a line is added. I have this RichEdit in a separate form, that I don't want to get focus at all. I tried often suggested solution: RichEdit.Lines.Add(someText); RichEdit.SelStart:=RichEdit.GetTextLen; SendMessage(RichEdit.handle, EM_SCROLLCARET, 0, 0); But this doesn't work for me. However, when I focus the RichEdit before calling the SendMessage using RichEdit.SetFocus; it works just fine. That, however, ruins my other needs for the app. I'm using XE2. Thanks This is what I do: SendMessage(RichEdit.Handle, WM_VSCROLL, SB_BOTTOM, 0); See this

RichEdit not respecting PlainText with pasted content

元气小坏坏 提交于 2019-12-05 01:40:35
问题 I create a new application, drop on a TRichedit and set the PlainText property to true. I then run the application and paste some rich formatted text into the RichEdit. I would expect it to display as plain text however it shows the content with the formatting. Anyone know how to use a TRichedit just as plain text (and not using a memo :)) 回答1: You'll need to do the paste manually ensuring that the formatting is ignored. if Clipboard.HasFormat(CF_TEXT) then RichEdit.SelText := Clipboard

Change highlight color of selected text in RichEdit

谁说我不能喝 提交于 2019-12-04 16:16:58
How do I change the color of selected text in a RichEdit control, while the text is being selected? SetSysColor() can do it, but that changes the Highlight-color globally. Setting a CHARFORMAT2 with SCF_SELECTION, and sending a EM_SETCHARFORMAT does change the font and background color. But is only visible once you deselect the same range. That's not really helpful, since I want it to be the original color again once something is deselected. So, how it's really done puzzles me. Simply subclass it (posted a long time ago on google groups, C/Winapi code) 来源: https://stackoverflow.com/questions

How to Convert Simple RichText to HTML tags in Delphi?

 ̄綄美尐妖づ 提交于 2019-12-04 13:04:01
问题 You may say that there are lots of discussions about this in stackOverflow, but most of them are more complicated than what I need and mostly for other languages. I have a MySQL remote database in which I have a "Help" table with the code for filling the help pages of the dynamic web site that uses this database. I decided to make a Delphi application to manage that website instead of doing by the web site itself for more speed and security. I want to put a TRichEdit to make that help text

Colorful text in the same line in TRichEdit

こ雲淡風輕ζ 提交于 2019-12-04 02:23:28
How to write text in the same line but with different color? (I use richedit). procedure TForm1.btnEClick(sender: TObject); begin m0.SelAttributes.Color := clBlue; m0.SelAttributes.Style := [fsBold]; m0.lines.add('This is blue and it is bold'); m0.SelAttributes.Color := clGreen; m0.SelAttributes.Style := [fsBold]; m0.lines.add ('This is Green and it is bold'); m0.lines.add(''); m0.lines.add('But how to write text in the same line with different color?'); // i want to have both blue and green in the same line end; Best Wishes, Bee You're on the right track. Just change SelAttributes and use

How to change underlining color in a Rich Edit control (Win32/C)

与世无争的帅哥 提交于 2019-12-03 07:15:47
I’m looking for a way to make red squiggly underlining in a Rich Edit control (I’m using version 4.1 with Msftedit.dll). I’m able to produce squiggly underlining with this code : CHARFORMAT2 format; format.cbSize = sizeof(format); format.dwMask = CFM_UNDERLINETYPE; format.bUnderlineType = CFU_UNDERLINEWAVE; SendMessage(hWndEdit,EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format); The MSDN documentation doesn’t specify how to change the color of underlines, just the text (with underlines) and the text background. I’ve found some code that says to use the lower nibble for the underline type (CFU

How to autodetect urls in RichEdit 2.0?

半腔热情 提交于 2019-12-02 10:07:58
When we have a RichEdit control and send it an EM_AUTOURLDETECT message with WPARAM set to TRUE, it nicely hightlights the detected URLs and sends the EN_LINK notifications. But it does this only for text that is entered into the control. I haven't found the way to do it for text that's loaded into the control with SetWindowText or EM_STREAMIN . Please help! Thanks Upd: I've created a test application from scratch and it works fine there. I think the problem might be that I have superclassed the control, that is, created a new window class and just use the window procedure of the original

How to get text extent of RichEdit in Delphi

落花浮王杯 提交于 2019-12-01 23:08:04
Does anyone know how to get the width and height of text in a TRichEdit control, in the same way that you would use TextWidth and TextHeight on a TCanvas? The reason I need to know this doing this is I have a RichEdit on a non-visible form that I copy the contents of to a canvas using Richedit.Perform(EM_FORMATRANGE, ...). The problem is that the EM_FORMATRANGE requires a parameter of type TFormatRange in which the target rect is specified, but I don't know what the rect should be because I don't know in advance the size of the contents in the RichEdit. Hope that makes sense. Sertac Akyuz

Loading RTF text from database into TRichEdit

心已入冬 提交于 2019-12-01 16:44:35
问题 I am currently in the process of migrating our software solution from Delphi 7 to 2010. Mostly the changes have been simple and there are only a small amount of hurdles left to go. On a form we use a TRichEdit which displayed rtf text grabbed from a blob field in a MSSQL db. This is how it worked in Delphi 7: //Get RTF text from Blob field using TADOQuery rtfStream := sql.CreateBlobStream(sql.FieldByName('rtftext'), BmRead) as TMemoryStream; //Load into TRichEdit RichEdit.PlainText := False;