CFileDialog in Threads
I need to get handle of modal file dialog box. for that I am putting
CFileDialog in thread. I am creating 2 threads . In one thread i am
invoking CFileDialog and in another thread I am trying to get handle of
that dialog box using GetForegroundWindow().....but with code given
below I am not getting handle of file dialog box but getting my
CTestDlg dialog box handle.....
void CTestDlg::OnOK()
{
// TODO: Add extra validation here
CWinThread* pWThread1 = AfxBeginThread(Thread1, this);
CWinThread* pWThread2 = AfxBeginThread(Thread2, this);
.......
.......
}
UINT Thread1(LPVOID pParam)
{
static char szFilter[] = "COFF files (*.txt)|*.out|All Files
(*.*)|*.*||";
CFileDialog fileDlg(TRUE, NULL, NULL, OFN_HIDEREADONLY |
OFN_OVERWRITEPROMPT, szFilter);
fileDlg.DoModal();
return 1;
}
UINT Thread2(LPVOID pParam)
{
::SetWindowText(::GetForegroundWindow(),"Save Text File");
return 1;
}
**BUT... WHEN I CHANGE Thread2() FUNCTION LIKE BELOW I AM GETTING
HANDLE OF FILE DIALOG BOX AND ITS PROPERLY SETTING WINDOW TEXT...LIKE
THIS..
UINT Thread2(LPVOID pParam)
{
Sleep(100);
::SetWindowText(::GetForegroundWindow(),"Save Text File");
return 1;
}
but I think using Sleep() is not perfect way for doing this...because
100 factor for Sleep function is not fixed for every time...I am new to
thread programming. .. so I want to know which is other way to getting
handle of file dialog box... how can i know that my modal file dialog
box is become foreground window.....
Thanx in Advance
Akshay
.
Relevant Pages
- Re: CFileDialog in Threads
... >> 1) subclass CFileDialog and create a class called CMyFileDialog ... >>>I need to get handle of modal file dialog box. ... >>> UINT Thread1(LPVOID pParam) ... (microsoft.public.vc.mfc) - Re: CFileDialog in Threads
... subclass CFileDialog and create a class called CMyFileDialog ... In that you can use the GetSafeHwndto get the window handle. ... > UINT Thread1(LPVOID pParam) ... (microsoft.public.vc.mfc) |
|