[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 575
  • Last Modified:

Disable edit control in CFileDialog

I want to disable the edit control, where the user can input the filename in CFileDialog.

I dervived a class from CFileDialog and tried it with CWnd* pWnd->GetDlgItem (edt1). Unfortunately, it doesn't work. pWnd is always NULL.

How can I do that?
0
hstoessel
Asked:
hstoessel
1 Solution
 
hstoesselAuthor Commented:
Adjusted points to 100
0
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

Now U have the derived class of CFileDialog say CMyFileDialog. Now follow the steps
1. Map the OnInitDialog() for that class.
2. In that function put the following line before return TRUE
    SetTimer(1, 10, NULL);
3. Map the WM_TIMER message to that class and put the following lines
KillTimer(1);
EnumChildWindows((HWND)::GetParent(this -> m_hWnd), EnumChildProc, (LPARAM)this);

4. Declare the function as global in .h file as
BOOL CALLBACK EnumChildProc(HWND, LPARAM);

5. Put the code for function in .cpp as

BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam)
{
int id = ::GetDlgCtrlID(hWnd);
switch(id)
{
case 1152:
::EnableWindow(hWnd, FALSE);
break;
}
return TRUE;
}
}

That will disable the edit window. U can also hide it.
I have the sample for this.
Hope this helps.
VinExpert
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now