Re: CFileDialog in Threads
Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance
1) subclass CFileDialog and create a class called CMyFileDialog
2) provide a OnInitDialog handler.
In that you can use the GetSafeHwnd(...) to get the window handle.
No use like this
CMyFileDialog dlg;
dlg.DoModal();
--
Vipin Aravind
<akshay4friend@xxxxxxxxx> wrote in message
news:1138790055.413553.259400@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>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: How to make CFileDialog, MessageBox etc ..Layered ?
... Can you please tell me how to make CFileDialog, MessageBox, Tooltips ... I tried to extend the CFileDialog and in the OnInitDialogMethod I have ... // Make this window 70% alpha ... LPCTSTR lpszFileName = NULL, ... (microsoft.public.vc.mfc) - Re: opening CFileDialog from modeless or creating modeless CFileDialog
... (so the one that is Modal and calls the modeless dialog EDITOR which in turn ... so long as I don't open up the CFileDialog) but as soon as I do click on ... the afformentioned method and ViollA, ... Timer isn't halted while the dialog window is up. ... (microsoft.public.vc.mfc) - Re: stdafx.h and operating system support.
... The CFileDialog I use is raw. ... I tried pasting in your code (minus the last dwSize param) and still the ... Could there be a parent window issue? ... Thanks again Rail. ... (microsoft.public.vc.mfc) - Re: How can I take control ID from Spy++?
... I couldn't connect to GetScrollRange function because ... Scrollbars added to a window with the WS_HSCROLL and WS_VSCROLL window ... >CFileDialog dlg(TRUE, sFi, NULL, ... except you're calling scrollbar functions on the wrong window. ... (microsoft.public.vc.language) - RE: How can I take control ID from Spy++?
... The problem here is that, whilst you have constructed a CFileDialog object, ... the window itself has not been created - you create the window when you call ... > int nPos, nMin; ... > This didn't fine out right valuse for nMin and nPos. ... (microsoft.public.vc.mfc) |
|