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?
#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?
