Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #1253 > unrolled thread
| Started by | Guy Deprez <dpzguy@REMOVETHISskynet.be> |
|---|---|
| First post | 2011-06-05 19:38 +0200 |
| Last post | 2011-06-06 19:49 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
For TkTask class users... A TkTask:EndTask() method Guy Deprez <dpzguy@REMOVETHISskynet.be> - 2011-06-05 19:38 +0200
Re: For TkTask class users... A TkTask:EndTask() method "Willie Moore" <williem@wmconsulting.com> - 2011-06-06 06:58 -0500
Re: For TkTask class users... A TkTask:EndTask() method Carlos Rocha <carlos.rochaDELETETHIS@doossier.com> - 2011-06-06 17:25 +0100
Re: For TkTask class users... A TkTask:EndTask() method "Willie Moore" <williem@wmconsulting.com> - 2011-06-06 11:48 -0500
Re: For TkTask class users... A TkTask:EndTask() method Guy Deprez <dpzguy@REMOVETHISskynet.be> - 2011-06-06 19:49 +0200
| From | Guy Deprez <dpzguy@REMOVETHISskynet.be> |
|---|---|
| Date | 2011-06-05 19:38 +0200 |
| Subject | For TkTask class users... A TkTask:EndTask() method |
| Message-ID | <vbfnu6tgg0s4ci7n9e3pvintkoiurnjm44@4ax.com> |
Advices or better suggestions are wellcome but here the code i'm using
to stop an application started using the TkTask class..
Guy
--------------------
METHOD EndTask() AS VOID PASCAL CLASS TKTask
/*
---> Lorque l'opération est commandée de l'extérieur
---> How to use it?
oTkTask:EndTask()
if ! oTkTask:StillRunning
oTkTask := NULL_OBJECT
endif
*/
LOCAL hWnd AS PTR
LOCAL aThreadWindows,aTopLevelWins AS ARRAY
LOCAL dw,dwLen,dwPos AS DWORD
aThreadWindows := GetAllThreadWindows(SELF:ThreadId)
aTopLevelWins := GetAllTopLevelWindows()
dwLen := ALen(aThreadWindows)
FOR dw:=1 UPTO dwLen
hWnd:= ArrayGet(aThreadWindows,dw)
//Is the "top level" window visible and does it have a caption?
IF IsWindowVisible( hWnd) .and. !Empty(GetWindowCaption(
hWnd))
dwPos:= AScanExact(aTopLevelWins,hWnd)
IF dwPos > 0
dw:=dwLen+1
ENDIF
ENDIF
NEXT
IF hwnd != NULL_PTR
PostMessage(hWnd,WM_CLOSE,0,0 ) //WM_QUIT,0,0)
ELSE
//Info to say that the task is still running...
ENDIF
----------------------
FUNCTION GetAllThreadWindows(dwThreadID AS DWORD) AS ARRAY PASCAL
/*
The EnumThreadWindows function enumerates all nonchild windows
associated with a thread by passing the handle of each window, in
turn,
to an application-defined callback function.
EnumThreadWindows continues until the last window is enumerated or the
callback function returns FALSE.
To enumerate child windows of a particular window, use the
EnumChildWindows function.
This function supersedes the EnumTaskWindows function.
*/
LOCAL aWindows AS ARRAY
LOCAL ptrCallBackFunction AS AddWindowToArray PTR
aWindows:= ArrayCreate(0)
ptrCallBackFunction := @AddWindowToArray()
EnumThreadWindows(dwThreadID,ptrCallBackFunction,LONGINT(_CAST,aWindows))
/*
--> ==
EnumThreadWindows(dwThread,@AddTopLevelWindowToArray(),LONGINT(_CAST,aWindows))
*/
RETURN aWindows
FUNCTION GetAllTopLevelWindows() AS ARRAY PASCAL
/*
EnumWindows() is a Windows API function, not a VO one, and it calls an
application defined callback function for ALL TOP LEVEL WINDOWS ON THE
SCREEN.
*/
LOCAL aWindows AS ARRAY
LOCAL ptrCallBackFunction AS AddWindowToArray PTR
aWindows:= ArrayCreate(0)
ptrCallBackFunction := @AddWindowToArray()
EnumWindows(ptrCallBackFunction,LONGINT(_CAST,aWindows))
/*
--> ==
EnumWindows(@AddTopLevelWindowToArray(),LONGINT(_CAST,aWindows))
*/
RETURN aWindows
STATIC FUNCTION AddWindowToArray(hWnd AS PTR,aWindows AS ARRAY) AS
WORD CALLBACK
AAdd(aWindows,hWnd)
RETURN 1
--------------------
FUNCTION GetAllTopWindowsCaptions() AS ARRAY PASCAL
LOCAL aWinNames AS ARRAY
aWinNames := GetAllTopLevelWindows()
AEvalA(aWinNames,{|hwnd|GetWindowCaption(hwnd)})
RETURN aWinNames
FUNCTION GetWindowCaption(hWindow AS PTR) AS STRING
LOCAL pCaption AS PSZ
LOCAL cCaption AS STRING
pCaption := MemAlloc(1024)
GetWindowText(hWindow,pCaption,1024)
cCaption := Psz2String(pCaption)
MemFree(pCaption)
RETURN AllTrim(cCaption)
[toc] | [next] | [standalone]
| From | "Willie Moore" <williem@wmconsulting.com> |
|---|---|
| Date | 2011-06-06 06:58 -0500 |
| Message-ID | <isifcc$vsd$1@speranza.aioe.org> |
| In reply to | #1253 |
Guy, Thanks for posting! Regards, Willie
[toc] | [prev] | [next] | [standalone]
| From | Carlos Rocha <carlos.rochaDELETETHIS@doossier.com> |
|---|---|
| Date | 2011-06-06 17:25 +0100 |
| Message-ID | <4decff9c$0$9700$a729d347@news.telepac.pt> |
| In reply to | #1253 |
What is TkTask? -- Carlos Rocha --- avast! Antivirus: mensagem Enviada limpa. Base de Dados de virus (VPS): 110606-0, 06-06-2011 Testada a: 06-06-2011 17:25:10 avast! - copyright (c) 1988-2011 AVAST Software. http://www.avast.com
[toc] | [prev] | [next] | [standalone]
| From | "Willie Moore" <williem@wmconsulting.com> |
|---|---|
| Date | 2011-06-06 11:48 -0500 |
| Message-ID | <isj0cm$ivn$1@speranza.aioe.org> |
| In reply to | #1261 |
Carlos, TKTask is a high level class that you can use to start another process without having to know all of the details. Regards, Willie "Carlos Rocha" wrote in message news:4decff9c$0$9700$a729d347@news.telepac.pt... What is TkTask? -- Carlos Rocha --- avast! Antivirus: mensagem Enviada limpa. Base de Dados de virus (VPS): 110606-0, 06-06-2011 Testada a: 06-06-2011 17:25:10 avast! - copyright (c) 1988-2011 AVAST Software. http://www.avast.com
[toc] | [prev] | [next] | [standalone]
| From | Guy Deprez <dpzguy@REMOVETHISskynet.be> |
|---|---|
| Date | 2011-06-06 19:49 +0200 |
| Message-ID | <og4qu6p5vbqafjl1vctfq02lru2d1ornnu@4ax.com> |
| In reply to | #1261 |
On Mon, 06 Jun 2011 17:25:10 +0100, Carlos Rocha <carlos.rochaDELETETHIS@doossier.com> wrote: >What is TkTask? Carlos You can find this class in the VO25Lib. You can find it here: http://www.mmnt.net/db/0/0/ftp.grafxsoft.com/VO25patches Guy
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web