Page 1 of 1

Posted: Tue Feb 04, 2003 2:31 am
by BackupUser
Restored from previous forum. Originally posted by pusztry.

I have been trying to use, the Icon that the .exe has when you include one during creating an .exe, in the tray icon. How can I do this? I have been tring to use "iconid.l = GetClassLong_(WindowID(), #GCL_HICON)" But I can't even get this to work.
Please help


- Ryan
RJP Computing

WinXP, PIII 800 MHz, 512MB RAM, SB Live 5.1, NVidia TNT 2 Ultra

Posted: Tue Feb 04, 2003 3:14 am
by BackupUser
Restored from previous forum. Originally posted by Paul.

Personally I use this:
AddSysTrayIcon(1,WindowID(),ExtractIcon_(0,"ProgramName.exe",0))

Of course you must compile your app to make this work because it takes the icon from the compiled exe :)




----------
Visit the PB Resources Site at http://www.reelmediaproductions.com/pb

Posted: Tue Feb 04, 2003 12:40 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

I am using the following code:

Code: Select all

FileName.s = Space(1024)
GetModuleFileName_(GetModuleHandle_(0), @FileName, 1025)  ; Get Name of Exe

hImg.l = ExtractIcon_(GetModuleHandle_(0), @FileName, 0) ; Extract Icon

If hImg = 1 Or hImg = 0     ; If it fails in some Way (for example none included)
  hImg = LoadIcon_(0,#IDI_APPLICATION)   ; Load a Standart Icon
EndIf

AddSysTrayIcon(0,WindowID(),hImg)
This way, the code will find the Executable name by himselve (just in case some User changes it), And if reading fails, a Standart Icon is loaded.

So you can also run this from the Editor, and the Code will automatically use this Standart Icon.

Timo

--------------------------------
Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs and the universe trying to produce bigger and better idiots.

...So far, the universe is winning.

Posted: Tue Feb 04, 2003 9:02 pm
by BackupUser
Restored from previous forum. Originally posted by pusztry.

Does anybody have a sample using 'GetClassLong_'. There are other things that you can pull from that. I can't get that to work.
Thanks Paul and Timo

@Timo I actually used that method without error checking so I will add that now.

- Ryan
RJP Computing

WinXP, PIII 800 MHz, 512MB RAM, SB Live 5.1, NVidia TNT 2 Ultra

Posted: Tue Feb 04, 2003 10:10 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

> Does anybody have a sample using 'GetClassLong_'.

I just played around with that, and had no problems.
Here's some code:

Code: Select all

OpenWindow(0, 0, 0, 100, 100, #PB_Window_Screencentered|#PB_Window_SystemMenu, "Icon test")

hIcon = GetClassLong_(WindowID(), #GCL_HICON)
If hIcon = 0
  MessageRequester("Error!",Str(GetLastError_()), 0)
  End
EndIf

AddSysTrayIcon(0, WindowID(), hIcon)

While WaitWindowEvent()  #PB_EventClosewindow: Wend
End
Important: This one only works, if you create an Executable out of it, including an Icon. Otherwise it will report some error.

By the way, what else do you want to get from it?

Maybe this one helps a bit...

Timo