This is the mail archive of the cygwin-xfree@cygwin.com mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: XWin and the ICON on xterm window


On Wed, 19 May 2004, Earle F. Philhower III wrote:

> Howdy,
> 
> At 02:36 PM 5/19/2004 +0200, Alexander Gottwald wrote:
> >On Wed, 19 May 2004, Angelo Graziosi (D. Zanello) wrote:
> > > From version 6.7-5 I have noted that starting XWin with startxwin.bat
> > > (.sh) produces an xterm window for which the X-Icon near its title looks
> > > corrupted, as if there were a double reflection/refraction.
> > > Also others X-Windows application (like emacs) presents this effect.
> >With XWin-6.7-5 there was a change in the way how Icons are loaded to fix a
> >problem with freeing icons twice.
> >@Earle: What about using LoadIcon again and duplicating the handle with 
> >CopyIcon?
> >      HICON tmp = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN));
> >      g_hiconX = CopyIcon(tmp);
> 
> I'm not sure what's being to referred to in the original problem from Angelo,
> but FWIW the change back a while was getting rid of all LoadIcon() calls and
> instead using LoadImage()s instead (since we support DLL icons, .ico files,
> etc.).  You need to use DestroyIcon() if the HANDLE is a from LoadIcon, and
> just plain DestroyObject() if the HANDLE is from LoadImage or you get a
> GDI leak.

from MSDN LoadImage()

When you are finished using a bitmap, cursor, or icon you loaded without 
specifying the LR_SHARED flag, you can release its associated memory by calling 
one of the functions in the following table.

Resource 	Release function
Bitmap		DeleteObject
Cursor 		DestroyCursor
Icon 		DestroyIcon

All calls to LoadImage use the IMAGE_ICON type. 

I know that we can not call DestroyIcon() on an handle created by LoadIcon() since 
windows takes care of them and they are shared. That's why i mentioned CopyIcon().
This will create a copy that is not managed by windows and can be safely destroyed.

DeleteObject is never called on an icon handle in out code. Only DestroyIcon is.

> Lev Bishop was talking about doing some changes to do a LoadImage() for both
> large and small icon sizes, but I don't think anything became of it...

Using LoadImage results in broken images now. I'd like to revert to LoadIcon but 
in a safe way. 

bye
	ago
BTW: I think we need to use a bug tracking system. When I'll change the code, I need
the testcase without digging through hundred of mails. The next user complaints will
definitly go into the freedesktop.org bugzilla.
-- 
 Alexander.Gottwald@s1999.tu-chemnitz.de 
 http://www.gotti.org           ICQ: 126018723


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]