controls - see this link:
http://www.powerbasic.com/support/pb...ad.php?t=24564
thanks for the inspiration.

best regards,
erik
------------------
FUNCTION RichEditDoFindReplaceAction(BYVAL lpfr AS FINDREPLACE PTR, BYVAL hDlg AS DWORD, BYVAL DlgItem AS LONG) AS LONG STATIC ft AS FINDTEXTEX LOCAL st AS SETTEXTEX LOCAL result AS LONG STATIC newfind AS LONG ReplaceAll: IF (@lpfr.Flags AND %FR_DIALOGTERM) THEN 'Find or replace dialog is closed hFindReplaceDialog = %NULL FUNCTION = 0 : EXIT FUNCTION END IF 'save the flags for the next time: SearchFlags = @lpfr.Flags 'get the position of the current selection: CALL SendMessage(GetDlgItem(hDlg, DlgItem), %EM_EXGETSEL, 0, VARPTR(ft.chrg)) 'if Replace or Replace All button was used, and there is a new find.. IF (@lpfr.Flags AND %FR_REPLACE) = %FR_REPLACE OR (@lpfr.Flags AND %FR_REPLACEALL) = %FR_REPLACEALL AND newfind THEN 'replace RESET newfind 'allow only one replacement per find st.flags = %ST_KEEPUNDO OR %ST_SELECTION st.codepage = %CP_ACP 'default (ANSI) code page CALL SendMessage(GetDlgItem(hDlg, DlgItem), %EM_SETTEXTEX, VARPTR(st), @lpfr.lpstrReplaceWith) 'adjust the selected text range to match the new replacement text length: ft.chrgText.cpMax = ft.chrgText.cpMin + LEN(@[email protected]) CALL SendMessage(GetDlgItem(hDlg, DlgItem), %EM_EXSETSEL, 0, VARPTR(ft.chrgText)) END IF 'put the text to search for into the FINDTEXTEX struct: ft.lpstrText = @lpfr.lpstrFindWhat 'if the search direction is down, then the char range needs to be modified: IF (@lpfr.Flags AND %FR_DOWN) = %FR_DOWN THEN INCR ft.chrg.cpmin 'add one to the position of the last find, otherwise the position won't advance forward. ft.chrg.cpmax = -1 'look to the end of the text END IF 'perform the search operation: CALL SendMessage(GetDlgItem(hDlg, DlgItem), %EM_FINDTEXTEX, @lpfr.Flags, VARPTR(ft)) TO result IF result > -1 THEN 'the search str was found CALL SendMessage(GetDlgItem(hDlg, DlgItem), %EM_EXSETSEL, 0, VARPTR(ft.chrgText)) newfind = 1 'keep track of the new find ELSE RESET newfind MSGBOX "No matches found." END IF 'if Replace All, then loop until all found text has been replaced: IF (@lpfr.Flags AND %FR_REPLACEALL) = %FR_REPLACEALL AND newfind THEN GOTO ReplaceAll END FUNCTION
CONTROL GET TEXT hWnd, id TO txt ' text to search in REPLACE $LF WITH "" IN txt '<-- fixes problem
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: