CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2010
    Posts
    94

    Arrow ExtractAssociatedIcon

    I have an icon file name specified arbitrarily as
    filename, filename.ico, filename.exe etc
    How can I use this function to extract the main icon from the file ?

    My attempt was

    WORD id;
    HICON hc=ExtractAssociatedIcon(0, szfilename, &id);
    where szfilename specified tha path to the icon file.

    But the icon displayed as an unknown file icon.

    If I changed it into
    WORD id=0;
    HICON hc=ExtractAssociatedIcon(0, szfilename, &id);

    then I would get icons with black background (without transparancy)

    Any advice please ?

    Thank you.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: ExtractAssociatedIcon

    Quote Originally Posted by Sharpie View Post
    My attempt was

    WORD id;
    HICON hc=ExtractAssociatedIcon(0, szfilename, &id);
    where szfilename specified tha path to the icon file.

    But the icon displayed as an unknown file icon.
    Perhaps, uninitialized id contains some garbage, so it cannot be treated as the valid icon index?

    Quote Originally Posted by Sharpie View Post
    If I changed it into
    WORD id=0;
    HICON hc=ExtractAssociatedIcon(0, szfilename, &id);

    then I would get icons with black background (without transparancy)
    Any advice please ?
    But this function does not display the icon! How do you know its background is black?
    Victor Nijegorodov

  3. #3
    Join Date
    Jul 2010
    Posts
    94

    Re: ExtractAssociatedIcon

    Thanks alot,
    I know it because I have tested both of which I have stated above along with the final solution.
    In the first case when no value is assigned, the icon is displayed as an unknown icon (it looks like an unidentified file icon in one's folder) while it is displayed as a non-transparent ico-image in the second case. The final solution provides a transparent image that I have no idea why so it does.

  4. #4
    Join Date
    Jul 2010
    Posts
    94

    Re: ExtractAssociatedIcon

    Hello, anybodys here ?
    I would like to display icons in my listview control (report style), and as mentioned some icons extracted with initialised iconID equal to 0 result in non-transparent background images. Therefore, in Vista or Win7 I can still see the icon of a selected item but in XP the selected highlight color turns it off completely. Have you ever had this problem before ?

    Thank you.

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: ExtractAssociatedIcon

    Which icons?
    How do you display them in the listview control? Could you show your code?
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured