Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Phili
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
#include "resource.h" #include <windows.h> #include "person.h" BOOL CALLBACK MainDialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); BOOL CALLBACK AddDialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); BOOL CALLBACK ShowDialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); HINSTANCE hinst; int WINAPI WinMain(HINSTANCE hInst, HINSTANCE previnst, LPSTR cmdline, int showcmd) { DialogBox(hinst, MAKEINTRESOURCE(IDD_DIALOG1),0, MainDialogProc); return 0; } BOOL CALLBACK MainDialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_CLOSE: case WM_DESTROY: { EndDialog(hwnd,0); } case WM_INITDIALOG: { return true; } case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_ADD: { DialogBox(hinst, MAKEINTRESOURCE(IDD_DIALOG2), 0, AddDialogProc); } case IDC_ANSEHEN: { DialogBox(hinst, MAKEINTRESOURCE(IDD_DIALOG3), 0, ShowDialogProc); } } } } return false; } BOOL CALLBACK AddDialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_CLOSE: case WM_DESTROY: { EndDialog(hwnd,0); } case WM_INITDIALOG: { return true; } case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_HINZU: { char dateiname[29]; person kontakt; char nachname[50],beruf[50],spitzname[50]; char vorname[50],ort[50]; int telefon,postleitzahl; GetDlgItemText(hwnd, IDC_VORNAME, vorname,49); strcpy(kontakt.vorname, vorname); GetDlgItemText(hwnd, IDC_NAME, nachname,49); strcpy(kontakt.nachname, nachname); GetDlgItemText(hwnd, IDC_ORT, ort,49); strcpy(kontakt.ort, ort); GetDlgItemText(hwnd, IDC_BERUF, beruf,49); strcpy(kontakt.beruf, beruf); telefon = GetDlgItemInt(hwnd, IDC_TELEFON, 0,FALSE); kontakt.telefon=telefon; postleitzahl=GetDlgItemInt(hwnd, IDC_LEITZAHL, 0,FALSE); kontakt.postleitzahl=postleitzahl; sprintf(dateiname, "%s.kf", nachname); ofstream out(dateiname,ios::binary); out.write((char*)&kontakt, sizeof(kontakt)); out.close(); out.open("kontakte.txt", ios::app); out<<dateiname; out<<endl; out.close(); } } } } return false; } BOOL CALLBACK ShowDialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: { person kontakt; char dateiname[200]; char message[300]; ifstream in("kontakte.txt"); while(in.getline(dateiname,199)); { ifstream input(dateiname); input.read((char*)&kontakt, sizeof(kontakt)); sprintf(message, "%s %s wohnt in %s, mit der Postleitzahl %i. Seine Telefonnummer ist %i und er ist von Beruf %s." ,kontakt.vorname, kontakt.nachname, kontakt.ort, kontakt.postleitzahl, kontakt.telefon ,kontakt.beruf); MessageBox(0, 0, kontakt.vorname, 0); input.close(); } in.close(); return true; } case WM_CLOSE: case WM_DESTROY: { EndDialog(hwnd,0); } } return false; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
ifstream in("kontakte.txt"); while(in.getline(dateiname,199)); { //hier ifstream input(dateiname); input.read((char*)&kontakt, sizeof(kontakt)); sprintf(message, "%s %s wohnt in %s, mit der Postleitzahl %i. Seine Telefonnummer ist %i und er ist von Beruf %s." ,kontakt.vorname, kontakt.nachname, kontakt.ort, kontakt.postleitzahl, kontakt.telefon ,kontakt.beruf); MessageBox(0, 0, kontakt.vorname, 0); input.close(); } in.close(); return true; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
#include "resource.h" #include <windows.h> #include <tchar.h> #include "person.h" INT_PTR CALLBACK MainDialogProc(HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK AddDialogProc(HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK ShowDialogProc(HWND, UINT. WPARAM, LPARAM); int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR, int nCmdShow) { return static_cast<int>(DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLG_DEVICE), NULL, WndProc)); } INT_PTR CALLBACK MainDialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: { return static_cast<INT_PTR>(TRUE); } break; case WM_CLOSE: { EndDialog(hWnd, 0); return static_cast<INT_PTR>(TRUE); } break; case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_ADD: { DialogBox(hinst, MAKEINTRESOURCE(IDD_DIALOG2), 0, AddDialogProc); return static_cast<INT_PTR>(TRUE); } break; case IDC_ANSEHEN: { DialogBox(hinst, MAKEINTRESOURCE(IDD_DIALOG3), 0, ShowDialogProc); return static_cast<INT_PTR>(TRUE); } break; } } break; } return static_cast<INT_PTR>(FALSE); } INT_PTR CALLBACK AddDialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: { return static_cast<INT_PTR>(TRUE); } break; case WM_CLOSE: { EndDialog(hWnd, 0); return static_cast<INT_PTR>(TRUE); } break; case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_HINZU: { person kontakt; kontakt.telefon = GetDlgItemInt(hwnd, IDC_TELEFON, 0,FALSE); kontakt.postleitzahl = GetDlgItemInt(hwnd, IDC_LEITZAHL, 0,FALSE); // Den Rest machst de nomma neu ... musst dir einfach die Länge des Textes der Editfelder holen und dem entsprechend arrays erstellen. std::string file_name = nachname; file_name += ".kf"; std::ofstream file_out(filename.c_str(), std::ios::binary | std::ios::out); if (!file_out) break; file_out.write(reinterpret_cast<char*>(&kontakt), sizeof(kontakt)); file_out.close(); file_out.clear(); file_out.open("kontakte.txt", std::ios::out | std::ios::app); if (!file_out) break; file_out << file_name << std::endl; file_out.close(); } } } break; } return static_cast<INT_PTR>(FALSE); } |
Werbeanzeige