Hi Enrico and friends
I am trying to put 3 TIMERs in the Message Bar of main window.
They are working OK. But when I leave the application window,
one of the timers I have dedfined is still appearing on the desktop.
And when I refresh the desktop, it is getting disappeared.
Based on the signal strength, I am calling different bitmap resources
and painting on the Message bar.
Below is my code.
Can you please point out where I am making mistake.
This is the image obtained from the following code.
Code: Select all
#include "FiveWin.ch"
STATIC oWnd, oFont, oTimer1, oTimer2, oTimer3
STATIC objSMS, oProvider, oNSignalStrength, oSignalStrength
//----------------------------------------------------------------------------//
FUNCTION Main()
* Serial Port Properties
oSMS := CreateObject("BulkSMS.Sender")
oSMS:BaudRate := 9600
oSMS:COMPort := "COM1"
oSMS:DataBits := 8
oSMS:Parity := "N"
oSMS:StopBits := "1"
oSMS:FlowControl := 0
oSMS:OpenCOMPort()
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -9
DEFINE WINDOW oWnd TITLE "Timer Testing"
SET MESSAGE OF oWnd TO "Signal Test" ;
KEYBOARD CLOCK DATE 2007
DEFINE TIMER oTimer1 OF oWnd INTERVAL 400 ACTION GetProvider(oFont,1)
DEFINE TIMER oTimer2 OF oWnd INTERVAL 400 ACTION GetProvider(oFont,2)
DEFINE TIMER oTimer3 OF oWnd INTERVAL 400 ACTION GetProvider(oFont,3)
WndCenter(oWnd:hWnd)
ACTIVATE WINDOW oWnd ON INIT (oTimer1:hWndOwner := oWnd:oMsgBar:hWnd, ;
oTimer1:Activate(), ;
oTimer2:hWndOwner := oWnd:oMsgBar:hWnd, ;
oTimer2:Activate(), ;
oTimer3:hWndOwner := oWnd:oMsgBar:hWnd, ;
oTimer3:Activate()) ;
VALID (DeleteObject( oSignalStrength:hBitmap1 ), .T.)
objSMS:CloseCOMPort()
RELEASE TIMER oTimer1
RELEASE TIMER oTimer2
RELEASE TIMER oTimer3
RETURN nil
**********
FUNCTION GetProvider(oFont, nOpt)
LOCAL cNewResource
DO CASE
CASE nOpt = 1
IF oProvider = nil
oProvider := TMsgItem():New( oWnd:oMsgBar, "SIM: "+objSMS:NetworkInfo,;
MAX(LEN("SIM: "+objSMS:NetworkInfo)*6.53,100),,nRGB(128,0,128),;
,.t.,,,, "Service+CRLF+Provider" )
ENDIF
CASE nOpt = 2
IF oNSignalStrength = nil
oNSignalStrength := TMsgItem():New( oWnd:oMsgBar, "SIGNAL:"+LTRIM(STR(objSMS:SignalStrength))+;
"%", 75, oFont,nRGB(0,111,0),,.t.,,,, "" )
oNSignalStrength:bMsg := {||"SIGNAL:"+LTRIM(STR(objSMS:SignalStrength))+"%"}
oNSignalStrength:lTimer := .T.
ENDIF
CASE nOpt = 3
IF oSignalStrength = nil
cNewResource := "SIGNAL"+LTRIM(STR(ROUND(objSMS:SignalStrength /10,0)*10))
oSignalStrength := TMsgItem():New( oWnd:oMsgBar,, 40, oFont,,,.t.,,cNewResource,, "" )
oSignalStrength:bMsg := {||GetSignalStrength()}
oSignalStrength:lTimer := .T.
ENDIF
ENDCASE
RETURN nil
**********
STATIC FUNCTION GetSignalStrength()
LOCAL cNewResource
IF VALTYPE(oSignalStrength) = "O"
DeleteObject( oSignalStrength:hBitmap1 )
cNewResource := "SIGNAL"+LTRIM(STR(ROUND(objSMS:SignalStrength/10,0)*10))
oSignalStrength:hBitmap1 := LoadBitmap( GetResources(), cNewResource )
oSignalStrength:Paint()
ENDIF
RETURN nil
**********