CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 1999
    Location
    Lat: 47.285235, Lon: 8.565238
    Posts
    293

    Unhappy Showing Registry Content in CFileDialog

    Hi

    I'd like to give a user the opportunity to store workspace in both, registry and file system.

    Therfore I derieved my own CFileDialog and added a selection for the two storage locations.

    The problem I have now is how to show the registry content. I tried to create a new CListCtrl and place it where the original one of CFileDialog is. I tried to show/hide this new list according to the user selection. But it doesn't work! When I do a ShowWindow(SW_HIDE) of the original list control (lst1), only it's content gets hidden. And additionally I don't get my new list control to be shown.

    I create and place the new list as follows in OnInitDone():
    Code:
    	CRect rc;
    	CWnd* pChildWnd  = NULL;
    	CWnd* pParentWnd = NULL;
    
    	pParentWnd = GetParent();
    	ASSERT(NULL != pParentWnd);
    	pChildWnd = pParentWnd->GetDlgItem(lst1);	// File list of the common file dialog. We need
    							// the coordinates for our registry list ctrl
    	ASSERT(NULL != pChildWnd);
    	pChildWnd->GetWindowRect(&rc);
    	// For now, don't set the VISIBLE flag --> we first need to check whether registry is chosen
    	m_ctlLCWspList.Create(	WS_CHILD | /*WS_VISIBLE |*/ WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_HSCROLL |
    				LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_EDITLABELS,
    				rc, this, WM_USER	);
    
    	DWORD dwStyle = m_ctlLCWspList.GetStyle();
    	m_ctlLCWspList.ModifyStyleEx(0, WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_CLIENTEDGE | 
    					LVS_EX_INFOTIP | LVS_EX_UNDERLINEHOT | LVS_EX_UNDERLINECOLD);
    	m_ctlLCWspList.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
    Maybe I need to create the list with another parent? I already tried lst1->GetParent() and lst1 itself (actually CWnd* to lst1).

    For changing which list to display I do the following when I got a change notification:
    Code:
    	CWnd* pParentWnd = NULL;
    	CWnd* pChildWnd1 = NULL;
    	CWnd* pChildWnd2 = NULL;
    	pParentWnd = GetParent();
    	ASSERT(NULL != pParentWnd);
    	pChildWnd1 = pParentWnd->GetDlgItem(cmb2);
    	ASSERT(NULL != pChildWnd1);
    	pChildWnd2 = pParentWnd->GetDlgItem(lst1);
    	ASSERT(NULL != pChildWnd2);
    
    	if (m_bStoreToRegistry)
    	{
    		// Registry: diable file related controls
    		pChildWnd1->EnableWindow(FALSE);
    		m_ctlLCWspList.ShowWindow(SW_SHOW);
    		pChildWnd2->ShowWindow(SW_HIDE);
    	} // if (m_bStoreToRegistry)
    	else
    	{
    		// File system: enable file related controls
    		pChildWnd1->EnableWindow(TRUE);
    		m_ctlLCWspList.ShowWindow(SW_HIDE);
    		pChildWnd2->ShowWindow(SW_SHOW);
    	} // else
    Maybe this is all wrong I try here and there is a simple way to cope with lst1 only? If yes, how (e.g. fill registry content and when required fill file system content again in an easy way)?

    Many thanks for any help!

    Holi

    P.S.: Another related thread of me is http://www.codeguru.com/forum/showth...702#post927702 (actually quite the same).

  2. #2
    Join Date
    Mar 2002
    Location
    Philadelphia
    Posts
    150
    Try Customize Your File Dialog by Dino Esposito in his Cutting Edge column in the March 2003 edition of MSDN Mag.
    Sincerely,
    - Ron

  3. #3
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    It is difficult to modify the CFileDialog dialog. You should add customization using the documented capabilities. However that article referenced previously is probably not what you want. Look at the CFileDialog documentation about how to customize it.

    However in my opinion, opening from the registry is different enough from opening from a file system that it probably would work better if a separate dialog were used for opening from the registry.
    Last edited by Sam Hobbs; April 8th, 2004 at 08:20 PM.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  4. #4
    Join Date
    May 1999
    Location
    Lat: 47.285235, Lon: 8.565238
    Posts
    293
    Hi Sam

    You're right, the article referenced previously is not what I was looking for.

    Anyhow, I already studied the cusomization capabilities of CFileDialog. And I already added some controls (mainly a combo) to the dialog by setting a new template. The CFileDialog "nests" into this new template to the place of "stc32". But these are undocumented features as for now I found out (i.e. I use the SetTemplate() function where I got the hint from a friend and I cannot find anything in the DevStudio help).

    What I found out meanwhile is, that the problem that the created list (m_ctlLCWspList) is not shown seems to lie in the call to SetWindowPos(). Without this call, the list control is displayed as expected, but as soon as I do a call to SetWindowPos(), it gets hidden. I think that it has something to do with the "insertAfter", which I tried with NULL and wndTopMost - none of them with success (also in combination with the SWP_NOZORDER flag).

    Maybe another hint on that? How do I need to change the z-order?
    A mabe relatet thing: when I go to have a look with Spy++, I can see, that I can position the finder tool only above the list control and the rest of the file dialog to get a thick frame, not above all controls displayed. Why is that? is there an invisible dialog? Maybe that could be the reason why my own list control cannot be shown?

    Thanx

    Holi

  5. #5
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    The documented solution involves creating a dialog template that gets added to the bottom of the file dialog dialog. You will be successful if you use the documented solution. I think it is unlikely anyone can help you with undocumented solutions, but you might get lucky.

    In your situation, I think that customizing the file dialog using the documented solution would be the equivalent of creating a separarate dialog; that is, either the file part of the file dialog would be used, or your customized portion would be used, but neither of them would have anything significant in common, except Ok and Cancel buttons.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured