Click to See Complete Forum and Search --> : Is it Possible to retrieve the File Path from Common Dialog Controls?


Revolution
November 18th, 2005, 05:11 AM
Dear Gurus,

I want to know that is it possible to get the Full Path from Common Dialog Controls ( like Open or Save ) used by Another Process.

Here is the Scenario:
-------------------------

-> I am Running a EventHook Which will watch for Windows Created
and Destroyed

-> When the User Closes the Open Dialog Box, I want to Get the Path
Choosed by the User

Pls show me the way, how I have to do it.

Pls Guide me

kkez
November 18th, 2005, 05:19 AM
Try:

CDM_GETFILEPATH (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/commondialogboxlibrary/commondialogboxreference/commondialogboxmessages/cdm_getfilepath.asp)
CDM_GETFOLDERPATH (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/commondialogboxlibrary/commondialogboxreference/commondialogboxmessages/cdm_getfilepath.asp)

humptydumpty
November 18th, 2005, 05:32 AM
Dear Gurus,

I want to know that is it possible to get the Full Path from Common Dialog Controls ( like Open or Save ) used by Another Process.

Here is the Scenario:
-------------------------

-> I am Running a EventHook Which will watch for Windows Created
and Destroyed

-> When the User Closes the Open Dialog Box, I want to Get the Path
Choosed by the User

Pls show me the way, how I have to do it.

Pls Guide me
use CFileDialog

CFileDialog cfd(1,"txt",0,0,"Text|*.txt|All Files|*.*||");
cfd.m_ofn.lpstrTitle ="Browse";
CString str;
if(cfd.DoModal()==IDOK)
{
str = cfd.GetPathName(); //now you have pathname in str

}
else
{
//do somethig
}

golanshahar
November 18th, 2005, 07:54 AM
Dear Gurus,

I want to know that is it possible to get the Full Path from Common Dialog Controls ( like Open or Save ) used by Another Process.

Here is the Scenario:
-------------------------

-> I am Running a EventHook Which will watch for Windows Created
and Destroyed

-> When the User Closes the Open Dialog Box, I want to Get the Path
Choosed by the User

Pls show me the way, how I have to do it.

Pls Guide me

i hope i understood your question correctly.

you have hooking to trace WM_CREATE on windows and when you run into Open/save as dialog box in a different process then yours you want to be able to get the path to the folder/file the user choose?

if so then:
one thing i can suggest you ( i didnt try it myslef) but it suppose to work :D
is when the Open/Save dialog is opened...use ::FindWindow(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/findwindow.asp) / ::FindWindowEx(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/findwindowex.asp) to locate the combox box that have the path to the file, now when you will get that combobox handle you can use ::SendMessage(..) with combobox messages to get the count and items in there.. (CB_GETCOUNT (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/comboboxes/comboboxreference/comboboxmessages/cb_getcount.asp),CB_GETLBTEXT (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/comboboxes/comboboxreference/comboboxmessages/cb_getlbtext.asp) )

then you will need to use some pharsing to build the path yourself since probably you will get:
(item 0)A:
(item 1)C:
(item 2)D:
(item 3)Program Files
(item 4)----My Folder
(item 5)------MyFolder2

and so on. so you will need to build the path.

since you are hooking and you in the context of the remote process if you will do it in the hook you should be able to get it.

and to get the file name you will need to ::FindWindow(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/findwindow.asp) / ::FindWindowEx(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/findwindowex.asp) to get that handle to the EditBox and get the text from there.

hope it helps

Cheers

Revolution
November 18th, 2005, 07:57 AM
Dear Gurus,

Thanks for ur Valuable Information.

But I can't achieve it..

I will explain once again, I want to get the Path from the Dialog box which is used by another Process ( I know only the HWND to the Dialog Box).

I Got some Information from MSDN that is we can do this with the help of the OFNHookProc ( ), but still I can't achieve it ( That is I don't know how and when to use it correctly)

Please correct me If I am wrong

Once again Thanks for ur Valuable Information

(and one more thing I know only C I don't know C++)

golanshahar
November 18th, 2005, 08:05 AM
Dear Gurus,

Thanks for ur Valuable Information.

But I can't achieve it..

I will explain once again, I want to get the Path from the Dialog box which is used by another Process ( I know only the HWND to the Dialog Box).

I Got some Information from MSDN that is we can do this with the help of the OFNHookProc ( ), but still I can't achieve it ( That is I don't know how and when to use it correctly)

Please correct me If I am wrong

Once again Thanks for ur Valuable Information

(and one more thing I know only C I don't know C++)

did you read my post?

Cheers

Revolution
November 18th, 2005, 10:51 PM
No I haven't Read ur Information before posting my previous message. I will try to work it out and if there is any problem I will post here.

Thanks