Problem with catch events from EditorGadget() -->PB 3.7

Everything else that doesn't fall into one of the other PB categories.
Andy
User
User
Posts: 18
Joined: Wed Jun 18, 2003 8:32 pm
Location: Switzerland

put memory to EditorGadget

Post by Andy »

Ah, I see - the result of the StreamFileInCallback procedure is now as described in the API reference (EDITSTREAM structure). OK - fine. :D

Good night
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

El_Choni wrote: You can convert any text in a clickable link by using CFE_LINK and sending an EM_SETCHARFORMAT message.
Could you write a little example for that please?

Thanks for your help,

cya dige
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Code: Select all

Declare WndProc(hWnd, uMsg, wParam, lParam)

Structure ENLINK
  nmhdr.NMHDR
  msg.l
  wParam.l
  lParam.l
  chrg.CHARRANGE
EndStructure

Structure CHARFORMAT2
  cbSize.l
  dwMask.l
  dwEffects.l
  yHeight.l
  yOffset.l
  crTextColor.l
  bCharSet.b
  bPitchAndFamily.b
  szFaceName.b[#LF_FACESIZE]
  _wPad2.w
  wWeight.w
  sSpacing.w
  crBackColor.l
  lcid.l
  dwReserved.l
  sStyle.w
  wKerning.w
  bUnderlineType.b
  bAnimation.b
  bRevAuthor.b
  bReserved1.b
EndStructure

#EN_LINK = $70b
#ENM_LINK = $4000000
#CFM_LINK = $20
#CFE_LINK = $20

Procedure WndProc(hWnd, uMsg, wParam, lParam)
  result = #PB_ProcessPureBasicEvents
  Select uMsg
    Case #WM_NOTIFY
      *el.ENLINK = lParam
      If *el\nmhdr\code=#EN_LINK
        If *el\msg=#WM_LBUTTONDOWN
          StringBuffer = AllocateMemory(0, 512)
          txt.TEXTRANGE
          txt\chrg\cpMin = *el\chrg\cpMin
          txt\chrg\cpMax = *el\chrg\cpMax
          txt\lpstrText = StringBuffer
          SendMessage_(GadgetID(0), #EM_GETTEXTRANGE, 0, txt)
          Debug PeekS(StringBuffer)
          FreeMemory(0)
        EndIf
      EndIf
  EndSelect
  ProcedureReturn result
EndProcedure

If OpenWindow(0, 100, 200, 195, 260, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget, "PureBasic Window")=0:End:EndIf
If CreateGadgetList(WindowID())=0:End:EndIf
EditorGadget(0, 0, 0, WindowWidth(), WindowHeight())
SendMessage_(GadgetID(0), #EM_SETEVENTMASK, 0, #ENM_LINK|SendMessage_(GadgetID(0), #EM_GETEVENTMASK, 0, 0))
EditorText$ = "I don't wanna be a link,"+Chr(10)+"but I am a link,"+Chr(10)+"what do you think?"
Link$ = "I am a link"
SetGadgetText(0, EditorText$)
Start = FindString(EditorText$, Link$, 1)
SendMessage_(GadgetID(0), #EM_EXGETSEL, 0, chr.CHARRANGE)
SendMessage_(GadgetID(0), #EM_HIDESELECTION, #TRUE, 0)
SendMessage_(GadgetID(0), #EM_SETSEL, Start-1, Start+Len(Link$)-1)
cf.CHARFORMAT2
cf\cbSize = SizeOf(CHARFORMAT2)
SendMessage_(GadgetID(0), #EM_GETCHARFORMAT, #SCF_SELECTION, cf)
cf\cbSize = SizeOf(CHARFORMAT2)
cf\dwMask|#CFM_LINK
cf\dwEffects|#CFE_LINK
SendMessage_(GadgetID(0), #EM_SETCHARFORMAT, #SCF_SELECTION, cf)
SendMessage_(GadgetID(0), #EM_EXSETSEL, 0, chr)
SendMessage_(GadgetID(0), #EM_HIDESELECTION, #FALSE, 0)
SetWindowCallback(@WndProc())
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
End
El_Choni
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

Wow, thank you very very much El_Choni!!!!
That help me a lot, I bowing low for the master :-)

cya dige
Post Reply