static void text_OnClose( HWND hwnd) { int result; result = text_QueryClose(hwnd); if (result == IDCANCEL) { return; } if (result == IDYES) { text_Save(hwnd); } FORWARD_WM_CLOSE(hwnd,DefMDIChildProc); }
BOOL text_SaveAs( HWND hwnd) { struct textWindowData *oldData, *theData; HWND hEditWnd; hEditWnd = hwnd; /*====================================*/ /* Get rid of the current window data */ /* so the save dialog will appear. */ /*====================================*/ oldData = (struct textWindowData *) GetWindowLongPtr(hEditWnd,GWLP_USERDATA); SetWindowLongPtr(hEditWnd,GWLP_USERDATA,(LONG_PTR) NULL); /*================*/ /* Save the file. */ /*================*/ text_Save(hwnd); /*=========================================*/ /* Restore the old window data if the save */ /* was cancelled, otherwise get rid of the */ /* old window data. */ /*=========================================*/ theData = (struct textWindowData *) GetWindowLongPtr(hEditWnd,GWLP_USERDATA); if (theData != NULL) { SetWindowText(hEditWnd,szFileName); if (oldData != NULL) { free(oldData); } } else { SetWindowLongPtr(hEditWnd,GWLP_USERDATA,(LONG_PTR) oldData); } return(TRUE); }
static void text_OnCommand( HWND hwnd, int id, HWND hctl, UINT codeNotify) { switch (id) { case ID_EDIT_SET_FONT: text_OnFont(hwnd); return; case ID_EDIT_BALANCE: Balance(GetDlgItem(hwnd,ID_EDIT_CONTROL)); return; case ID_EDIT_COMMENT: DoComment(GetDlgItem(hwnd,ID_EDIT_CONTROL)); return; case ID_EDIT_UNCOMMENT: DoUncomment(GetDlgItem(hwnd,ID_EDIT_CONTROL)); return; case ID_HELP_COMPLETE: EditComplete(GetDlgItem(hwnd,ID_EDIT_CONTROL)); return; case ID_EDIT_UNDO: FORWARD_WM_UNDO(GetDlgItem(hwnd, ID_EDIT_CONTROL), SendMessage); return; case ID_EDIT_CUT: FORWARD_WM_CUT(GetDlgItem(hwnd, ID_EDIT_CONTROL), SendMessage); return; case ID_EDIT_COPY: FORWARD_WM_COPY(GetDlgItem(hwnd, ID_EDIT_CONTROL), SendMessage); return; case ID_EDIT_PASTE: FORWARD_WM_PASTE(GetDlgItem(hwnd, ID_EDIT_CONTROL), SendMessage); FixTextLineEndings(GetDlgItem(hwnd, ID_EDIT_CONTROL)); return; case ID_EDIT_CLEAR: FORWARD_WM_CLEAR(GetDlgItem(hwnd, ID_EDIT_CONTROL), SendMessage); return; case ID_EDIT_SELECT_ALL: Edit_SetSel(GetDlgItem(hwnd, ID_EDIT_CONTROL), 0, -1); return; case ID_EDIT_CONTROL: text_OnEdit(hwnd,id,hctl,codeNotify); return; case ID_BUFFER_FIND: SetUpSearch(GetDlgItem(hwnd,ID_EDIT_CONTROL),0); return; case ID_BUFFER_REPLACE: SetUpSearch(GetDlgItem(hwnd,ID_EDIT_CONTROL),1); return; case ID_FILE_PRINT: PrintFile(hwnd); return; case ID_FILE_SAVE: text_Save(hwnd); return; case ID_FILE_SAVE_AS: text_SaveAs(hwnd); return; case ID_BUFFER_LOAD: case ID_BUFFER_BATCH: case ID_BUFFER_LOAD_BUFFER: LoadBatchBufferSelection(GetDlgItem(hwnd,ID_EDIT_CONTROL),id); return; } FORWARD_WM_COMMAND(hwnd, id, hctl, codeNotify, DefMDIChildProc); }