/****************************************************************************** * void SaveOnFileSave(HWND hwnd) * * frame window File/Save menu command handler * * parameters: * hwnd - window handle of active child window or NULL of none active ******************************************************************************/ void SaveOnFileSave(HWND hwnd) { CHILDINSTANCEDATA PICFAR* pInstance = ChildGetInstanceData(hwnd); BYTE PICHUGE* pSavedImage; DWORD dwSavedLen; SAVEOP *pSaveOp; char szFilename[_MAX_PATH + 1]; if ( hwnd == NULL || pInstance == NULL || !ChildIsModified(hwnd) ) return; /* File/Save should have been grayed */ pSaveOp = pInstance->pOpenOp->pSaveOp; lstrcpy(szFilename, pInstance->pszFilename); if ( pSaveOp == 0 || pSaveOp->nFoundParmVer == 0 || pInstance->bFormatModified ) { if ( !SaveGetSaveAs(szFilename, &pSaveOp) ) return; } /* save the image, then reopen the image into the same window so the user can see the result of the save options */ if ( SaveImage(hwnd, szFilename, pSaveOp, &pSavedImage, &dwSavedLen) ) /* re-open from saved image into same window */ OpenImage(hwnd, szFilename, pSavedImage, dwSavedLen, OP_SILENT | OP_INISETTINGS); }
/****************************************************************************** * void MenuStatusFileSave(HMENU hmenu, HWND hwnd) * * enable/gray File/Save menu item * * parameters: * hmenu - menu containing the item (could be frame menu or popup) * hwnd - active child window or NULL * * notes: * grayed unless there is an active child, and it has been modified * and its image's open opcode defines a save opcode for saving and * that save opcode dll is loaded ******************************************************************************/ void MenuStatusFileSave(HMENU hmenu, HWND hwnd) { CHILDINSTANCEDATA PICFAR* pInstance = ChildGetInstanceData(hwnd); int i; for ( i = 0; pSaveOpTable[i] != 0 && pSaveOpTable[i]->nFoundParmVer == 0; i++ ) ; if ( hwnd != NULL && pInstance != 0 && ChildIsModified(hwnd) && pSaveOpTable[i] != 0 ) EnableMenuItem(hmenu, IDM_FILE_SAVE, MF_BYCOMMAND | MF_ENABLED); else EnableMenuItem(hmenu, IDM_FILE_SAVE, MF_BYCOMMAND | MF_GRAYED); }