Window Icons

Just starting out? Need help? Post your questions and find answers here.
neomancer
User
User
Posts: 14
Joined: Fri Jun 04, 2004 10:25 am

Window Icons

Post by neomancer »

How do i get an ICON in the window? like they normally do? system control box (top left)
Manolo
User
User
Posts: 75
Joined: Fri Apr 25, 2003 7:06 pm
Location: Spain

Re: Window Icons

Post by Manolo »

neomancer wrote:How do i get an ICON in the window? like they normally do? system control box (top left)
This one template from Franco

Code: Select all

; (c) 2001 - Franco's template - absolutely freeware
; How to change an application icon on the fly 
Procedure ChangeAppIcon(Image$)  
hIco=LoadImage(0,Image$)  
SetClassLong_(WindowID(),#GCL_HICON,hIco)
EndProcedure 
;test
If OpenWindow(0, 200, 200, 320,240, #PB_Window_SystemMenu ,"Test Window")
ChangeAppIcon("yourico.ico") ; <- your icon name...   
Repeat    
EventID.l = WaitWindowEvent()  
Until EventID = #PB_EventCloseWindow
EndIf 
End
Manolo :wink:
Return to the forum
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

Was to slow !

I loose ...

Code: Select all

If OpenWindow(0, 100, 200, 195, 260, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window")
  hIcon = LoadIcon_(0, #IDI_ASTERISK)
  Debug SetClassLong_(WindowID(), #GCL_HICON, hIcon)
  Repeat
    EventID.l = WaitWindowEvent()
    If EventID = #PB_Event_CloseWindow
      Quit = 1
    EndIf
  Until Quit = 1
EndIf
End
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Yet another way :

Code: Select all

SendMessage_(WindowID(#Window), #WM_SETICON, 0, UseImage(#Icon))
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Randy Walker
Addict
Addict
Posts: 989
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Post by Randy Walker »

I've tried all 3 variations and they all work but, my icons come up corrupted in the title bar of all my windows.

Same icon works fine if I provide the path and let the editor/compiler install the icon for me. Do these methods of changing icons depend on a specific icon format? My current icon is 32x32 and I think 256 color.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

Perhaps your icon is XP and your system is W2000 or less...
User avatar
Fou-Lu
Enthusiast
Enthusiast
Posts: 201
Joined: Tue Jul 12, 2005 8:30 am
Location: I'm pretty sure this is all a nightmare
Contact:

Post by Fou-Lu »

Now that you mention that, what's the difference between a XP icon and a win9x icon? I always thought that icons were just .bmp files with a different extension. :?

~Fou-Lu (aka Lørd Cinneris (actually Elias Sant'Ana))

Image Image
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

.ico files are bmp-ish but can hold more than one image, eg, 16x16, 32x32, 48x48 instances.

If your .ico holds sizes not compatible with the destination then I think it gets resized and that can cause poor results.

Software like iconedit allows you to edit/create icon files with instances that work best for each requirement.
@}--`--,-- A rose by any other name ..
Randy Walker
Addict
Addict
Posts: 989
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Post by Randy Walker »

My OS is XP Pro and XP Home and both have same symptoms. Both show icons fine if installed during compile. Both show distorted icons when I load and apply them manually. The icons I am using were created back in the Win95 era so I would expect them to be compatible.

I pulled down SNicon as suggested elseware, loaded my icon and saved it thinking maybe Snicon woulld fix any OS incompatibility. That made no difference. Tried both the SetClassLong and the SendMessage approaches and both render distorted icons. Icons appeareing when using Alt-Tab look fine no mattter what.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

You can choose an icon for your application on the compiler options menu.
BERESHEIT
Intrigued
Enthusiast
Enthusiast
Posts: 501
Joined: Thu Jun 02, 2005 3:55 am
Location: U.S.A.

Post by Intrigued »

Thanks for sharing the run-time way of showing a different icon for a given window. I was wondering if that was possible a few weeks ago.
Intrigued - Registered PureBasic, lifetime updates user
Randy Walker
Addict
Addict
Posts: 989
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Post by Randy Walker »

netmaestro wrote:You can choose an icon for your application on the compiler options menu.
I know that... and that gives me a perfect icon in my title bar... BUT when I change the icon using ether of the two methods:

SetClassLong_(WindowID(), #GCL_HICON, hIcon)

-or-

SendMessage_(WindowID(), #WM_SETICON, 1, hIcon)

The icon in the title bar is replaced and looks very distorted. My question is NOT "how to change the icon?" It is "Why does the icon get corrupted when my app loads it in manually?"
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

This works fine for me, without problems or distortions!

As long has i use 16 x 16 icons!
Post Reply