How do you get Microsoft Visual C++ to put carriage returns into strings and use them in list boxes? It just puts a small line in whenever I try using the old \n. I need to have carriage returns in the strings.
How do you get Microsoft Visual C++ to put carriage returns into strings and use them in list boxes? It just puts a small line in whenever I try using the old \n. I need to have carriage returns in the strings.
I've tried \r\n as well, and it didn't work. None of the escape sequences do.
I'm trying to add the text from a text box because it's the only way I can get the data to transfer from another dialog box. This is the text string:
CEdit* pTxtBurgers = (CEdit*)GetDlgItem(IDC_TXTBURGERS);
pTxtBurgers->SetWindowText(Cheese + Lettuce +
Ketchup + Mustard + Onions + Pickles +
Tomato + Cooked + Bun);
The third line is where it adds the text string.
CBurgers dlgBurgers;
dlgBurgers.DoModal();
m_Orders.AddString(dlgBurgers.m_TxtBurgers);
It does add the text, but you can't read the whole line because it goes off the edge and I can't figure out how to even get the list box to scroll. I set the scroll properties to yes but it doesn't scroll.
I really don't want to add a text box for every variable in the other dialogue, since they are set up as checkboxes anyway. This is how the example in my text book adds the string, so it's what I'm doing for now. I'm not a programming newbie but I am a VC++ newbie, and the book for my class is not the most helpful. Neither is Microsoft's help.
> Neither is Microsoft's help.
Which is odd, because that's all I use.
You're trying to get a list box to do something it can't do. List boxes do not have horizontal scrollbars, and they don't accept line breaks in text. If you want to do this, you must make an owner-draw list box.
Why are you trying to do this? If something is outside the realms of the standard controls, often it's because your interface could be done better in another way.
Ess
Like a rat in a maze who says,
"Watch me choose my own direction"
Are you under the illusion
The path is winding your way? - Rush
The project required that each item be added to a list box on the main dialogue screen. I can live without the extra formatting, but it would have been nice.
Statics text controls accept /r and /n but if you need listboxes this won't help.
>>The project required that each item be added to a list box on the main dialogue screen
MSVC 6.0 + MFC
To add items to a list box you have to InsertString() in order to add things to your list box.
First create a member variable in class wizard for the drop box.
I use something like m_drItems.
Then using this member variable InsertString().
Now you should beable to see items added to your drop box.Code:m_drItems.InsertString(0,"Item1"); m_drItems.InsertString(1,"Item2"); //Updatedata UpdateData(FALSE);
C++ Is Powerful
I use C++
There fore I am Powerful
Also if you do not want to have the items in order, you can leave the 0 or 1 off and it will sort them alphabeticaly.
C++ Is Powerful
I use C++
There fore I am Powerful