Author Topic: Simple Circular Activity Indicator  (Read 409 times)

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 1043
  • ObjAsm Developer
    • ObjAsm
Simple Circular Activity Indicator
« 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
« Last Edit: August 27, 2022, 03:43:47 AM by Biterider »

fearless

  • Member
  • ****
  • Posts: 564
    • Github
Re: Simple Circular Activity Indicator
« Reply #1 on: August 25, 2022, 02:53:55 AM »
Looks good, I like the exit transitions as they fade and shrink.
fearless

ASUS Crosshair 8 Hero, AMD 5950X, 32GB, MSI 5700XT, NZXT Kraken Z73, Seasonic 1000W PSU

Github Twitter Mastodon Gitbook

NoCforMe

  • Member
  • ****
  • Posts: 842
Re: Simple Circular Activity Indicator
« Reply #2 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. ???

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 1043
  • ObjAsm Developer
    • ObjAsm
Re: Simple Circular Activity Indicator
« Reply #3 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

jj2007

  • Member
  • *****
  • Posts: 13275
  • Assembly is fun ;-)
    • MasmBasic
Re: Simple Circular Activity Indicator
« Reply #4 on: August 26, 2022, 06:29:06 PM »
Of course, it would be better if the demo application warned you about an old, unsupported operating system.

For inspiration ;-)

Code: [Select]
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
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 1043
  • ObjAsm Developer
    • ObjAsm
Re: Simple Circular Activity Indicator
« Reply #5 on: August 26, 2022, 06:31:45 PM »
 :thumbsup:

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 1043
  • ObjAsm Developer
    • ObjAsm
Re: Simple Circular Activity Indicator
« Reply #6 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

NoCforMe

  • Member
  • ****
  • Posts: 842
Re: Simple Circular Activity Indicator
« Reply #7 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 ...

LiaoMi

  • Member
  • *****
  • Posts: 1038
Re: Simple Circular Activity Indicator
« Reply #8 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