Changing Icon based on the window state

Hi all, I have created a custom toolbar for my app and I want the maximize button icon to change to un-maximize when the app is maximized.
I tried toggling between the icons when the maximize button is pressed and that works except it only works if the app is maximized using the maximize button. If the app is maximized by dragging it to the top of the screen or by using hotkeys it doesn’t work.
I also tried using a while loop to constantly check for the window state to change the icon accordingly but that just breaks the whole app.
So what is the proper way to check for the window state and how should I implement it?

Hi @jainjude,

Welcome to the Github Community Forum!

We are missing some infos to help you. For app what do you mean? Ios, android, web app or desktop app? What language are you use or what framework/library. You can also paste some part of the code to help us understand the problem. I can give you some hints for java, python or even typescript, but if I don’t know what you are use so all the suggestion can be all useless.


Mark helpfull posts with Accept as Solution to help other users locate important info. Don’t forget to give Kudos for great contents!

In traditional Win32 programming, the WM_SIZE message includes maximize/minimize states etc. In WinForms, this is the OnSize handler.