Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SYS(1500) Help
Message
From
08/01/2008 10:23:24
 
 
To
08/01/2008 10:10:54
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01280185
Message ID:
01280207
Views:
28
>>>>Hi,
>>>>
>>>>I'd like to automate the process of loading the contents of a PRG to the clipboard.
>>>>For this task, I'm trying to use SYS(1500) to simulate some menu actions, like "Select All" and "Copy" - CtrlA and CtrlC
>>>>
>>>>Below is the code I'm using:
>>>>
>>>>
>>>>
LOCAL lcFile
>>>>lcFile = GETFILE("prg")
>>>>
>>>>MODIFY COMMAND (lcFile) NOWAIT
>>>>
>>>>* Select all
>>>>SYS(1500, '_MED_SLCTA ', '_MEDIT')  && Select All menu item
>>>>
>>>>* Copy
>>>>SYS(1500, '_MED_COPY ', '_MEDIT')  && Copy menu item
>>>>
>>>>
>>>>The problem is that sometimes it seems to work fine, and sometimes, nothing happens. I've already tried lots of things, like ensuring that the menu is visible, prior checking if the menu is available using SYS(2013), DOEVENTS, waiting for a second before each action...
>>>>
>>>>Can someone provide a hint on this ?
>>>>
>>>>
>>>>I really need the content of the PRG to the clipboard, in order use the new feature from VFP9 that sends the copied part of the PRG to the clipboard in the HTML mode.
>>>>
>>>>
>>>>Thanks in advance
>>>>
>>>>Cesar
>>>
>>>Cesar,
>>>Do you need Ctrl+A,C ... to do that? Isn't
>>>
>>>_cliptext = FileToStr(m.lcFile)
>>>
>>>sufficient?
>>>Cetin
>>
>>
>>Hi Cetin,
>>
>>Thanks for your answer.
>>But if I send the contents using _Cliptext variable, I will loose all the HTML formatting. Unfortunately, this doesn't work.
>>
>>You can test this in this simple way:
>>
>>Open any PRG, then "Select ALL" (CTRL+A), "Copy", CTRL+C
>>
>>Then, run this simple script:
>>
>>
>>
LOCAL loIE as "InternetExplorer.Application"
>>loIE = CREATEOBJECT("InternetExplorer.Application")
>>#DEFINE READYSTATE_COMPLETE      4
>>#DEFINE MAX_TIME                30
>>#DEFINE OLECMDID_PASTE          13
>>#DEFINE OLECMDEXECOPT_DODEFAULT  0
>>
>>local lcInnerHTML && HTML of the webpage
>>local lnStarted && Seconds when started loading
>>local lnWaiting && Seconds waiting for the document to load
>>local lcRetVal && Return Value
>>
>>lnStarted = SECONDS()
>>
>>lcUrl = "about:blank"
>>
>>loIE.navigate(lcUrl)
>>loIE.Visible = .T.
>>
>>* * Wait till page totally loaded
>>DO WHILE loIE.Readystate <> READYSTATE_COMPLETE or lnWaiting >= MAX_TIME
>>   lnWaiting = SECONDS() - lnStarted
>>ENDDO
>>
>>* Make the page editable
>>loIE.Document.Body.contentEditable = .T.
>>
>>And select the IE window, and click "CTRL+V" to Paste the contents, and you'll see all the formatting preserved.
>
>Cesar,
>O noticed what you meant just after I sent:) Thanks for the heads up! I was wondering where I was going wrong and the code I copied to clipboard gets screwed when pasting to forums (well only MSDN forum:). From now on I'll use an earlier version to copy&paste if I can't find a way to turn that off.
>For your case I had some clipboard data formatter (RegiserClipboradFormat based) somewhere. If I can find it and works will post.
>
>PS: Mine was using Data object. Is this for a drag&drop copy?
>Cetin


Cetin,

My goal here is to create a script that automates the conversion of some PRGS to HTM files, in order to keep the same appearance that we are used to have in our VFP program editor.

As VFP9 brings this possibility, I'd like to automate this without needing to recreate the wheel, creating a program that will apply the formatting in the VFP keywords, comments, functions etc, just like we have when we adda "PRE" tag here in UT or "VFP" in Foxite.

This will be used in some places
- GdiPlusX help files, adding the samples keeping the formatting
- And samples to be posted in my blog, in HTML


BTW, I've already tried using the API RegisterClipboradFormat , using "HTML Format" as parameter, with no success... maybe I configured it wrong, I'll try to check this again too.

Thanks again,

Cesar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform