Solved

Locfile() on top - Foxpro?

Posted on 2014-09-12
6
306 Views
Last Modified: 2014-10-03
I have a PRG which runs a top-level form. In the PRG I want to use locfile() to create a reference to a file which will be used in the form. How can I force the locfile() dialog to come up on top?

The application is a COM server (EXE), which is run from a C++ application. When I run it the locfile comes up hidden behind the Calling EXE.
0
Comment
Question by:krhag28
  • 3
  • 3
6 Comments
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 40320828
LOCFILE() is not what you should use, if you want a file dialog. LOCFILE() only falls back to using a dialog as last resort, if it doesn't find a file. Use GETFILE().

Bye, Olaf.
0
 

Author Comment

by:krhag28
ID: 40320850
GETFILE() has no default folder, but LOCFILE() has, so that's why I prefer LOCFILE(). However the problem with not being on top is the same.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 40320856
Interesting,
a) CD into the desired default folder and GETFILE starts there.
b) GETFILE uses the system open file dialog, which should appear on top always.

You might set the alwaysontop=.f. when your form is started and right before you start LOCFILE or GETFILE.

Bye, Olaf.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:krhag28
ID: 40321248
a) I prefer not to change the default folder, but of course it is possible...
b) Unfortunately it does not appear on top

No form is started - I run the file open dialog from the main PRG.

My conclusion is that I need to involve a form to force it on top.
0
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
ID: 40321645
>My conclusion is that I need to involve a form to force it on top

You initially said "I have a PRG which runs a top-level form". You also said "In the PRG I want to use locfile() to create a reference to a file which will be used in the form"

You didn't made very clear what you do when, but GETFILE and LOCFILE should display their dialog on top no matter if a VFP form already is shown or not.

You also said "The application is a COM server (EXE)", then you'll have an olepublic class to start it from C++. How about showing your code?

Here's what I tested:
Define Class myclass as custom olepublic
   somefile = ""

   Procedure init()   
      somefile = LocFile("C:\temp\test.txt")
      somefile = GetFile("txt")
   EndProc 
EndDefine

Open in new window

Compiled into myapp.exe and registered by compilation.

Started from Word via:
Dim o As Object
   Set o = CreateObject("myapp.myclass")

Open in new window


This displays both dialogs in front if the word document. I'd say you have to figure out where Windows stores defaults/last usage and positioning of the system file open dialog, this is at least not a general misbehaviour of VFP.

Bye, Olaf.
0
 

Author Closing Comment

by:krhag28
ID: 40360942
The solution is correct, but does not solve my problem. I had to move the opendialog from the prg to a form, then it works.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question