Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jun Tangunan
  Where is Jun Tangunan?
 Cabanatuan
 Philippines
 Jun Tangunan
 To: Stary
  Where is Stary?
 Ljubljana
 Slovenia
 Stary
 Tags
Subject: RE: TXT File Viewer
Thread ID: 249014 Message ID: 249015 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Sunday, December 27, 2009 2:26:23 AM         
   


> I'm looking for a simple txt file viewer which could be run from VFP to show some text contents of files I created in my VFP code (XMLs, Memo Fields, ASCII files etc...).
>
> I know I can do it with MODIFY FILE ... NOEDIT, but I want users can see line and column numbers of the current position while they move thru the file.
>
> In old DOS days I did it with a small LIST external program which was doing exactly what I needed: showed the file content with a line and column number and had some simple search options.
>
> There is a Notepad++ which can do all those things, but it is too big, as it includes tons of options for editing which I really don't need and it isn't suitable to be distributed with my application.
>
> So my question is – is there a small file viewer I can use from my application?

You can try using an RTF control. Here is a sample that you can download: http://weblogs.foxite.com/sandstorm36/archive/2009/11/21/9403.aspx

Then instead of showing the number of characters selected/highlighted (which is what is in the sample), you can do this in the mousemove event:

*** ActiveX Control Event ***
LPARAMETERS button, shift, x, y
*thisform.contrtf.lblselectNo.Caption = "Characters Selected: "+TRANSFORM(thisform.contRTF.oleRTF.objECT.SelLength)
thisform.contrtf.lblSelectNo.Caption = "Column: "+TRANSFORM(x)+SPACE(5)+"Row: "+TRANSFORM(y)
thisform.contRTF.edit1.Value = thisform.contRTF.oleRTF.seltext 



Another is by using a plain EditBox then utilizing FILETOSTR() to get the contents of a text file into a string then make that string the value of your editbox. For saving changes back to the text file, use STRTOFILE(). Likewise on MouseMove Event, you can do something like this:

LPARAMETERS nButton, nShift, nXCoord, nYCoord
WAIT "Column: "+TRANSFORM(nXCoord)+SPACE(5)+"Row: "+TRANSFORM(nYCoord) WINDOW NOWAIT 


However, note that in both cases you will have a different row and column numbers as what you normally see in DOS apps. The reason is standard DOS screens are fixed on a scale of 24 rows by 80 columns whereas with Windows apps, we are dealing with fonts and it is measured by pixels.


Jun Tangunan
http://weblogs.foxite.com/sandstorm36/default.aspx
http://www.coderisland.com/forum/viewforum.php?f=10

ENTIRE THREAD

TXT File Viewer Posted by Stary @ 12/27/2009 12:23:14 AM
RE: TXT File Viewer Posted by Jun Tangunan @ 12/27/2009 2:26:23 AM
RE: TXT File Viewer Posted by Harry Lode @ 12/27/2009 5:04:19 AM