NO

Author Topic: Listview progressbar control  (Read 18830 times)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Listview progressbar control
« on: October 22, 2023, 09:40:40 PM »
Following a post about a listview progress bar control I felt a compulsive necessity to produce a control usable for any listview window.  ::)
So I produced the code below that:
  • Is completely transparent to the user.
    All graphical and system code is inside the control module, including memory allocation and freeing.
    The user interface make available, actually, just 2 functions 5 functions, one to create the progress bar inside a list view at specific row and column, and the other to set current progress for a specific bar, the last 2 to set and retrieve progress bar properties. Added destroy function that can remove a single ListView control or all child controls. (V.2.02)
  • More listview controls can be handled.
  • The graphic can include or not the current percentage value in text.
  • High contrast text (color changes againt background to maintain high contrast).
  • Can prepend a text string to the percentage.
  • The progress bar can be positioned in the first column without occupying the whole row.
  • Made available the destroy function (V2.02).
    If you pass the ListView control handle it will destroy only that control, if you pass the parent window handle, it will destroy all controls and remove the subclassing (full remove).
  • Correctly handle theme change now (V2.02).
In hope it could be of any use...  :)

EDIT: Updated version V2.02.    Fixed some bugs and added new feature.
« Last Edit: November 02, 2023, 04:34:25 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline Vortex

  • Member
  • *
  • Posts: 865
    • http://www.vortex.masmcode.com
Re: Listview progressbar control
« Reply #1 on: October 22, 2023, 09:59:14 PM »
Hi frankie,

Impressive work.
Code it... That's all...

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Listview progressbar control
« Reply #2 on: October 22, 2023, 10:11:25 PM »
Hi frankie,

Impressive work.
Thanks Erol  :)
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline MrBcx

  • Global Moderator
  • Member
  • *****
  • Posts: 189
    • Bcx Basic to C/C++ Translator
Re: Listview progressbar control
« Reply #3 on: October 23, 2023, 02:41:53 AM »
Nice job Frankie ... I wish I had a need for this. 

Until that time arrives, I plan to run ListviewProgressBar.exe anytime I need to look busy.   ;D
Bcx Basic to C/C++ Translator
https://www.BcxBasicCoders.com

Offline Robert

  • Member
  • *
  • Posts: 247
Re: Listview progressbar control
« Reply #4 on: October 23, 2023, 08:26:40 AM »
Hi frankie:

Your .exe doesn't work on my Windows 11 x64 machine.

I recompiled and still nothing when I tried to run the .exe.

Redownloaded and as above no luck.

 :'(


Offline Vortex

  • Member
  • *
  • Posts: 865
    • http://www.vortex.masmcode.com
Re: Listview progressbar control
« Reply #5 on: October 23, 2023, 09:12:20 AM »
Hello,

I can confirm Robert's test result. The executable does not display the GUI on Windows 11.
Code it... That's all...

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Listview progressbar control
« Reply #6 on: October 23, 2023, 10:21:45 AM »
Hello,
I can confirm Robert's test result. The executable does not display the GUI on Windows 11.
Unfortunately I don't have a WIN11 machine to test right now.  :-\
I made some modifications and added a manifest resource to force commoncontrols version 6.00.00
Let me know if this works.
The new version has been loaded in the first post of this thread.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline Vortex

  • Member
  • *
  • Posts: 865
    • http://www.vortex.masmcode.com
Re: Listview progressbar control
« Reply #7 on: October 23, 2023, 10:34:43 AM »
Hi frankie,

Thanks for the update. The result is the same, the GUI does not appear :

Code: [Select]
C:\>ListViewProgressBar.exe && tasklist | findstr "ListViewProgressBar.exe"
ListViewProgressBar.exe       3940 Console                    3      8.448 K

Some seconds later :

Code: [Select]
C:\>tasklist | findstr "ListViewProgressBar.exe"
Tasklist does not return anything.

Tested on Windows 11 2022 H2, Version 10.0.22621.2428
Code it... That's all...

Offline John Z

  • Member
  • *
  • Posts: 860
Re: Listview progressbar control
« Reply #8 on: October 23, 2023, 11:09:20 AM »
You just need to disable Optimization under code generation.
Yes I'm on Win 11 22H2 and Pelles C V12.00.2

Works fine then.

John Z

Update:
Level 2 warnings show 2 places with "Dead code removed (around here)." ...
these are both on macro statement
ListView_GetSubItemRect(pCustomDraw->nmcd.hdr.hwndFrom, pCustomDraw->nmcd.dwItemSpec, pCustomDraw->iSubItem, LVIR_BOUNDS, &rcBar);

which invokes
(BOOL)SNDMSG((hwnd),LVM_GETSUBITEMRECT,(WPARAM)(int)(iItem),((prc)?((((LPRECT)(prc))->top = iSubItem),(((LPRECT)(prc))->left = code),(LPARAM)(prc)):(LPARAM)(LPRECT)NULL))

I suspect optimizer might be having issues with (prc)? parameter 3 ...  but this is just a guess. To test the (prc)? parameter could be broken out into one line which then precedes a standard SendMessage statement with the parameters rather than the macro.

 
« Last Edit: October 23, 2023, 12:02:18 PM by John Z »

Offline Vortex

  • Member
  • *
  • Posts: 865
    • http://www.vortex.masmcode.com
Re: Listview progressbar control
« Reply #9 on: October 23, 2023, 12:13:30 PM »
Hi John,

Quote
You just need to disable Optimization under code generation.
Yes I'm on Win 11 22H2 and Pelles C V12.00.2

Works fine then.

Confirmed. Rebuilding the application without optimization solved the issue on Windows 11. Thanks.
Code it... That's all...

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Listview progressbar control
« Reply #10 on: October 23, 2023, 01:43:15 PM »
Could you test this version with optimizations on?
I corrected some bugs and removed macros.
« Last Edit: October 23, 2023, 02:19:00 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline John Z

  • Member
  • *
  • Posts: 860
Re: Listview progressbar control
« Reply #11 on: October 23, 2023, 02:21:42 PM »
Attached.

Compiled and ran with optimizations including extras.  Probably some UTF-8 issue though unless you too know Chinese... :)

John Z

Update
Without optimization - no 'Chinese'  ;D
« Last Edit: October 23, 2023, 02:34:24 PM by John Z »

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Listview progressbar control
« Reply #12 on: October 23, 2023, 02:53:19 PM »
Probably some UTF-8 issue though unless you too know Chinese... :)
Well I speak a little poor chinese... But can't write or read it   ;D
Could you check also this please?
Can't really understand what could be the point....  :-\
Anyway what's sure is that the compiler mess-up the code when optimizing the macro ListView_GetSubItemRect>:(
« Last Edit: October 23, 2023, 03:24:58 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline John Z

  • Member
  • *
  • Posts: 860
Re: Listview progressbar control
« Reply #13 on: October 23, 2023, 03:32:47 PM »
Well I speak a little poor chinese... But can't write or read it   ;D
Me too, speak and understand some but illiterate except for my name!
----
Anyway you nailed it.  Works with full optimization.

John Z

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Listview progressbar control
« Reply #14 on: October 23, 2023, 03:38:52 PM »
Anyway you nailed it.  Works with full optimization.

John Z
Good  :)
It seems that WIN11 is intollerant to UNICODE/ANSI mixing, WHILE WIN10 was more easygoing on that.  :P
OK ladies and gentlemen to use this code under WIN11 you must always use UNICODE.

To me another reason to stay with WIN10 for now...  ;D

If there ane no more problems I'll move the last code to main post.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide