daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Sep 19th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifdef __WXMSW__
  2.     #include <Windows.h>
  3.     #include <CommCtrl.h>
  4.     #include <wx/msw/private.h>
  5.     typedef int (WINAPI *func_LoadIconWithScaleDown)(HINSTANCE, LPCWSTR, int, int, HICON*);
  6. #endif
  7.  
  8. void MainFrame::BindAppIcon() {
  9. #ifdef __WXMSW__
  10.     wxDynamicLibrary comctl32("comctl32", wxDL_DEFAULT | wxDL_QUIET);
  11.     func_LoadIconWithScaleDown load_icon_scaled = reinterpret_cast<func_LoadIconWithScaleDown>(comctl32.GetSymbol("LoadIconWithScaleDown"));
  12.     int icon_set_count = 0;
  13.  
  14.     HICON hIconLg;
  15.     if (load_icon_scaled && SUCCEEDED(load_icon_scaled(wxGetInstance(), _T("AAAAA_MAINICON"), ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), &hIconLg))) {
  16.         ::SendMessage(GetHandle(), WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(hIconLg));
  17.         ++icon_set_count;
  18.     }
  19.     HICON hIconSm;
  20.     if (load_icon_scaled && SUCCEEDED(load_icon_scaled(wxGetInstance(), _T("AAAAA_MAINICON"), ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), &hIconSm))) {
  21.         ::SendMessage(GetHandle(), WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(hIconSm));
  22.         ++icon_set_count;
  23.     }
  24.  
  25.     if (icon_set_count == 2) return;
  26.     // otherwise fall back to Wx method of setting icon
  27. #endif
  28.     wxIcon icon = wxXmlResource::Get()->LoadIcon(wxT("MainIcon"));
  29.  
  30.     if (!icon.IsOk()) {
  31.         wxLogInfo(_("Main icon not found"));
  32.         icon = wxICON(wxvbam);
  33.     }
  34.  
  35.     SetIcon(icon);
  36. }
RAW Paste Data
Top