Hi John
I want to prevent the form from being re-opened, but bring the form to
the top so to the employee it appears that they have opened it.
The Windows API does not work here as checking for open windows only
works with top level forms. I.e. calling
Function IsRunning
Lparameter tcTitle && all or part of the
app's window title
* Generic routine to check if a given application is running on the
user's system
Local hNext As Number, cText As Character
hNext = GetActiveWindow() && current app's window
* iterate through the open windows
Do While hNext<>0
cText = Replicate(Chr(0),80)
GetWindowText(hNext,@cText,80) && get window
title
If Upper(Alltrim(tcTitle)) $ Upper(cText)
* parameter text is present in window title
Return hNext
Endif
hNext = GetWindow(hNext,2) && next window
Enddo
* required window not found
Return 0
Endfunc
From
Local lnHand
Declare Integer BringWindowToTop In Win32API INTEGER HWnd
Declare Integer GetActiveWindow IN Win32API
Declare Integer GetWindow In Win32API INTEGER HWnd, Integer nType
Declare Integer GetWindowText In Win32API INTEGER HWnd, String @cText,
Integer nType
lnHand = IsRunning("Application Name")
If lnHand # 0
BringWindowToTop(lnHand)
Return To Master
Endif
Doesn't find forms on the FoxPro desktop. Anyway I am having trouble to
get code round the command to open the form to work.
Define Class myclass As Session OlePublic
Implements Ialertevents In "vfpalert.AlertEvents"
Procedure Ialertevents_AlertResult(tnResult As Number) As Number
Local lnCount As Number, lcRunningForm As Character,
llAlreadyOpen As Logical
For lnCount = 1 To _Screen.FormCount
lcRunningForm = _Screen.Forms(lnCount).Caption
If lcRunningForm = "Send Message"
llAlreadyOpen = .T.
EndIf
EndFor
If !llAlreadyOpen
Do Form frmSendMessage.scx
EndIf
Endproc
Enddefine
Doesn't work as I would expect
Cheers
Peter
On Behalf Of John Weller
Sent: 09 September 2009 10:45
Hi Peter,
Do you want to prevent the form from re-opening or close the open form?
I
have to say I don't know how to do this myself but have read posts here
that
mention the technique. When the alert happens check if that form is
already
open using an API call then ask the user if they want to close it. If
they
don't then perhaps you should open a new form so they have both messages
open.
HTH
John
John Weller
_______________________________________________
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/a57fa4cf19531343a2ee11b57db8e3af04c...@server.peterhartcomputers.local
** 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.