fix a notifier error that can't set icon from its exe file

This commit is contained in:
Jinhao
2016-06-05 02:36:38 +08:00
parent 108a31d907
commit 5ab0cfdd17
5 changed files with 84 additions and 61 deletions

View File

@@ -34,10 +34,27 @@
#include "detail/image_bmp.hpp"
#include "detail/image_ico.hpp"
#include "image_accessor.hpp"
namespace nana
{
namespace paint
{
#if defined(NANA_WINDOWS)
HICON image_accessor::icon(const nana::paint::image& img)
{
auto ico = dynamic_cast<paint::detail::image_ico*>(img.image_ptr_.get());
if (ico && ico->ptr())
return *(ico->ptr());
return nullptr;
}
#else
int image_accessor::icon(const image&)
{
return 0;
}
#endif
namespace detail
{
//class image_ico

View File

@@ -0,0 +1,30 @@
/*
* Paint Image Accessor
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file nana/paint/image_accessor.hpp
* @brief A declaration of class image_accessor. It is used to access image private data, internal use.
*/
#ifndef NANA_PAINT_IMAGE_ACCESS_HEADER_INCLUDED
#define NANA_PAINT_IMAGE_ACCESS_HEADER_INCLUDED
namespace nana
{
namespace paint
{
class image_accessor
{
public:
#if defined(NANA_WINDOWS)
static HICON icon(const image&);
#else
static int icon(const image&);
#endif
};
}
}
#endif