当前位置: 首页>>代码示例>>C++>>正文


C++ wxIconBundle::AddIcon方法代码示例

本文整理汇总了C++中wxIconBundle::AddIcon方法的典型用法代码示例。如果您正苦于以下问题:C++ wxIconBundle::AddIcon方法的具体用法?C++ wxIconBundle::AddIcon怎么用?C++ wxIconBundle::AddIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wxIconBundle的用法示例。


在下文中一共展示了wxIconBundle::AddIcon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetDolphinIconBundle

wxIconBundle GetDolphinIconBundle()
{
  static wxIconBundle s_bundle;
  if (!s_bundle.IsEmpty())
    return s_bundle;

#ifdef _WIN32

  // Convert the Windows ICO file into a wxIconBundle by tearing it apart into each individual
  // sub-icon using the Win32 API. This is necessary because WX uses its own wxIcons internally
  // which (unlike QIcon in Qt) only contain 1 image per icon, hence why wxIconBundle exists.
  HINSTANCE dolphin = GetModuleHandleW(nullptr);
  for (int size : {16, 32, 48, 256})
  {
    // Extract resource from embedded DolphinWX.rc
    HANDLE win32_icon =
        LoadImageW(dolphin, L"\"DOLPHIN\"", IMAGE_ICON, size, size, LR_CREATEDIBSECTION);
    if (win32_icon && win32_icon != INVALID_HANDLE_VALUE)
    {
      wxIcon icon;
      icon.CreateFromHICON(reinterpret_cast<HICON>(win32_icon));
      s_bundle.AddIcon(icon);
    }
  }

#else

  for (const char* fname : {"Dolphin.png", "dolphin_logo.png", "[email protected]"})
  {
    wxImage image{StrToWxStr(File::GetSysDirectory() + RESOURCES_DIR DIR_SEP + fname),
                  wxBITMAP_TYPE_PNG};
    if (image.IsOk())
    {
      wxIcon icon;
      icon.CopyFromBitmap(image);
      s_bundle.AddIcon(icon);
    }
  }

#endif

  return s_bundle;
}
开发者ID:DINKIN,项目名称:dolphin,代码行数:43,代码来源:WxUtils.cpp


注:本文中的wxIconBundle::AddIcon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。