怎样将图标资源(IDR_XXX)加载到HICON里!!!????

解决方案 »

  1.   

    LoadIcon
    The LoadIcon function loads the specified icon resource from the executable (.EXE) file associated with an application instance. This function has been superseded by the LoadImage functionHICON LoadIcon(
      HINSTANCE hInstance, // handle to application instance
      LPCTSTR lpIconName   // icon-name string or icon resource 
                           // identifier
    );
     
    Parameters
    hInstance 
    Handle to an instance of the module whose executable file contains the icon to be loaded. This parameter must be NULL when a standard icon is being loaded. 
    lpIconName 
    Pointer to a null-terminated string that contains the name of the icon resource to be loaded. Alternatively, this parameter can contain the resource identifier in the low-order word and zero in the high-order word. Use the MAKEINTRESOURCE macro to create this value. 
    To use one of the predefined icons, set the hInstance parameter to NULL and the lpIconName parameter to one of the following values: Value Description 
    IDI_APPLICATION Default application icon. 
    IDI_ASTERISK Same as IDI_INFORMATION. 
    IDI_ERROR Hand-shaped icon. 
    IDI_EXCLAMATION Same as IDI_WARNING. 
    IDI_HAND Same as IDI_ERROR.  
    IDI_INFORMATION Asterisk icon. 
    IDI_QUESTION Question  icon. 
    IDI_WARNING Exclamation point icon. 
    IDI_WINLOGO Windows logo icon. Return Values
    If the function succeeds, the return value is a handle to the newly loaded icon.If the function fails, the return value is NULL. To get extended error information, callGetLastError. Res
    LoadIcon loads the icon resource only if it has not been loaded; otherwise, it retrieves a handle to the existing resource. The function searches the icon resource for the icon most appropriate for the current display. The icon resource can be a color or monochrome bitmap. LoadIcon can only load an icon whose size conforms to the SM_CXICON and SM_CYICON system metric values. Use the LoadImage function to load icons of other sizes.Windows CE: Predefined icons (IDI_*) are not supported. In Windows CE 1.0, the icon must be a two bit per pixel (.ic2) icon or a monochrome icon. See Also
    Icons Overview, Icon Functions, CreateIcon, LoadImage, MAKEINTRESOURCE  
      

  2.   

    楼上的强, 真应了MSDN的话为了让你了解我们产品的一句话, 我愿意说 100句话来解释!
      

  3.   

    HICON hIconNew = AfxGetApp()->LoadIcon(IDI_ICON1);