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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Viewing a text file within an app 1

Status
Not open for further replies.

wetton

Technical User
Jun 26, 2006
42
AU
I note and have used faq184-4268 to allow an HTML file to be shown in a window.

Is there a way to convert that to show a simple text file in the window?

My attempts at getting modi file to open in a larger window have failed.

Thanks

PW
 
One way is to create a VFP form for this purpose. Add a property to hold the text of the file you want to display, let's call that property cTextString. Place an editbox on the form and set its ControlSource to thisform.cTextString. Use FILETOSTR to load the value of thisform.cTextString from the file you want to display. For example if you pass the name of the file to the form's Init method as tcFileName then you can do thisform.cTextString = FILETOSTR( tcFileName). Since it's a form you can make both it and the edit box resizeable, too. Does that help?
 
Rick


Big star for you my friend

many thanks

PW
 


PW,

Another option would be to do a MODIFY FILE <filename>. That would be a slightly simpler solution to the one Rick suggested, although it would not give you so much control over the display.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,
I explained in a previous post that that only gave a quarter size window. The suggested code changes didn't have the desired effect.
Rick's option is grand

Thanks

PW
 
I've taken a similar approach in the past to what Rick suggested but instead of using an editbox control I used the Web Browser control (Shell.Explorer.2 control).

The benefit is that you can load different file types without having to make any changes to the form (Word, Excel, Visio, Text, Html, Bitmap, etc)

The downside is that you have add more code to control events and errors and loading some file types will take longer as the control is also loading the automation server. Some file types will also launch the associated program outside of you app as well, but that can be controlled by limited file selection.

Have to say that an editbox is a simpler solution and many times simpler is better but take a few minutes to play with the browser control and see if you like it.

Ralph Kolva
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top