$No_Borland
$Noini
$No_LCCWin
$No_VKKeys
Gui "SwatchWndClass", Pixels
Enum
IDC_START_PAUSE = 101
IDC_RESET
IDC_TIME_LABEL
IDC_TIME_FIELD
IDT_UPDATE_TIMER = 200
End Enum
Global As Control MainForm, StartPauseButton, ResetButton, TimeLabel, TimeField
Global Running As Bool
Global Elapsed#, Start#
Global tix_started As Bool ' Added by MrBcx
Sub Formload
MainForm = Bcx_Form("Swatch", 0, 0, 400, 200)
StartPauseButton = Bcx_Button("&Start", MainForm, IDC_START_PAUSE, 5, 5, 50, 50)
ResetButton = Bcx_Button("&Reset", MainForm, IDC_RESET, 5, 100, 50, 50)
EnableWindow(ResetButton, False)
TimeLabel = Bcx_Label("Time &elapsed", MainForm, IDC_TIME_LABEL, 100, 5, 230, 30)
TimeField = Bcx_Input(GetElapsed$(), MainForm, IDC_TIME_FIELD, 100, 35, 230, 40, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_READONLY)
Center(MainForm)
Show(MainForm)
SetFocus(StartPauseButton)
End Sub
Begin Events
Select Case Cbmsg
Case WM_SETFOCUS
Global As HWND hPrevFocus, hFocusedCtrl
If hPrevFocus Then
SetFocus(hPrevFocus)
hPrevFocus = 0
End If
Exit Function
Case WM_KILLFOCUS
hFocusedCtrl = GetFocus()
Exit Function
Case WM_ACTIVATEAPP
If Cbwparam = 0 Then
hFocusedCtrl = GetFocus()
Else
If hFocusedCtrl Then
hPrevFocus = hFocusedCtrl
SetFocus(hFocusedCtrl)
hFocusedCtrl = NULL
End If
End If
Exit Function
Case WM_QUIT, WM_CLOSE
PostQuitMessage(0)
Exit Function
Case WM_COMMAND
Select Case Cbctl
Case IDC_START_PAUSE
If Running Then
Elapsed# = Elapsed# + (Tix_Now - Start#)
KillTimer(MainForm, IDT_UPDATE_TIMER)
SetWindowText(StartPauseButton, "&Resume")
Else
If tix_started = False Then ' Added by MrBcx
Tix_Start ' Added by MrBcx
tix_started = True ' Added by MrBcx
End If ' Added by MrBcx
Start# = Tix_Now
SetWindowText(StartPauseButton, "&Pause")
SetTimer(MainForm, IDT_UPDATE_TIMER, 1000, NULL)
End If
Running = Not Running
EnableWindow(ResetButton, True)
Case IDC_RESET
Elapsed# = 0
KillTimer(MainForm, IDT_UPDATE_TIMER) ' Added by MrBcx
EnableWindow(ResetButton, False) ' Added by MrBcx
SetWindowText(StartPauseButton, "&Start")
SetWindowText(TimeField, "") ' Added by MrBcx
UpdateWindow(TimeField) ' Added by MrBcx
SetFocus(StartPauseButton)
Running = False
End Select
Case WM_TIMER
If Running Then
'MrBcx says -- Do not change Elapsed# here!
SetWindowText(TimeField, GetElapsed$())
End If
End Select
End Events
Function GetElapsed$()
Local Total#, Seconds, Minutes, Hours, Days, Res$
If Running Then
Total# = Elapsed# + (Tix_Now - Start#)
Else
Total# = Elapsed#
End If
If Total# < 1000 Then Function = "0 seconds"
Seconds = Total# / 1000
Minutes = Seconds / 60
Seconds = Seconds % 60
Hours = Minutes / 60
Minutes = Minutes % 60
Days = Hours / 24
Hours = Hours % 24
Days = Round(Days, 2)
If Days > 0 Then Res$ += Str$(Days, 1) + " " + Iif$(Days = 1, "day", "days") + ", "
If Hours > 0 Then Res$ += Str$(Hours , 1) + " " + Iif$(Hours = 1, "hour", "hours") + ", "
If Minutes > 0 Then Res$ += Str$(Minutes, 1) + " " + Iif$(Minutes = 1, "minute", "minutes") + ", "
If Seconds > 0 Then Res$ += Str$(Seconds, 1) + " " + Iif$(Seconds = 1, "second", "seconds") + ", "
Function = Left$(Res$, Len(Res$) - 2)
End Function
$No_Borland
$Noini
$No_LCCWin
$No_VKKeys
Gui "SwatchWndClass", Pixels
Enum
IDC_START_PAUSE = 101
IDC_RESET
IDC_TIME_LABEL
IDC_TIME_FIELD
IDT_UPDATE_TIMER = 200
End Enum
Global As Control MainForm, StartPauseButton, ResetButton, TimeLabel, TimeField
Global Running As Bool
Global Elapsed#, Start#
Sub Formload
MainForm = Bcx_Form("Swatch")
StartPauseButton = Bcx_Button("&Start", MainForm, IDC_START_PAUSE, 5, 5, 50, 50)
ResetButton = Bcx_Button("&Reset", MainForm, IDC_RESET, 5, 100, 50, 50)
EnableWindow(ResetButton, False)
TimeLabel = Bcx_Label("Time &elapsed", MainForm, IDC_TIME_LABEL, 200, 5, 30, 5)
TimeField = Bcx_Input(GetElapsed$(), MainForm, IDC_TIME_FIELD, 200, 15, 200, 40, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_READONLY)
Center(MainForm)
Show(MainForm)
SetFocus(StartPauseButton)
End Sub
Begin Events
Select Case Cbmsg
Case WM_SETFOCUS
Global As HWND hPrevFocus, hFocusedCtrl
If hPrevFocus Then
SetFocus(hPrevFocus)
hPrevFocus = 0
End If
Exit Function
Case WM_KILLFOCUS
hFocusedCtrl = GetFocus()
Exit Function
Case WM_ACTIVATEAPP
If Cbwparam = 0 Then
hFocusedCtrl = GetFocus()
Else
If hFocusedCtrl Then
hPrevFocus = hFocusedCtrl
SetFocus(hFocusedCtrl)
hFocusedCtrl = NULL
End If
End If
Exit Function
Case WM_QUIT, WM_CLOSE
PostQuitMessage(0)
Exit Function
Case WM_COMMAND
Select Case Cbctl
Case IDC_START_PAUSE
If Running Then
Elapsed# = Elapsed# + (Tix_Now - Start#)
KillTimer(MainForm, IDT_UPDATE_TIMER)
SetWindowText(StartPauseButton, "&Resume")
Else
Tix_Start
Start# = Tix_Now
SetWindowText(StartPauseButton, "&Pause")
SetTimer(MainForm, IDT_UPDATE_TIMER, 1000, NULL)
End If
Running = Not Running
EnableWindow(ResetButton, True)
Case IDC_RESET
Elapsed# = 0
EnableWindow(ResetButton, False)
SetWindowText(StartPauseButton, "&Start")
SetFocus(StartPauseButton)
End Select
Case WM_TIMER
If Running Then
Elapsed# = Tix_Now
SetWindowText(TimeField, GetElapsed$())
End If
End Select
End Events
Function GetElapsed$()
Local Total#, Seconds, Minutes, Hours, Days, Res$
If Running Then
Total# = Elapsed# + (Tix_Now - Start#)
Else
Total# = Elapsed#
End If
If Total# < 1000 Then Function = "0 seconds"
Seconds = Total# / 1000
Minutes = Seconds / 60
Seconds = Seconds % 60
Hours = Minutes / 60
Minutes = Minutes % 60
Days = Hours / 24
Hours = Hours % 24
Days = Round(Days, 2)
If Days > 0 Then Res$ += Str$(Days, 1) + " " + Iif$(Days = 1, "day", "days") + ", "
If Hours > 0 Then Res$ += Str$(Hours , 1) + " " + Iif$(Hours = 1, "hour", "hours") + ", "
If Minutes > 0 Then Res$ += Str$(Minutes, 1) + " " + Iif$(Minutes = 1, "minute", "minutes") + ", "
If Seconds > 0 Then Res$ += Str$(Seconds, 1) + " " + Iif$(Seconds = 1, "second", "seconds") + ", "
Function = Left$(Res$, Len(Res$) - 2)
End Function
Quote from: MrBcx on May 08, 2025, 01:24:03 PMI fully agree, and my intention wasn't to speak negatively about Pelle as a project maintainer, or anything of the sort. I was simply highlighting that Robert's incredible dedication and skill are rare to come by, and that's why BCX has my favorite help file out of any productQuote from: Quin on May 08, 2025, 07:21:28 AM... Meanwhile, on the Pelles forums, I'm told Pelle is done with my suggestions after the table headers provided by another forum member looked ugly to him. Completely his prerogative, of course, PellesC is his baby and he is free to choose how his docs look, ...
In defense of Pelle, and speaking from personal experience, being interested in coding does not dispose one to an interest in technical writing (documentation). 25 years ago, I was the chief, cook, and bottle washer for the infant BCX project. I wrote the first codes, revision log, help files, and setup and administered the first websites and forums. Plus, I had a full time job, a career, and a family to support. Soon after, I started incorporating codes from BCX users, maintained the revision log, and watched BCX mature. Oh yeah, and testing -- lots of testing. All those things required a lot of time and effort. Until one walks in the shoes of others ...
I was never more grateful than when Robert volunteered to take over the maintenance of BCX Help. To this day, we all benefit from Robert's generosity. The fact that Robert has, and continues to provide updates that benefit sight impaired BCX users is an extremely rare gift indeed.
DIM AS DOUBLE Random
DIM AS DOUBLE TheSeed
DIM AS INTEGER i, j
TheSeed = CryptoSeed()
PUSHCOLORS
CLS
COLOR 2, 0 : LOCATE 12, 25, 0
INPUT "Hit [Enter] to see a sample", i : COLOR 7, 0
CLS
RANDOMIZE(TheSeed)
FOR i = 1 TO 23
FOR j = 1 TO 70 STEP 20
Random = RND
LOCATE i, j, 0
COLOR MOD(i, 4.0) + 10, 0
PRINT Random
NEXT
NEXT
LOCATE i, j
COLOR 7, j
FUNCTION CryptoSeed AS DOUBLE
STATIC AS HCRYPTPROV hProv
STATIC AS INTEGER isInit
DIM AS UINT n
DIM AS INTEGER ok
IF isInit = 0 THEN
ok = CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)
IF ok = FALSE THEN FUNCTION = -1
isInit = 1
END IF
' Cast &n to BYTE* so it works with CryptGenRandom
ok = CryptGenRandom(hProv, SIZEOF(n), (BYTE*)&n)
IF ok = FALSE THEN FUNCTION = -1
FUNCTION = CAST(DOUBLE, n / 4294967296.0)
END FUNCTION
POPCOLORS
PAUSE
Quote from: Quin on May 08, 2025, 07:21:28 AM... Meanwhile, on the Pelles forums, I'm told Pelle is done with my suggestions after the table headers provided by another forum member looked ugly to him. Completely his prerogative, of course, PellesC is his baby and he is free to choose how his docs look, ...