Click to See Complete Forum and Search --> : CFileDialog: problem with resource ID. I am desperate, please help
Will Rothwell
May 10th, 1999, 02:11 AM
Hi all,
I followed the example from David Kruglinski's Inside Visual C++, 4th Ed., to use CFileDialog in my own dialog box (the child) to show a directory picker. Basically my dialog class derived from CFileDialog instead of CDialog. All is well and it works.
I want to do the same thing in other dialog box using CFileDialog, but as a file picker instead. The book suggested I need to put a static group box to 'contain' the CFiledialog and its controls. The problem is the ID of the group box for the first CFileDialog is "stc32=0x045f", according to the book. I have no idea why this is needed and the value of course.
I cannot define the second group box with the same "stc32=0x045f". So I just put "stc32" and it compile OK. However, I want to hide some of the CFileDialog controls by :
HideControl(edt1);
HideControl(stc3);
HideControl(cmb1);
HideControl(stc2);
(I found these control IDs from this site).
The compiler cannot find these IDs for the second CFileDialog where they were alright in the first. The second CFileDialog shows but no file appears (which is what I need for the first one but not the second one)
Can someone please tell me how to have a second CFileDialog in another dialog.
Will
sally
May 10th, 1999, 08:24 AM
you have done correct with stc32 as the id for the static, this will put the entire normal CFileDialog inside that static control. Remember that stc32 is a child of your dialog, and edt1 is a child of stc32. That is important. You will find edt1 etc defined in commctrl.dlg maybe, I am not sure, make a seach on your system. They will be there
Sally
Sally
May 10th, 1999, 08:24 AM
you have done correct with stc32 as the id for the static, this will put the entire normal CFileDialog inside that static control. Remember that stc32 is a child of your dialog, and edt1 is a child of stc32. That is important. You will find edt1 etc defined in commctrl.dlg maybe, I am not sure, make a seach on your system. They will be there
Sally
Will Rothwell
May 10th, 1999, 09:28 AM
Hi,
I must say I am rather confused with this parent-child relationship here. Yes, you are right that stc32 is a child control of my dialog. However, I believe (edt1), (stc3), (cmb1), (stc2) etc. are the control IDs of CFileDialog. As I can hide them in my first use of the CFileDialog. Somehow, CFileDialog is the 'parent' of my dialog, it follows that these things, e.g. edt1, should not be the children of my dialog, but rather brother and sisters. Am I going crazy ? If these CFileDialog control are really children of my dialog, please tell me how to access them.
As I tried to HideControl() them as the first case but they are 'undeclared identifers', when I compile.
Thanks in advance.
Will
BrianOG
May 10th, 1999, 10:21 AM
The CFileDialog (which replaces the stc32 frame) *IS* the parent of your dialog. So to access the control on this you will have to do something likeCWnd *pEdt = GetParent()->GetDlgItem(edt1)
As for the second CFileDialog, am I correct in assuming you are trying to put 2 CFileDialogs onto your dialog. If so, hmmmmm..... I would be surprised if this is possible. How are you supposed to distunguish between them. Also how is windows going to handle the parent/child thingy.
Will Rothwell
May 10th, 1999, 11:17 AM
Hi,
Thanks for the suggestion to access parent's children, I'll try that.
Well, I am not putting two CFileDialogs on one of my dialogs. What I need is to have two separate dialogs ,no relation at at :), and each has a CFileDialog.
The first one is to pick directory and the second is a file picker. Be more specific, the first dialog let user pick a directory, and some operations later a file will be placed in the selected directory. The user can later retrieve the file (a configuration file) from the directory he selected. There can be as many directories as he likes to have configuration files. These configuration file store an encryption key for that one directory only.
The trouble is in the first dialog I used 'str32 = 0x045f' to hold the the CFileDialog, when I tried to do the same thing for the second file picker dialog, I apparently cannot do 'stc32=0x45f' again. I don't mind but the compiler says no. Any idea what I do from here. Thanks
Will
sally
May 10th, 1999, 08:35 PM
Use SHBrowseForFolder() to select a folder instead
and a basic vanilla CFileDialog to select a file
Sally
Sally
May 10th, 1999, 08:35 PM
Use SHBrowseForFolder() to select a folder instead
and a basic vanilla CFileDialog to select a file
Sally
Will Rothwell
May 11th, 1999, 12:52 AM
Hi,
Thank you for the suggestion of using SHBrowseForFolder(). Can anyone share any coding example of how to set it up and use it as a directory browser so I can make reference. That is because I really need it urgently for the project. Many thanks.
My e-mail is wrothwell@theissen.com
Will
sally
May 11th, 1999, 01:53 AM
TCHAR fileName[ _MAX_PATH + 1 ];
m_showSelect.GetWindowText( fileName, _MAX_PATH );
BROWSEINFO bi;
::ZeroMemory( &bi, sizeof( BROWSEINFO ) );
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = NULL;
bi.lpszTitle = _T("Select Folder to View");
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = NULL;
bi.iImage = NULL;
ITEMIDLIST* pidl = ::SHBrowseForFolder( &bi );
if ( pidl == NULL )
return;
const BOOL ret = ::SHGetPathFromIDList( pidl, fileName );
if ( ret )
m_showSelect.SetWindowText( fileName );
LPMALLOC pMalloc;
::SHGetMalloc( &pMalloc );
pMalloc->Free( pidl );
pMalloc->Release();
Sally
May 11th, 1999, 01:53 AM
TCHAR fileName[ _MAX_PATH + 1 ];
m_showSelect.GetWindowText( fileName, _MAX_PATH );
BROWSEINFO bi;
::ZeroMemory( &bi, sizeof( BROWSEINFO ) );
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = NULL;
bi.lpszTitle = _T("Select Folder to View");
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = NULL;
bi.iImage = NULL;
ITEMIDLIST* pidl = ::SHBrowseForFolder( &bi );
if ( pidl == NULL )
return;
const BOOL ret = ::SHGetPathFromIDList( pidl, fileName );
if ( ret )
m_showSelect.SetWindowText( fileName );
LPMALLOC pMalloc;
::SHGetMalloc( &pMalloc );
pMalloc->Free( pidl );
pMalloc->Release();
Will Rothwell
May 12th, 1999, 03:24 AM
Hi,
Thanks for the suggestion as getting a pointer to the CFileDialog control by : CWnd *pEdt = GetParent()->GetDlgItem(edt1);
The point is it failed to compile at all with error of ->
C:\DDK\src\ThSS\APP\SCR\RegEnvelope.cpp(69) : error C2065: 'edt1' : undeclared identifier
I have included the header file <afxdlgs.h> but no luck. I also tried stc31 = 0x45e and it didn't work. Can you help please.
Will
Anarchi
April 20th, 2009, 01:02 AM
I ran into this problem as well, I couldnt find "edt1" in VS2005
Solution:
Add #include <dlgs.h>
then change 'edt1' to 'cmb13'
(Yes I know this thread is 10 years old lol)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.