Icon Conundrum

Windows specific forum
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Icon Conundrum

Post 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?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
skywalk
Addict
Addict
Posts: 4242
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Icon Conundrum

Post by skywalk »

That's why I don't specify an icon in the compiler. :wink:
I keep images in a datasection and set an explicit icon for each window.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Icon Conundrum

Post 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'
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Icon Conundrum

Post 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
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
skywalk
Addict
Addict
Posts: 4242
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Icon Conundrum

Post 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)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Icon Conundrum

Post 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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply