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

Everything else that doesn't fall into one of the other PB categories.
talun
User
User
Posts: 28
Joined: Mon May 05, 2003 3:53 pm
Location: Italy

Post by talun »

Hi El_Choni,
can you say me if it's possible to display the vertical scrollbar in the EditorGadget? (I wasn't able to find this style in the Win Api guide)

many thanks

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

Post by El_Choni »

The vertical scrollbar appears when the cursor reaches the bottom of the gadget.
El_Choni
talun
User
User
Posts: 28
Joined: Mon May 05, 2003 3:53 pm
Location: Italy

Post by talun »

El_Choni,
thank you for the reply, but I'm sorry, I've formulated my question badly.
I would like to use the wordwrap capabilities of the EditorGadget in order to show some help pages and therefore I've modified the gadget style in read only mode by using:
SendMessage_(GadgetID(#MyGadget), #EM_SETOPTIONS, #ECOOP_SET, #ECO_READONLY)
All works fine but with this setting the vertical scrollbar don't appear and this creates problems with longer documents of the page because you need scroll the page by using the cursor keys.
Can you say me if it's possible to enable the vertical scrollbar in readonly mode?

Thanks in advance

Sergio
Thorsten
User
User
Posts: 28
Joined: Sun Apr 27, 2003 2:55 pm
Location: Germany
Contact:

Post by Thorsten »

Right - I had this problem too :D

You can send this messages to the gadget:

Code: Select all

SendMessage_(GadgetID(#Number), #EM_SHOWSCROLLBAR, #SB_VERT, #True)
  SendMessage_(GadgetID(#Number), #EM_SHOWSCROLLBAR, #SB_HORZ, #True)
Now the scrollbars always showed - and your problem is solved :D
talun
User
User
Posts: 28
Joined: Mon May 05, 2003 3:53 pm
Location: Italy

Post by talun »

Thorsten many thanks for your reply; now my window have the scrollbar!
The #EM_SHOWSCROLLBAR isn't reported in my (old) Win32Api help file; I need to be accustomed with the MSDN Microsoft site.. 8O

bye

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

Post by dige »

@El_Choni:

I dont wana use callbacks to detect url-clicks ( #EM_LINK ) at editor
gadgets. Is there another way to get the #EM_LINK message?

Unfortunately it seems that WaitWindowEvent() doesnt realize that message ...

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

Post by El_Choni »

I don't know other way. Messages are sent to the Window callback procedure. You can write an userlib to handle this, but I don't see it necessary. Is there any special reason why you don't want to use the callback?
El_Choni
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

The reason is that I lose all the standard features like copy, paste and select all. If I use windowcallbacks I have to code this features by myself.

Or is there a possibility to hook the eventhandling and not to replacing?

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

Post by El_Choni »

The reason is that I lose all the standard features like copy, paste and select all. If I use windowcallbacks I have to code this features by myself.
That shouldn't happen at all. Can you post some code where you have this problem?
El_Choni
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

El_Choni, you are right. It works now with my new procedure.
Unfortunately I forgot my old procedure where I determined this circumstance. So I cant replicate the problem...

What I still wanted to annotate :
(1.) Would it not be better to use strings than memory allocations?

For example:
glink_.s = Space ( 512 )
txt\lpstrText = <a href="mailto:@gl">@gl</a>ink_.s

instead of:
StringBuffer = AllocateMemory(0, 512)
txt\lpstrText = StringBuffer

So it cant be happen to allocate the same memorybank at the same time, right?

(2.) What is the reason for : ProcedureReturn #PB_ProcessPureBasicEvents

(3.) It is possible to expand the autourldedection for own ids?

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

Post by El_Choni »

Would it not be better to use strings than memory allocations?
I don't know if it's better or faster, AFAIK it's just your choice.
What is the reason for : ProcedureReturn #PB_ProcessPureBasicEvents
When you use SetWindowCallback(), you must ensure to return #PB_ProcessPureBasicEvents, unless you don't want a particular message to be processed further by the default PB window procedure or the default window procedure.
It is possible to expand the autourldedection for own ids?
You can convert any text in a clickable link by using CFE_LINK and sending an EM_SETCHARFORMAT message. But AFAIK, autourldetection will just detect common URLs.
El_Choni
Andy
User
User
Posts: 18
Joined: Wed Jun 18, 2003 8:32 pm
Location: Switzerland

Load binary

Post by Andy »

El_Choni wrote:(Mo Jun 09, 2003 07:12)

Code: Select all

Procedure StreamFileInCallback(hFile, pbBuff, cb, pcb)
  ProcedureReturn ReadFile_(hFile, pbBuff, cb, pcb, 0)!1
EndProcedure

Procedure loadFile(pFilePath.s)
  If ReadFile(0, pFilePath)
    ...
    uFormat = #SF_RTF
    edstr.EDITSTREAM
    edstr\dwCookie = UseFile(0)
    edstr\dwError = 0
    edstr\pfnCallback = @StreamFileInCallback()
    SendMessage_(GadgetID(0), #EM_STREAMIN, uFormat, edstr)
    CloseFile(0)
  EndIf 
EndProcedure 

ETC. ...
With the same algorithm, it should be possible to load an included binary from memory to the EditorGadget... So I have try to change it... :?

But I think, I don't understand exactly, how to use the pointers - I have try many ideas - but sadly with no success...

Look here some of my code:

Code: Select all

Global RTFPtr.l

Procedure StreamFileInCallback(dwCookie, pbBuff, cb, *pcb.l)
  If ?RTFEnd-RTFPtr>cb
    *pcb=cb
    weiter=cb
  Else
    *pcb=?RTFEnd-RTFPtr
    weiter=0
  EndIf  
  CopyMemory(RTFPtr, pbBuff, *pcb)
  RTFPtr+*pcb
  ProcedureReturn weiter 
EndProcedure 

Procedure _PutRTF()
  RTFPtr=?RTFStart
  uFormat = #SF_RTF 
  edstr.EDITSTREAM 
  edstr\dwCookie = 0 
  edstr\dwError = 0 
  edstr\pfnCallback = @StreamFileInCallback() 
  SendMessage_(GadgetID(0), #EM_STREAMIN, uFormat, edstr) 
EndProcedure 

If OpenWindow(0, 200, 200, 400, 200, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget,"Memory Put")=0:End:EndIf 
  If CreateGadgetList(WindowID())=0:End:EndIf 
  EditorGadget(0, 0, 0, WindowWidth(), WindowHeight())
  _PutRTF() 
  Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow 
End

End

DataSection 
  RTFStart:
  IncludeBinary "includes\hinweis.rtf"
  RTFEnd:
EndDataSection
What's going wrong? Could anybody help me?

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

Post by El_Choni »

This may give you a hint:

Code: Select all

Global RTFPtr.l

Procedure StreamFileInCallback(dwCookie, pbBuff, cb, pcb)
  result = 0
  If RTFPtr>=?RTFEnd
    cb = 0
    result = 1
  ElseIf RTFPtr+cb>=?RTFEnd
    cb = ?RTFEnd-RTFPtr
  EndIf
  CopyMemory(RTFPtr, pbBuff, cb)
  RTFPtr+cb
  PokeL(pcb, cb)
  ProcedureReturn result
EndProcedure

Procedure _PutRTF()
  RTFPtr=?RTFStart
  uFormat = #SF_RTF
  edstr.EDITSTREAM
  edstr\dwCookie = 0
  edstr\dwError = 0
  edstr\pfnCallback = @StreamFileInCallback()
  SendMessage_(GadgetID(0), #EM_STREAMIN, uFormat, edstr)
EndProcedure

If OpenWindow(0, 200, 200, 400, 200, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget,"Memory Put")=0:End:EndIf
  If CreateGadgetList(WindowID())=0:End:EndIf
  EditorGadget(0, 0, 0, WindowWidth(), WindowHeight())
  SendMessage_(GadgetID(0), #EM_LIMITTEXT, -1, 0)
  _PutRTF()
  Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
End

End

DataSection
  RTFStart:
  IncludeBinary "includes\hinweis.rtf"
  RTFEnd:
EndDataSection
Last edited by El_Choni on Thu Jun 19, 2003 1:10 am, edited 1 time in total.
El_Choni
Andy
User
User
Posts: 18
Joined: Wed Jun 18, 2003 8:32 pm
Location: Switzerland

Post by Andy »

Yes, that it is! Your are great! Thank you very much.

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

Post by El_Choni »

No, it wasn't :lol:, pick the new source (I've just updated it).
El_Choni
Post Reply