Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB UINT16 and FIX32

Status
Not open for further replies.

CBellucci

Programmer
Apr 20, 2007
38
US
I have software where I am Negotiating the capabilities of a TWAIN scanner.

Definition of routine in VB:
[tt]Public Overloads Function NegotiateCapability( _
ByVal capability As Capabilities, _
ByVal capabilityValue As Object _
) As Boolean[/tt]

The problem I'm having is that the particular three capabilities I'm negotiating require an Unsigned 16 bit integer as the capabilityValue.

I have tried sending just a value:
[tt] jnCapability = 3
STORE oleTWAINControl.NegotiateCapability(ICAP_PIXELTYPE, @M.jnCapability) TO jlSuccess[/tt]
Nope.

I have tried sending as a double CHR:
[tt] jnCapability = CHR(0) + CHR(3)
STORE oleTWAINControl.NegotiateCapability(ICAP_PIXELTYPE, @M.jnCapability) TO jlSuccess[/tt]
Nope.

I have tried sending as a single CHR:
[tt] jnCapability = CHR(3)
STORE oleTWAINControl.NegotiateCapability(ICAP_PIXELTYPE, @M.jnCapability) TO jlSuccess[/tt]
Nope.

On the Nopes, I get a "Type Mismatch" error.

The three capabilities I'm trying to negotiate are CAP_DUPLEX, ICAP_PIXELTYPE, and ICAP_BITDEPTH. It seems I can negotiate Boolean and FIX32 objects fine (at least I'm getting a successful return).

Any ideas? Is there a good place to find out how to convert a VFP9 value to UINT16 or FIX32?

Many thanks in advance!
[tt][/tt]
 
Why are you trying to pass by reference, when the definition says ByVal?

With a COM class you have nothing to define as with DLL function DECLARES, so you can't play with different base types here, but in the end oleTWAINControl.NegotiateCapability(ICAP_PIXELTYPE, 3) sould work and oleTWAINControl.NegotiateCapability(ICAP_PIXELTYPE, M.jnCapability)

Is it perhaps the ICAP_PIXELTYPE causing the type mismatch?

The VB type definitions don't make clear, what basic types are meant with "Capabilities" and "Object". Object in the .NET world is anything, any type inherits from Object, so this is very unspecific, though I assume this isn't VB.NET, but VB6, is it? Could you tell a bit more about the DLL or OCX you're using here?

Bye, Olaf.
 
I might be missing something obvious, but if you're using a Twain control, shouldn't you be referring to the ActiveX version of the library?

That is,

Code:
Public Function NegotiateCapability( _
   ByVal Capability As Long, _
   ByVal Value As Variant _
) As Boolean

to which your VFP code would be something like

Code:
#DEFINE TWAIN_PIXEL_TYPE 257
m.Result = m.oleTwainControl.NegotiateCapability(TWAIN_PIXEL_TYPE, 3)
 
Well, duh... That's what I get for staring at the screen and not reading it. One of the methods does require by reference (GetCapabilities). But this does not. What can I say? The end of a long day... but this is exactly an example of clear eyes and multiple eyes looking at the "problem" -- even if there isn't a problem.

And... after a meeting this morning, the scope of the project has changed and all of this is moot. "That's exactly what I asked for, but not what I wanted." Ah, the wonders of being a programmer!

Thank you all so much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top