Icon on title bar?
Icon on title bar?
How do you put an icon on the left side of the title bar in Linux and Win32 without using the API?
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
- Arctic Fox
- Enthusiast
- Posts: 609
- Joined: Sun Dec 21, 2008 5:02 pm
- Location: Aarhus, Denmark
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
-
- Addict
- Posts: 1027
- Joined: Sun May 15, 2005 5:15 am
- Location: Australia
- Contact:
Linux does not support icons for exe's the way Windows does, hence why you can't use that option on Linux.
GTK API would be needed. I'm sure I've seen samples of it somewhere here on the forum...
@Kaeru: even the checkbox is grayed on linux if I recall correctly.
GTK API would be needed. I'm sure I've seen samples of it somewhere here on the forum...
@Kaeru: even the checkbox is grayed on linux if I recall correctly.
Demonio Ardente
Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
Here is the gtk function:
http://library.gnome.org/devel/gtk/unst ... w-set-icon
http://library.gnome.org/devel/gtk/unst ... w-set-icon
A short example which runs in Windows and Linux and uses a CDPlayer icon which is contained in each PB Windows and Linux installation:
Code: Select all
IconPath.S = #PB_Compiler_Home + "examples/sources/Data/CdPlayer.ico"
OpenWindow(0, 0, 0, 300, 100, "<-- Changed titlebar icon", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
gtk_window_set_icon_from_file_(WindowID(0), PeekS(@IconPath), IconError)
CompilerElse
IconPath = ReplaceString(IconPath, "/", "\")
If LoadImage(0, IconPath)
SendMessage_(WindowID(0), #WM_SETICON, 0, ImageID(0))
EndIf
CompilerEndIf
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
This should be added to feature request as a built-in command SetWindowIcon - like SetWindowTitle.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
This works well and I can even use CatchImage in the Windows version so I don't have to load it from a file. Is it possible to do the same thing with the GTK API? I looked at the docs but I don't see any possibility... of course I've never looked at GTK docs before so I'm probably missing something.Shardik wrote:A short example which runs in Windows and Linux and uses a CDPlayer icon which is contained in each PB Windows and Linux installation:Code: Select all
IconPath.S = #PB_Compiler_Home + "examples/sources/Data/CdPlayer.ico" OpenWindow(0, 0, 0, 300, 100, "<-- Changed titlebar icon", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) CompilerIf #PB_Compiler_OS = #PB_OS_Linux gtk_window_set_icon_from_file_(WindowID(0), PeekS(@IconPath), IconError) CompilerElse IconPath = ReplaceString(IconPath, "/", "") If LoadImage(0, IconPath) SendMessage_(WindowID(0), #WM_SETICON, 0, ImageID(0)) EndIf CompilerEndIf Repeat Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: Icon on title bar?
Hello Shardik,
today I've come to share your help ~
but it wouldn't work for me on Linux (Suse 11.1) with all pb-versions down to 4.31. (???) until I exchanged the WindowID(0) by an enumerated constant.
Strange this makes a difference ~ but this way the icon shines from the title to me
thanks ~ Vera
today I've come to share your help ~

but it wouldn't work for me on Linux (Suse 11.1) with all pb-versions down to 4.31. (???) until I exchanged the WindowID(0) by an enumerated constant.
Strange this makes a difference ~ but this way the icon shines from the title to me

thanks ~ Vera
Two growing code-collections: WinApi-Lib by RSBasic ~ LinuxAPI-Lib by Omi
Missing a download-file on the forums? ~ check out this backup page.
Missing a download-file on the forums? ~ check out this backup page.
Re: Icon on title bar?
Why PeekS()? IconPath is already string variable.Shardik wrote:Code: Select all
gtk_window_set_icon_from_file_(WindowID(0), PeekS(@IconPath), IconError)
Re: Icon on title bar?
Dear Vera,Vera wrote:but it wouldn't work for me on Linux (Suse 11.1) with all pb-versions down to 4.31. (???)
I have tested my above example on OpenSUSE 11.1 with 4 freshly installed PB versions
(4.20, 4.31, 4.41 and 4.51) and discovered that only 4.20 doesn't display the CD icon.
This is caused by a rename in the distributed PB tgz archive of the sub folder /data
from 4.20 to /Data in 4.31 and subsequent versions. Since Linux is case sensitive, this
change of one character from lowercase to uppercase had the effect that the icon file
couldn't be found. Therefore everyone should improve my code example by testing the
return value of the GTK function:
Code: Select all
If gtk_window_set_icon_from_file_(WindowID(0), @IconPath, IconError) = #False
MessageRequester("Error", "Icon file couldn't be found!")
EndIf
@cas,
you are right, the PeekS(@IconPath) is not necessary. Just using "@IconPath" is sufficient.
Thank you for your hint.