I am just changing the color on a static control from red to green and then back to red when the SQL query is completed. However, it stays red. I can't see anything I am doing wrong. Depending on my query it takes 6-8 seconds to run (lots of data).
CONTROL win,@STATIC,"DB Closed",1050,80,150,25,0,win_s_dbopen
SUB OpenCSB()
SETCONTROLTEXT(win,win_s_dbopen,"DB Open")
SETCONTROLCOLOR win,win_s_dbopen,green,GetSysColor(15)
IF pCSB=NULL THEN pCSB=DBCONNECT("SQL Server","","SERVER=BILLSLAPTOP;DATABASE=collinstreet;")
IF pCSB=NULL
mb=MESSAGEBOX win,"DB not available\nSerious Error","Problem",@MB_ICONQUESTION
CLOSEDIALOG win,@IDOK
SETCONTROLTEXT(win,win_s_dbopen,"DB Closed")
SETCONTROLCOLOR win,win_s_dbopen,red,GetSysColor(15)
ENDIF
RETURN
ENDSUB
SUB CloseCSB()
IF pCSB<>NULL THEN DBDISCONNECT(pCSB)
pCSB=NULL
SETCONTROLTEXT(win,win_s_dbopen,"DB Closed")
SETCONTROLCOLOR win,win_s_dbopen,red,GetSysColor(15)
RETURN
ENDSUB
Thanks,
Bill
Bill,
I did a little test, and it works here with the attached code. All I can think of is: Is the pointer pCSB actually NULL when the database is closed?
Brian
I do set it to NULL at the start of the program, so it should be. Let me try what you came up with and see what happens. It could just be an oddity.
Thanks,
Bill
Tested your sample, yours was a WINDOW, I was doing a DIALOG (I know, I did win). But the funny thing is yours did change from black to red when I changed the line from:
SETCONTROLCOLOR win,BUTTON1,RGB(255,0,0),GetSysColor(15)
to:
SETCONTROLCOLOR win,STATIC1,RGB(255,0,0),GetSysColor(15)
Weird!!
Thanks,
Bill
It turned out it was a sequence thing and I did DEF win: WINDOW so I changed that to DEF win: DIALOG and did:
SUB OpenCSB()
SETCONTROLCOLOR win,win_s_dbopen,green,GetSysColor(15)
SETCONTROLTEXT(win,win_s_dbopen,"DB Open")
IF pCSB=NULL THEN pCSB=DBCONNECT("SQL Server","","SERVER=BILLSLAPTOP;DATABASE=collinstreet;")
IF pCSB=NULL
mb=MESSAGEBOX win,"DB not available\nSerious Error","Problem",@MB_ICONQUESTION
CLOSEDIALOG win,@IDOK
ENDIF
RETURN
ENDSUB
SUB CloseCSB()
IF pCSB<>NULL THEN DBDISCONNECT(pCSB)
pCSB=NULL
SETCONTROLCOLOR win,win_s_dbopen,red,GetSysColor(15)
SETCONTROLTEXT(win,win_s_dbopen,"DB Closed")
RETURN
ENDSUB
Bill