The MASM Forum

Projects => ObjAsm => Topic started by: Biterider on August 25, 2022, 02:34:24 AM

Title: Simple Circular Activity Indicator
Post by: Biterider on August 25, 2022, 02:34:24 AM
Hi
"Simple Circular Activity Indicator" is a long name for something not that complicated. It's an indicator that shows ongoing activity but not progress, it's circular and not linear, and finally it's based on a single image rather than a series of images.
Windows 8 extended WS_EX_LAYERED to work with child windows, which was a big step for animations beyond popup windows. I combined this function (in combination with UpdateLayeredWindow) and created a world transformation to simultaneously rotate and scale a previously loaded .png with transparency. All this together with a variable blend factor gives a nice fade in/out effect. :cool:

All is implemented using the regular GDI API. The only exception is the loading of the .png, which was done using GDI++ for simplicity.

The demo application shows 2 of them overlapping and in different colors to show the transparency and active background change on one of the controls.
The demo runs the controls on the main thread, which can be very easily changed as needed.

Attached is the binary of the demo. The source is available on GitHub.

Biterider
Title: Re: Simple Circular Activity Indicator
Post by: fearless on August 25, 2022, 02:53:55 AM
Looks good, I like the exit transitions as they fade and shrink.
Title: Re: Simple Circular Activity Indicator
Post by: NoCforMe on August 26, 2022, 01:45:23 PM
Trying to run it under Windows 7-64; click on either "Start" and it hangs ("not responding"), Olly Debug opens with a blank window. ???
Title: Re: Simple Circular Activity Indicator
Post by: Biterider on August 26, 2022, 05:07:55 PM
Hi NoCforMe
Thank you for your feedback signal.
As mentioned in the first post, this control uses a feature introduced with Windows 8. All previous operating systems will not work.
Of course, it would be better if the demo application warned you about an old, unsupported operating system. Maybe I'll add this code too.

Biterider
Title: Re: Simple Circular Activity Indicator
Post by: jj2007 on August 26, 2022, 06:29:06 PM
Quote from: Biterider on August 26, 2022, 05:07:55 PMOf course, it would be better if the demo application warned you about an old, unsupported operating system.

For inspiration ;-)

MbWinVersion MACRO arg
  ifndef NTDLL_INC
  uselib ntdll
  endif
  push eax
  mov eax, esp
  push eax
  mov edx, esp
  push eax
  invoke RtlGetNtVersionNumbers, edx, eax, esp
  pop edx ; build in dx
  pop eax ; major
  pop ecx ; minor
  ifidn <arg>, <b>
EXITM <al>
  elseifidn <arg>, <build>
EXITM <dx>
  else
EXITM <eax>
  endif
ENDM
Title: Re: Simple Circular Activity Indicator
Post by: Biterider on August 26, 2022, 06:31:45 PM
 :thumbsup:
Title: Re: Simple Circular Activity Indicator
Post by: Biterider on August 27, 2022, 03:45:01 AM
Hi
I updated the application to show a warning if the OS Version is below Windows 8.
Binary can be downloaded from the first post.


Biterider
Title: Re: Simple Circular Activity Indicator
Post by: NoCforMe on August 27, 2022, 05:25:14 AM
So what exactly does Windows 7 not support here? And why is it that instead of just rendering incorrectly it hangs? Failure mode doesn't seem too elegant here ...
Title: Re: Simple Circular Activity Indicator
Post by: LiaoMi on August 27, 2022, 06:48:52 AM
 :tongue:
WS_EX_LAYERED
0x00080000
The window is a layered window. This style cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.
Windows 8: The WS_EX_LAYERED style is supported for top-level windows and child windows. Previous Windows versions support WS_EX_LAYERED only for top-level windows.

A window that has no parent, or whose parent is the desktop window, is called a top-level window.
https://docs.microsoft.com/en-us/windows/win32/winmsg/about-windows#parent-or-owner-window-handle
A window can be created as a child window (WS_CHILD set) or a top-level window (WS_CHILD not set).
https://devblogs.microsoft.com/oldnewthing/20100315-00/?p=14613