2019-02-28 02:14:54 +00:00
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "MFC_UI.h"
|
|
|
|
|
#include "TwainUIDlg.h"
|
|
|
|
|
#include "IndicatorDlg.h"
|
|
|
|
|
#include "hugaotwainds.h"
|
|
|
|
|
#include "Resource.h"
|
|
|
|
|
|
|
|
|
|
extern ChugaotwaindsApp theApp;
|
|
|
|
|
|
2019-12-04 14:43:40 +00:00
|
|
|
|
void DeleteWnd(CDialog* pWnd)
|
|
|
|
|
{
|
|
|
|
|
if (pWnd && pWnd->GetSafeHwnd())
|
|
|
|
|
{
|
|
|
|
|
pWnd->DestroyWindow();
|
|
|
|
|
delete pWnd;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-28 02:14:54 +00:00
|
|
|
|
MFC_UI::MFC_UI(CTWAINDS_FreeImage *pDS)
|
|
|
|
|
: CTWAIN_UI(pDS)
|
2019-12-04 14:43:40 +00:00
|
|
|
|
, m_pChildWnd(0, DeleteWnd)
|
|
|
|
|
, m_pDlg(0, DeleteWnd)
|
|
|
|
|
, m_pIndicator(0, DeleteWnd)
|
2019-02-28 02:14:54 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MFC_UI::~MFC_UI()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TW_INT16 MFC_UI::DisplayTWAINGUI(TW_USERINTERFACE Data, bool bSetup, bool bIndicators)
|
|
|
|
|
{
|
2019-11-14 08:42:24 +00:00
|
|
|
|
TW_INT16 ret = TWRC_SUCCESS;
|
2019-02-28 02:14:54 +00:00
|
|
|
|
TW_INT16 nRes = CTWAIN_UI::DisplayTWAINGUI(Data, bSetup, bIndicators);
|
|
|
|
|
if (nRes)
|
|
|
|
|
{
|
|
|
|
|
return nRes;
|
|
|
|
|
}
|
|
|
|
|
if (bSetup)
|
|
|
|
|
{
|
|
|
|
|
Data.ShowUI = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Data.ShowUI == 0 && !bIndicators)
|
|
|
|
|
{
|
2019-05-10 02:51:26 +00:00
|
|
|
|
return ret;
|
2019-02-28 02:14:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Data.hParent)
|
|
|
|
|
{
|
2019-12-04 14:43:40 +00:00
|
|
|
|
m_pChildWnd = std::unique_ptr<CDialog, void(*)(CDialog*)>(new CDialog(), DeleteWnd);
|
|
|
|
|
m_pChildWnd->Create(IDD_DIALOGBACK, CWnd::FromHandle((HWND)Data.hParent));
|
|
|
|
|
long ll = GetWindowLong(m_pChildWnd->GetSafeHwnd(), GWL_STYLE);
|
|
|
|
|
SetWindowLong(m_pChildWnd->GetSafeHwnd(), GWL_STYLE, WS_CHILD | ll);
|
|
|
|
|
SetParent(m_pChildWnd->GetSafeHwnd(), (HWND)Data.hParent);
|
2019-02-28 02:14:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Data.ShowUI)
|
2019-11-14 08:42:24 +00:00
|
|
|
|
{
|
2019-12-04 14:43:40 +00:00
|
|
|
|
m_pDlg.reset(new TwainUIDlg(this, m_pChildWnd.get()));
|
|
|
|
|
m_pDlg->Create(IDD_DIALOG_TWAINUI, m_pChildWnd.get());
|
|
|
|
|
m_pDlg->SetDlgItemText(IDC_CONFIRM,bSetup ? _T("ȷ<EFBFBD><EFBFBD>") : _T("ɨ<EFBFBD><EFBFBD>"));
|
2019-05-10 02:51:26 +00:00
|
|
|
|
|
2019-12-04 14:43:40 +00:00
|
|
|
|
if (m_pDlg) {
|
2019-02-28 02:14:54 +00:00
|
|
|
|
m_pDlg->ShowWindow(SW_SHOWNORMAL);
|
|
|
|
|
}
|
2019-12-04 14:43:40 +00:00
|
|
|
|
else {
|
2019-11-14 08:42:24 +00:00
|
|
|
|
ret = TWRC_FAILURE;
|
2019-02-28 02:14:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-10 02:51:26 +00:00
|
|
|
|
|
|
|
|
|
return ret;
|
2019-02-28 02:14:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MFC_UI::DestroyTWAINGUI()
|
|
|
|
|
{
|
2019-12-04 14:43:40 +00:00
|
|
|
|
m_pIndicator.reset();
|
|
|
|
|
m_pDlg.reset();
|
|
|
|
|
m_pChildWnd.reset();
|
2019-05-10 02:51:26 +00:00
|
|
|
|
|
2019-12-04 14:43:40 +00:00
|
|
|
|
CTWAIN_UI::DestroyTWAINGUI();
|
2019-02-28 02:14:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-11-14 08:42:24 +00:00
|
|
|
|
void MFC_UI::UpdateProgress(bool bShow, unsigned char ucProgress, unsigned int unPageNo, string strProgressTitle)
|
2019-02-28 02:14:54 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-04 01:46:32 +00:00
|
|
|
|
unsigned int MFC_UI::MyMessageBox(string strMessage, string strTitle, unsigned int unIconID)
|
2019-02-28 02:14:54 +00:00
|
|
|
|
{
|
2019-11-14 08:42:24 +00:00
|
|
|
|
if (m_pChildWnd != NULL)
|
|
|
|
|
{
|
2019-05-10 02:51:26 +00:00
|
|
|
|
return ::MessageBox(m_pChildWnd->m_hWnd, strMessage.c_str(), strTitle.c_str(), unIconID);
|
|
|
|
|
}
|
2019-02-28 02:14:54 +00:00
|
|
|
|
return ::MessageBox(NULL, strMessage.c_str(), strTitle.c_str(), unIconID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MFC_UI::processEvent(pTW_EVENT _pEvent)
|
|
|
|
|
{
|
2019-11-14 08:42:24 +00:00
|
|
|
|
if (m_pDlg)
|
2019-02-28 02:14:54 +00:00
|
|
|
|
{
|
2019-05-10 02:51:26 +00:00
|
|
|
|
if (IsDialogMessage(m_pDlg->m_hWnd, (LPMSG)(((pTW_EVENT)_pEvent)->pEvent)))
|
2019-02-28 02:14:54 +00:00
|
|
|
|
{
|
2019-11-14 08:42:24 +00:00
|
|
|
|
m_pDlg->SendMessage(_pEvent->TWMessage);
|
|
|
|
|
return TRUE;
|
2019-02-28 02:14:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2019-12-04 14:43:40 +00:00
|
|
|
|
|
|
|
|
|
void MFC_UI::ShowIndicators()
|
|
|
|
|
{
|
|
|
|
|
if (m_bIndicators) {
|
|
|
|
|
m_pIndicator.reset(new IndicatorDlg(this));
|
|
|
|
|
m_pIndicator->Create(IDD_DIALOG_INDICATOR,m_pDlg ? m_pDlg.get() : m_pChildWnd.get());
|
|
|
|
|
m_pIndicator->ShowWindow(SW_SHOWNORMAL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MFC_UI::DestroyIndicators()
|
|
|
|
|
{
|
|
|
|
|
m_pIndicator.reset();
|
|
|
|
|
}
|