I am using Windows 10 (Visual Studio 2015).
Alright I just want to start off by saying is that I am using an edit box for the user to write a directory,appname,comboboxname then having wofstream output the directory,appname,comboboxname into a .txt file.
My problem is that some directories have spaces so when wifstream reads those spaces then cuts off the directory to early and stores the cut off version into one of the wchar_t variables.
What I need for the program to do (I am not sure if its possible) is output line by line.
Example:
C:\Program Files (x86)\Minecraft
MinecraftLauncher
Minecraft
Then use getline to read the whole line including the spaces, store that line into a variable and then get the next line. (But it also can't grab any extra white spaces that aren't in the directory otherwise it won't work) you guys probably know how directories work lol)
So you guys don't have to look that hard, I want this to occur in the case IDB_CLICK_ME.
Here is my code currently, something I am tinkering with before I decide to add it to my main application:
This is where I am trying to read the file (without whitespaces)
case WM_CREATE:
{
wchar_t testData[20] = L"Hai";
CreateWindow(L"button", L"CLICK ME", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 5, 5, 200, 25, hwnd, (HMENU)IDB_CLICK_ME, NULL, NULL);
comboBox = CreateWindow(L"combobox", L" ", WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST, 5, 50, 100, 100, hwnd, (HMENU)4, NULL, NULL);
hProgramName = CreateWindow(L"edit", L"Program Name", WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, 5, 100, 200, 25, hwnd, NULL, NULL, NULL);
hProgramDirectory = CreateWindow(L"edit", L"Program Directory", WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, 5, 130, 200, 25, hwnd, NULL, NULL, NULL);
hProgramNameComboBox = CreateWindow(L"edit", L"Name listed in ComboBox", WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOHSCROLL, 5, 160, 200, 25, hwnd, NULL, NULL, NULL);
std::wifstream myfile;
myfile.open("LaunchLocations.txt");
myfile >> std::noskipws >> gameLaunchtest.directory;
myfile >> std::noskipws >> gameLaunchtest.AppName;
myfile >> std::noskipws >> gameLaunchtest.ComboBoxName;
This is where I am writing it, so far this works correctly
ComboBox_AddString(comboBox, gameLaunchtest.directory);
break;
case WM_COMMAND:
switch (LOWORD(wparam))
{
case IDB_CLICK_ME:
GetWindowText(hProgramDirectory, gameLaunchtest.directory, MAX_PATH);
GetWindowText(hProgramName, gameLaunchtest.AppName, MAX_PATH);
GetWindowText(hProgramNameComboBox, gameLaunchtest.ComboBoxName, MAX_PATH);
wofstream launchLocations;
launchLocations.open("LaunchLocations.txt");
launchLocations << gameLaunchtest.directory << endl;
launchLocations << gameLaunchtest.AppName << endl;
launchLocations << gameLaunchtest.ComboBoxName << endl;
launchLocations.close();