|
-
March 14th, 2006, 03:55 AM
#1
open a folder and select the specified file ?
ShellExecute(GetSafeHwnd(),_T("open"),_T("explorer"),_T("D:\\interface source"),NULL,SW_SHOW);
the code above can open the folder,but want to achieve a further request,
I want to select a specified file in it ( you know make it hight-lighted).
my approach is to find out the window refers to the process of "explorer",
get its handle,send a message to its list control within it.such approach make my program quite complicated.
-
March 14th, 2006, 04:05 AM
#2
Re: open a folder and select the specified file ?
 Originally Posted by suchuhui80
I want to select a specified file in it .( you know make it hight-lighted).
using CFileDialog or not?
If I Helped You, "Rate This Post"
Thanks
Guna
-
March 14th, 2006, 04:19 AM
#3
Re: open a folder and select the specified file ?
of course not.only that window opened by system (you know what I say).
-
March 14th, 2006, 04:29 AM
#4
Re: open a folder and select the specified file ?
i can't underswtand ur problem can u explain?
If I Helped You, "Rate This Post"
Thanks
Guna
-
March 14th, 2006, 05:52 AM
#5
Re: open a folder and select the specified file ?
seems like you are tryin to implement a explorer kinda API ....you might wanna look at these links
Treeview Control
CTreeFileCtrl & CSortedArray v1.06
- Sreehari
"Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
" Everybody is sent to Earth on a purpose. I am so Lagging behind that i won't die." – Calvin
-
March 15th, 2006, 12:38 AM
#6
Re: open a folder and select the specified file ?
I am not going to implement a explorer,
all I want to do is to have the explorer openned the folder of the specified file and select the file.
The former can be easy achieved by the code below :
ShellExecute(GetSafeHwnd(),_T("open"),_T("explorer"),_T("D:\\interface source"),NULL,SW_SHOW);
but how to achieve the second one ?
This is the explicitest way I can clarify.
-
March 15th, 2006, 02:49 AM
#7
Re: open a folder and select the specified file ?
 Originally Posted by suchuhui80
my approach is to find out the window refers to the process of "explorer",
get its handle,send a message to its list control within it.such approach make my program quite complicated.
What’s so complicated in that approach?
::FindWindow()/::FindWindowEx() and ::SendMessage() ? 
Another way you can consider is after launching Explorer, set the focus to the file list window, and then simply emulate keyboard keys with the file name that you want to select.
Cheers
-
March 17th, 2006, 04:38 AM
#8
Re: open a folder and select the specified file ?
 Originally Posted by golanshahar
What’s so complicated in that approach?
::FindWindow()/::FindWindowEx() and ::SendMessage() ?
Another way you can consider is after launching Explorer, set the focus to the file list window, and then simply emulate keyboard keys with the file name that you want to select.
Cheers
I know somes of sofeware can achieve my request,that seems cool.
And I know definitely that someone has successfully written this similar
routine before,I will be appreciated being given help.
thank you golanshahar. if I finally can't figure it out,I should have considered two ways,one is what I considered it to be complicated,
another is your non-precise and non-reliable approach ( I mean no offence :-) ). thanks.
-
March 17th, 2006, 05:59 AM
#9
Re: open a folder and select the specified file ?
 Originally Posted by suchuhui80
thank you golanshahar. if I finally can't figure it out,I should have considered two ways,one is what I considered it to be complicated,
Why you think its complicated? using ::FindWindow(..) and ::SendMessage(..) ? What’s so complicated about it? By the time are replying this thread you could have written this “complicated” program 100 times 
If you have problem using those functions simply ASK! Don’t say it complicated.
 Originally Posted by suchuhui80
another is your non-precise and non-reliable approach ( I mean no offence :-) ). thanks.
What’s non precise and non-reliable here? I do agree that the "complicated" solution using ::FindWindow(..) and ::SendMessage(..) is more correct. My solution is simply simulating user action, when you open Explorer and set focus to the file list when you start typing the name of the file you want it will get selected, are you saying that this approach of explorer is non-reliable and non precise?
Cheers
-
March 17th, 2006, 08:37 PM
#10
Re: open a folder and select the specified file ?
 Originally Posted by golanshahar
Why you think its complicated?  using ::FindWindow(..) and ::SendMessage(..) ? What’s so complicated about it? By the time are replying this thread you could have written this “complicated” program 100 times 
If you have problem using those functions simply ASK! Don’t say it complicated.
What’s non precise and non-reliable here? I do agree that the "complicated" solution using ::FindWindow(..) and ::SendMessage(..) is more correct. My solution is simply simulating user action, when you open Explorer and set focus to the file list when you start typing the name of the file you want it will get selected, are you saying that this approach of explorer is non-reliable and non precise?
Cheers
thanks for replying.
maybe we can discuss this issue if it really do not occupy much of your invaluable time.In my defense, I consider the fomer solution to be complicated because I alway consider that there should be a shortcut ( for example,changing the param for ::ShellExecute(),or simplely invoking a API ).For the second solution,it's difficult to find out the specified folder window,what if there are two alike title of this sort of window ? Besides,
if I successfully get the handle of my specified folder window and I try to
imitate user action to select the file,what if the fold has a sub-folder with the same name ? what if the fold has a file with the same name ? Besides,what if ,no what if again for this will make my thread lengthy.
I am not new to developing software,so it's natural to make software more precise and more reliable :-).
Last edited by suchuhui80; March 17th, 2006 at 08:39 PM.
-
March 18th, 2006, 05:58 AM
#11
Re: open a folder and select the specified file ?
 Originally Posted by suchuhui80
what if there are two alike title of this sort of window ?
In that case you need also check that the EXE is Explorer and not something else.
Or that the class name of the window is "ExploreWClass" which is the class of explorer (at least in windows XP ).
If you got 2 Explorers open i don’t think its a problem cause if i understand what you need to do you can simply open one of them. 
 Originally Posted by suchuhui80
Besides,
if I successfully get the handle of my specified folder window and I try to
imitate user action to select the file,what if the fold has a sub-folder with the same name ?
Here it might fails (it will select the first of the two it will run into that’s depend on the current sorting of explorer) , that’s why even in my last post I told you that this solution is less good than the first one.
 Originally Posted by suchuhui80
what if the fold has a file with the same name ? Besides,what if ,no what if again for this will make my thread lengthy.
I am not new to developing software,so it's natural to make software more precise and more reliable :-).
There cant be a folder like the file name under the same folder, Explorer wont let it, unless you have file with the same name with an extension (maybe the extension is hidden so it looks like you have folder and file with the same name).
BTW another way to look for the items in Explorer by using Active accessibility. 
Cheers
Last edited by golanshahar; March 18th, 2006 at 07:21 AM.
-
March 19th, 2006, 10:27 PM
#12
Re: open a folder and select the specified file ?
 Originally Posted by golanshahar
BTW another way to look for the items in Explorer by using Active accessibility.
Cheers
what is meaning of " active accessibility" ?
may I enlist your help a little further ?:-)
-
March 19th, 2006, 10:35 PM
#13
Re: open a folder and select the specified file ?
it's fortunate that the invention of the Internet offers me who is unforunate to stay at non-software corp a way to ask somebody else.
-
March 20th, 2006, 02:31 AM
#14
Re: open a folder and select the specified file ?
 Originally Posted by suchuhui80
what is meaning of " active accessibility" ?
may I enlist your help a little further ?:-)
Sure 
Here is the link Active Accessibility.
It will enable you to get the data from file explorer.
Download the AccExplorer32.exe run it and look at the File explorer file list you should be able to grab all the text from there. (This tool is used similar to Spy++ )
You can also look at this thread to see how to use ::AccessibleObjectFromWindow(..).
Cheers
-
March 30th, 2006, 04:21 PM
#15
Re: open a folder and select the specified file ?
I am trying to do the same thing. I open the folder in explore but want the concerned file to be selected as well in that folder.
How do I use ::FindWindow(..) and ::SendMessage(..) to implement this? because the other method is the OLE and I don't want to go with OLE for this.
Good Answers, Good Points.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|