Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Streaming RichEdit Control Data
#1
Hi G,

Would it be possible for you to give an example of how to read "Rich Text" from a Richedit Control ?

I have a lot of articles on EDITSTREAM...etc...however, I am unable to implement in QM.

Thx in advance
#2
You can use functions RichEditLoad and RichEditSave. Also, rich text files can be automatically loaded into rich edit controls in custom dialogs.

_________________

I found these functions in my archive but don't remember whether they are complete and worked.

Function RtfOpen
Code:
Copy      Help
;/
function# hre $filename

EDITSTREAM es
es.pfnCallback=&RtfOpenProc
es.dwCookie=CreateFile(filename GENERIC_READ 0 0 OPEN_EXISTING FILE_ATTRIBUTE_NORMAL 0)
if(es.dwCookie=-1) ret
SendMessage(hre EM_STREAMIN SF_RTF &es)
CloseHandle(es.dwCookie)
ret !es.dwError

Function RtfOpenProc
Code:
Copy      Help
function dwCookie !*pbBuff cb *pcb
ReadFile(dwCookie pbBuff cb pcb 0)

Function RtfSave
Code:
Copy      Help
;/
function# hre $filename

EDITSTREAM es
es.pfnCallback=&RtfSaveProc
es.dwCookie=CreateFile(filename GENERIC_WRITE 0 0 CREATE_ALWAYS FILE_ATTRIBUTE_NORMAL 0)
if(es.dwCookie=-1) ret
SendMessage(hre EM_STREAMOUT SF_RTF &es)
CloseHandle(es.dwCookie)
ret !es.dwError

Function RtfSaveProc
Code:
Copy      Help
function dwCookie !*pbBuff cb *pcb
WriteFile(dwCookie pbBuff cb pcb 0)
#3
Cool !

Another question though....Can I get the result in a string instead of file...

Also, which would be the easiest way to convert thr rtf text to html ?

Any ideas...
#4
Quote:Can I get the result in a string instead of file...

Yes. Instead of creating file, pass the address of the variable as dwCookie.

Function GetRTF
Code:
Copy      Help
;/
function# hre str&s

s.all
EDITSTREAM es
es.pfnCallback=&GetRTF_Proc
es.dwCookie=&s
SendMessage(hre EM_STREAMOUT SF_RTF &es)
ret !es.dwError

Function GetRTF_Proc
Code:
Copy      Help
;/
function str&s !*pbBuff cb *pcb
s.fromn(s s.len pbBuff cb)
*pcb=cb

Function GetRTF_Test
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3"
str rea3
rea3="&$desktop$\Document.rtf"
if(!ShowDialog("GetRTF_Test" &GetRTF_Test &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 RichEdit20A 0x54233044 0x200 6 6 96 48 ""
;4 Button 0x54032000 0x0 6 64 48 14 "Button"
;END DIALOG
;DIALOG EDITOR: "" 0x2020002 "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 4
,str s
,if(GetRTF(id(3 hDlg) s))
,,mes s
,,ShowText "" s
,case IDOK
,case IDCANCEL
ret 1

Quote:which would be the easiest way to convert thr rtf text to html ?

Search for an ActiveX component on the Internet...
#5
I am getting errors:
Error (RT) in GetRTF_Proc: invalid pointer

GetRTF
Code:
Copy      Help
/
function# hre str&s

EDITSTREAM es
es.pfnCallback=&GetRTF_Proc
es.dwCookie=&s
SendMessage(hre EM_STREAMIN SF_RTF &es)
ret !es.dwError

GetRTF_Proc
Code:
Copy      Help
function str&s !*pbBuff cb *pcb
s.fromn(s s.len pbBuff cb)
*pcb=cb

Maybe I am calling it wrong?
#6
I just found the answer...

GetRTF was sending EM_STREAMIN message....it should have been EM_STREAMOUT..

Working perfectly now !

And, since I am on a roll now...I thought I'll ask u another question :-)

Can we have a Node of treeview as BOLD.....I am using Custom Draw (your example)
#7
I'm sorry, the code was incorrect, now replaced.

Quote:Can we have a Node of treeview as BOLD.....I am using Custom Draw (your example)

I didnt try but know it is possible. Read in MSDN library.
#8
Use messages TVM_GETITEM and TVM_SETITEM to add TVIS_BOLD state.
#9
Thx a lot, G
Works perfectly !


Attached Files Image(s)
   
#10
Hi - this is perhaps more of a Windows question than QM one.

I can run the GetRTF example without a problem but I'm having trouble running it on an accessible object. I suspect the problem is that I don't understand the runtime hierarchy of objects in Windows.

The following code works fine:
Code:
Copy      Help
int w1=win("Nuance PowerScribe 360" "WindowsForms10.Window.8.app.0.3ce0bb8_r13_ad1")
Acc a.Find(w1 "TEXT" "" "class=WindowsForms10.RICHEDIT50W.app.0.3ce0bb8_r13_ad1")
int controlID = child(a)

str report
report.getwintext(controlID)
out F"report  is {report}"

But - I want the RTF format of the text. If I try
Code:
Copy      Help
str rtfReport
GetRTF(controlID rtfReport)
the application that I'm retrieving data from crashes.

I'm assuming that it's possible to get the RTF because the class of the object is RICHEDIT50W. I tried passing
Code:
Copy      Help
id(w1 controlID)
but this returns 0 so I don't understand what the scope of the id is. Any suggestions welcomed (including RTFM - but it would be helpful if you pointed me at the URL or give me a phrase I can google so that I can solve this). I believe that my basic problem is that I'm not getting the appropriate window handle from the ID returned by the child() function but even that could be wrong Big Grin

Thanks!
#11
To get RTF from other process, would need to create dll file, for example in C language, and inject it into that process, for example with a hook.

To make it work with any process, would need 2 dll files - 32-bit and 64-bit. But quite difficult to inject into 64-bit processes...

QM does not create dll files, unless you know C language, then can use __Tcc class, but only if the process is not 64-bit.


Forum Jump:


Users browsing this thread: 1 Guest(s)