1 #include <Windows.h> 2 #include "resource.h" 3 #include <stdio.h> 4 5 void echo(char *str) 6 { 7 MessageBox(NULL, str, TEXT("提示"), MB_OK); 8 } 9 10 int CALLBACK DialogProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) 11 { 12 OPENFILENAME ofn; // OpenFileName 的结构体 13 char szFile[260]; // 保存文件名称的缓冲字符串 14 HANDLE hf; // 文件句柄 15 DWORD fileSize, readSize; 16 char *buffer; 17 18 switch(Message) 19 { 20 case WM_INITDIALOG: 21 break; 22 case WM_COMMAND: 23 { 24 switch(wParam) 25 { 26 case ID_NEW_FILE: 27 SetDlgItemText(hwnd, IDC_TEXT, ""); 28 break; 29 case ID_OPEN_FILE: 30 // 初始化 OPENFILENAME 结构体 31 ZeroMemory(&ofn, sizeof(ofn)); 32 ofn.lStructSize = sizeof(ofn); 33 ofn.hwndOwner = hwnd; 34 ofn.lpstrFile = szFile; 35 // Set lpstrFile[0] to ' ' so that GetOpenFileName does not 36 // use the contents of szFile to initialize itself. 37 ofn.lpstrFile[0] = '