VMP Home
Product Information
Testimonials
Message Board
Download VMP
Training and Demos
Support
Previous versions
User Contributions
VFP Tools & Downloads
Subscription Policy
Order Now
  frmReportDestinationSPF mods

I am using VMP4 (07/12/2001 build) and VFP6 (SP5) under WIN98 SE.

ITEM #1:
========
I have been playing around with the XXFWFRM\frmReportDestinationSPF 
classs and have noticed that the default value for 
cmdGetFile1.icFileNameCaption appears to be ' ' (i.e., space(1)) 
instead of being empty (i.e., space(0) and display "(None)" on the 
property sheet). With the default value (i.e., space(1)) , the 
GETFILE screen displays no text for parameter #2 (e.g., cText or 
.icFileNameCaption) as it should if space(1) is the desired default 
value. However, setting .icFileNameCaption to space(0) displays 
"File name:" on the GETFILE screen for parameter #2 which is VFP's 
default value.

ITEM #2:
========
I have been testing my VMP4 apps under various OS platforms (e.g., Win
9x, Win NT4, Win2000). In the past, I have populated the default
value of ctrGetFile1.txtFileName with the path of the Windows TEMP
folder + the FRX name + the appropriate file extension (e.g., TXT,
PDF, XLS, etc.). However, in the later OS versions, not all users
have easy access to their Windows TEMP folder (e.g., the folder may be
hidden and the user may not know how to un-hide the folder); so, I now
direct FILE output to the "My Documents" folder as the default. If
for some reason the My Doc folder does not exist, the default becomes
the Windows TEMP folder, and should the Window TEMP folder not exist
the default becomes SYS(2023).

I have subclassed XXFWFRM\frmReportDestinationSPF and I have tweaked
several PEMs so when the File output option is selected the default
value of ctrGetFile1.txtFileName gets populated with the destination
path + the FRX name + the appropriate file extension. My code uses a
PUBLIC variable to supply the FRX name, but modifiying the
x3wrpfrm.prg to allow an extra parameter and modifying the
frmReportDestinationSPF.INIT() to process this parameter is one way to
avoid the use of PUBLIC variables (I am sure you know many more ways
than I do).

Below are the code snippets I used which you may find useful for
future enhancements.


==================================================================
Code forfrmMYReportDestinationSPF.ctrDestination.opgBase1.Option3.Click()

*==
*==   the Get My Documents folder path code section should actually be
*==     place in its own method or prg, called from the 
*==     frmMYReportDestinationSPF.Init method, and populate a custom
*==     form property to contain the path data. 
*==

*
* Get My Documents folder path
*
#INCLUDE registry.h

* Constants used to obtain 'My Documents' folder path
#define
#MYDOCSTRING	"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
#Folders" define FOLDERPROP	"Personal"

SET CLASSLIB TO registry.vcx ADDITIVE
oReg=CREATEOBJECT('registry')

LOCAL lFoundMyDocs, cValue
lFoundMyDocs = .F.
IF oReg.OpenKey(MYDOCSTRING, HKEY_CURRENT_USER,.F.) = 0
   cValue = ''
   IF oReg.GetKeyValue(FOLDERPROP,@cValue) = 0
      lFoundMyDocs = IIF(!EMPTY(cValue),.T.,.F.)
      =oReg.CloseKey()
   ENDIF
ENDIF

=oReg.CloseKey()
RELEASE CLASSLIB registry.vcx

IF lFoundMyDocs
   TempPath = ADDBS(ALLTRIM(cValue))
ELSE
   * Find default TEMP directory via WIN32API
   nbufferLength = 255
   lpBuffer      = SPACE(255)
   DECLARE GetTempPath IN KERNEL32.DLL AS XTmpPath INTEGER
   nBufferLength, STRING lpBuffer =XTmpPath(@nbufferLength,@lpBuffer)

   * lpBuffer is NULL terminated, so remove NULL character
   cWinTempPathName = ALLTRIM(STRTRAN(lpBuffer,CHR(0),SPACE(0)))

   IF !EMPTY(cWinTempPathName)
      TempPath = ADDBS(cWinTempPathName)
   ELSE
      TempPath = ADDBS(SYS(2023))
   ENDIF
ENDIF


*
* Assign TMPPathNFile value
*

* pcRptName is expected to be a public variable
IF TYPE('pcRptName')<>'U'
   TMPPathNFile = TempPath + pcRptName
ELSE
   TMPPathNFile = TempPath + 'RptFile.txt'
ENDIF

WITH THISFORM.ctrDestination
   .ctrgetfile1.cmdgetfile1.icFileExtensions = 'TXT (*.txt):TXT'
   .ctrgetfile1.cmdgetfile1.icSelectedFile = TMPPathNFile
   .ctrgetfile1.txtFileName.VALUE = TMPPathNFile
ENDWITH

==================================================================
Code for frmMYReportDestinationSPF.ctrDestination.ctrGetFile1.cmdGetFile1.Click()

NODEFAULT
*
* This code is modified from XXFWCTRL.VCX/cmdgetfile.click
*    Code for EMPTY(lcFile) was modified 

LOCAL lcFile, llRetVal
llRetVal = .T.

WITH THIS
   IF "VISUAL FOXPRO 05" $ UPPER(VERSION())
      lcFile = GETFILE(.icFileExtensions, ;
         x3i(.icFileNameCaption), ;
         x3i(.icOpenButtonCaption), ;
         .inButtonType)
   ELSE
      lcFile = GETFILE(.icFileExtensions, ;
         x3i(.icFileNameCaption), ;
         x3i(.icOpenButtonCaption), ;
         .inButtonType, ;
         x3i(.icDialogCaption))
   ENDIF

   IF EMPTY(lcFile)
      * do not allow empty FileName
      WITH THISFORM.ctrDestination
         IF .Opgbase1.Option3.VALUE=1  && TXT
            .Opgbase1.Option3.CLICK()
         ENDIF
*         IF .Opgbase1.Option4.VALUE=1  && PDF
*            .Opgbase1.Option4.CLICK()
*         ENDIF
*         IF .Opgbase1.Option5.VALUE=1  && XLS
*            .Opgbase1.Option5.CLICK()
*         ENDIF
      ENDWITH
      RETURN .F.
   ENDIF

   IF .ilAskIfOverwrite AND FILE(lcFile)
      IF x3msgsvc("File exists, overwrite?",lcFile) # "Y"
         llRetVal = .F.
      ENDIF
   ENDIF .ilAskIfOverwrite

   IF llRetVal
      .icSelectedFile = UPPER(ALLTRIM(lcFile))
      THISFORM.ctrDestination.ctrGetFile1.txtFileName.VALUE = lcFile
   ENDIF
ENDWITH
RETURN llRetVal

==================================================================
Code for frmMYReportDestinationSPF.ctrDestination.ctrGetFile1.cmdGetFile1.RightClick()

DODEFAULT()

* Reset File Destination to default setting
WITH THISFORM.ctrDestination
   IF .opgBase1.Option3.VALUE=1  && TXT
      .opgBase1.Option3.CLICK()
   ENDIF
*   IF .opgBase1.Option4.VALUE=1  && PDF
*      .opgBase1.Option4.CLICK()
*   ENDIF
*   IF .opgBase1.Option5.VALUE=1  && XLS
*      .opgBase1.Option5.CLICK()
*   ENDIF
ENDWITH

 

==================================================================
Code for frmMYReportDestinationSPF.ctrDestination.ctrGetFile1.cmdGetFile1

.icFileExtensions = "TXT (*.TXT): TXT"
.icFileNameCaption = space(0)
.ilAskIfOverWrite = .T.

==================================================================
Code for frmMYReportDestinationSPF.ctrDestination.ctrGetFile1.txtFileName.CustomValid()

*
* This code is modified from of XXFWCTRL.VCX/cmdgetfile.click
*
LOCAL lcFile, llRetVal
WITH THISFORM.ctrDestination
   lcFile   = .ctrGetFile1.txtFileName.VALUE
   llRetVal = .T.

   IF EMPTY(lcFile)
      IF .Opgbase1.Option3.VALUE=1  && TXT
         .Opgbase1.Option3.CLICK()
      ENDIF
*      IF .Opgbase1.Option4.VALUE=1  && PDF
*         .Opgbase1.Option4.CLICK()
*      ENDIF
*      IF .Opgbase1.Option5.VALUE=1  && XLS
*         .Opgbase1.Option5.CLICK()
*      ENDIF
      RETURN .T.
   ENDIF

   IF .ctrGetFile1.cmdGetFile1.ilAskIfOverwrite AND FILE(lcFile)
      IF x3msgsvc("File exists, overwrite?",lcFile) # "Y"
         IF .Opgbase1.Option3.VALUE=1  && TXT
            .Opgbase1.Option3.CLICK()
         ENDIF
*         IF .Opgbase1.Option4.VALUE=1  && PDF
*            .Opgbase1.Option4.CLICK()
*         ENDIF
*         IF .Opgbase1.Option5.VALUE=1  && XLS
*            .Opgbase1.Option5.CLICK()
*         ENDIF
         RETURN .T.
      ENDIF
   ENDIF

   IF llRetVal
      .ctrGetFile1.cmdGetFile1.icSelectedFile = UPPER(ALLTRIM(lcFile))
   ENDIF
ENDWITH
RETURN llRetVal

Patrick Godfrey