Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Word Pad as text editor from VFP

Status
Not open for further replies.

Apata

Programmer
Apr 5, 2006
52
US
Is there a way I could make Word Pad the text editor to open text stored in a Memo field? This is because some users may not have Word installed on their system.
 
There used to be a way in foxplus or foxbase to assign another editor to be used by default when you typed modi comm or modi memo, but i cannot remember the setting or find any reference to it here or in the foxpro(old versions) forum. If my memory is correct the editor addin had bells and whisles that modi comm did not have at the time, some similar to changes and enhancments made to the standard modi comm editor in later versions. As a user of foxbase, time has passed by, and my memory is fading. mabee someone else here has a recolection of what the command was
wjwjr
 

Apata,

I think what White had in mind was using an external editor in the development environment. I used to do that in the old FoxBase (I used Brief), but there's no easy way of integrating an editor in VFP.

But, I think what you want is an external editor for your users -- so that the users can edit memo fields, for example.

What exactly are you trying to achieve? If you want to let the user edit rich text (with fonts, styles, colours, etc)., you can do that using the Rich Edit ActiveX control within VFP.

Alternatively, if you want to let the user use a specific editor, such as Wordpad, you can copy the memo to a temporary file, ShellExecute() into Wordpad or whatever, then copy the edited version back to the memo.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
That's what I'm looking for, Mike. Firstly, I am not sure how well the Rich Edit control does with pagination, top, bottom, left and right margin settings. Maybe you could shed light on that.

Could you show me how to shellexecute() from memo into Wordpad and then make the user put the edited version back to the memo?
 
Apata,

Re pagination with the Rich Text control ... I'm not sure. The Rich Text format knows about pagination and margins, but I don't know whether the control supports it.

Re ShellExecute() ... You'd have to save the memo to a file, using either COPY MEMO or STRTOFILE(). Then ShellExecute() that file. You'll need a way to know when the user has finished the editing and saved the file. At that point, copy it back to the memo, using APPEND MEMO or FILETOSTR().

For details about how to call ShellExecute(), see:

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks, Mike. That will help me a great deal. To know when the user has finished editing with Word Pad, is there a way I could put Word Pad in a form so I could have a button do the after-editing stuff?
 

Apata,

is there a way I could put Word Pad in a form so I could have a button do the after-editing stuff?

No chance. Wordpad's not that kind of application.

However, there is another possibility:

Code:
oWSH = CREATEOBJECT("wscript.shell")
oWSH.Run("MyDocument.doc", 2, .T.)

This will launch whichever application is registered for a Doc file (Word, Wordpad, whatever). The "2" means run in a normal window. The .T. means suspend the calling program until the user quits the called program, which I think is what you want.

The only reason I don't use this more often is that I've had problems when the filename contains spaces .. but maybe that's just me.

Mike





__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike, have a big star! That'll do it. I can make the filename to not have spaces and warn the users to keep it that way.
 
Something else came to my mind on this, Mike. I am thinking of using one of the two methods you mentioned to open a jpg file. I don't want to load just any graphics program, because it may be too involved. So, I would like to use Paint that came with Windows, because it's simple enough. How can I call up Paint with a file named "Mine.jpg"? Sorry if I am repeating myself.
 
Apata

Following Mike's suggestion of using WSH, the following code will work
Code:
[COLOR=blue]oWSH = CreateObject("wscript.shell")
oWSH.Run(mspaint "D:\my jpgs\mine.jpg"],1,.T.)[/color]
Note that the second parameter is '1' and mspaint will open with the size and position as last used.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.net
PDFcommandertm.com
 
Apata,

You can use the following code in a form to sorta 'take wordpad' and place it in your form but you'll have some work to do to figure out how to get some real control of it.

Code:
DECLARE INTEGER FindWindow IN user32 ;
STRING lpClassName, STRING lpWindowName
DECLARE INTEGER SetParent IN user32 ;
INTEGER hWndChild, INTEGER hWndNewParent 

LOCAL liWordPadHandle AS Integer

liWordPadHandle = FindWindow(Null, 'document - wordpad') 
liReturn = SetParent( liWordPadHandle , THISFORM.HWnd )

You'll have to launch wordpad prior to firing this code and you'll quickly notice I didn't bother to check to see if it even found wordpad. You'll have to trap for WordPad exiting also. Just an idea that may work if you're willing to exlpore it a bit.

Ralph Kolva
 
Wow! Thanks, guys. You made my day.
 
Hi Chris:

I couldn't get that to work. Is there a typo in the code?
 
Apata,

Looks like the typo in Chris's code is that it's missing the '[' before 'mspaint'.

Should be:

Code:
oWSH.Run([mspaint "C:\temp\DSCF0001.JPG"],1,.T.)

The first arg is a string and then paint wants a string path to the file.

Ralph Kolva
 
RE: I am not sure how well the Rich Edit control does with pagination, top, bottom, left and right margin settings

You'll find that WordPad doesn't handle Pagination at all...

It does let you set the margins, but without page breaks, I find it very crippled.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
I didn't know that about Worpad. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top