Grigore Dolghin wrote:
> Hi
> 
> Does anyone have such thing? I want to enhance the error routine to
> send me a desktop screenshot by mail.
> 
> Thanks


Yeah, I've got that in FabMate.  Well, kind of.  In my error routine, I 
just capture lots of data, but not screenshots.  I have another "User 
Comments" screen where It's using the GDI+ stuff that I got from other 
devs here and Foxite.

in the form's load event:
DODEFAULT()
#DEFINE HKEY_CURRENT_USER           -2147483647  && BITSET(0,31)+1

LOCAL loGdiPlusX as Object, lcKey as String, lnError as Integer, 
loRegistry as Object, loException as Exception, ;
                lcValue as String, loCaptureBmp AS xfcBitmap, loForm as Form, n 
as 
Integer, lcCmd as String
TRY
        loGdiPlusX = newobject("xfcSystem", ".\classes\system.vcx")

        *loBmp = loGdiPlusX.Drawing.Bitmap.FromScreen()

        *you can also use this syntax to capture the current form
        *loBmp = loGdiPlusX.Drawing.Bitmap.FromScreen(Thisform)

        *or this syntax to capture the vfp screen area
        *loBmp = loGdiPlusX.Drawing.Bitmap.FromScreen(_screen)

        *loBmp.Save("ScreenCapture.jpg", 
loGdiPlusX.Drawing.Imaging.ImageFormat.Jpeg)
        
        * clear out any previous screenshots
        DELETE FILE CapturedForm*.*
        
        * mjb 06-01-07 taken form Cesar Chalom's publishing on Foxite
        n = 1
        FOR EACH loForm IN _Screen.Forms
           loCaptureBmp = loGdiPlusX.Drawing.Bitmap.FromScreen(loForm.HWnd)
           loCaptureBmp.Save("CapturedForm" + TRANSFORM(n) + ".png", 
loGdiPlusX.Drawing.Imaging.ImageFormat.Png)
           n = n + 1
        ENDFOR

        lcCmd = [RUN /N 7za.exe a -tzip screenshots.zip CapturedForm*.png 
-pmbss!] + JUSTSTEM(LOWER(oUtils.cAppName))
        &lcCmd
        
        this.lAttachImage = .T.

        lcKey = "Software\MB Software Solutions\" + JUSTSTEM(oUtils.cAppName)
        lcValue = SPACE(100)
        loRegistry = NEWOBJECT("registry",".\classes\registry.vcx")
        lnError = 
loRegistry.GetRegKey("SupportEmail",@lcValue,lcKey,HKEY_CURRENT_USER)
        IF NOT EMPTY(lcValue) THEN
                this.cEmailaddress = ALLTRIM(lcValue)
        ENDIF && NOT EMPTY(lcValue)

CATCH TO loException
        this.lAttachImage = .F.

FINALLY

ENDTRY


...and in the SendComments method of that form:

IF NOT EMPTY(this.cEmailaddress) AND NOT EMPTY(this.cComments) THEN
        IF AT('@',this.cEmailaddress) > 0 AND AT('.',this.cEmailaddress) > 0 
THEN
                LOCAL lcMailString as String, lcCmd as String
                WAIT WINDOW NOWAIT "Sending comments..."
                STRTOFILE(this.cComments,"usercomments.txt",0)
                lcMailString = [ usercomments.txt -to 
[email protected]] ;
                        + [ -s "] + oUtils.cSystemName + [ user comments"] ;
                        + [ -i ] + ALLTRIM(this.cEmailAddress) ;
                        + [ -server smtp.dssco.net] ;
                        + [ -attach screenshots.zip] ;
                        + [ -u [email protected] -pw bug123] + ;
                        + [ -f ] + ALLTRIM(this.cEmailAddress)

                lcCmd = "Send(lcMailString)"
                &lcCmd
                WAIT CLEAR
                this.Release()
        ELSE && invalid email address (by basic validation)
                MESSAGEBOX("You must enter a valid email address.  Please 
ensure that 
it is correct so that we can reply to your message to give you an update 
on your message.",48,"Invalid email address format.")
        ENDIF
ELSE
        IF EMPTY(this.cEmailaddress) THEN
                MESSAGEBOX("You must enter an email address.  Please ensure 
that it is 
correct so that we can reply to your message to give you an update on 
your message.",48,"Email address required.")
        ENDIF
        IF EMPTY(this.cComments) THEN
                MESSAGEBOX("You must enter some comments first!",48,"Comments 
required.")
        ENDIF
ENDIF




-- 
Mike Babcock, MCP
MB Software Solutions, LLC
President, Chief Software Architect
http://mbsoftwaresolutions.com
http://fabmate.com
http://twitter.com/mbabcock16


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to