*!*	*---------------------------------------------------------------------------
*!*	*-  2000.08.15
*!*	*- File Name...: getimage.prg                                                      $
*!*	*- ت:o@bmp file name                                                $
*!*	*----------------------------------------------------------------------------
*!*	PARAMETER s_only,S_RESULT
*!*	if !file("c:\windows\system\EZTW32.DLL")
*!*		MESSAGEBOX("Ъ`N:zèS䴩Camara\", 0+48+0,"T")
*!*		return
*!*	endif
*!*	&&ΨxsbmpɦW s_only, S_RESULT=0\s,ls

*!*	*  MsgBox BMPS

*!*	#DEFINE kstopsign		16
*!*	#DEFINE kquestion		32
*!*	#DEFINE kexclam			48
*!*	#DEFINE kinfo			64

*!*	*  MsgBox Buttons

*!*	#DEFINE kokmsg			0
*!*	#DEFINE kokcanc			1
*!*	#DEFINE kabrtretca		2
*!*	#DEFINE kyesnocanc		3
*!*	#DEFINE kyesno			4
*!*	#DEFINE kretrycanc		5

*!*	*  MsgBox Replies

*!*	#DEFINE kok				1
*!*	#DEFINE kcancel			2
*!*	#DEFINE kabort			3
*!*	#DEFINE kretry			4
*!*	#DEFINE kignore			5
*!*	#DEFINE kyes			6
*!*	#DEFINE kno				7


*!*	AA= ALLTRIM(SYS(5))+ALLTRIM(SYS(2003))+"\foxTOOLS.fll"
*!*	SET LIBRARY  TO &AA ADDITIVE

*!*	PUBLIC Gl_TwnOk, Gc_fnBMP
*!*	TwnAvail = RegFn32("TWAIN_IsAvailable","","I","c:\windows\system\EZTW32.DLL")
*!*	pn_TwnOk = CallFn(TwnAvail)
*!*	Gl_TwnOk = IIF(pn_TwnOk = 1, .T., .F.)


*!*	****  Note that the line below would be set in a System Default screen  ****


*!*	IF Gl_TwnOk
*!*		PUBLIC Gn_TwnVer, TwnSelSrc, TwnAcqNat, TwnDib2BMP, TwnDib2Fil, ;
*!*			TwnFree
*!*		TwnVer     = RegFn32("TWAIN_EasyVersion","","I","EZTW32.DLL")
*!*		Gn_TwnVer  = CallFn(TwnVer) / 100
*!*		TwnSelSrc  = RegFn32("TWAIN_SelectImageSource","I","I","EZTW32.DLL")
*!*		TwnAcqNat  = RegFn32("TWAIN_AcquireNative","II","I","EZTW32.DLL")
*!*		TwnDib2BMP = RegFn32("TWAIN_WriteNativeToFilename","IC","I","EZTW32.DLL")
*!*		TwnFree    = RegFn32("TWAIN_FreeNative","I","I","EZTW32.DLL")
*!*	ENDIF

*!*	**** Check Directory ****
*!*	PA="IMAGES"
*!*	IF !DIRECTORY(PA)
*!*		IF RIGHT(PA,1)="\"
*!*			PA=LEFT(PA,LEN(PA)-1)
*!*		ENDIF
*!*		REG="MD "+PA
*!*		&REG
*!*	ENDIF	

*!*	****  EndJob is the global for ending the menu's Foundation Read  ****

*!*	pc_fnBMP = "_"+ ALLTRIM(s_only) 

*!*	pc_FHandle=ALLTRIM(SYS(5))+ALLTRIM(SYS(2003))+"\images\" + ALLTRIM(s_only) + ".BMP"

*!*	PRIVATE   pn_hDib,		;
*!*		pn_Result,	;
*!*		pl_Done,		;
*!*		pc_Topic,		;
*!*		pn_Free

*!*	pl_Done    = .F.

*!*	IF FILE(pc_FHandle)
*!*		IF  MESSAGEBOX('ɤwgsb.  nл\',4+32+256,"T")=6
*!*			Delete FILE &pc_FHandle
*!*		ELSE
*!*			pl_Done = .T.
*!*		ENDIF
*!*	ENDIF

*!*	IF NOT pl_Done

*!*		***  Acquire the image.  pn_hDIB is a HUGE pointer that points to the DIB  ***

*!*		pn_hDib    = CallFn(TwnAcqNat,0,0)

*!*		IF pn_hDib = 0
*!*			MESSAGEBOX("User cancelled, or Acquire failed, Acquire Image", 0+48+0,"T")

*!*		ELSE
*!*			pn_Result = CallFn(TwnDib2BMP,pn_hDib,pc_FHandle)
*!*			pn_Free   = CallFn(TwnFree,pn_hDib)
*!*			S_RESULT=pn_Result
*!*			DO CASE

*!*			CASE pn_Result = 0

*!*	*!*				IF NOT WEXIST("LW_Image")
*!*	*!*				DEFINE WINDOW LW_Image         ;
*!*	*!*					AT  0.000, 0.000        ;
*!*	*!*					SIZE 30.1,57.0          ;
*!*	*!*					FONT "MS Sans Serif", 8 ;
*!*	*!*					TITLE "Scanned Image"   ;
*!*	*!*					FLOAT                   ;
*!*	*!*					GROW                    ;
*!*	*!*					CLOSE                   ;
*!*	*!*					SYSTEM
*!*	*!*				Move WINDOW LW_Image CENTER
*!*	*!*				ENDIF

*!*	*!*				CREATE CURSOR TmpImgDBF (Gr_Image G)
*!*	*!*				APPEND BLANK
*!*	*!*				APPEND GENERAL Gr_Image FROM (pc_FHandle) LINK
*!*	*!*				MODIFY GENERAL Gr_Image WINDOW LW_Image
*!*	*!*				USE IN TmpImgDBF
*!*	*!*				
*!*	*!*				Release WINDOW LW_Image


*!*			****  -1, -2, -3, and -4 are error codes from the EZTWAIN functions  ****

*!*			CASE pn_Result = -1
*!*				MESSAGEBOX("Ъ`N:zèSs", 0+48+0,"T")

*!*			CASE pn_Result = -2
*!*				MESSAGEBOX("File open error invalid path or name, or access denied", 0+48+0,"T")

*!*			CASE pn_Result = -3
*!*				MESSAGEBOX("Unable to lock image", 0+48+0,"T")

*!*			CASE pn_Result = -4
*!*				MESSAGEBOX("Unable to save image to BMP file, possibly output device is full", 0+48+0,"T")

*!*			OTHERWISE
*!*				MESSAGEBOX("General error in acquiring the image", 0+48+0,"T")

*!*			ENDCASE

*!*	ENDIF  && pn_hDib

*!*	ENDIF		&& NOT pl_Done
*!*	SET LIBRARY  TO
