largo_winch
10-01-2013, 20:20
here's a simple dialog with colour switching for background. Only the "mod" problem change for three time background, but perhaps anybody can fix this little problem. bye, largo
' Empty GUI script created on 01-10-2013 17:57:34 by (thinAir)
Uses "UI"
%ID_TIMER = 1000
Function TBMain() As Long
Local lRslt As Long
Local hDlg As DWord
Dialog New 0, "Switching Color Background", -1, -1, 260, 140, _
%WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPCHILDREN Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_MINIMIZEBOX, _
0 To hDlg
Dialog Show Modal hDlg, Call myColorProc
End Function
Function ChangeColor(ByVal hDlg As Long) As Long
Static static_counter As Double
Incr static_counter
If static_counter = Mod(1,2) Then 'Mod 2 = 0
Dialog Set Color hDlg, -1, %BLUE
Else
Dialog Set Color hDlg, -1, %RED
End If
Dialog Redraw hDlg
End Function
CallBack Function myColorProc()
Select Case CBMSG
Case %WM_INITDIALOG
Dialog Set Timer CBHNDL, %ID_Timer, 1000, 0
Case %WM_COMMAND
Case %WM_TIMER
ChangeColor(CBHNDL)
Case %WM_DESTROY
Function = 0
Dialog Kill Timer CBHNDL, %ID_TIMER
End Select
End Function
' Empty GUI script created on 01-10-2013 17:57:34 by (thinAir)
Uses "UI"
%ID_TIMER = 1000
Function TBMain() As Long
Local lRslt As Long
Local hDlg As DWord
Dialog New 0, "Switching Color Background", -1, -1, 260, 140, _
%WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPCHILDREN Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_MINIMIZEBOX, _
0 To hDlg
Dialog Show Modal hDlg, Call myColorProc
End Function
Function ChangeColor(ByVal hDlg As Long) As Long
Static static_counter As Double
Incr static_counter
If static_counter = Mod(1,2) Then 'Mod 2 = 0
Dialog Set Color hDlg, -1, %BLUE
Else
Dialog Set Color hDlg, -1, %RED
End If
Dialog Redraw hDlg
End Function
CallBack Function myColorProc()
Select Case CBMSG
Case %WM_INITDIALOG
Dialog Set Timer CBHNDL, %ID_Timer, 1000, 0
Case %WM_COMMAND
Case %WM_TIMER
ChangeColor(CBHNDL)
Case %WM_DESTROY
Function = 0
Dialog Kill Timer CBHNDL, %ID_TIMER
End Select
End Function