** How to use screen capture as a good tool for error log
1. Add the ON ERROR.. code as given below in the beginning of your Main.PRG
*********************************************************
ON ERROR DO errhand WITH ;
ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO(1)
*********************************************************
2. AT the end of your Main.Prg, add the following .. two procedures..
*********************************************************
** My error handler
PROCEDURE errhand
PARAMETER merror, mess, mess1, mprog, mlineno
LOCAL myMessage, lcAlias
lcALias = ALIAS()
myMessage='Error number: ' + LTRIM(STR(merror))+ CHR(13) ;
+ 'Error message: ' + mess + CHR(13) ;
+ 'Line of code with error: ' + mess1 + CHR(13);
+ 'Line number of error: ' + LTRIM(STR(mlineno)) + CHR(13) ;
+ 'Program with error: ' + mprog
DO shot_screen
WAIT WINDOW myMessage +CHR(13)+CHR(13)+"Press Any Key to Continue"
** Baltmans idea of capturing image in a General Field
SELECT 0
IF !FILE("ErrorLog.DBF"
CREATE TABLE ErrorLog (eDateTime T, UserInfo M, ErrorImg G)
ELSE
USE ErrorLog ALIAS errorLog
ENDIF
SCATTER MEMVAR BLANK
m.eDateTime = DATETIME()
m.UserInfo = ;
"User : "+GETENV("USERNAME"
+ CHR(13)+ ;
"Computer :"+ GETENV("ComputerName"
+CHR(13)+ ;
"User Profile :"+ GETENV("USERPROFILE"
+CHR(13)+ ;
"OS :"+ GETENV("OS"
+ CHR(13)+ ;
"Alias In Use : " + lcAlias + CHR(13)+ ;
"Error Message..... " + CHR(13)+ myMessage
INSERT INTO ErrorLog FROM MEMVAR
MODIFY General ErrorImg NOWAIT
KEYBOARD '{CTRL+V}'
DOEVENTS
USE IN ErrorLog
IF !EMPTY(lcALias)
SELECT (lcAlias)
ENDIF
RETURN
*********************************************************
PROCEDURE shot_screen
** Microsoft's code
DECLARE INTEGER keybd_event IN Win32API ;
INTEGER, INTEGER, INTEGER, INTEGER
VK_SNAPSHOT = 44 && from the winuser.h
VK_LMENU = 164
KEYEVENTF_KEYUP = 2
KEYEVENTF_EXTENDEDKEY = 1
DOEVENTS
keybd_event( VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY, 0 ) && key down
keybd_event( VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY, 0 )
keybd_event( VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0 )
keybd_event( VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0 )
DOEVENTS
RETURN
*********************************************************
** EOF
*********************************************************
I have been working on this idea when time permits as to how we can save that easily as JPG image, so that the file size is limited. There are alternatives available.
1. Use Office automation (excel or word) - depends on OFFICE software availability.
2. MSPAINT.. looking into tighter code patterns.
Once these objectives are achieved, I will post the whole thing as an FAQ. Baltman has been of immense help in providing the views in a related thread. Appropriate credit to him.
Also, once this concept is completed, I will post another FAQ as to how we can use this for possible documentation screen capture or such possibilities. I have already tried successfully, but the BMP method is extremely space consuming and so holding it for a while. The way to go is very simple..
at the beginning of MAIN.PRG as in step 1 here, add a line
ON KEY LABEL F12 DO myCapture
Add a function..
PROCEDURE MyCapture
DO shot_screen
DO shot_save && and in Shot save open the table and save whatever..
The possibilities are countless.

____________________________________________
ramani - (Subramanian.G)
When you ask VFP questions, please add VFP version.
1. Add the ON ERROR.. code as given below in the beginning of your Main.PRG
*********************************************************
ON ERROR DO errhand WITH ;
ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO(1)
*********************************************************
2. AT the end of your Main.Prg, add the following .. two procedures..
*********************************************************
** My error handler
PROCEDURE errhand
PARAMETER merror, mess, mess1, mprog, mlineno
LOCAL myMessage, lcAlias
lcALias = ALIAS()
myMessage='Error number: ' + LTRIM(STR(merror))+ CHR(13) ;
+ 'Error message: ' + mess + CHR(13) ;
+ 'Line of code with error: ' + mess1 + CHR(13);
+ 'Line number of error: ' + LTRIM(STR(mlineno)) + CHR(13) ;
+ 'Program with error: ' + mprog
DO shot_screen
WAIT WINDOW myMessage +CHR(13)+CHR(13)+"Press Any Key to Continue"
** Baltmans idea of capturing image in a General Field
SELECT 0
IF !FILE("ErrorLog.DBF"
CREATE TABLE ErrorLog (eDateTime T, UserInfo M, ErrorImg G)
ELSE
USE ErrorLog ALIAS errorLog
ENDIF
SCATTER MEMVAR BLANK
m.eDateTime = DATETIME()
m.UserInfo = ;
"User : "+GETENV("USERNAME"
"Computer :"+ GETENV("ComputerName"
"User Profile :"+ GETENV("USERPROFILE"
"OS :"+ GETENV("OS"
"Alias In Use : " + lcAlias + CHR(13)+ ;
"Error Message..... " + CHR(13)+ myMessage
INSERT INTO ErrorLog FROM MEMVAR
MODIFY General ErrorImg NOWAIT
KEYBOARD '{CTRL+V}'
DOEVENTS
USE IN ErrorLog
IF !EMPTY(lcALias)
SELECT (lcAlias)
ENDIF
RETURN
*********************************************************
PROCEDURE shot_screen
** Microsoft's code
DECLARE INTEGER keybd_event IN Win32API ;
INTEGER, INTEGER, INTEGER, INTEGER
VK_SNAPSHOT = 44 && from the winuser.h
VK_LMENU = 164
KEYEVENTF_KEYUP = 2
KEYEVENTF_EXTENDEDKEY = 1
DOEVENTS
keybd_event( VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY, 0 ) && key down
keybd_event( VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY, 0 )
keybd_event( VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0 )
keybd_event( VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0 )
DOEVENTS
RETURN
*********************************************************
** EOF
*********************************************************
I have been working on this idea when time permits as to how we can save that easily as JPG image, so that the file size is limited. There are alternatives available.
1. Use Office automation (excel or word) - depends on OFFICE software availability.
2. MSPAINT.. looking into tighter code patterns.
Once these objectives are achieved, I will post the whole thing as an FAQ. Baltman has been of immense help in providing the views in a related thread. Appropriate credit to him.
Also, once this concept is completed, I will post another FAQ as to how we can use this for possible documentation screen capture or such possibilities. I have already tried successfully, but the BMP method is extremely space consuming and so holding it for a while. The way to go is very simple..
at the beginning of MAIN.PRG as in step 1 here, add a line
ON KEY LABEL F12 DO myCapture
Add a function..
PROCEDURE MyCapture
DO shot_screen
DO shot_save && and in Shot save open the table and save whatever..
The possibilities are countless.
____________________________________________
ramani - (Subramanian.G)
When you ask VFP questions, please add VFP version.