00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "FolderBrowser.h"
00009 #include <AlsFolderBrowser.h>
00010
00011 #ifdef _DEBUG
00012 #define new DEBUG_NEW
00013 #undef THIS_FILE
00014 static char THIS_FILE[] = __FILE__;
00015 #endif
00016
00017 IMPLEMENT_DYNCREATE(CFolderBrowser, CWinThread)
00018
00019 CFolderBrowser::CFolderBrowser()
00020 {
00021 }
00022
00023 CFolderBrowser::~CFolderBrowser()
00024 {
00025 }
00026
00027 BOOL CFolderBrowser::InitInstance()
00028 {
00029 AfxOleInit ();
00030
00031 AlsFolderBrowser fb;
00032 m_bResult = fb.Create (m_pszTitle, m_pszPath, m_pszRoot, m_hWndParent);
00033
00034 if (m_bResult)
00035 m_strResPath = fb.GetPath ();
00036
00037 return FALSE;
00038 }
00039
00040 int CFolderBrowser::ExitInstance()
00041 {
00042
00043 return CWinThread::ExitInstance();
00044 }
00045
00046 BEGIN_MESSAGE_MAP(CFolderBrowser, CWinThread)
00047
00048
00049
00050 END_MESSAGE_MAP()
00051
00052 CFolderBrowser* CFolderBrowser::Create(LPCSTR pszTitle, LPCSTR pszPath, LPCSTR pszRoot, CWnd *pWndParent)
00053 {
00054 CFolderBrowser* pThis = (CFolderBrowser*) RUNTIME_CLASS (CFolderBrowser)->CreateObject ();
00055 pThis->m_bAutoDelete = FALSE;
00056
00057 pThis->m_pszTitle = pszTitle;
00058 pThis->m_pszPath = pszPath;
00059 pThis->m_pszRoot = pszRoot;
00060 pThis->m_hWndParent = pWndParent ? pWndParent->m_hWnd : NULL;
00061
00062 pThis->CreateThread ();
00063
00064 HANDLE hThread;
00065 DuplicateHandle (GetCurrentProcess (), pThis->m_hThread, GetCurrentProcess (),
00066 &hThread, 0, TRUE, DUPLICATE_SAME_ACCESS);
00067
00068 DWORD dw = 0;
00069 do
00070 {
00071 Sleep (10);
00072
00073 MSG msg;
00074 while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
00075 DispatchMessage (&msg);
00076
00077 GetExitCodeThread (hThread, &dw);
00078 }
00079 while (dw == STILL_ACTIVE);
00080
00081 CloseHandle (hThread);
00082
00083 if (pThis->m_bResult)
00084 return pThis;
00085
00086 delete pThis;
00087 return NULL;
00088 }
00089
00090 LPCSTR CFolderBrowser::GetPath()
00091 {
00092 return m_strResPath;
00093 }