surinder singh


Hi

I want to show the properties window to the file selected by user on right click -> properties option.

(as this is shown with any file when we right click on that file and click on properties option in widows explorer)

If anybody knows about it , please tell me how to do this

If any one knows to do this in Visual Foxpro then it will be good for me.





Re: How to show properties window to a file in foxpro

Markish


Hi,

I really don't get what you want. I assume you are trying for the context menus in VFP. Context menus can be created by defining a popup as shortcut

For Example, Put the following code in right-click event of some control

Code Snippet

DEFINE POPUP mtest_menu SHORTCUT RELATIVE FROM MROW(),MCOL()

DEFINE BAR 1 OF mtest_menu PROMPT "\<Options"

DEFINE BAR 2 OF mtest_menu PROMPT "\-"

DEFINE BAR 3 OF mtest_menu PROMPT "\<Help "

ON SELECTION POPUP mtest_menu moption=BAR()

ACTIVATE POPUP mtest_menu

DO case

CASE moption=1

MESSAGEBOX("Options")

* Handle here...

CASE moption=3

MESSAGEBOX("Help")

* Handle here...

ENDCASE

Best regards,

Markish







Re: How to show properties window to a file in foxpro

surinder singh

I have Treeview control on my form which displays all files & folder names from selected drive (say C:\MyFolder)

Now if user right clicks on any node in the tree a shortcut menu appears with options Open,Delete,Copy,Paste,Rename,Cut etc.

I want to add one more option to this menu say PROPERTIES.

Whenever user clicks on PROPERTIES option I want to show properties window associated with that file/folder.

(as this is shown in windows explorer when we right click on any file/folder and choose PROPERTIES option )

I want to know how to display property window.

Thanks







Re: How to show properties window to a file in foxpro

PB_UK

I think the ADIR() command may be most useful - though if you already have the files listed into an array you may already have retrieved the details available. It allows you to see file size, date/time last modified and file attributes (such as read only, system, hidden etc.). Of course, it would mean you need to create a form to display the properties - it's not the windows explorer file properties function being called.

Is that sufficient Or are you hoping to be able to get the windows operating system file properties window to be shown






Re: How to show properties window to a file in foxpro

surinder singh

Yes, I want to get the windows operating system file properties window.






Re: How to show properties window to a file in foxpro

PB_UK

I have seen a number of items that relate to doing this in C++ (using shellexecute), but there seems to be nothing in the VFP classes for doing similar, though I'm sure there would be a way.

I also have not been able to find the appropriate entry point for shell32.dll or explorer.exe (or wherever) to show the properties of a file.

However, I have found a simple utility (freeware) that allows you to run context menu items from a command line: http://www.eluent.com/runmenu.htm

If you download the runmenu program you can call (for example)

runmenu /verbStick out tongueroperties <filename>

e.g. runmenu /verbStick out tongueroperties c:\file.txt

That will bring up the properties window as if you had right clicked on the file in windows explorer and selected properties.

So, if you wanted to call that from within VFP you would use the ! to access the system, however, the command window (black command.com screen) shows as well, so it's not perfect.






Re: How to show properties window to a file in foxpro

PB_UK

This may be of interest:

http://www.ml-consult.co.uk/foxst-26.htm

It goes into a lot of detail about the shellexecute function (using a call to shell32.dll). I can get it to work to open files, but for some reason for me whenever I send the verb/action "properties" I get a return of 31 which indicates invalid action or no application associated - which is rubbish as I tried a .PDF as well as a simple .TXT file)

Hopefully you'll have more luck with it than me.

The short version:

DECLARE INTEGER ShellExecute IN shell32.dll ;

INTEGER hndWin, ;

STRING cAction, ;

STRING cFileName, ;

STRING cParams, ;

STRING cDir, ;

INTEGER nShowWin

then call it by:

retval = shellexecute(0,"<action>","<file>","<parameters - usually blank>","<default directory - usually blank">,1)

so, if you had a file c:\test.txt you *should* be able to use:

retval = shellexecute(0,"properties","c:\test.txt","","",1)

retval holds the return code where >31 is a success, and less an error.


I take no credit for this work - I found all the above at the first posted address (as well as similar on other sites on the web).






Re: How to show properties window to a file in foxpro

Naomi Nosonovsky

You may want to check this MSKB article http://support.microsoft.com/default.aspx scid=kb;EN-US;Q224351

But I also think, you may be able to get the properties dialog by other way, though I'm not yet sure how.

See this http://support.microsoft.com/default.aspx scid=kb;EN-US;152457 and http://www.berezniker.com/display/VFP/Launching+Windows+Explorer+for+Specified+Drive%2C+Folder+or+File

May be you can just lauch explorer on the selected file and then emulate Right Click Just an idea.





Re: How to show properties window to a file in foxpro

PB_UK

I think the problem with the launching explorer window with file select is that it will mean having the explorer window launched. I believe the desired solution is to just get the file properties window up.

The dsofile.dll solution you suggested may be better assuming it will work with all file types and not just office documents.






Re: How to show properties window to a file in foxpro

Naomi Nosonovsky

Yes, I later thought it would be better to do something without openning Windows Explorer. I'll check the link you provided. AFAIK dso only allows to get/update extended properties for office documents.





Re: How to show properties window to a file in foxpro

surinder singh

Hi PB

There is nothing like "properties" action in SHELLEXECUTE api.

Thanks






Re: How to show properties window to a file in foxpro

PB_UK

Hi Surinder

Thanks for the update - that would explain why it wouldn't work. It doesn't explain why many sites claim that it would, however. Unless, of course, it was a previous OS (maybe Win 2k ) and shellexecute no longer includes the properties action

Shame - it would have been ideal had it worked the way many sites claimed it did.

Cheers






Re: How to show properties window to a file in foxpro

CetinBasoz

You can use Shell.Application.

lcFile = getfile()

loShell = Createobject("Shell.Application")

loFolder = loShell.Namespace(JUSTPATH(m.lcFile))

loItem = loFolder.ParseName(JUSTFNAME(m.lcFile))

If !Isnull(loItem)

IF loItem.IsLink

objLink = loItem.GetLink()

"Link properties of shortcut:"

"-------------------------------------"

"Description:", objLink.Description

"Path:", objLink.Path

"Arguments:", objLink.Arguments

"WorkingDirectory:", objLink.WorkingDirectory

"-------------------------------------"

else

For ix= 0 To 34

"Column "+Str(m.ix,2)+": "+ ;

loFolder.GetDetailsOf(loItem, m.ix)

Endfor

endif

Else

"File doesn't exist"

Endif





Re: How to show properties window to a file in foxpro

surinder singh

Hi PB

you are right but shellexecute includes the properties action only for files with .lnk extension and not for any other files/folders.

My target is to show property window just like windows explorer without designing any extra form and to show properties on that form.

Best Regards

Surinder Singh






Re: How to show properties window to a file in foxpro

surinder singh

Hi CetinBesoz

That code works fine for files but fails if user will right click on any folder.

If you have any idea to view folder properties just like as done for file please post it.

Thanks & Regards

Surinder Singh