Win32 C++ Listbox export

So I have this here. I got the code importing the users from a text file. Now I want it to format the names into a certain criteria. And save it to a new file called abc.txt I can't even get it to save the listbox to a file please someone help.

I want it to put a file like this.

Zachary CMDR Schulze
Caleb HRD Butler
Kyle SUP Brander

to export it to

MC: MN= Schulze CMDR Zachary, YU=USUS, YU=COM, YU= NM
YD: add
M: Schulze CMDR Zachary
OW: Zachary.Schulze

MC: MN= Butler HRD Caleb, YU=USUS, YU=COM, YU= NM
YD: add
M: Butler HRD Caleb
OW: Caleb.Butler

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
switch(LOWORD(wParam))
            {
				case IDC_BUTTON1:
				{
					OPENFILENAME ofn;
					char szFileName[MAX_PATH] = "";

					ZeroMemory(&ofn, sizeof(ofn));

					ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
					ofn.hwndOwner = hWnd;
					ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
					ofn.lpstrFile = szFileName;
					ofn.nMaxFile = MAX_PATH;
					ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
					ofn.lpstrDefExt = "txt";

					if(GetOpenFileName(&ofn))
					{
						ifstream nameFile(szFileName);
						HWND List = GetDlgItem(hWnd, IDC_LISTBOX1);
						do
						{
							char name[MAX_PATH];
							nameFile.getline(name, MAX_PATH);
							SendMessage(List, LB_ADDSTRING, 0, (LPARAM)name);
						}
							 
						while(!nameFile.eof());
							nameFile.close();
					}
				} break;
				case IDC_BUTTON2: {	
				string txt;
				ofstream myFile;
				SendMessage(ListBox1, LB_GETCOUNT, NULL, nCount);
				myFile.open( ".\abc.txt",  ifstream::in|ios::out);
				if(myFile.good()) {
					c = char(nCount+'0');
					for(int i = 0; i< c ; i++) {
						MessageBox(hWnd,NULL,(LPCSTR)nCount,MB_OK);
						//myFile.write((char*)c,2);
						}
					myFile.close();
					}
				} break;
			} break;
Topic archived. No new replies allowed.