WinX and timer function

171 views
Skip to first unread message

Gary Sarela

unread,
Apr 29, 2025, 1:44:06 PMApr 29
to xblite
Hi Guy,

I upgraded to the 2022-10-13 version of WinX found at SourceForge and ran 'MakeWinXLib.bat'. My programs can now work with the latest WinX, but I've noticed an issue:

When my WinX program window loses focus, the timer function stops running! I start my timer with the following code and want it to keep running always, regardless of window focus.

XstStartTimer (@timer1, 1, 1000, &Timer())  ' In Entry() function

FUNCTION  Timer (timer, count, msec, time)
  count=1
  PRINT time
END FUNCTION

Older WinX versions allow the timer to run uninterrupted. How can I make that happen with this latest version?

Regards,
Gary

Guy Lonne

unread,
Apr 29, 2025, 5:02:03 PMApr 29
to xbl...@googlegroups.com
Hi Gary.

Welcome to the list.

Please attach the code that does not work with WinX.dll within a
compilable stub, and I'll debug it ASAP on my computer.

Bye! Guy

Gary Sarela

unread,
Apr 29, 2025, 6:59:14 PMApr 29
to xblite
I wrote a small program called TimerExample.x to show the issue. I would have preferred to attach it, but I'm not sure I have that ability.


' ####################
' #####  PROLOG  #####
' ####################
VERSION "1.00"

IMPORT "kernel32" ' operating system
IMPORT "gdi32"    ' Graphic Device Interface
IMPORT "shell32"  ' interface to the operating system
IMPORT "user32"   ' Windows management
IMPORT "comctl32" ' common controls (for the styles)
IMPORT "xst_s"    ' xblite Standard Library
IMPORT "xsx_s"    ' xblite Extended Standard Library
IMPORT "xio_s"    ' console
IMPORT "xma_s"    ' math library (needed by WinX_s.lib)
IMPORT "WinX_s"   ' Callum Lowcay's Windows GUI library
IMPORT "adt_s"

$$PB1 = 100

DECLARE FUNCTION Entry ()
DECLARE FUNCTION initWindow ()
DECLARE FUNCTION Timer (timer, count, msec, time)
DECLARE FUNCTION onClose (hWnd)

FUNCTION Entry ()
IF WinX() THEN QUIT(0)
IF initWindow () THEN QUIT(0)
'XioCreateConsole (title$, 30): cWnd = XioGetConsoleWindow (): MoveWindow (cWnd, 900, 300, 400, 500, $$TRUE)

XstStartTimer (@timer1, 1, 1000, &Timer())
WinXDoEvents(0)
WinXCleanUp ()
XioFreeConsole ()
QUIT (0)
END FUNCTION

FUNCTION initWindow ()
SHARED LOGFONT logFont
ACCEL accel[]
#hMain = WinXNewWindow (0, "TIMER", 500, 300, 390, 280, $$XWSS_APPNORESIZE, 0, 1, 0)
logFont = WinXDraw_MakeLogFont ("Arial", 30, $$FONT_BOLD|$$FONT_ITALIC)
#hFont = CreateFontIndirectA (&logFont)
logFont = WinXDraw_MakeLogFont ("Arial", 19, $$FONT_ITALIC)
#hFont2 = CreateFontIndirectA (&logFont)
WinXDrawText (#hMain, #hFont, "Timer Example", 20, 10, $$TRUE, $$Black)
WinXDrawText (#hMain, #hFont2, "Timer stops working when window focus is lost!", 20, 40, $$TRUE, $$Black)
XstGetDateAndTimeFormatted (0, 13, @date$, 9, @time$): time$=LEFT$(time$,11)
#PB1=WinXAddButton (#hMain, time$, 0, $$PB1): MoveWindow (#PB1, 80, 120, 200, 40, 0)
SendMessageA (#PB1, $$WM_SETFONT, #hFont, $$TRUE)
WinXRegOnClose (#hMain, &onClose())
WinXEnableDialogInterface(#hMain, $$TRUE)
WinXDisplay (#hMain)
RETURN 0
END FUNCTION


FUNCTION Timer (timer, count, msec, time)
count=1
XstGetDateAndTimeFormatted (0, 12, @date$, 9, @time$): time$=LEFT$(time$,11)
WinXSetText (GetDlgItem(#hMain, $$PB1), time$)
PRINT time
END FUNCTION

FUNCTION onClose (hWnd)
QUIT(0)
END FUNCTION

END PROGRAM

Guy Lonne

unread,
May 5, 2025, 8:27:31 PMMay 5
to xbl...@googlegroups.com

Hi Gary!

I found the source of the problem with the timer demo program:
    the static libraries cause the timer to sleep when its owner window loses focus.

        So, forget WinX_s.lib and co. and use WinX.dll instead!

To help you to fix the timer problem, I attached WinX.zip file, which contains all what you need:

  • "timer.x": a fixed demo to load into XSED.

A tiny script to refresh your WinX dev. environment with:

  • "deploy_WinX.txt": copies in the right folders WinX.dec, WinX.lib, and WinX.dll.

            Run deploy_WinX.txt before any compile.
(Well, not right out of the box: you have to change its extension to DOS batch file)

  • WinX.dec, WinX.lib, and WinX.dll: to compile, link, and run in XSED

As a bonus,  I added the static version of WinX:

  • WinX_s.dec and WinX_s.lib

 but...I never use static libraries in my programs (They are also installed by "deploy_WinX.**t").

Let me know if this solves the timer bug; in the mean time: Happy Xbliting.

-- 
Bye! Guy
--
You received this message because you are subscribed to the Google Groups "xblite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xblite+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/xblite/bcb2e2e0-75b1-4923-9aac-cad0428a7b65n%40googlegroups.com.
-- 
Bye! Guy

Gary Sarela

unread,
May 5, 2025, 11:34:34 PMMay 5
to xblite
Hi Guy,

Thank you. I appreciate your help. Is WinX.zip attached to your last message?

Gary

Guy Lonne

unread,
May 6, 2025, 5:05:26 AMMay 6
to xbl...@googlegroups.com
Hi Gary!

%*§! ('scuse my French): I did attach WinX.zip in my e-mail, but it was
stripped off!?

Let's try again in 2 steps.

Step #1: the install script:
____________________________________________________________________________
rem copy *.dec
copy .\WinX.dec C:\xblite\include\
copy .\WinX_s.dec C:\xblite\include\

rem copy *.lib
copy .\WinX.lib C:\xblite\lib\
copy .\WinX_s.lib C:\xblite\lib\

rem copy WinX.dll
copy .\WinX.dll C:\xblite\programs\

pause
_______________________________________________________________________________

Guy Lonne

unread,
May 6, 2025, 5:16:32 AMMay 6
to xbl...@googlegroups.com
Hi Gary.

I don't know if it is related to my attemps to send an attachment thru
the Google Group, but my Google e-mail is stating to behave strangely...

Here is another way: just use the dynamic WinX: that'll do the job! Do
you need help for that fix?

Keep me informed, please: it's a new situation for me.

Bye! Guy

Le 06/05/2025 à 05:34, Gary Sarela a écrit :

Gary Sarela

unread,
May 6, 2025, 9:49:44 AMMay 6
to xblite
Hi Guy,

So far, no luck. I followed your instructions and then changed the line to IMPORT "WinX" instead of "WinX_s". My timer still stops when the program window doesn't have focus. My WinX version is: 
VERSION "0.6.0.4" ' GL-10oct22

Gary
Message has been deleted

Gary Sarela

unread,
May 12, 2025, 7:15:32 AMMay 12
to xblite
Hi Guy,

I fixed the timer issue by modifying WinXDoEvents() in WinX.x code:

FUNCTION WinXDoEvents (passed_accel)
  .
  .
      CASE ELSE
        ' deal with window messages
        hWnd = GetActiveWindow ()
'IFZ hWnd THEN DO DO    'fail         <-- *** Comment out, or delete this line ***

TimerExample.x works properly now and this also fixed some window redraw issues as well.

Regards,
Gary

Guy Lonne

unread,
May 12, 2025, 4:09:04 PMMay 12
to xbl...@googlegroups.com

Hi Gary!

I'm glad you solved your TIMER problem, but I'm skeptical about your solution.

Especially because I noticed a deprecated version of the WinXDoEvents function.

Indeed, I experimented passing the handle of an accelerator table to use as a default: "FUNCTION WinXDoEvents (passed_accel)".

10 years ago, it seemed to me like a good idea to pass an accelerator table to the event loop, but in fact, it was not.

Regarding the TIMER control, I never experienced any problems with it.

I'll make a quick check of your fix on my PC to see if it has any impact on my own setup.

Bye! Guy

Guy Lonne

unread,
May 12, 2025, 4:23:14 PMMay 12
to xbl...@googlegroups.com
Hi Gary,

Sorry, but I will be away for 2 months, so I won't be able to follow up
with you.

To address your bug report on the TIMER demo, I updated WinX in
SourceForge and GitHub with the latest version on my PC.

I suggest that you put aside your WinX.x, download a fresh WinX.x from
SourceForge as you did in the past, and recompile it in your PC.

I can't figure out how you got an obsolete version of WinX.x. (a ghost
from the past?)

Bye! Guy

Gary Sarela

unread,
May 12, 2025, 8:57:43 PMMay 12
to xblite
Hi Guy,

I think WinX is a really useful library for the XBLite project and I can see you're working on improving it, so I will be patient. Right now, the older version is fine for my purposes.

Kind Regards,
Gary

Gary Sarela

unread,
May 13, 2025, 10:36:23 PMMay 13
to xblite
Hi Guy,

Sorry to bother you again. I have something worth mentioning.

The latest WinX version allows compiling with  IMPORT "WinX", but not  IMPORT "WinX_s".

In WinX.x code the function name "LinkedList_Init" itself is to blame.

I renamed the function name which is found in 3 places (twice in comments) with "LinkedList_Initialize" and now WinX programs can successfully use the line  IMPORT "WinX_s".

Gary

Guy LONNE

unread,
May 14, 2025, 8:36:23 PMMay 14
to xbl...@googlegroups.com
Good news! Keep track of any glitch and problem you had to deal with, as you are the second user of WinX that has given me a feedback. Thank you, little Grasshopper!

Bye! Guy

--
You received this message because you are subscribed to the Google Groups "xblite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xblite+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages