183 lines
3.3 KiB
C++
183 lines
3.3 KiB
C++
#include "stdafx.h"
|
|
#include "MFC_UI.h"
|
|
#include "TwainUIDlg.h"
|
|
#include "IndicatorDlg.h"
|
|
#include "hugaotwainds.h"
|
|
#include "Resource.h"
|
|
|
|
extern ChugaotwaindsApp theApp;
|
|
|
|
MFC_UI::MFC_UI(CTWAINDS_FreeImage *pDS)
|
|
: CTWAIN_UI(pDS)
|
|
{
|
|
m_pDlg = NULL;
|
|
m_pChildWnd = NULL;
|
|
indicator=NULL;
|
|
indicatorCreated=false;
|
|
}
|
|
|
|
|
|
MFC_UI::~MFC_UI()
|
|
{
|
|
|
|
}
|
|
|
|
TW_INT16 MFC_UI::DisplayTWAINGUI(TW_USERINTERFACE Data, bool bSetup, bool bIndicators)
|
|
{
|
|
TW_INT16 ret=TWRC_SUCCESS;
|
|
TW_INT16 nRes = CTWAIN_UI::DisplayTWAINGUI(Data, bSetup, bIndicators);
|
|
if (nRes)
|
|
{
|
|
return nRes;
|
|
}
|
|
if (bSetup)
|
|
{
|
|
Data.ShowUI = 1;
|
|
}
|
|
|
|
if (Data.ShowUI == 0 && !bIndicators)
|
|
{
|
|
return ret;
|
|
}
|
|
|
|
if (Data.hParent)
|
|
{
|
|
if (m_pChildWnd==NULL)
|
|
{
|
|
CDialog* dlg =new CDialog();
|
|
dlg->Create(IDD_DIALOGBACK);
|
|
m_pChildWnd = dlg;
|
|
theApp.m_pMainWnd = m_pChildWnd;
|
|
|
|
//long ll = GetWindowLong(m_pChildWnd->GetSafeHwnd(), GWL_STYLE);
|
|
//SetWindowLong(m_pChildWnd->GetSafeHwnd(), GWL_STYLE, WS_CHILD | ll);
|
|
SetParent(m_pChildWnd->GetSafeHwnd(), (HWND)Data.hParent);
|
|
//dlg->ShowWindow(SW_SHOWNORMAL);
|
|
}
|
|
}
|
|
|
|
if (Data.ShowUI)
|
|
{
|
|
if (m_pDlg==NULL)
|
|
{
|
|
m_pDlg = new TwainUIDlg(this, m_pChildWnd);
|
|
m_pDlg->Create(IDD_DIALOG_TWAINUI, m_pChildWnd);
|
|
}
|
|
if (!bSetup)
|
|
{
|
|
m_pDlg->SetDlgItemTextA(IDC_CONFIRM, _T("ɨÃè"));
|
|
}
|
|
else
|
|
{
|
|
m_pDlg->SetDlgItemTextA(IDC_CONFIRM, _T("È·¶¨"));
|
|
}
|
|
|
|
|
|
if (m_pDlg)
|
|
{
|
|
m_pDlg->ShowWindow(SW_SHOWNORMAL);
|
|
SetWindowPos(m_pDlg->m_hWnd,HWND_TOPMOST,500,500,0,0,SWP_NOSIZE|SWP_NOMOVE);
|
|
//m_pDlg->BringWindowToTop();
|
|
}
|
|
else
|
|
{
|
|
ret=TWRC_FAILURE;
|
|
}
|
|
}
|
|
|
|
|
|
if (bIndicators)
|
|
{
|
|
if (indicator==NULL)
|
|
{
|
|
indicator=new IndicatorDlg(this,Data.ShowUI?m_pDlg:m_pChildWnd);
|
|
}
|
|
showUI=Data.ShowUI;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
void MFC_UI::DestroyTWAINGUI()
|
|
{
|
|
CTWAIN_UI::DestroyTWAINGUI();
|
|
if (indicator!=NULL)
|
|
{
|
|
indicator->DestroyWindow();
|
|
delete indicator;
|
|
indicator=NULL;
|
|
indicatorCreated=false;
|
|
}
|
|
|
|
if (m_pDlg!=NULL)
|
|
{
|
|
m_pDlg->DestroyWindow();
|
|
delete m_pDlg;
|
|
m_pDlg = NULL;
|
|
}
|
|
|
|
if (m_pChildWnd!=NULL)
|
|
{
|
|
m_pChildWnd->DestroyWindow();
|
|
delete m_pChildWnd;
|
|
m_pChildWnd = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
void MFC_UI::UpdateProgress(bool bShow, unsigned char ucProgress, unsigned int unPageNo, string strProgressTitle)
|
|
{
|
|
if (indicator==NULL)
|
|
{
|
|
indicator=new IndicatorDlg(this,NULL);
|
|
}
|
|
|
|
if (!indicatorCreated)
|
|
{
|
|
indicator->Create(IDD_DIALOG_INDICATOR,m_pChildWnd);//m_pChildWnd
|
|
indicatorCreated=true;
|
|
}
|
|
|
|
if (bShow)
|
|
{
|
|
indicator->ShowWindow(SW_SHOWNORMAL);
|
|
}
|
|
else
|
|
{
|
|
indicator->DestroyWindow();
|
|
delete indicator;
|
|
indicator=NULL;
|
|
indicatorCreated=false;
|
|
}
|
|
//indicator->ShowWindow(bShow?SW_SHOWNORMAL:SW_HIDE);
|
|
if (m_pDlg)
|
|
{
|
|
m_pDlg->EnableWindow(bShow?FALSE:TRUE);
|
|
}
|
|
}
|
|
|
|
unsigned int MFC_UI::MyMessageBox(string strMessage, string strTitle, unsigned int unIconID)
|
|
{
|
|
//QMessageBox msgBox(QMessageBox::NoIcon, strTitle.c_str(), strMessage.c_str());
|
|
if (m_pChildWnd!=NULL)
|
|
{
|
|
return ::MessageBox(m_pChildWnd->m_hWnd, strMessage.c_str(), strTitle.c_str(), unIconID);
|
|
}
|
|
return ::MessageBox(NULL, strMessage.c_str(), strTitle.c_str(), unIconID);
|
|
}
|
|
|
|
bool MFC_UI::processEvent(pTW_EVENT _pEvent)
|
|
{
|
|
if(m_pDlg)
|
|
{
|
|
if (IsDialogMessage(m_pDlg->m_hWnd, (LPMSG)(((pTW_EVENT)_pEvent)->pEvent)))
|
|
{
|
|
m_pDlg->SendMessage(_pEvent->TWMessage);
|
|
//XdPrint("_pEvent->TWMessage %d\n",_pEvent->TWMessage);
|
|
return TRUE;
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|