#include "stdafx.h"
#include <afxpriv.h>			// For HID_BASE_RESOURCE.
#include "DynamicDraw.h"		// For FFGetApp(),IDS_CTRL_FILE_KIND.
// 06.01.21 Fukushiro M. 1_xZkqqHx_iNhDiNoNiPjM_xHqqkZx_ ()
//#include "UtilStr.h"			// For FFExtractUntil.
#include "UtilDlg.h"			// For FFSetDlgItemText.
// 06.01.21 Fukushiro M. 1_xZkqqHx_iNhDiNoNiPjM_xHqqkZx_ ()
//#include "UtilFile.h"			// For FFGetFileExtension.
#include "FileDialogBase.h"	// This header.

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCFileDialogBase::FCFileDialogBase
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfCiDjDiDfIiDgHiDiJiDeOiDfOiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	bOpenFileDialog	:_xZkqqHx_jDmHiCnNiPgPiClFiDfPiDeDiDeBiDiNiDePiCmMiPoKiNiHiCmN_xHqqkZx_TRUE_xZkqqHx_iBeBiPjBiCkLiNjOiCnN_xHqqkZx_
 *							 _xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmMiPoKiNiHiCmN_xHqqkZx_FALSE_xZkqqHx_iCpAiOhHjCoIiBeC_xHqqkZx_
 *			wcpDefExt		:_xZkqqHx_iKpJjCoIiCmMiDhEiDeAiDeDiDiLiKgHjCkDiOhBiCpAiOhHjCoIiBeCiDhEiDeAiDeDiDiLjGlMjHhAiCmM_xHqqkZx_
 *							 _xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDhLiDgCiDeOiDfIiCmJiBeBiDiGiBfLiDfFiBfLiCkKiKgHjCkDiOhBiCpAjFhEiCkPiClIiCmJ_xHqqkZx_
 *							 _xZkqqHx_iDhEiDeAiDeDiDiLjGlMiCpAjDpMjHmNiClFiClN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CnGiCmMiDhMiDeDiDjDiDfOiCpAiOhHjCoIiBeC_xHqqkZx_
 *			wcpTitle		:_xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmMiDfOiDeDiDgHiDiLiCpAiOhHjCoIiBeCiDgGiDhEiDeIiDiLiDgHiDfOiDeDiDgHiDiLiCpA_xHqqkZx_
 *							 _xZkqqHx_iOgHiCkEiPoKiNiHiCmN_xHqqkZx_NULL_xZkqqHx_iCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.11 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
FCFileDialogBase::FCFileDialogBase (BOOL bOpenFileDialog,
									const wchar_t* wcpDefExt,
									const wchar_t* wcpFileName,
									DWORD dwFlags,
									const wchar_t* wcpFilter,
									HWND hwndParent,
									const wchar_t* wcpTitle)
				:	BASE_CLASS(	bOpenFileDialog,
								wcpDefExt,
								wcpFileName,
								dwFlags,
								wcpFilter,
								hwndParent,
								wcpTitle),
					m_dwHelpId(DWORD(-1))
{
} // FCFileDialogBase::FCFileDialogBase.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCFileDialogBase::SetHelpID
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmMiDhHiDiLiDhG_xHqqkZx_ID_xZkqqHx_iCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	dwId	:_xZkqqHx_iDhHiDiLiDhG_xHqqkZx_ID_xZkqqHx_iCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iJpAjAoA_xHqqkZx_>	_xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmMiDhHiDiLiDhGiDhLiDfOiDjDiCkKiJjPiClDiCoKiClNiCmGiCkLiBeBiOhHjCoIiClDiCoKiClNiDhHiDiLiDhG_xHqqkZx_ID_xZkqqHx_iCmJ_xHqqkZx_
 *			_xZkqqHx_jBmOiJjOiClHiCoJiDhHiDiLiDhGiCkKjFfMiOkGiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.12 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void FCFileDialogBase::SetHelpID (DWORD dwId)
{
	m_dwHelpId = dwId;
} // FCFileDialogBase::SetHelpID.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCFileDialogBase::OnInitDialog
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfPiDeDiDeBiDiNiDePiPiJiKpKiJlLiOjOiCmJiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iPiJiKpKiJlLiCkKjAkMiMpHiClFiClNiPoKiNiHiCmN_xHqqkZx_TRUE_xZkqqHx_iBeBiOlIjEhDiClFiClNiPoKiNiHiCmN_xHqqkZx_FALSE_xZkqqHx_iBeC_xHqqkZx_FALSE_xZkqqHx_iCpAjFnEiClFiClN_xHqqkZx_
 *			_xZkqqHx_iPoKiNiHiCmNiDfPiDeDiDeBiDiNiDePiCkKiPeJjHlJiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.11 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
BOOL FCFileDialogBase::OnInitDialog ()
{
	// Baseclass_xZkqqHx_iOmAiNhDiBeC_xHqqkZx_
	if (!BASE_CLASS::OnInitDialog())
		return FALSE;

	// _xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmMjCfAiImKjFfMiOkGiCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
	::SetUnitString(::GetParent(m_hWnd));

//----- 06.01.21 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
//	// _xZkqqHx_jHjIiCkLjIhCjBmOiJjOjFlGiOjKjHpBiCmMjAnNjCoIiCpAiNhDiCkEiBeC_xHqqkZx_
//	::RightByLeftHand(::GetParent(m_hWnd));
//	// _xZkqqHx_iDfPiDeDiDeBiDiNiDePiCpAiDhNiDeFiDfIiImKjChFiCmJiInKjDkOiBeC_xHqqkZx_
//	FFJustifyWindow(::GetParent(m_hWnd));
//----- 06.01.21 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----

	return TRUE;
} // FCFileDialogBase::OnInitDialog.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCFileDialogBase::OnHelp
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	Help_xZkqqHx_iDhLiDfOiDjDiCkJiCoHiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.12 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void FCFileDialogBase::OnHelp ()
{
	FFGetApp()->WinHelp(HID_BASE_RESOURCE + m_dwHelpId);
} // FCFileDialogBase::OnHelp.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCFileDialogBase::OnCtlColor
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmMiDfCiDjDiDgHiDiNiBfLiDiLiCpAjDgIiCoIiCmCiCnEiClHiNnLiCmMiDhFiDiJiDfGiCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	hDC		:_xZkqqHx_jFgAiJoGjHhAiDgGiDgPiDeDiDfIiDfCiDjDiDgFiDeMiDfIiDgHiCpAiOhHjCoIiBeC_xHqqkZx_
 *			pWnd	:_xZkqqHx_iDfCiDjDiDgHiDiNiBfLiDiLiCpAiOhHjCoIiBeC_xHqqkZx_
 *			nCtlColor:_xZkqqHx_iDfCiDjDiDgHiDiNiBfLiDiLiCmMiOoNjHnOiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iDhFiDiJiDfGiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.12 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
HBRUSH FCFileDialogBase::OnCtlColor (HDC hDC, HWND hWnd, UINT nCtlColor)
{
	CDC dc;
	dc.Attach(hDC);
	HBRUSH hb = OnCtlColor(&dc, CWnd::FromHandle(hWnd), nCtlColor);
	dc.Detach();
	return hb;
} // FCFileDialogBase::OnCtlColor.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCFileDialogBase::OnCtlColor
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmMiDfCiDjDiDgHiDiNiBfLiDiLiCpAjDgIiCoIiCmCiCnEiClHiNnLiCmMiDhFiDiJiDfGiCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pDC		:_xZkqqHx_jFgAiJoGjHhAiDgGiDgPiDeDiDfIiDfCiDjDiDgFiDeMiDfIiDgHiCpAiOhHjCoIiBeC_xHqqkZx_
 *			pWnd	:_xZkqqHx_iDfCiDjDiDgHiDiNiBfLiDiLiCpAiOhHjCoIiBeC_xHqqkZx_
 *			nCtlColor:_xZkqqHx_iDfCiDjDiDgHiDiNiBfLiDiLiCmMiOoNjHnOiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iDhFiDiJiDfGiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.12 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
HBRUSH FCFileDialogBase::OnCtlColor (CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
//	AfxDebugBreak();
	return (HBRUSH)DefWindowProc(	GetCurrentMessage()->hwnd,
									GetCurrentMessage()->message,
									GetCurrentMessage()->wParam,
									GetCurrentMessage()->lParam);
} // FCFileDialogBase::OnCtlColor.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCFileDialogBase::GetDlgItem
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	
 *
 * <_xZkqqHx_iPnKiNnH_xHqqkZx_>	
 *
 * <_xZkqqHx_jCiNiInD_xHqqkZx_>	
 *
 * <_xZkqqHx_iJpAjAoA_xHqqkZx_>	
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.11 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
CWnd* FCFileDialogBase::GetDlgItem (int nID) const
{
	return CWnd::FromHandle(::GetDlgItem(m_hWnd, nID));
} // FCFileDialogBase::GetDlgItem.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCFileDialogBase::GetParent
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	
 *
 * <_xZkqqHx_iPnKiNnH_xHqqkZx_>	
 *
 * <_xZkqqHx_jCiNiInD_xHqqkZx_>	
 *
 * <_xZkqqHx_iJpAjAoA_xHqqkZx_>	
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.11 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
CWnd* FCFileDialogBase::GetParent () const
{
	return CWnd::FromHandle(::GetParent(m_hWnd));
} // FCFileDialogBase::GetParent.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	FCFileDialogBase::DDXControl
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	MFC_xZkqqHx_iCmM_xHqqkZx_DDX_Control_xZkqqHx_iKnGjAjEiCmGjDkPjHgMiBeCiDfCiDjDiDgHiDiNiBfLiDiLiCpAjChFiCkLiKlHiCkGiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	dwControlId	:_xZkqqHx_jChFiCkLiKlHiCkGiCoJiDfCiDjDiDgHiDiNiBfLiDiLiCmM_xHqqkZx_ID_xZkqqHx_iCpAiOhHjCoIiBeC_xHqqkZx_
 *			wndControl	:_xZkqqHx_jChFiCkLiKlHiCkGiCoJjAoGiCmMiDfCiDjDiDgHiDiNiBfLiDiLiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.12 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void FCFileDialogBase::DDXControl (DWORD dwControlId, CWnd& wndControl)
{
	// MFC_xZkqqHx_iCmM_xHqqkZx_DDX_Control_xZkqqHx_iKnGjAjEiCpAiOfBiPmGiBeC_xHqqkZx_
	if (wndControl.m_hWnd == NULL)
	//----- not subclassed yet -----
	{
		HWND hWndCtrl = ::GetDlgItem(m_hWnd, dwControlId);
		if (!wndControl.SubclassWindow(hWndCtrl))
		{
			ASSERT(FALSE);      // possibly trying to subclass twice?
			AfxThrowNotSupportedException();
		}
//----- 05.10.13 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
//		else
//		{
//			// If the control has reparented itself (e.g., invisible control),
//			// make sure that the CWnd gets properly wired to its control site.
//			if (m_hWnd != ::GetParent(wndControl.m_hWnd))
//				wndControl.AttachControlSite(CWnd::FromHandle(m_hWnd));
//		}
//----- 05.10.13 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----
	}
} // FCFileDialogBase::DDXControl.

