Solved

Locfile() on top - Foxpro?

Posted on 2014-09-12
6
278 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
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.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

760 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

17 Experts available now in Live!

Get 1:1 Help Now