using #EM_FINDTEXT

Just starting out? Need help? Post your questions and find answers here.
Yian_The_Craft
User
User
Posts: 15
Joined: Sun Sep 12, 2004 6:41 am

using #EM_FINDTEXT

Post by Yian_The_Craft »

Hey guys I really need some help on how to use
#EM_FINDTEXT http://msdn.microsoft.com/library/defau ... ndtext.asp
The lpstrText is what is confusing me...is a callback needed?Or some peek/poke commands?
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

Post by GreenGiant »

Here's some quick and easy code that should show you how to use the message. You basically just specify a start and end for the search and the word to find.

Code: Select all

OpenWindow(0,0,0,400,400,#PB_Window_SystemMenu | #PB_Window_ScreenCentered,"test")
CreateGadgetList(WindowID(0))
  EditorGadget(0,10,10,380,350)
  For a=0 To 20 
    AddGadgetItem(0,a,"This is line "+Str(a)) 
  Next
  ButtonGadget(1,10,370,380,20,"Click to find the word 'line'")
  
word$="line"

text.FINDTEXT
text\chrg\cpmin=0
text\chrg\cpmax=1000
text\lpstrText=@word$

Repeat
ev=WaitWindowEvent()
  If ev=#PB_Event_Gadget And EventGadgetID()=1
    Repeat
      res=SendMessage_(GadgetID(0),#EM_FINDTEXT,#FR_DOWN | #FR_WHOLEWORD,@text.FINDTEXT)
      Debug res
      text\chrg\cpmin=res+1
    Until res<0
    text\chrg\cpmin=0
  EndIf
Until ev=#PB_Event_CloseWindow

But if you're using it for something real, you might want to put a real top value in, rather than just putting a thousand like I did :P
Yian_The_Craft
User
User
Posts: 15
Joined: Sun Sep 12, 2004 6:41 am

Post by Yian_The_Craft »

could the last parameter of the #EM_ message not simply be

Code: Select all

text
?
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

Post by GreenGiant »

Yeah, it probably could. Just my coding style I guess. Probably silly, but I keep it like that so that at a glance I know that its a pointer and that its a structure. Just helps me when I need to change things and I can glance at it and remember what's going on.
Post Reply