Home › Forums › TWAIN Classic › Twain Source UI does not respond to my inputs.
- This topic has 8 replies, 2 voices, and was last updated 16 years, 2 months ago by Sanjeev.
- AuthorPosts
I am using EPSON scanner and I enable the EPSON source from within my application. The EPSON twain software comes up but I cannot change the DPI, Image Type or any other properties. When i click the drop down to select a different DPI the drop down opens and then closes. It does not give me optin to chose a DPI. It looks like souce properties cannot be changed. Is there anything I can do to allow me to change the properties from within the source UI?
Thanks in advance.Sanjeev
not so much. there are lots of cases where the Ui doesn’t reflect restrictions of cap settings made by you before you pop the Ui, and if you talk to Epson support that say they don’t support twain (despite their .ds installing under twain_32 and despite their device responding to twain method calls) and insist they support ‘Epson Scan’.
When I’m forced to use an Epson I don’t pop their Ui, it only seems to complicate matters.
.
When I use PaintShop Pro or other graphing tools, i am able to change the cap settings like DPI etc. but not when i launch the software from my application. is there a setting I have to change so that EPSON software will allow me to change the parameters?
I thought you were describing trouble where you tell the device to use resolution Y then pop their Ui and it says it is going to use resolution X.
If the Ui doesn’t work (comboboxes behave oddly, etc) then more than likely your messageloop is messed up.
.
I am sorry if i was not clear in defining my problem.
What is a message loop and how do i fix it?no, you weren’t unclear. for the messageloop I need more information on your programming enviroment – c++, java, c# vb.net, etc… and whether you’re doing all the twain calls in your code or whether you’re using someone elses library, and depending on how you answer the first to I might ask some more about whether you doing to twian work in another thread or in a dll or whether you’re just running a simple dialog or form..
.
I am wriing my code in C++ and my application is a DLL. All the twain calls in this dll are from within the DLL. I call this DLL from another application. Here are some of my functions.
bool TwainProcedure(pTW_IDENTITY pOrigin,pTW_IDENTITY pDest,TW_UINT32 DG,TW_UINT16 DAT,TW_UINT16 MSG,TW_MEMREF pData)
{ //Use: Entry point into Twain. For a complete description of thisif(IsValidDriver())
{
unsigned short ret_val;
ret_val = (*m_pDSMProc)(pOrigin,pDest,DG,DAT,MSG,pData);
m_returnCode = ret_val;
if(ret_val != TWRC_SUCCESS)
{
(*m_pDSMProc)(pOrigin,pDest,DG_CONTROL,DAT_STATUS,MSG_GET,&m_Status);
}
return (ret_val == TWRC_SUCCESS);
}
else
{
m_returnCode = TWRC_FAILURE;
return FALSE;
}
}
**********************bool SelectSource()
{ //Use:Called to display a dialog box to select the Twain source to use.
memset(&m_Source,0,sizeof(m_Source));
if(!SourceSelected())
{
SelectDefaultSource();
}
if(TwainProcedure(&m_AppId,NULL,DG_CONTROL,DAT_IDENTITY,MSG_USERSELECT,&m_Source))
{
m_bSourceSelected = TRUE;
}
return m_bSourceSelected;
}************************************************************
void CloseDS()
{ //Use: Closes the Data Source
if(DSOpen())
{
DisableSource();
TwainProcedure(&m_AppId,NULL,DG_CONTROL,DAT_IDENTITY,MSG_CLOSEDS,(TW_MEMREF)&m_Source);
m_bDSOpen = FALSE;
}
}*******************************************************
void CloseDSM()
{ //Use: Closes the Data Source Manager
if(DSMOpen())
{
CloseDS();
TwainProcedure(&m_AppId,NULL,DG_CONTROL,DAT_PARENT,MSG_CLOSEDSM,(TW_MEMREF)&m_hMessageWnd);
m_bDSMOpen = FALSE;
}
}ok. if you want to keep everything in a dll then you’ll need to throw a window in the dll (I would use a messageOnlyWindow if the platform(s) you’re targeting support it but anything derived from CWnd should work).
You may also need/have to pump the messages yourself because Dlls don’t (typically) pump.I usually use a whole bunch of classes so that the final consumer doesn’t have to deal with the whole mess.
I’ll give you simplistic example that I’ve used in the past.
the highest level class is simple – doesn’t derive from anything, just a simple class – we ca call it CATwainSession. CATwainSession contains an instance of a class derived from CWinThread, we’ll call it CAMessagePump. CAMessagePump is there because I like having a separate thread do my twain work and because then I don’t have to think about whether I’m trying to run twain from a dialog or a command prompt or a windows service they all behave the same if your class does it’s own pumping. CAMessagePump contains another class derived from CWnd, we’ll call it CAMessegeOnlyWindow. CAMessegeOnlyWindow is there because twain wants to talk to a window.In CAMessageOnlyWindow you override PreTranslateMessage. PreTranslateMessage is the messageloop that I was talking about… the same one you heard so much about when you read the twain spec – the one that the spec is pretty about when it says you have to modify it to talk to twain…
my PreTranslateMessage method usually ends up looking something like this, ymmv:
BOOL CAMessegeOnlyWindow::PreTranslateMessage(MSG* pMsg)
{
int bProcessed = FALSE;
if (twState >= 5) {
TW_EVENT twEvent;
twEvent.pEvent = (TW_MEMREF)pMsg;
twEvent.TWMessage = MSG_NULL;
TW_UINT16 rc = TWRC_NOTDSEVENT;
rc = CallDSMEntry(&appID, &dsID, DG_CONTROL, DAT_EVENT, MSG_PROCESSEVENT, (TW_MEMREF)&twEvent);
switch (rc)
{
case TWRC_DSEVENT:
bProcessed = TRUE;
break;
case TWRC_FAILURE:
::PostThreadMessage(mpThreadId, UWM_MESSAGE_STOPPUMPING, WPARAM(0), LPARAM(rc));
return FALSE;
break;
}
switch (twEvent.TWMessage)
{
case MSG_NULL:
return TRUE;
break;
case MSG_CLOSEDSREQ:
::PostThreadMessage(mpThreadId, UWM_MESSAGE_SCAN_CANCELLED, WPARAM(0), LPARAM(0));
return FALSE;
break;
case MSG_CLOSEDSOK:
::PostThreadMessage(mpThreadId, UWM_MESSAGE_STOPPUMPING, WPARAM(0), LPARAM(0));
return TRUE;
break;
case MSG_DEVICEEVENT:
return TRUE;
break;
case MSG_XFERREADY:
::PostThreadMessage(dwThreadId, UWM_MESSAGE_STOPPUMPING, WPARAM(0), LPARAM(0));
twState = 6;
TWTransferImage();
return TRUE;
break;
default:
break;
}
}
if (bProcessed)
return bProcessed;
else
return CWnd::PreTranslateMessage(pMsg);
}
For the communication I use registered messages because they’re simple, they’re thread safe, and… huh there was another reason,… maybe two be they’re slipped my mind. Well anyway I use registered window messages but you cold probably use just about anything.
If you have not already read thru Dosadi’s CTwain sample you should probably whip google out right now and search for Dosadi CTwain. there will be a license to read about how you shouldn’t steal and how their code can be used to learn twain but that you can’t sell their code to other people without cutting them in ona pieve of the action – pretty standard stuff, then if that’s all on the up and up you should download and read their code. It explains alot of stuff really well.
.
Thank you so much for your detail explanation. I will work on this and will let you know if I have a problem.
Thank You.- AuthorPosts