Page 1 of 1

Add Function SetWindowIcon()

Posted: Mon Nov 14, 2011 12:10 pm
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

Re: Add Function AddWindowIcon()

Posted: Wed Nov 16, 2011 1:54 am
by em_uk
Actually, I get no icon on Windows 7.

Re: Add Function AddWindowIcon()

Posted: Wed Nov 16, 2011 12:56 pm
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

Re: Add Function AddWindowIcon()

Posted: Wed Nov 16, 2011 1:28 pm
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.

Re: Add Function AddWindowIcon()

Posted: Fri Nov 18, 2011 1:41 am
by Wolf
+1

Re: Add Function SetWindowIcon()

Posted: Sun Nov 08, 2020 8:34 pm
by doctorized
9 years later and the function is not added. :( :( :(

+1