pb pour utiliser fcts de scann via TWAIN (EZTW32.DLL)

Forum destiné aux questions sur le développement : Formules, LotusScript, Java ...

pb pour utiliser fcts de scann via TWAIN (EZTW32.DLL)

Messagepar Stef » 07 Juil 2003 à 16:43

j'ai recuperé un code Lotuscript qui utilise les fonctions de la bibliotheque EZTW32.DLL (Twain 32) pour piloter un scanneur et donc lancer des scans via un bouton sous notes.1er probleme :J'ai fait un test et cela a bien lancé le scan mais l'image qui etait restituée etait vierge (alors qu'il mettait 'scanning in progress...').2e probleme :Apres, j'ai voulu lancer une fonction qui permet de choisir le scanneur a utiliser via une bte de dialogue. après l'avoir testée, lorsque je lance a nouveau le scan, ce coup ci , plus rien ne se passe.Si quelqu'un a deja été confronté au probleme du scan sous notes... ca m'interesse !Merci par avance.
Stef
 

Re: pb pour utiliser fcts de scann via TWAIN (EZTW32.DLL)

Messagepar Stephane Maillard » 08 Juil 2003 à 12:20

Bonjour,Je n'est que le code VB, mais c'est assez rapprochant :' API de la DLLDeclare Function TWAIN_AcquireToClipboard Lib "EZTW32.DLL" (ByVal hwndApp&, ByVal wPixTypes&) As LongDeclare Function TWAIN_SelectImageSource Lib "EZTW32.DLL" (ByVal hwndApp&) As Long' Sélection de la sourcer = TWAIN_SelectImageSource(Me.hWnd) ' Je crois que pour LS il faut remplacer Me.hWnd par 0' Scanner le presse papierr = TWAIN_AcquireToClipboard(Me.hWnd, t%) ' Pareil que ci-dessus pour le Me.hWndAprès il faut trouvé un code qui copie le presse papier vers ce que vous voulez, cela doit ce trouver Notes.net[%sig%]
Cordialement

Stéphane Maillard
Avatar de l’utilisateur
Stephane Maillard
Lord of DominoArea
Lord of DominoArea
 
Message(s) : 8695
Inscrit(e) le : 16 Déc 2004 à 01:10
Localisation : Bretagne

Re: Utilisation du presse papier

Messagepar Stephane Maillard » 09 Juil 2003 à 09:08

Bonjour,Ci-dessous un article avec son code pour pouvoir utilisé le presse papier de Windows en LotusScript :If you have a need to read the windows clipboard (or write to it) while in LotusScript, this custom class makes it easy. Create a Script Library, and call it Windows Clipboard. Go into the (Declarations) area of the script library, and put in this class definition. First, you need to declare the API classes that you will need: Declare Private Function GetClipboardData Lib "User32" (Byval wFormat As Long) As LongDeclare Private Function SetClipboardData Lib "user32" (Byval wFormat As Long, Byval hData As Long) As LongDeclare Private Function OpenClipboard Lib "User32" Alias "OpenClipboard" (Byval hwnd As Long) As LongDeclare Private Function CloseClipboard Lib "User32" Alias "CloseClipboard" () As LongDeclare Private Function GlobalLock Lib "kernel32" Alias "GlobalLock" (Byval hMem As Long) As LongDeclare Private Function GlobalUnlock Lib "kernel32" Alias "GlobalUnlock" (Byval hMem As Long) As LongDeclare Private Function GlobalAlloc Lib "kernel32" (Byval wFlags As Long, Byval dwBytes As Long) As LongDeclare Private Function GlobalFree Lib "kernel32" (Byval hMem As Long) As LongDeclare Private Function EmptyClipboard Lib "user32" () As LongDeclare Private Function lstrcpyLP2Str Lib "kernel32" Alias "lstrcpyA" (Byval lpString1 As String, _Byval lpString2 As Long) As LongDeclare Private Function lstrlenLP Lib "kernel32" Alias "lstrlenA" (Byval lpString As Long) As LongDeclare Private Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (Byval strDest As Any, _Byval lpSource As Any, Byval Length As Any)Declare Private Function GetFocus Lib "User32" Alias "GetFocus" () As Long You will also need soem constant defined, so add those next: Private Const CF_TEXT = 1Private Const GMEM_MOVABLE = &H2&Private Const GMEM_DDESHARE = &H2000&Finally, add in the class definition. First, let's go over the property that will read from the clipboardClass WindowsClipboard Public Property Get Contents As String Dim hClipboard As Long Dim LpStrl As Long Dim Resultl As Long Dim Clipboardstr As String If (OpenClipboard(0&) <> 0) Then hClipboard = GetClipboardData(CF_TEXT) If (hClipboard <> 0) Then LpStrl = GlobalLock(hClipboard) Clipboardstr = Space$(lstrlenLP(LpStrl)) Resultl = lstrcpyLP2Str(Clipboardstr, LpStrl) GlobalUnlock(hClipboard) Else Clipboardstr = "NULL" End If Call CloseClipboard() Else Clipboardstr = "" End If Contents = Clipboardstr End Property ' Ends the "Get" method for the "Contents" propertyThe first thing the class does is get a handle to the clipboard. Then the clipboard is locked. A temporary blank area of data is made so there's a big enough block of string data to hold the results. The clipboard data is put into that blank area and the clipboard is unlocked to free it up again. The results are returned to the user. For setting the clipboard contents, this uses the same Contents property, but this time the property is Set instead of Get. Public Property Set Contents As String Dim lSize As Long Dim hMem As Long Dim pMemory As Long Dim temp As Variant lSize = Len(Contents)+1 hMem = GlobalAlloc(GMEM_MOVABLE Or GMEM_DDESHARE, lSize) If hMem = 0 Or Isnull(hMem) Then Exit Property pMemory = GlobalLock(hMem) If pMemory = 0 Or Isnull(pMemory) Then GlobalFree(hMem) Exit Property End If Call MoveMemory(pMemory, Contents, lSize) Call GlobalUnlock(hMem) If (OpenClipboard(0&) <> 0) Then If (EmptyClipboard() <> 0) Then temp = SetClipboardData(CF_TEXT, hMem) End If temp = CloseClipboard() End If GlobalFree(hMem) End Property ' Ends the "Set" method for the "Contents" propertyEnd ClassFirst, figure out how much memory needs to be allocated. This will be one more character than the size of the data being sent. Then allocate enough memory to hold this text and put the text into the allocated memory location. (This involves locking the memory, then moving the text into the locked memory, then unlocking the memory). Then we get a handle to the clipboard, just like the "get" property did. Once we have that handle, we wipe out whatever is on the clipboard. This could be text, or graphics, or anything else. After the clipboard has been cleared, then the data in memory is placed on the clipboard. Then things are cleaned up - the clipboard is closed and memory is freed. To use this class, it's pretty easy. First, build an agent. Make sure to include the script library with the statement Use "Windows Clipboard" in the (Options) area. Then your test code is just a few lines: Dim x As WindowsClipboardSet x = New WindowsClipboard()Msgbox x.Contentsx.Contents = "Check the setting of the clipboard data by putting in some text"Msgbox x.ContentsThis will give you two message boxes - one with the clipboard contents from before you ran the agent, the other with the clipboard contents we set during the running of the agent.[%sig%]
Cordialement

Stéphane Maillard
Avatar de l’utilisateur
Stephane Maillard
Lord of DominoArea
Lord of DominoArea
 
Message(s) : 8695
Inscrit(e) le : 16 Déc 2004 à 01:10
Localisation : Bretagne

Re: Utilisation du presse papier

Messagepar Stef » 09 Juil 2003 à 09:39

Merci beaucoup pour ton aide.J'espere arriver a me depatouiller avec tout ca ;-)
Stef
 


Retour vers Développement

cron