Thread: LoadImage() Problem

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    83

    LoadImage() Problem

    Code:
    // Create an Icon
        HICON hIcon;
        HICON hIconSm;
        
        hIcon = LoadImage(NULL, "menu_two.ico", IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
        if(!hIcon)
        {
            MessageBox(0, "Large Icon could not be loaded.", "Error #3", 0);
        }
    I'm getting an error on my hIcon = LoadIcon() line.. "invalid conversion from void* to "HICON__*" What's the problem? It looks fine to me! I'm using the win32 api and using dev-c++ 5 (g++)

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    try casting the result of LoadImage to HICON.

    Also notice we have a windows board for questions particularly about windows api and mfc programming.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    83
    Wow! You're my hero man! Worked perfect! BTW is there any difference between a c-style cast and a c++ style cast? (static_cast)?

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Yes some small differences. If using c++ then prefer the c++ style of casting.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM