Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newline 2

Status
Not open for further replies.

michaelkrauklis

Programmer
Dec 5, 2001
226
US
Is there a new line char or carriage return or something I can do to bring me down to the next line in my Editable Text windown in my CDialog Box? And is there a way to make sure that my output is flushed to the screen and printed when I change the text? MYenigmaSELF:-9
myenigmaself@yahoo.com
"If debugging is the process of removing bugs, then programming must be the process of putting them in." --Dykstra
 
If you are talking about an edit box on your dialog, then change its properties to "multiline" and then when you are typing in it, hit ctrl+enter to move to the next line.

John
 
I'm editing the text from my program, so I cant' hit ctrl-enter. Will it do the same thing if I find the ASCII char # and put it in? so tired MYenigmaSELF:-9
myenigmaself@yahoo.com
"If debugging is the process of removing bugs, then programming must be the process of putting them in." --Dykstra
 
I'm sorry, can you explain more. I am unclear on your meaning of "I am editing the text from my program". I thought you wanted the user to be able to enter multiple lines in an Edit Box.
 
I edit my edit box in the following manner:
Code:
  CString err=CString("")+"CDBException "+error+"Attempt CDatabase::Rollback()\n";
#ifndef DEFINES_H_VCPPGUI
  cerr<<err<<flush;
#else
  CWnd *win = AfxGetMainWnd();
  CString tmp(&quot;&quot;);
  win->GetDlgItemText(IDC_EDIT1, tmp);
  tmp+=err;
  //AfxMessageBox(tmp+t);
  win->SetDlgItemText(IDC_EDIT1, tmp);
#endif
I have code like this all through my program. I'm working on some standardization, it's not terribly difficult, but development time is an issue right now. Anyawy, I basically want my output to go to my Edit Box instead of cerr. It does that fine, but when I print out a '\n' char it just gives me the invalid charachter pipe. I want it to go down to a new line. This is what I'm asking. And if you can think of just a better way to do this dont' hesitate to tell me. I've been programming in C++ for years but this is my first experience with VC++. Makes me want to go back to java! Thanks for the help. MYenigmaSELF:-9
myenigmaself@yahoo.com
&quot;If debugging is the process of removing bugs, then programming must be the process of putting them in.&quot; --Dykstra
 
Have you tried \r\n (or \n\r for that matter)....also, I'm pretty sure you need to have it set to multiline to accept a newline character...try \r\n, let me know ;)

Good luck, Rob
&quot;Programming is like art...It makes me feel like chopping my ear off.&quot;

- Currently down
 
/r/n = carriage return - new line, btw...it should most definately work ;) Rob
&quot;Programming is like art...It makes me feel like chopping my ear off.&quot;

- Currently down
 
Absolutely brilliant. I feel kind of stupid asking this but I never learned what the difference between a carriage return and a new line are. Might you enlighten me? I've been programming for years, this is something I should have known for a long time. Also, is there any way to make the screen refresh after I print out each statement? Or refresh or something? The scroll bars refresh but the text doesn't show until my Start button is finished executing. MYenigmaSELF:-9
myenigmaself@yahoo.com
&quot;If debugging is the process of removing bugs, then programming must be the process of putting them in.&quot; --Dykstra
 
I'm not very familiar with C++ in a windows environment, i've just started down that road myself ;). But I do know there is a procedure to redraw an instance...I'm at work, so I can't test it, but look into redraw/repaint, and the like. As far as /r/n, unix uses /n for line fead, mac uses /r, and windows (of corse) uses /r/n.

Good luck, I hope you find what you're looking for, I'll look when I get home tonight if you havn't found it by then. Rob
&quot;Programming is like art...It makes me feel like chopping my ear off.&quot;

- Currently down
 
CWnd::RedrawWindow
I just call that with no parameters on my edit box and it works like a charm. Now the next task... changing the colors on buttons. By the way, I had tried Print and PrintClient before with no avail. I didn't think of Redraw. Thanks a lot! MYenigmaSELF:-9
myenigmaself@yahoo.com
&quot;If debugging is the process of removing bugs, then programming must be the process of putting them in.&quot; --Dykstra
 
Great, i KNEW there was a redraw...glad I could help, thanks for the star. Rob
&quot;Programming is like art...It makes me feel like chopping my ear off.&quot;

- Currently down
 
:^) Thanks, rjr9999! I've been looking for this too.

I should have thought of this, since I came to Windows from a Unix environment (but it's been over 6 years now)...
 
Ok, this is probably another stupid question...
I have three Bitmap resources. They are, in essence, red, green, and yellow boxes.
I have an instance of the red box in my dialog window. I went about this by simply clicking on the picture button on the controls panel when I'm editing my dialog box. Then creating the picture obviously. Then changing the type to Bitmap and setting the Image to the appropriate resource. Now my question is, how do I change which resource I am using while my program is executing? I want to change from red to green or yellow, depending on weither or not there were errors.
My first question is this, what is this &quot;Picture&quot; stored as? Is it like a CPicture or something? And, how can I change the resource it is using? Either by directly accessing the object or if there is some function that does it... I didn't see anything like that in the member functions of CWin but maybe it's an Afx or some other standard function?? MYenigmaSELF:-9
myenigmaself@yahoo.com
&quot;If debugging is the process of removing bugs, then programming must be the process of putting them in.&quot; --Dykstra
 
For future reference, I created a FAQ regarding the line feed. 2 actually, for each C++ microsoft forum -

faq116-1455
faq116-1456

as far as your last question goes. I'm not sure how VC++ handles multiple image instances, but I know VB has an image combo (or image list) that you can call several images from by an index...(Sort of like an array of bitmaps :p).

I help so much more from home....Wish I was there, oh well, hope I helped a little bit. Rob
&quot;Programming is like art...It makes me feel like chopping my ear off.&quot;

- Currently down
 
I would just like to add a little something. It was good that you said &quot;Windows&quot; and not &quot;Microsoft&quot; because '\n' is a new line in dos. Just not in windows. Just thought I'd clarify that a little more, and I dno't know if you can edit faqs but if you can you might want to add that. Just a suggestion. And yes, you've been a huge help. Thanks. I still need to know how to access &quot;Picture Objects&quot; or whatever they are. I don't really need to have an array of bitmaps because I can already access them by their resource ID. If anyone can help me with this I will be eternally greatful... or at least a little greatful:) Does anyone know how big the buffer is from the keyboard? Because I've been writing for about 4 minutes and none of it has shown up... I don't know if what I type in will all of the sudden appear... I hope so. btw, the cpu is spiked at 100% vby an application I've developed... ahhh, there's all the text I wrote:) If there are typos in here it's because I couldnt' see what I was/am typing and it's too hard to go back and edit. Anyway, I was rambling. If anyone can help me that'd be great. Thanks! and thanks rjr9999. MYenigmaSELF:-9
myenigmaself@yahoo.com
&quot;If debugging is the process of removing bugs, then programming must be the process of putting them in.&quot; --Dykstra
 
Actually, in all MS systems, a /r/n terminates a line in a file. It's just that the C/C++ libraries handle the translation for the console, whereas the MFC classes display text just like it would a text file. For a perspective on this, UNIX OS's use /n, and (IIRC), MacOS uses /r for a line terminator.
 
Another note, \n and \r\n both work for text in a button. That's so messed up... MYenigmaSELF:-9
myenigmaself@yahoo.com
&quot;If debugging is the process of removing bugs, then programming must be the process of putting them in.&quot; --Dykstra
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top