Matt Jarvis wrote:
> Dang - this will be my first real VFP coding project in 3 ½ years....
>
>  
>
> We have a 3rd party product running on a server on our network. The program 
> crashes from time to time and it would be great to get an email to me and our 
> Sys Admin before the user gets the error when he's using it.
>
>  
>
> I *think* it's VB code that this thing is written in if that matters...
>
>  
>
> When the error occurs a window appears with the title of "ERROR"  - how 
> convenient...   <g>
>
>  
>
> So - how do I query all the windows open on the system looking for one with 
> the title of "ERROR" ?
>
>   
I use the function below, which I got from the list somewhere.  You will 
need these declarations:

DECLARE INTEGER GetActiveWindow IN Win32API
DECLARE INTEGER GetWindow IN Win32API INTEGER nHwnd, INTEGER nFlag
DECLARE INTEGER GetWindowText IN Win32API INTEGER nHwnd, STRING @cText, 
INTEGER nMax

if chkrunning()
    do whatever
endif

Peter
*********************************************************
FUNCTION chkrunning
LOCAL nSafecounter,nWin1,lFound,cSrchTitle,cCurWinTitle,nLen
*-- set your search string for the window title
IF ps_standalone
   cSrchTitle = "Rajan X-Tra Offline"
ELSE
   cSrchTitle = "Rajan X-Tra Live"
ENDIF
nLen=LEN(cSrchTitle)
*-- get a starting point window ref
nWin1 = GetActiveWindow()
*--   An assumption here is that after calling GetWindow with a flag of 
2 (to get 'next'
*-- window), eventually the call will return a 0. In other words, the 
call will not
*-- 'loop' around to the original window handle. For now, there is a 
safety catch of
*-- calling the GetWindow API only 300 times, max.
lFound = .F.
nSafecounter=0
DO WHILE NOT EMPTY(nWin1) AND nSafeCounter < 300 AND lFound=.f.
        IF NOT EMPTY(nWin1)
                cCurWinTitle = SPACE(200) + CHR(0)
                nTitleLen = GetWindowText(nWin1, @cCurWinTitle, 200)
                IF Left(cCurWinTitle,nLen) = cSrchTitle
                        lFound = .T.
                ELSE
                        *nWin1 = GetWindow(nWin1, nFlag)
                        nWin1 = GetWindow(nWin1, 2)
                ENDIF
        ENDIF
        nSafeCounter = nSafeCounter + 1
ENDDO

RETURN lFound



----------------------------------------------------------------------------------------

This communication and the information it contains is intended for the person 
or organisation to whom it is addressed.Its contents are confidential and may 
be protected in law.  Unauthorised use, copying or disclosure of any of it may 
be unlawful.If you have received this message in error, please notify us 
immediately by telephone or email.


While Rajan Imports has taken every reasonable precaution to minimise the risk 
of virus transmission through email, we cannot accept liability for any damage 
which you sustain as a result of software viruses. 
It is the responsibility of the recipient to ensure that they have adequate 
virus protection.

www.rajan-group.co.uk

Rajan Imports Ltd
Head Office:61 Great Ducie Street, Manchester M3 1RR. Tel:0161 831 3700 
Fax:0161 831 3715 

London Office:17-19 Foley Street, London  W1W 6DW Tel:0207 299 7960



_______________________________________________
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