Add Function SetWindowIcon()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
lakomet
User
User
Posts: 53
Joined: Mon Apr 04, 2011 3:56 am
Location: Russia,Angarsk

Add Function SetWindowIcon()

Post by lakomet »

Want to see this feature?

Code: Select all

UsePNGImageDecoder() 

Procedure SetWindowIcon(WinID, IconID)
     CompilerSelect  #PB_Compiler_OS 
          CompilerCase  #PB_OS_Linux
               gtk_window_set_icon_(WinID, IconID) 
          CompilerCase #PB_OS_Windows
               SendMessage_(WinID,#WM_SETICON,#False,IconID) 
          CompilerCase #PB_OS_MacOS
               ; :?: 
     CompilerEndSelect
EndProcedure

If OpenWindow(0, 50, 50, 350, 50, "Icon Test", #PB_Window_ScreenCentered) 
     SetWindowIcon(WindowID(0), CatchImage(1, ?WindowIcon) )
EndIf 

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
End 

DataSection 
     WindowIcon: 
     IncludeBinary "ICO.png" 
EndDataSection
Last edited by lakomet on Sun Dec 04, 2011 10:26 am, edited 1 time in total.
Linux Mint Maya(Mate), x86, PureBasic 5.00(5.10b1)
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Re: Add Function AddWindowIcon()

Post by em_uk »

Actually, I get no icon on Windows 7.
----

R Tape loading error, 0:1
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: Add Function AddWindowIcon()

Post by Bisonte »

The only necessary thing is to have an 16x16 sized image.

And the name AddWindowIcon sounds not right ... better "SetWindowIcon(Window, Image)"

This is my try...

Code: Select all

Procedure SetWindowIcon(Window, Image)
  
  If IsWindow(Window) And IsImage(Image)
    
    CompilerSelect  #PB_Compiler_OS
        
      CompilerCase  #PB_OS_Linux
        gtk_window_set_icon_(WindowID(Window), ImageID(Image))
        
      CompilerCase #PB_OS_Windows
        If ImageWidth(Image) <> 16 Or ImageHeight(Image)<>16
          ResizeImage(Image,16,16)
        EndIf
        SendMessage_(WindowID(Window), #WM_SETICON, #False, ImageID(Image))
        
      CompilerCase #PB_OS_MacOS
        ; :?:
        
    CompilerEndSelect
  
  EndIf

EndProcedure
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Add Function AddWindowIcon()

Post by IdeasVacuum »

I think this request is better suited:

http://www.purebasic.fr/english/viewtop ... =3&t=48103

Define your icons with an app that is designed for the job, there is normally more than one image in an icon file and you need an icon elsewhere too - for the executable and perhaps the installer, app folder etc.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Wolf
Enthusiast
Enthusiast
Posts: 232
Joined: Sat Apr 03, 2004 12:00 pm
Location: S.T

Re: Add Function AddWindowIcon()

Post by Wolf »

+1
User avatar
doctorized
Addict
Addict
Posts: 882
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: Add Function SetWindowIcon()

Post by doctorized »

9 years later and the function is not added. :( :( :(

+1
Post Reply