0

I want to open a folder, and select a file by default.

I do it like this:

Declare Long WinExec In kernel32 String @, Integer
WinExec("Explorer /select, C:\tt.txt",5)

But if the folder has been opened, the file can't be selected by default.

How to do it?

pb2q
  • 58,613
  • 19
  • 146
  • 147
lichaoz
  • 1
  • 1
  • 1
  • What you are asking doesn't make sense to me. You can't open a folder in VFP. Can you clarify what you mean a bit please. – Caltor Nov 07 '12 at 15:20

1 Answers1

1

What is your purpose of prompting a user with picking a particular file...

The closest you can get from wthin VFP is "GetFile()" where you can give it a default extension of a file you are hoping to find and it brings up a file selection dialog.

lcFileSelected = GetFile( "Txt", "Caption left of combobox selection (but only shows about 16 chars)", "Button Caption", nOptionalButton )

where ex: nOptionalButton 0 = no extra button at bottom right, just the OK, Cancel (where OK is overridden by the "Button Caption" sample above.

1 = OK, New, Cancel

2 = Ok, None, Cancel

If a value selected, you'll have the file name, otherwise blank.

REVISED ANSWER..

Then what you want is PUTFILE() which allows you to prompt a user a simple message, similar to a "Save to", and allows to put a fully qualified path and file name. Upon return, much like that of doing GETFILE() will return the final path/file name entered by the user. Ex:

lcUserAnswer = PUTFILE( "save where", "C:\program files\myTest.txt" )

now you can do whatever with the "lcUserAnswer" variable...

DRapp
  • 47,638
  • 12
  • 72
  • 142
  • Thanks for your answer I just want to achieve a functions like operating system For example: Right-click a shortcut icon for a program on the desktop, select properties,left-click "Find target" button in the Properties window When the window is opened, the EXE file was selected by default – lichaoz Jun 18 '12 at 08:27
  • My email:zhan0926@yahoo.com.cn – lichaoz Jun 18 '12 at 08:29
  • @lichaoz, see revised answer with PUTFILE() – DRapp Jun 18 '12 at 09:06
  • Sorry,these are not what I need. I just need when a folder opened, a file was selected by default. Just like [WinExec("Explorer /select, C:\tt.txt",5)] – lichaoz Jun 22 '12 at 03:46