src/Notepad3.c
bool SelectExternalToolBar(HWND hwnd)
{
  UNUSED(hwnd);

  WCHAR szArgs[MAX_PATH] = { L'\0' };
  WCHAR szArg2[MAX_PATH] = { L'\0' };
  WCHAR szFile[MAX_PATH] = { L'\0' };
  WCHAR szFilter[MAX_PATH] = { L'\0' };
  OPENFILENAME ofn;
  ZeroMemory(&ofn, sizeof(OPENFILENAME));

  GetDlgItemText(hwnd, IDC_COMMANDLINE, szArgs, COUNTOF(szArgs));
  ExpandEnvironmentStringsEx(szArgs, COUNTOF(szArgs));
  ExtractFirstArgument(szArgs, szFile, szArg2, MAX_PATH);

  GetLngString(IDS_MUI_FILTER_BITMAP, szFilter, COUNTOF(szFilter));
  PrepareFilterStr(szFilter);

  ofn.lStructSize = sizeof(OPENFILENAME);
  ofn.hwndOwner = hwnd;
  ofn.lpstrFilter = szFilter;
  ofn.lpstrFile = szFile;
  ofn.nMaxFile = COUNTOF(szFile);
  ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT
    | OFN_PATHMUSTEXIST | OFN_SHAREAWARE | OFN_NODEREFERENCELINKS;

  if (GetOpenFileName(&ofn)) {
    PathQuoteSpaces(szFile);
    if (StrIsNotEmpty(szArg2))
    {
      StringCchCat(szFile, COUNTOF(szFile), L" ");
      StringCchCat(szFile, COUNTOF(szFile), szArg2);
    }
    PathRelativeToApp(szFile, s_tchToolbarBitmap, COUNTOF(s_tchToolbarBitmap), true,true, true);
    IniFileSetString(Globals.IniFile, L"Toolbar Images", L"BitmapDefault", s_tchToolbarBitmap);
  }

  if (StrIsNotEmpty(s_tchToolbarBitmap))
  {
    StringCchCopy(szFile, COUNTOF(szFile), s_tchToolbarBitmap);
    PathRemoveExtension(szFile);
    StringCchCat(szFile, COUNTOF(szFile), L"Hot.bmp");
    if (PathFileExists(szFile)) {
      PathRelativeToApp(szFile, s_tchToolbarBitmapHot, COUNTOF(s_tchToolbarBitmapHot), true, true, true);
      IniFileSetString(Globals.IniFile, L"Toolbar Images", L"BitmapHot", s_tchToolbarBitmapHot);
    }
    else {
      StringCchCopy(s_tchToolbarBitmapHot, COUNTOF(s_tchToolbarBitmapHot), L"");
      IniFileDelete(Globals.IniFile, L"Toolbar Images", L"BitmapHot", false);
    }

    StringCchCopy(szFile, COUNTOF(szFile), s_tchToolbarBitmap);
    PathRemoveExtension(szFile);
    StringCchCat(szFile, COUNTOF(szFile), L"Disabled.bmp");
    if (PathFileExists(szFile)) {
      PathRelativeToApp(szFile, s_tchToolbarBitmapDisabled, COUNTOF(s_tchToolbarBitmapDisabled), true, true, true);
      IniFileSetString(Globals.IniFile, L"Toolbar Images", L"BitmapDisabled", s_tchToolbarBitmapDisabled);
    }
    else {
      StringCchCopy(s_tchToolbarBitmapHot, COUNTOF(s_tchToolbarBitmapHot), L"");
      IniFileDelete(Globals.IniFile, L"Toolbar Images", L"BitmapDisabled", false);
    }
    Settings.ToolBarTheme = 2;
    return true;
  }
  else {
    IniFileDelete(Globals.IniFile, L"Toolbar Images", L"BitmapHot", false);
    IniFileDelete(Globals.IniFile, L"Toolbar Images", L"BitmapDisabled", false);
  }
  return false;
}
//=============================================================================
//
//  SelectExternalToolBar() - Select and Load an external Bitmal as ToolBarImage
//

Select and Load an external Bitmal as ToolBarImage
Select and Load an external Bitmal as ToolBarImage
bool SelectExternalToolBar(HWND hwnd)
{
  UNUSED(hwnd);
  WCHAR szArgs[MAX_PATH] = { L'\0' };
  WCHAR szArg2[MAX_PATH] = { L'\0' };
  WCHAR szFile[MAX_PATH] = { L'\0' };
  WCHAR szFilter[MAX_PATH] = { L'\0' };
  OPENFILENAME ofn;
  ZeroMemory(&ofn, sizeof(OPENFILENAME));
  GetDlgItemText(hwnd, IDC_COMMANDLINE, szArgs, COUNTOF(szArgs));
  ExpandEnvironmentStringsEx(szArgs, COUNTOF(szArgs));
  ExtractFirstArgument(szArgs, szFile, szArg2, MAX_PATH);
  GetLngString(IDS_MUI_FILTER_BITMAP, szFilter, COUNTOF(szFilter));
  PrepareFilterStr(szFilter);
  ofn.lStructSize = sizeof(OPENFILENAME);
  ofn.hwndOwner = hwnd;
  ofn.lpstrFilter = szFilter;
  ofn.lpstrFile = szFile;
  ofn.nMaxFile = COUNTOF(szFile);
  ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT
    | OFN_PATHMUSTEXIST | OFN_SHAREAWARE | OFN_NODEREFERENCELINKS;
  if (GetOpenFileName(&ofn)) {
    PathQuoteSpaces(szFile);
    if (StrIsNotEmpty(szArg2))
    {
      StringCchCat(szFile, COUNTOF(szFile), L" ");
      StringCchCat(szFile, COUNTOF(szFile), szArg2);
    }
    PathRelativeToApp(szFile, s_tchToolbarBitmap, COUNTOF(s_tchToolbarBitmap), true,true, true);
    IniFileSetString(Globals.IniFile, L"Toolbar Images", L"BitmapDefault", s_tchToolbarBitmap);
  }
  if (StrIsNotEmpty(s_tchToolbarBitmap))
  {
    StringCchCopy(szFile, COUNTOF(szFile), s_tchToolbarBitmap);
    PathRemoveExtension(szFile);
    StringCchCat(szFile, COUNTOF(szFile), L"Hot.bmp");
    if (PathFileExists(szFile)) {
      PathRelativeToApp(szFile, s_tchToolbarBitmapHot, COUNTOF(s_tchToolbarBitmapHot), true, true, true);
      IniFileSetString(Globals.IniFile, L"Toolbar Images", L"BitmapHot", s_tchToolbarBitmapHot);
    }
    else {
      StringCchCopy(s_tchToolbarBitmapHot, COUNTOF(s_tchToolbarBitmapHot), L"");
      IniFileDelete(Globals.IniFile, L"Toolbar Images", L"BitmapHot", false);
    }
    StringCchCopy(szFile, COUNTOF(szFile), s_tchToolbarBitmap);
    PathRemoveExtension(szFile);
    StringCchCat(szFile, COUNTOF(szFile), L"Disabled.bmp");
    if (PathFileExists(szFile)) {
      PathRelativeToApp(szFile, s_tchToolbarBitmapDisabled, COUNTOF(s_tchToolbarBitmapDisabled), true, true, true);
      IniFileSetString(Globals.IniFile, L"Toolbar Images", L"BitmapDisabled", s_tchToolbarBitmapDisabled);
    }
    else {
      StringCchCopy(s_tchToolbarBitmapHot, COUNTOF(s_tchToolbarBitmapHot), L"");
      IniFileDelete(Globals.IniFile, L"Toolbar Images", L"BitmapDisabled", false);
    }
    Settings.ToolBarTheme = 2;
    return true;
  }
  else {
    IniFileDelete(Globals.IniFile, L"Toolbar Images", L"BitmapHot", false);
    IniFileDelete(Globals.IniFile, L"Toolbar Images", L"BitmapDisabled", false);
  }
  return false;
}
bool SelectExternalToolBar ( HWND hwnd ) { UNUSED ( hwnd ) ; WCHAR szArgs [ MAX_PATH ] = { L' \0 ' } ; WCHAR szArg2 [ MAX_PATH ] = { L' \0 ' } ; WCHAR szFile [ MAX_PATH ] = { L' \0 ' } ; WCHAR szFilter [ MAX_PATH ] = { L' \0 ' } ; OPENFILENAME ofn ; ZeroMemory ( & ofn , sizeof ( OPENFILENAME ) ) ; GetDlgItemText ( hwnd , IDC_COMMANDLINE , szArgs , COUNTOF ( szArgs ) ) ; ExpandEnvironmentStringsEx ( szArgs , COUNTOF ( szArgs ) ) ; ExtractFirstArgument ( szArgs , szFile , szArg2 , MAX_PATH ) ; GetLngString ( IDS_MUI_FILTER_BITMAP , szFilter , COUNTOF ( szFilter ) ) ; PrepareFilterStr ( szFilter ) ; ofn . lStructSize = sizeof ( OPENFILENAME ) ; ofn . hwndOwner = hwnd ; ofn . lpstrFilter = szFilter ; ofn . lpstrFile = szFile ; ofn . nMaxFile = COUNTOF ( szFile ) ; ofn . Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST | OFN_SHAREAWARE | OFN_NODEREFERENCELINKS ; if ( GetOpenFileName ( & ofn ) ) { PathQuoteSpaces ( szFile ) ; if ( StrIsNotEmpty ( szArg2 ) ) { StringCchCat ( szFile , COUNTOF ( szFile ) , L" " ) ; StringCchCat ( szFile , COUNTOF ( szFile ) , szArg2 ) ; } PathRelativeToApp ( szFile , s_tchToolbarBitmap , COUNTOF ( s_tchToolbarBitmap ) , true , true , true ) ; IniFileSetString ( Globals . IniFile , L" " , L" " , s_tchToolbarBitmap ) ; } if ( StrIsNotEmpty ( s_tchToolbarBitmap ) ) { StringCchCopy ( szFile , COUNTOF ( szFile ) , s_tchToolbarBitmap ) ; PathRemoveExtension ( szFile ) ; StringCchCat ( szFile , COUNTOF ( szFile ) , L" " ) ; if ( PathFileExists ( szFile ) ) { PathRelativeToApp ( szFile , s_tchToolbarBitmapHot , COUNTOF ( s_tchToolbarBitmapHot ) , true , true , true ) ; IniFileSetString ( Globals . IniFile , L" " , L" " , s_tchToolbarBitmapHot ) ; } else { StringCchCopy ( s_tchToolbarBitmapHot , COUNTOF ( s_tchToolbarBitmapHot ) , L" " ) ; IniFileDelete ( Globals . IniFile , L" " , L" " , false ) ; } StringCchCopy ( szFile , COUNTOF ( szFile ) , s_tchToolbarBitmap ) ; PathRemoveExtension ( szFile ) ; StringCchCat ( szFile , COUNTOF ( szFile ) , L" " ) ; if ( PathFileExists ( szFile ) ) { PathRelativeToApp ( szFile , s_tchToolbarBitmapDisabled , COUNTOF ( s_tchToolbarBitmapDisabled ) , true , true , true ) ; IniFileSetString ( Globals . IniFile , L" " , L" " , s_tchToolbarBitmapDisabled ) ; } else { StringCchCopy ( s_tchToolbarBitmapHot , COUNTOF ( s_tchToolbarBitmapHot ) , L" " ) ; IniFileDelete ( Globals . IniFile , L" " , L" " , false ) ; } Settings . ToolBarTheme = 2 ; return true ; } else { IniFileDelete ( Globals . IniFile , L" " , L" " , false ) ; IniFileDelete ( Globals . IniFile , L" " , L" " , false ) ; } return false ; }
SelectExternalToolBar() - Select and Load an external Bitmal as ToolBarImage
SelectExternalToolBar () - Select and Load an external Bitmal as ToolBarImage