#include "windows.h" #include "resource.h" //#include "stdafx.h" #include #include #include "String.h" using namespace std; BOOL CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM Param); fstream fin; #include "WString.h" int WINAPI WinMain(HINSTANCE hInst,HINSTANCE,LPSTR,int) { MSG Msg; HWND hWnd; hWnd = CreateDialog(hInst,MAKEINTRESOURCE(IDD_DIALOG_MAIN),NULL,WndProc); if (!hWnd) return 0; UpdateWindow(hWnd); ShowWindow(hWnd,SW_SHOW); while (GetMessage(&Msg,NULL,NULL,NULL)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return 0; } BOOL CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM Param) { switch(uMsg) { case WM_CLOSE: { EndDialog(hWnd,0); PostQuitMessage(0); return true; } case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_BUTTON: { char ssText[256]=""; GetWindowText(GetDlgItem(hWnd,IDC_EDIT1),ssText,256); MessageBox(hWnd,ssText,"CAPTION",MB_OK); }break; case ID_CANCEL: { EndDialog(hWnd,0); PostQuitMessage(0); return true; }break; case IDOK: { WString wsLine; fin.open("input.txt",ios::in); if(!fin){ SetWindowText(GetDlgItem(hWnd,IDC_EDIT1),"error loading"); return true;} char *buffer; buffer = new char[256]; while(!fin.eof()) { fin.getline(buffer,256); wsLine += buffer; SetWindowText(GetDlgItem(hWnd,IDC_EDIT1),wsLine.string); } fin.close(); }break; case IDC_CALCBUTT: { }break; } return true; } } return false; }