Click here to Skip to main content
16,012,028 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Enabling/Disabling Menu Items Pin
Frank Deo25-Jul-03 16:52
Frank Deo25-Jul-03 16:52 
GeneralRe: Enabling/Disabling Menu Items Pin
Toni7826-Jul-03 7:45
Toni7826-Jul-03 7:45 
GeneralGetting selected folder in a namespace extension Pin
Mike Hartway25-Jul-03 14:27
Mike Hartway25-Jul-03 14:27 
GeneralHelp Pin
Snyp25-Jul-03 13:34
Snyp25-Jul-03 13:34 
GeneralRe: Help Pin
Beer2625-Jul-03 13:42
Beer2625-Jul-03 13:42 
GeneralRe: Help Pin
Snyp25-Jul-03 13:51
Snyp25-Jul-03 13:51 
GeneralRe: Help Pin
Beer2625-Jul-03 13:53
Beer2625-Jul-03 13:53 
QuestionHow to set default view with CFileDialog Pin
plsmith25-Jul-03 12:30
plsmith25-Jul-03 12:30 
I'm trying to figure out how to set the first view (i.e. Icon, List, Details, etc) that CFileDialog uses. It seems to always default to the List style.

I've looked at a some good articles on CFileDialog customization, including:

http://archive.devx.com/free/mgznarch/vcdj/1998/oct98/opensave1.asp
http://msdn.microsoft.com/msdnmag/issues/02/01/c/default.aspx
http://www.codeproject.com/dialog/customize_dialog.asp

and the closest I've come is with a simple class derived from CFileDialog with an over-ridden OnFolderChange(). It's necessary to use OnFolderChange() for the file list access because the list has not yet been initialized when OnInitDialog() is called, and OnFolderChange() is called at the very end of initialization.

void CNewFileDialog::OnFolderChange()
{
CWnd *pW = GetParent();
HWND hWndExplorer = FindWindowEx(pW->m_hWnd, NULL, L"SHELLDLL_DefView", NULL);
if ( hWndExplorer )
{
HWND hWndFileList = FindWindowEx(hWndExplorer, NULL, L"SysListView32", NULL);
if ( hWndFileList )
{
DWORD dwCurrentStyle = GetWindowLong(hWndFileList, GWL_STYLE);
if ((dwCurrentStyle & LVS_TYPEMASK) != m_DefaultStyle)
{
SetWindowLong(hWndFileList, GWL_STYLE, (dwCurrentStyle & ~(LVS_TYPEMASK | LVS_NOCOLUMNHEADER)) | m_DefaultStyle);
}
}
}
}

However, this code only works if the new default style is LVS_ICON, LVS_SMALLICON, or LVS_LIST. Of course, I'm really only interested in setting the default style to LVS_REPORT, but the dialog comes up with a completely empty file list. I think this is because the list headers have not been initialized, so simply changing the style doesn't work. I need to kick-off some kind initialization, or try some other approach.

Any other ideas?

Thanks
Peter
AnswerRe: How to set default view with CFileDialog Pin
Neville Franks25-Jul-03 13:21
Neville Franks25-Jul-03 13:21 
GeneralRe: How to set default view with CFileDialog Pin
plsmith25-Jul-03 13:52
plsmith25-Jul-03 13:52 
GeneralRe: How to set default view with CFileDialog Pin
Neville Franks26-Jul-03 12:01
Neville Franks26-Jul-03 12:01 
GeneralDDK Problems Pin
yitzhak25-Jul-03 11:36
yitzhak25-Jul-03 11:36 
GeneralRe: DDK Problems Pin
Toni7825-Jul-03 12:24
Toni7825-Jul-03 12:24 
GeneralRe: DDK Problems Pin
yitzhak26-Jul-03 8:16
yitzhak26-Jul-03 8:16 
GeneralRe: DDK Problems Pin
Beer2625-Jul-03 12:48
Beer2625-Jul-03 12:48 
GeneralRe: DDK Problems Pin
yitzhak26-Jul-03 8:05
yitzhak26-Jul-03 8:05 
GeneralRe: DDK Problems Pin
Beer2626-Jul-03 8:37
Beer2626-Jul-03 8:37 
GeneralNeed help in writing files (log style most likely) Pin
Snyp25-Jul-03 11:02
Snyp25-Jul-03 11:02 
GeneralRe: Need help in writing files (log style most likely) Pin
Chris Maunder25-Jul-03 15:01
cofounderChris Maunder25-Jul-03 15:01 
GeneralRe: Need help in writing files (log style most likely) Pin
Snyp26-Jul-03 3:05
Snyp26-Jul-03 3:05 
Generaldeclaring 2 D array Pin
Anonymous25-Jul-03 8:22
Anonymous25-Jul-03 8:22 
GeneralRe: declaring 2 D array Pin
AlexO25-Jul-03 9:16
AlexO25-Jul-03 9:16 
GeneralRe: declaring 2 D array Pin
David Crow25-Jul-03 10:53
David Crow25-Jul-03 10:53 
GeneralRe: declaring 2 D array Pin
Bob Stanneveld25-Jul-03 10:17
Bob Stanneveld25-Jul-03 10:17 
GeneralHaving trouble using Chris' Grid Control Pin
Terry O'Nolley25-Jul-03 8:21
Terry O'Nolley25-Jul-03 8:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.