Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically close folder window

Status
Not open for further replies.

AlanArons

Programmer
Aug 1, 2002
91
US
Hi all,

I open a folder using a shellexecute command, and that works great.

The next task is to close the same window. Most posts about similar issues point toward the SendMessage command and the processes work great on other windows, but not on the folder window. Code I am using is as follows
Code:
DECLARE INTEGER SendMessage IN Win32API ;
    INTEGER hWnd, INTEGER uMsg, INTEGER wParam, ;
    INTEGER lParam
DECLARE Long FindWindow in Win32API String, String
DECLARE Long BringWindowToTop in Win32API Long

Local lnHWND,lcTitle

lcTitle = "C:\temp"    && The window title for the folder

lnHWND = FindWindow(null,m.lcTitle)

SendMessage(lnHWND,0x0010,0,0)

What am I missing?

Alan Arons [ponder]
 
Alan,

Sorry, I can't help with SendMessage().But here's an alternative approach, using SendKeys().

Code:
* Instantiate Windows Scripting Host
oWsh = CREATEOBJECT("wscript.shell")

DECLARE INTEGER ShellExecute IN shell32.dll ;
  INTEGER hndWin, STRING cAction, STRING cFileName, ;
  STRING cParams, STRING cDir, INTEGER nShowWin

lcTitle = "C:\temp"

ShellExecute(0,"open",lcTitle,"","",1)

* Folder window is now open.
* Do what you want to with it.

* When ready to close:

* Switch to the message window
oWsh.AppActivate(lcTitle)

* Send Ctrl-W to close
oWsh.Sendkeys("^w")

* Release oWsh
RELEASE oWsh

Not tested, but I think it should work.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Thanks for your input. I didnt think (always the case) about SendKeys. I will try it out.

The folder is to be created programatically and correspond to a record in the database. As the records change, the app should close the old folder and open the new, so no, the user will not close the folder.

Alan Arons [ponder]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top