[TC 8.0b20 x64] Changing themes cuses problems with menu bar

Bug reports will be moved here when the described bug has been fixed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
umbra
Power Member
Power Member
Posts: 871
Joined: 2012-01-14, 20:41 UTC

[TC 8.0b20 x64] Changing themes cuses problems with menu bar

Post by *umbra »

This is probably an edge-case but whatever.
  1. Switch to Classic Windows theme
  2. Start TC8.0b20 x64
  3. Switch to Aero theme
  4. Switch to Classic Windows theme again
After step 3 there will be a redraw error in the menu (the white rectangle in the picture), but it will disappear if you move focus to TC's window. But after step 4, buttons in menu bar will shrink and it stays that way until you restart TC or switch back to Aero.
Image: http://i1057.photobucket.com/albums/t399/uumbra8/TC/bugs/changetheme.jpg

BTW, TCx32 makes funny colors during these changes but it always ends up in a correct state after a second or two.
Windows 7 Pro x64, Windows 10 Pro x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48070
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Indeed you need to restart the 64bit version after such changes, sorry. It's a problem somewhere deep in Lazarus, I don't have the time to debug that in detail. I will make a short check, but cannot promise anything.
Author of Total Commander
https://www.ghisler.com
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48070
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Unfortunately I could not reproduce the problem. I tried with my own settings and with a fresh ini, and with beta 20, 15 and 10 (all 64-bit), no problem at all. It may be a timing problem on your system, e.g. TC gets the notification when the new theme isn't active yet. Or maybe it's a problem with your settings. Do you get this also with a fresh wincmd.ini?
Author of Total Commander
https://www.ghisler.com
umbra
Power Member
Power Member
Posts: 871
Joined: 2012-01-14, 20:41 UTC

Post by *umbra »

Here is a screen-capture so you can see what I mean: video

There is TCx32, TCx64 and Notepad (for reference). Also I always test with clean ini.
It may be a timing problem on your system
It is possible, because when I repeated it over 20 times, three or four times the error did not happen. Hard to tell why - as far as I can remember, every time I repeated the same steps.
However this applies only to the shrunk menu in TCx64. The other redraw errors happened every time.
Windows 7 Pro x64, Windows 10 Pro x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48070
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Unfortunately I could not reproduce the problem so far. I'm surprised that you can switch themes so quickly, here it takes about half a minute...
Author of Total Commander
https://www.ghisler.com
M0rpheuss
Junior Member
Junior Member
Posts: 12
Joined: 2009-08-15, 15:49 UTC

Post by *M0rpheuss »

I can reproduce this. The redraw error also occurs if I change the screen resolution.
umbra
Power Member
Power Member
Posts: 871
Joined: 2012-01-14, 20:41 UTC

Post by *umbra »

Hmm, when I tried to reproduce it in a virtual machine (which is obviously a bit slower) I got inverted results - the shrunk menu buttons appeared only a few times, most of the time not. I'll try to get another real machine and test it there.

EDIT
On a different computer (different HW, same OS) it behaves similarly to my virtual machine - the bug appears only rarely.
Last edited by umbra on 2012-02-24, 22:32 UTC, edited 1 time in total.
Windows 7 Pro x64, Windows 10 Pro x64
umbra
Power Member
Power Member
Posts: 871
Joined: 2012-01-14, 20:41 UTC

Post by *umbra »

Ok, it's starting to be a little bit confusing here, so I've decided to create a separate bug report for the redraw issue (the upper half of image in my first post).

2M0rpheuss
If you meant that issue, please confirm it here: http://www.ghisler.ch/board/viewtopic.php?t=33777
Windows 7 Pro x64, Windows 10 Pro x64
Sob
Power Member
Power Member
Posts: 941
Joined: 2005-01-19, 17:33 UTC

Post by *Sob »

About the shrinking menu items, I did a little debugging and I can answer the question, why they do it. But no, don't get excited, I don't have a solution. But for the record:

When the function for measuring item size is called after switching to Classic theme, sometimes Lazarus still thinks that themes are enabled. So it calls another function for measuring themed menu items, it fails and returns zero. I didn't investigate why, because that is not the source of the problem. Few strategicaly placed OutputDebugString() calls in WindowProc revealed, that sometimes WM_MEASUREITEM for all menubar items come before WM_THEMECHANGED. It explains it. But the real question is how it's possible. System sending messages in wrong order doesn't seem likely and I'm not sure if application has any chance to reoder them somehow. So unfortunately, no happy end yet.
M0rpheuss
Junior Member
Junior Member
Posts: 12
Joined: 2009-08-15, 15:49 UTC

Post by *M0rpheuss »

2umbra
I can confirm both issus.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48070
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

OK, I will try to call DrawMenuBar delayed with a timer after receiving WM_THEMECHANGED. I wonder whether these is any kind of MeasureMenuBar command which would force Windows to send again WM_MEASUREITEM for each item...
Author of Total Commander
https://www.ghisler.com
umbra
Power Member
Power Member
Posts: 871
Joined: 2012-01-14, 20:41 UTC

Post by *umbra »

I tried to reproduce this issue in TC8.0 beta 22 a few dozen times, but I wasn't successful. So I think it's fixed.
Windows 7 Pro x64, Windows 10 Pro x64
Sob
Power Member
Power Member
Posts: 941
Joined: 2005-01-19, 17:33 UTC

Post by *Sob »

I can confirm that. I tried changing themes with running TC and separate Lazarus application. And menu in TC stayed correct even when the one in Lazarus application shrinked.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48070
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

That's great, thanks! I changed the Lazarus code to use the non-themed measureitem function when the themed one returned an error or 0 width.
Author of Total Commander
https://www.ghisler.com
Post Reply