/*
 * ************************************************************************************************************
 * Author: Marcin Załęczny
 * Copyright (C)2010 Marcin Załęczny <mzaleczny@hotmail.com>
 * License: The GNU Lesser General Public License, version 3.0 (LGPLv3)
 * Library Name: mzstdgraphics
 * Version: 1.05
 * First release date:   2010-11-08
 * Current release date: 2011-03-04
 *
 *
 * This file is part of mzstdgraphics library
 * 
 * mzstdgraphics library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * mzstdgraphics library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 * ************************************************************************************************************
 */

#include "mzIcon.h"
#include "mzstdgraphicsGlobals.h"
#include "mzFileUtils.h"

CIcon::CIcon(HINSTANCE hInst, CString fname, LONG size) {
    this->setRealClassName(L"CIcon");
    this->fname = fname;
    this->_width = size;
    this->_height = size;

    if (FileExists(fname)) {
        this->hIcon = (HICON)LoadImage(hInst, fname.getBuffer(), IMAGE_ICON, this->_width, this->_height, LR_LOADFROMFILE);
    }
}

CIcon::~CIcon() {
    if (this->hIcon) {
        DestroyIcon(this->hIcon);
    }
    this->hIcon = 0;
}
