CHAMAR FUNCAO DO MODULO

USUARIO.EXCLUIDOS 05/09/2007 08:51:49
#234183
Alguem pode me ajudar?
Não estou conseguindo chamar as funções deste modulo.

Option Explicit

Private hDib As Long
Private hPal As Long
Private nPixTypes As Long

Public Enum OpcoesScanner
Selecionar_Scanner = 1
Scanear_Imagem = 2
End Enum


Declare Function TWAIN_AcquireNative Lib "EZTW32.DLL" (ByVal hwndApp As Long, ByVal wPixTypes As Long) As Long
Global Const TWAIN_BW = &H1
Global Const TWAIN_GRAY = &H2
Global Const TWAIN_RGB = &H4
Global Const TWAIN_PALETTE = &H8
Global Const TWAIN_ANYTYPE = &H0
Declare Sub TWAIN_FreeNative Lib "EZTW32.DLL" (ByVal hDib As Long)
Declare Function TWAIN_AcquireToClipboard Lib "EZTW32.DLL" (ByVal hwndApp As Long, ByVal wPixTypes As Long) As Long
Declare Function TWAIN_AcquireToFilename Lib "EZTW32.DLL" (ByVal hwndApp As Long, ByVal sFile As String) As Long
Declare Function TWAIN_SelectImageSource Lib "EZTW32.DLL" (ByVal hwnd As Long) As Long
Declare Function TWAIN_IsAvailable Lib "EZTW32.DLL" () As Long
Declare Function TWAIN_EasyVersion Lib "EZTW32.DLL" () As Long
Declare Function TWAIN_State Lib "EZTW32.DLL" () As Long
Global Const TWAIN_PRESESSION = 1
Global Const TWAIN_SM_LOADED = 2
Global Const TWAIN_SM_OPEN = 3
Global Const TWAIN_SOURCE_OPEN = 4
Global Const TWAIN_SOURCE_ENABLED = 5
Global Const TWAIN_TRANSFER_READY = 6
Global Const TWAIN_TRANSFERRING = 7
Declare Function TWAIN_DibDepth Lib "EZTW32.DLL" (ByVal hDib As Long) As Long
Declare Function TWAIN_DibWidth Lib "EZTW32.DLL" (ByVal hDib As Long) As Long
Declare Function TWAIN_DibHeight Lib "EZTW32.DLL" (ByVal hDib As Long) As Long
Declare Function TWAIN_DibNumColors Lib "EZTW32.DLL" (ByVal hDib As Long) As Long
Declare Function TWAIN_RowSize Lib "EZTW32.DLL" (ByVal hDib As Long) As Long
Declare Sub TWAIN_ReadRow Lib "EZTW32.DLL" (ByVal hDib As Long, ByVal nRow As Long, prow As Any)
Declare Function TWAIN_CreateDibPalette Lib "EZTW32.DLL" (ByVal hDib As Long) As Long
Declare Sub TWAIN_DrawDibToDC Lib "EZTW32.DLL" (ByVal hDC As Long, ByVal nDestX As Long, ByVal nDestX As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hDib As Long, ByVal nSrcX As Long, ByVal nSrcX As Long)
Declare Function TWAIN_WriteNativeToFilename Lib "EZTW32.DLL" (ByVal hDib As Long, ByVal sFile As String) As Long
Declare Function TWAIN_WriteNativeToFile Lib "EZTW32.DLL" (ByVal hDib As Long, ByVal hFile As Long) As Long
Declare Function TWAIN_LoadNativeFromFilename Lib "EZTW32.DLL" (ByVal sFile As String) As Long
Declare Function TWAIN_LoadNativeFromFile Lib "EZTW32.DLL" (ByVal hFile As Long) As Long
Declare Sub TWAIN_SetHideUI Lib "EZTW32.DLL" (ByVal nHide As Long)
Declare Function TWAIN_GetHideUI Lib "EZTW32.DLL" () As Long
Declare Sub TWAIN_RegisterApp Lib "EZTW32.DLL" (ByVal nMajorNum As Long, ByVal nMinorNum As Long, ByVal nLanguage As Long, ByVal nCountry As Long, ByVal sVersion As String, ByVal sMfg As String, ByVal sFamily As String, ByVal sProduct As String)
Declare Function TWAIN_GetResultCode Lib "EZTW32.DLL" ()
Declare Function TWAIN_GetConditionCode Lib "EZTW32.DLL" ()
Declare Sub TWAIN_ErrorBox Lib "EZTW32.DLL" (ByVal sMsg As String)
Declare Sub TWAIN_ReportLastError Lib "EZTW32.DLL" (ByVal sMsg As String)
Declare Function TWAIN_LoadSourceManager Lib "EZTW32.DLL" () As Long
Declare Function TWAIN_OpenSourceManager Lib "EZTW32.DLL" (ByVal hwnd As Long) As Long
Declare Function TWAIN_OpenDefaultSource Lib "EZTW32.DLL" () As Long
Declare Function TWAIN_EnableSource Lib "EZTW32.DLL" (ByVal hwnd As Long) As Long
Declare Function TWAIN_DisableSource Lib "EZTW32.DLL" () As Long
Declare Function TWAIN_CloseSource Lib "EZTW32.DLL" () As Long
Declare Function TWAIN_CloseSourceManager Lib "EZTW32.DLL" (ByVal hwnd As Long) As Long
Declare Function TWAIN_UnloadSourceManager Lib "EZTW32.DLL" () As Long
Declare Function TWAIN_MessageHook Lib "EZTW32.DLL" (lpMsg As Any) As Long
Declare Function TWAIN_WaitForNativeXfer Lib "EZTW32.DLL" (ByVal hwnd As Long) As Long
Declare Sub TWAIN_ModalEventLoop Lib "EZTW32.DLL" ()
Declare Function TWAIN_EndXfer Lib "EZTW32.DLL" () As Long
Declare Function TWAIN_AbortAllPendingXfers Lib "EZTW32.DLL" () As Long
Declare Function TWAIN_WriteDibToFile Lib "EZTW32.DLL" (ByVal lpDib As Long, ByVal hFile As Long) As Long
Declare Function TWAIN_NegotiateXferCount Lib "EZTW32.DLL" (ByVal nXfers As Long) As Long
Declare Function TWAIN_NegotiatePixelTypes Lib "EZTW32.DLL" (ByVal wPixTypes As Long) As Long
Declare Function TWAIN_GetCurrentUnits Lib "EZTW32.DLL" () As Long
Declare Function TWAIN_SetCurrentUnits Lib "EZTW32.DLL" (ByVal nUnits As Long) As Long
Declare Function TWAIN_GetBitDepth Lib "EZTW32.DLL" () As Long
Declare Function TWAIN_SetBitDepth Lib "EZTW32.DLL" (ByVal nBits As Long) As Long
Declare Function TWAIN_GetPixelType Lib "EZTW32.DLL" () As Long
Declare Function TWAIN_SetCurrentPixelType Lib "EZTW32.DLL" (ByVal nPixType As Long) As Long
Declare Function TWAIN_GetCurrentResolution Lib "EZTW32.DLL" () As Double
Declare Function TWAIN_SetCurrentResolution Lib "EZTW32.DLL" (ByVal dRes As Double) As Long
Declare Function TWAIN_SetContrast Lib "EZTW32.DLL" (ByVal dCon As Double) As Long
Declare Function TWAIN_SetBrightness Lib "EZTW32.DLL" (ByVal dBri As Double) As Long

Public Sub DiscardImage(Campo As Object)
If (hPal <> 0) Then
hPal = 0
End If
If (hDib <> 0) Then
TWAIN_FreeNative (hDib)
hDib = 0
End If

Set Campo.Picture = Nothing
Campo.Cls
End Sub


'Para usar o scanner. A variável CAMPO deve ser um form ou uma picturebox
Public Sub AtivarScanner(Campo As Object, Funcao As OpcoesScanner)

If (TypeOf Campo Is Form) Or (TypeOf Campo Is PictureBox) Then
Else
MsgBox "A variável CAMPO está inválida, só é permitido um FORM ou uma PICTUREBOX, VERIFIQUE!!!", vbCritical, "Falha na Definição"
Exit Sub
End If

Select Case Funcao
Case 1
TWAIN_SelectImageSource (Campo.hwnd)
Case 2
Call DiscardImage(Campo)
If TWAIN_OpenDefaultSource() <> 0 Then
hDib = TWAIN_AcquireNative(Campo.hwnd, nPixTypes)
If hDib <> 0 Then
hPal = TWAIN_CreateDibPalette(hDib)

Dim w As Long, h As Long
If hPal <> 0 Then
End If
If hDib <> 0 Then
w = TWAIN_DibWidth(hDib)
h = TWAIN_DibHeight(hDib)
TWAIN_DrawDibToDC Campo.hDC, 0, 0, w, h, hDib, 0, 0
End If
End If
End If
End Select

End Sub


'Salvar a imagem digitalizada no disco
Public Sub SalvarImagem(gCommonDialog As CommonDialog)
With gCommonDialog
.Filter = "Bitmaps (*.bmp)|*.bmp|"
.Filter = .Filter & "JPEG (*.jpg)|*.jpg|"
.ShowSave
End With

If hDib <> 0 Then
If TWAIN_WriteNativeToFilename(hDib, gCommonDialog.FileName) < -1 Then
MsgBox "Erro ao ler a imagem, VERIFIQUE!!!"
End If
End If
End Sub


'Exibe uma imagem gravada no HD ou em outro disco
Public Sub ExibirImagem(Campo As Object, gCommonDialog As CommonDialog)
With gCommonDialog
.Filter = "Bitmaps (*.bmp)|*.bmp|"
.Filter = .Filter & "JPEG (*.jpg)|*.jpg|"
.ShowOpen
End With

Call DiscardImage(Campo)
hDib = TWAIN_LoadNativeFromFilename(gCommonDialog.FileName)

Dim w As Long, h As Long
If hPal <> 0 Then
End If
If hDib <> 0 Then
w = TWAIN_DibWidth(hDib)
h = TWAIN_DibHeight(hDib)
TWAIN_DrawDibToDC Campo.hDC, 0, 0, w, h, hDib, 0, 0
End If
End Sub

USUARIO.EXCLUIDOS 05/09/2007 10:06:15
#234199
Resposta escolhida
qual erro aparece?
USUARIO.EXCLUIDOS 05/09/2007 10:20:57
#234204
Na verdade eu não sei como fazer para chamar a função, quais os parametros devo usar.
Quero chamar a função Public Sub AtivarScanner(Campo As Object, Funcao As OpcoesScanner)
Pode me ajudar?
USUARIO.EXCLUIDOS 05/09/2007 10:38:48
#234209

Acho q seria algo assim

AtivarScanner(Picture1, 1)

tenta ae

USUARIO.EXCLUIDOS 05/09/2007 11:09:47
#234217
Isso mesmo
mais precisa ser assim
Call AtivarScanner(CAMPO, Selecionar_Scanner) 'Para selecionar o Scanner.
Call AtivarScanner(CAMPO, Scanear_Imagem) 'Para capturar a imagem.
USUARIO.EXCLUIDOS 05/09/2007 11:17:37
#234222


faz assim

call AtivarScanner(Picture1, 1)


call AtivarScanner(Picture1, 2)

Tópico encerrado , respostas não são mais permitidas