Page 1 of 1
Icon Conundrum
Posted: Sat Feb 04, 2012 5:42 am
by IdeasVacuum
The main window of my utility app should not have an icon in the Title bar. If you do not specify your own icon for the compiler to use, a system default icon is used in the Title bar. The default icon can be suppressed using an extended window style:
Code: Select all
SetWindowLongPtr_(WindowID(#Win), #GWL_EXSTYLE, GetWindowLongPtr_(WindowID(#Win), #GWL_EXSTYLE) | #WS_EX_DLGMODALFRAME)
That certainly works with the system default icon, but if an icon is specified in the compiler, it still appears on the Title bar, meaning that your own icon cannot be applied to the exe file if you want it omitted from the window title bar............
Anybody have a workaround without resorting to a 'Tool' window?
Re: Icon Conundrum
Posted: Sat Feb 04, 2012 5:51 am
by skywalk
That's why I don't specify an icon in the compiler.
I keep images in a datasection and set an explicit icon for each window.
Re: Icon Conundrum
Posted: Sat Feb 04, 2012 6:06 am
by IdeasVacuum
That's an interesting idea. I assume it still works if an icon is specified for the compiler to use as the exe icon.
......It isn't a solution to my issue though, because I want an icon for the exe, but not for the window.
Edit: Unless there is a 'set icon' type of message (like PB's SetWindowTitle) which would permit the setting of 'no icon'
Re: Icon Conundrum
Posted: Sat Feb 04, 2012 6:47 am
by c4s
Simply set the icon to "none" before applying #WS_EX_DLGMODALFRAME, like this:
Code: Select all
Procedure WindowRemoveIcon(WindowNr)
Protected WindowID = WindowID(WindowNr)
SetClassLongPtr_(WindowID, #GCL_HICON, 0)
SetWindowLongPtr_(WindowID, #GWL_EXSTYLE, GetWindowLongPtr_(WindowID, #GWL_EXSTYLE) | #WS_EX_DLGMODALFRAME)
EndProcedure
Re: Icon Conundrum
Posted: Sat Feb 04, 2012 5:41 pm
by skywalk
Your original idea worked for me(Win7/XP) if you don't specify an icon in the exe.
Then overwrite the icon for additional windows as needed.
Code: Select all
; Set/Change icon.
SendMessage_(WindowHandle), #WM_SETICON, 0, ImageHandle) ; 0=ICON_SMALL, 1=ICON_BIG
; Drop icon.
SetWindowLongPtr_(WindowHandle, #GWL_EXSTYLE, GetWindowLongPtr_(WindowHandle, #GWL_EXSTYLE) | #WS_EX_DLGMODALFRAME)
Re: Icon Conundrum
Posted: Sat Feb 04, 2012 9:26 pm
by IdeasVacuum
Sorry guys, you are missing the point. My icon is wanted for the exe, but not wanted for any window. Using #GWL_EXSTYLE will only remove the system icon, not the one (my icon) embedded by the PB compiler. Possibly hacking the exe to replace the icon might work, have not tried that.