Page 1 of 1

Problem : transparent titlebar icon

Posted: Tue Sep 09, 2008 1:57 am
by eddy
Hi,

The SysTray icon and Taskbar icon are transparent.
I want to understand why my Titlebar icon is not tranparent.

Code: Select all

w=800
h=600
win=OpenWindow(1,0,0,w,h,"Animated Icon Titlebar",$C80001)
img=CreateImage(#PB_Any,16,16)
StartDrawing(ImageOutput(img))
   FrontColor(#Red)
   Box(0,0,16,16)
StopDrawing()
For i=1 To 16
   CreateImage(i,16,16)
   *Bitmap.LONG=IsImage(i)
   DeleteObject_(*Bitmap\l)
   
   msk=CreateImage(#PB_Any,16,16)
   StartDrawing(ImageOutput(msk))
      DrawingMode(0)
      FrontColor(#Black)
      Box(0,0,16,16)
      
      FrontColor(#White)
      y=Random(12)
      Box(00,(y+0),4,16)
      Box(04,(y+12),4,16)
      Box(08,(y+8),4,16)
      Box(12,(y+4),4,16)
   StopDrawing()
   
   NewIcon.ICONINFO
   NewIcon\fIcon=1
   NewIcon\hbmMask=ImageID(msk)
   NewIcon\hbmColor=ImageID(img)
   *Bitmap\l=CreateIconIndirect_(@NewIcon)
Next
AddSysTrayIcon(1,win,ImageID(ico+1))

Repeat
   e=WaitWindowEvent()
   ico=(ico+1)%16
   SendMessage_(win,#WM_SETICON,0,ImageID(ico+1))
   AddSysTrayIcon(1,win,ImageID(ico+1))
Until e=#PB_Event_CloseWindow

Re: Problem : transparent titlebar icon

Posted: Tue Sep 09, 2008 10:08 pm
by Demivec
eddy wrote:The SysTray icon and Taskbar icon are transparent.
I want to understand why my Titlebar icon is not tranparent
The SysTray icon and taskbar icon are transparent because they are overlaid on a grey background. To demonstrate this run your program and click on an empty spot on the taskbar. This will remove the focus from your window and leave it still visible. You should be able to see that it has a transparent icon (background).

I examined your code with my limited knowledge and high level of curiousity. You'll notice when your code runs that if you look closely at the Titlebar icon it is partially transparent. I noticed that the icon masks have green in them where they should have black, possibly the cause of the problem. I couldn't determine why they would have green in them, though I did try to remove it manually without much success. The solution may be to use CreateIcon_() instead of CreateIconIndirect_().

Your code does not implement DestroyIcon_() and so it doesn't free up the icon resources that were used. It should save the handles returned from CreateIconIndirec_() and then before the program exits cycle through the handles and call DestroyIcon_(). You're probably familiar with that process already.

I hope some of that helps you.