But how to activate it insite the program ?
I cropped a sample to run. If you create a text file "test.dat" in the sample folder and put some data into it like " 00320123456789"
then the sample while popup a simple msg. If you remove the test.dat file, the program keeps listening until you put it back (this process of deleting the file and put it back is automated, but not in this sample)
It is used to popup a customed dialog when a phonecall is coming in. Afther the call the msg will be deleted and the program keeps on checking for the file.
I do want to activate the program with a HOT-key like ctrl-Y of ctrl-T.
here the sample
- Code: Select all Expand view
#include "fivewin.ch"
FUNCTION MAIN()
LOCAL oMain, oTimer, oButton, oStr1, oFont1, aGrad, oBtn, oMenu
//SetKey( K_ALT_T, { || MyFunction() } )
//SETKEY(ASC("Y"), {|| IIF(GetKeyState(VK_CONTROL), EVAL( {|| MyFunction (oTimer,oMain) } ), NIL) } )
SETKEY(ASC("Y"), {|| IIF(GetKeyState(VK_CONTROL), EVAL( {|| oMain:show() } ), NIL) } )
DEFINE WINDOW oMain FROM 150 , 150 TO 500 , 500 PIXEL
DEFINE TIMER oTimer OF oMain INTERVAL 1000 ACTION ( Listen( oTimer,oMain ) )
DEFINE BUTTONBAR oBar OF oMain _3D SIZE 64,64 2007
// say no where needed
@ 7 , 5 SAY oStr1 PROMPT "Not Needed Say" OF oMain
// use the HIDDEN so it's working in the background
ACTIVATE WINDOW oMain HIDDEN ON INIT ( OTimer:Activate() )
//ACTIVATE WINDOW oMain ON INIT ( OTimer:Activate() )
RELEASE TIMER oTimer
RETURN NIL
FUNCTION Listen( oTimer,oMain )
LOCAL cFile := "test.dat"
LOCAL cString := ""
oTimer:deactivate()
IF FILE( cFile ) .and. len(MEMOREAD( cFile )) > 2
cString := MEMOREAD( cFile )
msginfo(cString)
//ShowcustData()
ENDIF
oTimer:activate()
RETURN NIL
//-------------------------------------------
function MyFunction(oTimer,oMain)
oTimer:deactivate()
msginfo("Test")
oTimer:activate()
return NIL
//-------------------------------------------