//Window Procedure LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { int id; static HWND hEdit; switch (msg) { case WM_CREATE: // Create Edit Control hEdit = CreateWindow(TEXT("EDIT"), NULL, WS_CHILD | WS_VISIBLE | ES_WANTRETURN | ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL | ES_AUTOHSCROLL | WS_HSCROLL, 0, 0, 0, 0, hWnd, (HMENU)ID_EDIT, hInst, NULL); lstrcat(szTitle, TEXT("[無題]")); SetWindowText(hWnd, szTitle); Edit_LimitText(hEdit, 0); break; case WM_SIZE: // Adjust Window Size MoveWindow(hEdit, 0, 0, LOWORD(lp), HIWORD(lp), TRUE); break; case WM_COMMAND: switch (LOWORD(wp)) { case IDM_NEW: MyNew(hEdit); break; case IDM_OPEN: MyOpen(hEdit); break; case IDM_END: SendMessage(hWnd, WM_CLOSE, 0, 0); break; case IDM_SAVE: MySave(hEdit); break; case IDM_SAVEAS: MySaveAs(hEdit); break; } break; case WM_SETFOCUS: SetFocus(hEdit); //set focus to edit control break; case WM_CLOSE: id = MyConfirm(hEdit); if (id == IDCANCEL) break; id = MessageBox(hWnd, TEXT("終了してもよろしいですか"), TEXT("確認"), MB_YESNO | MB_ICONQUESTION); if (id == IDYES) { DestroyWindow(hEdit); //destroy edit control DestroyWindow(hWnd); } break; case WM_DESTROY: PostQuitMessage(0); break; default: return (DefWindowProc(hWnd, msg, wp, lp)); } return 0; }
PATCH_RET_CODE OpenOld( foff len, int prompt, foff new_size, foff new_sum ) { int handle; foff actual_len; prompt=prompt; _splitpath( NewName, NULL, NULL, new_fname, new_ext ); _splitpath( path, drive, dir, fname, ext ); _makepath( new_path, drive, dir, new_fname, new_ext ); NewName = new_path; #if !defined( INSTALL_PROGRAM ) { char temp[_MAX_PATH]; char msgbuf[MAX_RESOURCE_SIZE]; if( prompt && DoPrompt ) { for( ;; ) { GetMsg( msgbuf, MSG_MODIFY ); cprintf( msgbuf, path ); while( kbhit() ) getch(); gets( temp ); if( tolower( temp[0] ) == 'n' ) { PatchError( ERR_PATCH_ABORTED ); } if( tolower( temp[0] ) == 'y' ) break; } } } #endif handle = open( path, O_RDONLY+O_BINARY, 0 ); FileCheck( handle, path ); MyOpen( &OldFile, handle, path ); actual_len = lseek( handle, 0, SEEK_END ); SeekCheck( actual_len, path ); if( actual_len != len && (actual_len + sizeof( PATCH_LEVEL )) != len && (actual_len - sizeof( PATCH_LEVEL )) != len ) { if( actual_len >= new_size ) { if( CheckSumOld( new_size ) == new_sum ) { MyClose( &OldFile ); return( PATCH_ALREADY_PATCHED ); } } PatchError( ERR_WRONG_SIZE, path, actual_len, len ); MyClose( &OldFile ); return( PATCH_BAD_LENGTH ); } SeekCheck( lseek( handle, 0, SEEK_SET ), path ); return( PATCH_RET_OKAY ); }