05-04-2006, 10:53 AM
How can I find a string in notepad using regular expresions?
Find and highlight text in other app using regular expresion
|
05-04-2006, 10:53 AM
How can I find a string in notepad using regular expresions?
05-04-2006, 12:37 PM
str rx="find this"
05-04-2006, 12:50 PM
Thanks.
Is it possible highlight all ocurrences?
05-04-2006, 12:53 PM
No, but I think in wordpad it is possible.
05-04-2006, 12:57 PM
using the same code?
05-04-2006, 01:02 PM
Using EM_SETCHARFORMAT messages. Use share for CHARFORMAT2 structure.
05-09-2006, 09:25 AM
I found this:
#CFM_BACKCOLOR = $4000000 #SCF_ALL = 4 ; --> Structure for formatting EditorGadget Structure myCHARFORMAT2 cbSize.l dwMask.l dwEffects.l yHeight.l yOffset.l crTextColor.l bCharSet.b bPitchAndFamily.b szFaceName.b[#LF_FACESIZE] nullPad.w wWeight.w sSpacing.w crBackColor.l LCID.l dwReserved.l sStyle.w wKerning.w bUnderlineType.b bAnimation.b bRevAuthor.b bReserved1.b EndStructure ; --> Find text from start to end of text editFind.FINDTEXT editFind\chrg\cpMin = 0 ; this will change in procedure as text is found editFind\chrg\cpMax = -1 ; --> Our found text background editFormat.myCHARFORMAT2 editFormat\cbSize = SizeOf(myCHARFORMAT2) editFormat\dwMask = #CFM_BACKCOLOR editFormat\crBackColor = RGB(128, 200, 200) ; --> Our default EditorGdaget background color defaultFormat.myCHARFORMAT2 defaultFormat\cbSize = SizeOf(myCHARFORMAT2) defaultFormat\dwMask = #CFM_BACKCOLOR defaultFormat\crBackColor = RGB(255, 255, 223) Global defaultFormat, editFind, editFormat Procedure findtext(textToFind$) ; --> Reset search to beginnng SendMessage_(GadgetID(0), #EM_SETSEL, 0, 0) ; --> For resetting to default text SendMessage_(GadgetID(0), #EM_SETCHARFORMAT, #SCF_ALL, defaultFormat) ; --> Split the seaarch words spaces = CountString(textToFind$, " ") For i = 1 To spaces+1 editFind\chrg\cpMin = 0 thisFind$ = StringField(textToFind$, i, " ") editFind\lpstrText = @thisFind$ Repeat found = SendMessage_(GadgetID(0), #EM_FINDTEXT, #FR_DOWN, editFind) If found > -1 editFind\chrg\cpMin = found+1 ; --> Set the selection to colorize SendMessage_(GadgetID(0), #EM_SETSEL, found, found + Len(thisFind$)) ; --> Colorize selection background SendMessage_(GadgetID(0), #EM_SETCHARFORMAT, #SCF_SELECTION | #SCF_WORD, editFormat) EndIf Until found = -1 Next i SendMessage_(GadgetID(0), #EM_SETSEL, 0, 0) EndProcedure If OpenWindow(0, 0, 0, 300, 150, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "EditorGadget Find Text") And CreateGadgetList(WindowID(0)) EditorGadget (0, 0, 40, 300, 120) StringGadget(1, 10, 10, 150, 20, "of three") ButtonGadget(2, 170, 10, 50, 20, "Find") AddGadgetItem(0, -1, "Line one of three") AddGadgetItem(0, -1, "This is the next line of three.") AddGadgetItem(0, -1, "End line is here") CreatePopupMenu(0) MenuItem(1, "Copy") MenuBar() MenuItem(2, "Select All") ActivateGadget(0) SendMessage_(GadgetID(0), #EM_SETREADONLY, 1, 0) SendMessage_(GadgetID(0), #EM_SETBKGNDCOLOR, 0, RGB(255, 255, 223)) Repeat event = WaitWindowEvent() Select event Case #PB_EventGadget Select EventGadgetID() Case 2 ActivateGadget(0) findtext(GetGadgetText(1)) ActivateGadget(1) EndSelect Case #WM_RBUTTONDOWN If EventGadgetID() = 0 selStart = 0 selEnd = 0 SendMessage_(GadgetID(0), #EM_GETSEL, @selStart, @selEnd) If selStart = selEnd DisableMenuItem(1,1) Else DisableMenuItem(1,0) EndIf GetCursorPos_(mouseP.POINT) DisplayPopupMenu(0,WindowID(),mouseP\x, mouseP\y) EndIf Case #PB_EventMenu Select EventMenuID() ; get the clicked menu item... Case 1 SendMessage_(GadgetID(0), #WM_COPY, 0, 0) SendMessage_(GadgetID(0), #EM_SETSEL, -1, 0) Case 2 editSel.CHARRANGE\cpMin = 0 editSel.CHARRANGE\cpMax = -1 SendMessage_(GadgetID(0), #EM_EXSETSEL, 0, @editSel) EndSelect EndSelect Until event = #PB_Event_CloseWindow EndIf End Can you convert it in QM code?
05-12-2006, 09:02 AM
How: Use share for CHARFORMAT2 structure?
I tried found=SendMessage(share(re) EM_FINDTEXT FR_DOWN &editfind) and Wordpad crash.
05-12-2006, 09:16 AM
Something like this:
CHARFORMAT2W* sm_in_wordpad=+share(worpad_edit_control_handle) I don't think you need EM_FINDTEXT if you use regular expressions. I don't think you should convert the sample as it is.
05-12-2006, 09:19 AM
Maybe better open the text in a web browser and use a bookmarklet capable to find/highlight text using regular expressions. You'll find such bookmarklets on the Internet. Search for bookmarklet highlight regular expression.
05-12-2006, 09:25 AM
I was looking for a function that worked with any editbox...
case 5 works case 6 crash \Dialog_Editor
05-12-2006, 09:45 AM
Why do you use share(re) where window handle mus be hock:
Never pass address of a variable to other applications. Use VARIABLETYPE* variable=+share variable.member=value ... SendMessage re ... share(re)
05-12-2006, 09:59 AM
On Windows XP, wordpad edit control class is richedit50w. The w at the end means that you must use wide character versions of structures, eg CHARFORMATW.
Note 2: If you use EM_FINDTEXT, FINDTEXT lpstrText member must point to string that is in shared memory.
05-12-2006, 10:02 AM
I never had been used SHARE, and in the help:
Return pointer to shared memory Syntax int* share([window]) can you help me in the case 6 to highlight all find words in any editbox?
05-12-2006, 10:51 AM
New version: Find and highlight text in other app using regular expresion
Function RichEditHighlight ;/
05-12-2006, 11:01 AM
Thank you.
It's perfect.
05-12-2006, 01:37 PM
The first version fas not perfect. For example, did not clear shared memory before using it. I converted the code to function.
10-18-2007, 09:28 AM
Is it possible in "+Scintilla"?. http://www.flos-freeware.ch/notepad2.html
10-18-2007, 09:54 AM
Don't know, probably not.
11-24-2007, 01:54 AM
Hi,
I would like to highlight text within a RichEdit20W field. After highlighting it, I would like to delete it - i.e. I am only highlighting it to be able to send a delete keystroke. int handw=GetWinId(child("" "WindowsForms10.RichEdit20W.app.0.378734a" win("Sample App" "WindowsForms10.Window.8.app.0.378734a") 0x5)) Anyway, everytime I do it, the appropriate text gets highlighted but then I get the following errors: Quote:An Unexpected Error Occurred: If I click "Retry", the text becomes unhighlighted and the dialog disappears. If I hit "Cancel", I get the following message: Quote:A fatal error occurred and the application will now terminate: When I press OK, the dialog goes away but the application of the RichEdit field doesn't close, though the text remains unhighlighted. I hope this explanation helps and that there is a solution. In the meantime, I will research what Richedit20W means - I see you have previously referred to RichEdit and RichEdit20 but not RichEdit20. Thanks, Stuart
11-24-2007, 05:47 PM
The function works with RichEditXXW too. Don't know why the target app crashes. I tested with Wordpad on XP and Vista. But if you need to select text for deleting or replacing, this function does not do it. It only changes colors. See this:
Selecting text within a text field
12-23-2010, 04:25 AM
Hi Gintaras,
I have a complex dialog that uses RichEditHighlight and would lilke to make exe out of it. It works when I comment out all the RichEditHighlight lines but when they are in place I get this error: Error in SampleDialog: cannot be used in exe. Cannot make exe. Error 4, failed to compile. The location of the error is in the following line of the RichEditHighlight function: Function RichEditHighlight_RefsManager This is such a great function that I hope it will be incorporated into the main version of QM and supported in the exe. Thanks for any thoughts on this! As always, DEEPLY grateful for all your help!! Stuart
12-23-2010, 05:36 AM
This works in exe too.
Also can remove highlighting - use color -1. Function RichEditHighlight ;/
12-23-2010, 06:02 AM
Thanks!!! Will test in my app when I get back to work tomorrow!! Merry Christmas Gintaras!!
S
02-04-2011, 04:57 AM
Hi Gintaras,
Thanks for the update on RichEditHighlight. It no longer is stopping the creation of the exe. However the dialog specified in my folder of macros is still not launching. At time of exe creation, I get this message: Quote:Warning: Cannot find function GetProcessHandleFromHwnd in dll oleacc. Make sure it is available when the code runs. Make sure the declaration contains true function name. When I attempt to run the exe, I get this: Quote:Error (RT) in SampleProgram: cannot show dialog I know this is very generic and it may be hard for you to help me with such little to go on. The dialog and associated user-defined functions it calls are very complex so it will be a challenge for me to rebuild it piece by piece confirming working exe each time (but I will do it that way if necessary). I was just wondering if there were some typical things that may cause a dialog to not launch in an exe. The issue with GetProcessHandleFromHwnd in dll oleacc did not stop a much simpler function from running properly after converted into an .exe so I don't think it is just that. Thanks so much for any help you can give me, Stuart
02-04-2011, 05:09 AM
Hi Gintaras,
I realized that the main dialog uses the splitters which required InitSplitter to create the QM_Splitter class. Is this something that is incompatible with exe. Is there a way to place to register the window class "QM_Splitter" when launching an exe? Thanks..I hope this is helpful in answering my previous question. Stuart
02-04-2011, 05:17 AM
Yes, it was definitely the splitters. I took them out of the dialog, made the exe and it ran fine!!
Hope there is a solution to including this class into exe Thanks!!! Stuart
02-04-2011, 05:18 AM
Call InitSplitter in your main exe function.
------------- Ignore the GetProcessHandleFromHwnd warning. Exe will find and use it on Windows Vista/7.
02-04-2011, 06:21 AM
Next QM will not show such warnings for dll functions declared in System.
02-04-2011, 07:28 AM
It's a QM world and I'm just happy to be living in it! Thanks for your fantastic assistance!
S |
« Next Oldest | Next Newest »
|