Window Icons
Window Icons
How do i get an ICON in the window? like they normally do? system control box (top left)
Re: Window Icons
This one template from Franconeomancer wrote:How do i get an ICON in the window? like they normally do? system control box (top left)
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

Return to the forum
Was to slow !
I loose ...
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.
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
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
-
- Addict
- Posts: 989
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
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.
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.
Randy
I *never* claimed to be a programmer.
.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.
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 ..
-
- Addict
- Posts: 989
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
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.
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.
Randy
I *never* claimed to be a programmer.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
-
- Addict
- Posts: 989
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
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:netmaestro wrote:You can choose an icon for your application on the compiler options menu.
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.
Randy
I *never* claimed to be a programmer.