May 04, 2024, 05:19:49 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Changing colors on a static control

Started by billhsln, June 28, 2023, 09:16:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

billhsln

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
When all else fails, get a bigger hammer.

Brian

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

billhsln

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
When all else fails, get a bigger hammer.

billhsln

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
When all else fails, get a bigger hammer.

billhsln

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
When all else fails, get a bigger hammer.