MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / Style_Export

Function Style_Export

src/Styles.c:1272–1312  ·  view source on GitHub ↗

============================================================================= Style_Export()

Source from the content-addressed store, hash-verified

1270// Style_Export()
1271//
1272BOOL Style_Export ( HWND hwnd )
1273{
1274 WCHAR szFile[MAX_PATH * 2] = L"";
1275 WCHAR szFilter[256];
1276 OPENFILENAME ofn;
1277 DWORD dwError = ERROR_SUCCESS;
1278 ZeroMemory ( &ofn, sizeof ( OPENFILENAME ) );
1279 GetString ( IDS_FILTER_INI, szFilter, COUNTOF ( szFilter ) );
1280 PrepareFilterStr ( szFilter );
1281 ofn.lStructSize = sizeof ( OPENFILENAME );
1282 ofn.hwndOwner = hwnd;
1283 ofn.lpstrFilter = szFilter;
1284 ofn.lpstrFile = szFile;
1285 ofn.lpstrDefExt = L"ini";
1286 ofn.nMaxFile = COUNTOF ( szFile );
1287 ofn.Flags = /*OFN_FILEMUSTEXIST |*/ OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT
1288 | OFN_PATHMUSTEXIST | OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/ | OFN_OVERWRITEPROMPT;
1289 if ( GetSaveFileName ( &ofn ) ) {
1290 int i, iLexer;
1291 WCHAR *pIniSection = LocalAlloc ( LPTR, sizeof ( WCHAR ) * 32 * 1024 );
1292 int cchIniSection = ( int ) LocalSize ( pIniSection ) / sizeof ( WCHAR );
1293 for ( iLexer = 0; iLexer < NUMLEXERS; iLexer++ ) {
1294 IniSectionSetString ( pIniSection, L"FileNameExtensions", pLexArray[iLexer]->szExtensions );
1295 i = 0;
1296 while ( pLexArray[iLexer]->Styles[i].iStyle != -1 ) {
1297 IniSectionSetString ( pIniSection, pLexArray[iLexer]->Styles[i].pszName, pLexArray[iLexer]->Styles[i].szValue );
1298 i++;
1299 }
1300 if ( !WritePrivateProfileSection ( pLexArray[iLexer]->pszName, pIniSection, szFile ) ) {
1301 dwError = GetLastError();
1302 }
1303 ZeroMemory ( pIniSection, cchIniSection );
1304 }
1305 LocalFree ( pIniSection );
1306 if ( dwError != ERROR_SUCCESS ) {
1307 MsgBox ( MBINFO, IDS_EXPORT_FAIL, szFile );
1308 }
1309 return ( TRUE );
1310 }
1311 return ( FALSE );
1312}
1313
1314
1315//=============================================================================

Callers 1

Style_ConfigDlgProcFunction · 0.85

Calls 3

PrepareFilterStrFunction · 0.85
IniSectionSetStringFunction · 0.85
MsgBoxFunction · 0.85

Tested by

no test coverage detected