/*****************************************************************************
Open Source MIT License

Copyright (c) 2017 Matthew Ahmed

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*****************************************************************************/

#include "ZWinUtil.h"

ZWinUtil::ZWinUtil(ZWin * pOwner, LPCTSTR sName)
  : ZWin(NULL, sName ? sName : _T("ZWinUtil"), NULL, pOwner)
{
  m_sOwnName = _T("ZWinUtil");
  SetOwner(pOwner);
  ClearError();
}

ZWinUtil::~ZWinUtil(void)
{
}

void ZWinUtil::SetOwner(ZWin * pOwner)
{
  m_pOwner = pOwner;
  m_hDlg = pOwner ? pOwner->GetWnd() : NULL;
}

//BOOL ZWinUtil::SetError(LPCTSTR sErr1, LPCTSTR sErr2)
//{
//	_stprintf(m_sError, "%s error:\r\n%s%s%s", m_sOwnName, sErr1,
//											sErr2 ? "\r\n" : "", sErr2 ? sErr2 : "");
//					
//	return FALSE;
//}

//BOOL ZWinUtil::AddToError(LPCTSTR sErr)
//{
//	_tcscat(m_sError, "\r\n");
//	_tcscat(m_sError, sErr);
//	return FALSE;
//}

LPCTSTR ZWinUtil::GetError(BOOL bClear) // Changed from CSettings
{
  _tcscpy(m_sReportError, m_sError);
	if (bClear) ClearError();
  return m_sReportError;
}

//void ZWinUtil::ClearError()
//{
//  m_sError[0] = '\0';
//}

BOOL ZWinUtil::ShowError(LPCTSTR sCapt, LPCTSTR sPre, LPCTSTR sPost)
{
	return fnError(m_hDlg, sCapt, sPre, m_sError, sPost);
}
