GetOpenFileName probably changes the current working directory and you're loading the images using relative path names. Try using absolute path names instead, check the loading function's return code and, in case of failure, call GetLastError to see what went wrong.
Window toolbar doesn't show button icons if initialized after GetOpenFileNameA
Hello
I have a WIN32 C program that has 2 modes and for each mode, the main window toolbar is different.
I initialize my toolbar with "CreateWindowEx(0, TOOLBARCLASSNAME...)" and all the "ImageList_xxx()" and "SendMessage(hwTB, TB_XXX...)" functions.
To switch to the other toolbar, I "DestroyWindow()" and "ImageList_Destroy()" before initializing as before the new one. It perfectly works until I first use "GetOpenFileNameA()".
After this "GetOpenFileNameA", if I switch, the new toolbar is created with all the buttons, their tooltips and sending the right messages to the window proc, but there is no icon on them.
If "GetOpenFileNameA" returns FALSE (cancel is pressed or the dialog is closed with the upper right [x]) it continues to show the icons.
I have checked that "GetOpenFileNameA" is responsible for this strange behaviour as I have tried to "return" the function just before the "GetOpenFileNameA" and everything works as usual and I have also tried to "return" just after the "GetOpenFileNameA" doing nothing as if the function has returned FALSE. If FALSE, it continues to work, if TRUE, it doesn't show the icons anymore.
Any idea why this happens, please?
Thanks
David
1 additional answer
Sort by: Most helpful
-
David L 161 Reputation points
2022-07-09T17:01:25.67+00:00 Wonderful!
You are perfectly right.
Thanks a lot
David