Home › Forums › TWAIN Classic › Setting CAPs works in twacker but not in app
- This topic has 6 replies, 3 voices, and was last updated 13 years, 7 months ago by MSM.
- AuthorPosts
Dear Experts!
I’m working with DSM 2.1 (using a FUJITSU fi-60F, just in case), everything fine so far.
The strange problem I have is: When I’m trying to set ICAP_XRESOLUTION/ICAP_YRESOLUTION, I get the code TWCC_BADVALUE . BUT using the twacker it works!
First I thought it is because of the twain_32.dll twacker is using but then I defined twaindsm.dll and it still works. The code I’m using is copied from toolkit:
const TW_UINT16 setCapability_OneValue(TW_UINT16 cap, float value)
{
TW_INT16 twrc = TWRC_FAILURE;
TW_CAPABILITY capability;
capability.Cap = cap;
capability.ConType = TWON_ONEVALUE;
capability.hContainer = dsm_Alloc(sizeof(TW_ONEVALUE));
if(0 == capability.hContainer) return twrc;
pTW_ONEVALUE pVal= (pTW_ONEVALUE)dsm_LockMemory(capability.hContainer);
pVal->ItemType = TWTY_FIX32;
TW_FIX32 fix32 = FloatToFix32(value);
pVal->Item = *((pTW_UINT32)(&fix32));
twrc = dsm_Entry(&ID_App, &ID_Source, DG_CONTROL, DAT_CAPABILITY, MSG_SET, (TW_MEMREF)&capability);
dsm_UnlockMemory(capability.hContainer);
dsm_Free(capability.hContainer);
return twrc;
}
What is the problem right here? Why I cannot set this CAPs via my app?
Thank you in advance
OliverHey, me again!
I’ve solved my problem, for those who are interested in the solution: I have to set the CAPs (ICAP_XRESOLUTION/ICAP_YRESOLUTION) first, before any other capabilities, that’s it! I didn’t know that there are any dependencies on CAPs…
Best wishes
OliverYeah, it matters: http://twain.org/docs/CapOrderForWeb.PDF
@twainuser123 wrote:
Yeah, it matters: http://twain.org/docs/CapOrderForWeb.PDF
Thanks a lot for the link!!! Why I have not noticed it…
Hi Oliver,
One error I saw in the code you posted –dsm_UnlockMemory must be called before you pass the handle to any other function.
dsm_UnlockMemory(capability.hContainer);
twrc = dsm_Entry(&ID_App, &ID_Source, DG_CONTROL, DAT_CAPABILITY, MSG_SET, (TW_MEMREF)&capability);
dsm_Free(capability.hContainer);@MSM wrote:
Hi Oliver,
One error I saw in the code you posted –dsm_UnlockMemory must be called before you pass the handle to any other function.
dsm_UnlockMemory(capability.hContainer);
twrc = dsm_Entry(&ID_App, &ID_Source, DG_CONTROL, DAT_CAPABILITY, MSG_SET, (TW_MEMREF)&capability);
dsm_Free(capability.hContainer);Hi MSM,
that’s right, I had corrected it already, thanks anyway.
But I’m still confused with Cap-Ordering. What do the arrows in document exactly mean?
Sample:
A->B: Does it mean A is dependent on B and the lowermost CAP must be set first? No information about that in paper…Hi Oliver,
You should set the top most Cap first.
Infact you should read it as a book left to right, top to bottom- AuthorPosts