Hi all
I am trying to copy the contents of the editing window that is currently active (i.e. that I am editing) as text with its RTF formatting code. What I have got (cribbed) so far is this:
SET LIBRARY TO (HOME()+"Foxtools.FLL")
nWHAND =_EDOPENFIL("TEST.PRG", 1)
nEDstart = _EDSKIPLIN(m.nWHAND,0,0)
nEDend = _EDSKIPLIN(m.nWHAND,0,10)
= _EDSELECT(m.nWHAND, m.nEDstart, m.nEDend)
= _EDCOPY(m.nWHAND)
= _EDCLOSEFI(m.nWHAND, 0)
This works fine insofar as I can paste the code into Word and see that the code highlighting is correct. But there are a couple of issues I haven't yet been able to resolve:
1. I want it to work with the current/open editing window 2. I want to work with the underlying RTF, i.e. the text together with the RTF formatting tags
I expect to invoke the code to do this via a hotkey so that the window that I am working on will be the active window. Any help or suggestions would be much appreciated. Many thanks.
Paul Newton
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
Hi Paul,
- I want it to work with the current/open editing window
in ISX I use the following code:
*----------------------------------------------------------------- * Get the current window and verify that it is a valid window. *----------------------------------------------------------------- Local lnWHandle lnWHandle = GetCurrentWindow() If lnWHandle == 0 If not Empty(m.tcInvocation) Clear TypeAhead Keyboard "{Mouse}{Mouse}"+m.tcInvocation Plain Endif Return Endif
*----------------------------------------------------------------- * Verify that the current window is indeed an edit window. *----------------------------------------------------------------- Local lnEditSource lnEditSource = GetEditSource(m.lnWHandle) If not InList( m.lnEditSource, 1, 8, 10, 12 ) If not Empty(m.tcInvocation) Clear TypeAhead Keyboard "{Mouse}{Mouse}"+m.tcInvocation Plain Endif Return EndIf
*==================================================================== * Determines the source of the window identified by the passed * WHandle. It returns the following values: * * -1 The window is not an edit window * 0 Command Window * 1 MODIFY COMMAND window * 2 MODIFY FILE window * 8 Menu Designer code window * 10 Method Edit Window in Class or Form Designer * 12 MODIFY PROCEDURE window * * This procedure uses _EdGetEnv() from the FoxTools.Fll to determine * the edit source. Passing an invalid handle causes an exception in * VFP 5 and VFP 3. In VFP 6 this raises an error 2028 (API function * caused an exception). Therefore we return -1 in this case, too. *==================================================================== Procedure GetEditSource LParameter tnWHandle
Local laEnv[25], lnSource, lnOK, lcError lcError = On( "Error" ) On Error lnOK = 0 lnOK = _EdGetEnv( m.tnWHandle, @laEnv ) On Error &lcError If m.lnOK == 0 lnSource = -1 Else lnSource = laEnv[25] Endif
Return m.lnSource
*==================================================================== * Returns the WHandle of the current edit window or 0, if no edit * window is available. *==================================================================== Procedure GetCurrentWindow
Local lnWindowOnTop lnWindowOnTop = _WOnTop() If m.lnWindowOnTop <= 0 Return 0 Endif If GetEditSource( m.lnWindowOnTop ) == -1 lnWindowOnTop = 0 Endif
Return m.lnWindowOnTop
Hi Christof
Many, many thanks for your reply. It looks like just what I need and I will try it out later today.
In the meantime I have come up with a different approach for the time being. I have created a form with an RTF OLE control and an edit box. I run the form using CTRL+F10. In my editing window I use CTRL+A, CTRL+C. Pressing CTRL+F10 brings up my form and in the RTL OLE control I press CTRL+V.
In the Change method/event of the RTF control I set the value of the edit box to the TextRTF property of the control.
BTW - ISX - Is that InstallShield Express?
Thanks again
Paul
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Christof Wollenhaupt Sent: 07 February 2022 06:43 To: profoxtech@leafe.com Subject: Re: Copy contents of code/editor window with formatting
Hi Paul,
- I want it to work with the current/open editing window
in ISX I use the following code:
*----------------------------------------------------------------- * Get the current window and verify that it is a valid window. *----------------------------------------------------------------- Local lnWHandle lnWHandle = GetCurrentWindow() If lnWHandle == 0 If not Empty(m.tcInvocation) Clear TypeAhead Keyboard "{Mouse}{Mouse}"+m.tcInvocation Plain Endif Return Endif
*----------------------------------------------------------------- * Verify that the current window is indeed an edit window. *----------------------------------------------------------------- Local lnEditSource lnEditSource = GetEditSource(m.lnWHandle) If not InList( m.lnEditSource, 1, 8, 10, 12 ) If not Empty(m.tcInvocation) Clear TypeAhead Keyboard "{Mouse}{Mouse}"+m.tcInvocation Plain Endif Return EndIf
*==================================================================== * Determines the source of the window identified by the passed * WHandle. It returns the following values: * * -1 The window is not an edit window * 0 Command Window * 1 MODIFY COMMAND window * 2 MODIFY FILE window * 8 Menu Designer code window * 10 Method Edit Window in Class or Form Designer * 12 MODIFY PROCEDURE window * * This procedure uses _EdGetEnv() from the FoxTools.Fll to determine * the edit source. Passing an invalid handle causes an exception in * VFP 5 and VFP 3. In VFP 6 this raises an error 2028 (API function * caused an exception). Therefore we return -1 in this case, too. *==================================================================== Procedure GetEditSource LParameter tnWHandle
Local laEnv[25], lnSource, lnOK, lcError lcError = On( "Error" ) On Error lnOK = 0 lnOK = _EdGetEnv( m.tnWHandle, @laEnv ) On Error &lcError If m.lnOK == 0 lnSource = -1 Else lnSource = laEnv[25] Endif
Return m.lnSource
*==================================================================== * Returns the WHandle of the current edit window or 0, if no edit * window is available. *==================================================================== Procedure GetCurrentWindow
Local lnWindowOnTop lnWindowOnTop = _WOnTop() If m.lnWindowOnTop <= 0 Return 0 Endif If GetEditSource( m.lnWindowOnTop ) == -1 lnWindowOnTop = 0 Endif
Return m.lnWindowOnTop
BTW - ISX - Is that InstallShield Express?
No, that's my original IntelliSense alternative for VFP 6 written at a time when we called everything soandsoX.
https://bitbucket.org/cwollenhaupt/foxpert.tools.isx/src/master/ https://bitbucket.org/cwollenhaupt/foxpert.tools.isx/src/master/
There's am enhanced version called IntelliSenseX that is part of Thor:
https://github.com/VFPX/IntelliSenseX https://github.com/VFPX/IntelliSenseX
I don't know about automating it but this seems to work in the edit window: Ctl_A Ctl_C -> in e.g. Word - Ctl_V - save as type .rtf
On 07-Feb-22 5:19 AM, paul.newton.hudl@gmail.com wrote:
Hi all
I am trying to copy the contents of the editing window that is currently active (i.e. that I am editing) as text with its RTF formatting code. What I have got (cribbed) so far is this:
SET LIBRARY TO (HOME()+"Foxtools.FLL")
nWHAND =_EDOPENFIL("TEST.PRG", 1)
nEDstart = _EDSKIPLIN(m.nWHAND,0,0)
nEDend = _EDSKIPLIN(m.nWHAND,0,10)
= _EDSELECT(m.nWHAND, m.nEDstart, m.nEDend)
= _EDCOPY(m.nWHAND)
= _EDCLOSEFI(m.nWHAND, 0)
This works fine insofar as I can paste the code into Word and see that the code highlighting is correct. But there are a couple of issues I haven't yet been able to resolve:
- I want it to work with the current/open editing window
- I want to work with the underlying RTF, i.e. the text together with
the RTF formatting tags
I expect to invoke the code to do this via a hotkey so that the window that I am working on will be the active window. Any help or suggestions would be much appreciated. Many thanks.
Paul Newton
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]
Hi Andy, thanks for your reply.
Yes but that displays the rendered RTF and I want to work with the underlying RTF (including the various tags - e.g. font name, size, weight, style, colour etc)
Paul
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of AndyHC Sent: 07 February 2022 07:19 To: profoxtech@leafe.com Subject: Re: Copy contents of code/editor window with formatting
I don't know about automating it but this seems to work in the edit window: Ctl_A Ctl_C -> in e.g. Word - Ctl_V - save as type .rtf
On 07-Feb-22 5:19 AM, paul.newton.hudl@gmail.com wrote:
Hi all
I am trying to copy the contents of the editing window that is currently active (i.e. that I am editing) as text with its RTF formatting code. What I have got (cribbed) so far is this:
SET LIBRARY TO (HOME()+"Foxtools.FLL")
nWHAND =_EDOPENFIL("TEST.PRG", 1)
nEDstart = _EDSKIPLIN(m.nWHAND,0,0)
nEDend = _EDSKIPLIN(m.nWHAND,0,10)
= _EDSELECT(m.nWHAND, m.nEDstart, m.nEDend)
= _EDCOPY(m.nWHAND)
= _EDCLOSEFI(m.nWHAND, 0)
This works fine insofar as I can paste the code into Word and see that the code highlighting is correct. But there are a couple of issues I haven't yet been able to resolve:
- I want it to work with the current/open editing window
- I want to work with the underlying RTF, i.e. the text together with
the RTF formatting tags
I expect to invoke the code to do this via a hotkey so that the window that I am working on will be the active window. Any help or suggestions would be much appreciated. Many thanks.
Paul Newton
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]