Abdelrhman-AK / WinPaletter

Advanced Windows Appearance Editor
Other
1.35k stars 54 forks source link

:x: [Error] Can't apply theme #218

Open MuscularPuky opened 6 months ago

MuscularPuky commented 6 months ago

:x: Error report

Describe the error

How to reproduce the error

WinPaletter Log

//General information
//...........................................................
   Report.Date = "2024년 2월 27일 화요일 오전 1:52:34";
   OS = "Windows 11, 10.0.26058.1000, 64-bit";
   WinPaletter.Version = "1.0.8.6, 베타, Build: Release";
   WinPaletter.Language = "한국어(대한민국)";
   WinPaletter.Debugging = false;

//Error details
//...........................................................
   Exception.message = "Cannot access a disposed object.
Object name: 'Icon'.";
   Exception.type = "System.ObjectDisposedException";
   Exception.stack.trace =
   {
      at System.Drawing.Icon.get_Handle()
      at System.Windows.Forms.Form.UpdateWindowIcon(Boolean redrawFrame)
      at System.Windows.Forms.Form.set_Icon(Icon value)
      at WinPaletter.Dialogs.ThemeLog.ThemeLog_Load(Object sender, EventArgs e)
      at System.Windows.Forms.Form.OnLoad(EventArgs e)
      at System.Windows.Forms.Form.OnCreateControl()
      at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
      at System.Windows.Forms.Control.CreateControl()
      at System.Windows.Forms.Control.OnVisibleChanged(EventArgs e)
      at System.Windows.Forms.ScrollableControl.OnVisibleChanged(EventArgs e)
      at System.Windows.Forms.Form.OnVisibleChanged(EventArgs e)
      at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
      at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
      at System.Windows.Forms.Control.Show()
      at WinPaletter.Tabs.TabsContainer.AddFormIntoTab(Form form)
      at WinPaletter.Dialogs.ThemeLog.Apply_Theme(Manager TM, Boolean AdditionalStoreTips, Boolean dontInvoke)
      at WinPaletter.Home.apply_btn_Click(Object sender, EventArgs e)
      at System.Windows.Forms.Control.OnClick(EventArgs e)
      at System.Windows.Forms.Button.OnClick(EventArgs e)
      at WinPaletter.UI.WP.Button.OnClick(EventArgs e)
      at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
      at WinPaletter.UI.WP.Button.OnMouseUp(MouseEventArgs e)
      at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
      at System.Windows.Forms.Control.WndProc(Message& m)
      at System.Windows.Forms.ButtonBase.WndProc(Message& m)
      at System.Windows.Forms.Button.WndProc(Message& m)
      at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
      at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
      at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   };
   Exception.target.void_function = "System.Drawing.get_Handle()";
   Exception.assembly = "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
   Exception.assembly.file = "C:\\WINDOWS\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Drawing\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.Drawing.dll";
   Exception.HRESULT = -2146232798;

Screenshots/Screen records

Additional context

+I'm testing more deflects, like wi-fi connected/disconnected, etc. I'll tell you as enhancement when I'm done :)

Abdelrhman-AK commented 6 months ago

I'll try to reproduce this and fix this. It is mainly not from theme JSON file, it is from adding form into tabs.

it prompt 2 JSON errors

It is a known issue that you can safely ignore. It results from the massively changed Windows Terminal structure in WinPaletter class. I made these changes to make implementing new Windows Terminal features easier, and make this class better in readability for any developer will open this class.

+I'm testing more deflects, like wi-fi connected/disconnected, etc. I'll tell you as enhancement when I'm done :)

I'll be waiting for these new ideas :) Once their event IDs are known, implementing these new sounds deflections will be easy.

Abdelrhman-AK commented 6 months ago

I have just implemented Wi-Fi sounds

Connection: *[System[(EventID = 8000)]]
Disconnection: *[System[(EventID = 8003)]]

Both will be available in the next update

MuscularPuky commented 6 months ago

Oh you're quick! Actually I'm comparing 8000, 8001, 11000, 11001 and found out these IDs are like lifecyle. not only these there is also about 30 events but would be too much. I summerized events roughly but some events seem to actually not work: 4003 Wi-Fi error and auto recoverin.txt

It would be better 11001 than 8000/8001 I think because virtual adaptor also uses that event

Abdelrhman-AK commented 6 months ago

I have used event viewer to watch the events:

11001: Wireless network association succeeded.

It is triggered correctly when there is a connection.

So, what ID will be used for disconnection instead of 8003 (As you said that 8003 may be used by virtual adaptor)?

There is 11004 triggered too by disconnection, but it is relevant to WLAN security.

11004: Wireless security stopped.
MuscularPuky commented 6 months ago

I write some event lifecycle in this roughly: 8000 - 11000 - 11001 - 10010 - 10005 - 8001 - 11004 - 8003

Abdelrhman-AK commented 6 months ago

I have tested these IDs, 11001 plays the sound first then a delay happens before connection is triggered and before taskbar icon change. And this behavior is identical to 8001.

I am going to use 11001 for Wi-Fi connection, 8003 for Wi-Fi disconnection.

Tell me if I should use these IDs and release the new update or not.

MuscularPuky commented 6 months ago

👍 How about triggering failed to connect (8002) too?

Abdelrhman-AK commented 6 months ago

Great! I'll add it, and push the new update either today or tomorrow.

Abdelrhman-AK commented 6 months ago

And please tell me whether the main issue (exception error) has been resolved in the new update or not. I have been unable to reproduce it myself, despite attempting code fixes based on the provided details.

Abdelrhman-AK commented 6 months ago

Tell me if the issue is fixed or not.

MuscularPuky commented 6 months ago

Good. it does not crash anymore. but WinPaletter ignores metrics & fonts preference. I had to use "apply metrics" button instead "apply this theme"

MuscularPuky commented 6 months ago

Good. it does not crash anymore. but WinPaletter ignores metrics & fonts preference. I had to use "apply metrics" button instead "apply this theme"

ah it's not ignores. just rollback to default

Abdelrhman-AK commented 6 months ago

Can you make verbose levels 'advanced', and include skipped items? (Temporarily for one time).

I want to know what skips Metric and Fonts or what makes the Metrics and Fonts aspect uses default theme.

Export the log after applying the whole theme.

https://github.com/Abdelrhman-AK/WinPaletter/wiki/Theme-log-verbose-level

Abdelrhman-AK commented 6 months ago

ah it's not ignores. just rollback to default

This is expected if you are using WinPaletter store, but let me see applying log.

MuscularPuky commented 6 months ago

Can you make verbose levels 'advanced', and include skipped items? (Temporarily for one time).

I want to know what skips Metric and Fonts or what makes the Metrics and Fonts aspect uses default theme.

Export the log after applying the whole theme.

https://github.com/Abdelrhman-AK/WinPaletter/wiki/Theme-log-verbose-level

OK I'll try soon

MuscularPuky commented 6 months ago

Can you make verbose levels 'advanced', and include skipped items? (Temporarily for one time). I want to know what skips Metric and Fonts or what makes the Metrics and Fonts aspect uses default theme. Export the log after applying the whole theme. https://github.com/Abdelrhman-AK/WinPaletter/wiki/Theme-log-verbose-level

OK I'll try soon

I'm here. it rollbacks classic colors, font & metrics, etc, to default. I forgot to change language to english so translated manually.

[info] Winpaletter appys theme on Windows 11 section
[info] apply started
[apply] saving theme infomatoin to registry
[skip] winpaletter application theme
[skip] wallpaper
[apply] applying Windows 11 scheme
[reg_add] HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent > AccentPalette = 107 107 107 255 89 89 98 255 76 76 255 63 63 63 255 0 0 0 255 0 0 0 255 20 20 20 255 136 23 152 255, RegistryValueKind = Binary
[reg_add] ditto > StartColorMenu = -16777216, RegistryValueKind = DWord
[apply] Windows 11 LogonUI
[apply] classic colors
[dll] calling user32.dll.SystemParameterInfo(SPI_SETFLATMENU, 0, True, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETGRADIENTCAPTIONS, 0, True, SPIF_UPDATEINIFILE)
[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > ActiveBorder = 32 32 32, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > ActiveTitle = 32 32 32, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > AppWorkspace = 8 8 8, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > ButtonDkShadow = 24 24 24, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > ButtonFace = 0 0 0, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > ButtonHilight = 96 96 96, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > ButtonLight = 64 64 64, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > ButtonShadow = 40 40 40, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > ButtonText = 255 255 255, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > GradientActiveTitle = 32 32 32, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > GradientInactiveTitle = 0 0 0, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > GrayText = 128 128 128, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > HotTrackingColor = 255 255 255, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > InactiveBorder = 0 0 0, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > InactiveTitle = 0 0 0, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > InactiveTitleText = 160 160 160, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > InfoText = 255 255 255, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > InfoWindow = 0 0 0, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > Menu = 0 0 0, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > MenuBar = 0 0 0, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > MenuText = 255 255 255, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > Scrollbar = 0 0 0, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > TitleText = 255 255 255, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > Window = 0 0 0, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > WindowFrame = 64 64 64, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > WindowText = 192 192 192, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > Hilight = 128 127 127, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > MenuHilight = 11 11 11, RegistryValueKind = String

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > Desktop = 0 0 0, RegistryValueKind = String
[dll] calling user32.dll.SystemParameterInfo(SPI_SETDROPSHADOW, 0, True, SPIF_UPDATEINIFILE)
[apply] apllying window metrics & fonts
[dll] calling user32.dll.SystemParameterInfo(SPI_SETDROPSHADOW, 0, True, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETFONTSMOOTHING, 0, True, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETUIEFFECTS, 0, True, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_GETICONMETRICS, 108, WinPaletter.NativeMethods.User32+ICONMETRICS, SPIF_NONE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETCLIENTAREAANIMATION, 0, True, SPIF_UPDATEINIFILE)
[skip] window switcher (Alt+Tab)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETDRAGFULLWINDOWS, 0, True, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETMENUANUMATION, 0, True, SPIF_UPDATEINIFILE)
[skip] Skipping WinPaletter Wallpaper Tone as it is disabled
[dll] calling user32.dll.SystemParameterInfo(SPI_SETMENUFADE, 0, True, SPIF_UPDATEINIFILE)
[skip] command prompt
[dll]  calling user32.dll.SystemParameterInfo(SPI_SETMENUSHOWDELAY, 400, True, SPIF_UPDATEINIFILE)
[skip] PowerShell x86
[dll] calling user32.dll.SystemParameterInfo(SPI_SETSELECTIONFADE, 0, True, SPIF_UPDATEINIFILE)
[skip] powershell x64
[dll] calling user32.dll.SystemParameterInfo(SPI_SETCOMBOBOXANIMATION, 0, True, SPIF_UPDATEINIFILE)
[skip] Windows Terminal stable & preview
[dll] calling user32.dll.SystemParameterInfo(SPI_SETLISTBOXSMOOTHSCROLLING, 0, True, SPIF_UPDATEINIFILE)
[skip] Skipping Screen Saver as its toggle is disabled
[dll] calling user32.dll.SystemParameterInfo(SPI_SETTOOLTIPANIMATION, 0, True, SPIF_UPDATEINIFILE)
[appy] applying sounds
[dll] calling user32.dll.SystemParameterInfo(SPI_SETTOOLTIPFADE, 0, True, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETKEYBOARDCUES, 0, False, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETFOCUSBORDERWIDTH, 0, 1, SPIF_UPDATEINIFILE)
[dkk] calling user32.dll.SystemParameterInfo(SPI_SETFOCUSBORDERHEIGHT, 0, 1, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETCARETWIDTH, 0, 1, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETACTIVEWINDOWTRACKING, 0, False, SPIF_UPDATEINIFILE)
[reg_add] CMD: HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System > DisabledStartupSound = 0, RegistryValueKind = DWord
[dll] calling user32.dll.SystemParameterInfo(SPI_SETACTIVEWNDTRKZORDER, 0, False, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETACTIVEWNDTRKTIMEOUT, 0, 500, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETSNAPTODEFBUTTON, 0, True, SPIF_UPDATEINIFILE)
[reg_add]    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\MTCUVC > EnableMtcUvc = 1, RegistryValueKind = DWord

[reg_add]    CMD: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\BootAnimation > DisableStartupSound = 0, RegistryValueKind = DWord

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Desktop > PaintDesktopVersion = 0, RegistryValueKind = DWord

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Desktop > CaretWidth = 1, RegistryValueKind = DWord

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Desktop > MenuShowDelay = 400, RegistryValueKind = DWord

[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Mouse > SnapToDefaultButton = 1, RegistryValueKind = DWord

[reg_add]    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\BootControl > BootProgressAnimation = 1, RegistryValueKind = DWord

[reg_delete] deleting HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}
[reg_delete] deleting HKCU\Software\Classes\CLSID\{1eeb5b5a-06fb-4732-96b3-975c0194eb39}
[reg_delete] deleting HKCU\Software\Classes\CLSID\{056440FD-8568-48e7-A632-72157243B55B}
[task_remove] deleting WinPaletter\Shutdown task from Task Scheduler
[task_remove] deleting WinPaletter\Logoff task from Task Scheduler
[task_remove] deleting WinPaletter\Logon task from Task Scheduler
[task_remove] deleting WinPaletter\Unlock task from Task Scheduler
[task_remove] deleting WinPaletter\ChargerConnected task from Task Scheduler
[info] saving Windows cursor colors to registry
[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Desktop > UserPreferencesMask = 158 126 6 128 146 0 0 0, RegistryValueKind = Binary
complete
MuscularPuky commented 6 months ago

weirdly eventhough I apply aspects manually, when I restart explorer, the changes rollback.

Abdelrhman-AK commented 6 months ago
[dll] calling user32.dll.SystemParameterInfo(SPI_SETGRADIENTCAPTIONS, 0, True, SPIF_UPDATEINIFILE)
[reg_add]    HKEY_USERS\.DEFAULT\Control Panel\Colors > ActiveBorder = 32 32 32, RegistryValueKind = String

[apply] apllying window metrics & fonts
[dll] calling user32.dll.SystemParameterInfo(SPI_SETDROPSHADOW, 0, True, SPIF_UPDATEINIFILE)

weirdly eventhough I apply aspects manually, when I restart explorer, the changes rollback.

I faced the same issue twice last year:

  1. In some aspects elements (not all aspects) (especially in Metrics and Fonts); when I used SystemParameterInfo in shell32.dll with parameter SPIF_SENDCHANGE, then I used instead SPIF_SENDWININICHANGE and SPIF_UPDATEINIFILE | SPIF_SENDCHANGE and both fixed the issue.
  2. In multiple users; lets assume that you have two users: x and y. You can use another user differs than the user that has logged in, but there is an issue that is similar to yours. If you are in x and selected user y, both users x: partially and y will be themed. When you logoff and logon, user x will revert the preferences. The best practice it when you open WinPaletter in user x, select user x, and if you're in y select user y.

You can these steps so that I can track this bug:

MuscularPuky commented 5 months ago

I applyed theme in SYSTEM account then non-SYSTEM accounts automatically applied new theme and problem solved. perhaps recent Windows build changeds theme mechanism. as I know this problem happned since WinPaletter UI update. I'll test old WinPaletter versoins.