Solved

Locfile() on top - Foxpro?

Posted on 2014-09-12
6
281 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
countPairs challenge 7 65
word0 challenge 4 64
Java Loop 6 48
iSeries email authority 4 19
A short article about a problem I had getting the GPS LocationListener working.
A short article about problems I had with the new location API and permissions in Marshmallow
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

929 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now