Archived

This topic is now archived and is closed to further replies.

bg3ntl

TextOut to a debug window ?

Recommended Posts

having a few problems with my debug window, which is a smaller window than my main window (which renders everything of course) and is always on top. my problem is outputting text to it. firstly, does anyone know how to set the background color to anything other than black or white during the building of the WNDCLASSEX struct? ok, now heres my real problem. i have been using TextOut to pring my debug strings to the window. only problem is they always over write each other, obviously since you have to specify the coords of where you want to position the text. I dont keep a record of where the last piece of text is printed too. is there an easy way to just append text to the end of text that is already there ? and what about scroll bars down the side of the window for when there is too much text to fit in the screen ? thanks for your help, bg3ntl

Share this post


Link to post
Share on other sites
Create a brush using CreateSolidBrush() and assign that value to WNDCLASSEX.hbrBackground (you should probably call DeleteObject on this brush during shutdown, after the window class has been unregistered).

After you create the debug window, create a child window that fills the entire client area. Make that window an edit window (using the "EDIT" window class). Setup the correct window style for it (scroll bars, child, multiline, etc). The edit class will pretty much handle the rest. You can use SetWindowText() to set the text. I can''t remember if there is a way to just append... I don''t think there is, so you''ll have to buffer the content of the window yourself, and then when it needs updating, just call SetWindowText() with the buffer. That should work fine if the text doesn''t become huge. The alternative is to use the RichEdit class, which does let you stream in pieces of text, but is much more complicated. Or, I suppose you could subclass the edit window, and add your own "append text" message, and then manage the buffer yourself.. but that''s pretty similar to the first approach.

Sorry, that ended up being kinda random. I''ve done this before by adding a child edit window. The scroll bars should work automagically if you set the right styles. It just might be a little slow with alot of text.


-Brannon

Share this post


Link to post
Share on other sites
Guest Anonymous Poster


Instead of just appending text, you might try creating a listbox the size of your output window. Then just add an item to the list box.

Share this post


Link to post
Share on other sites
quote:
Original post by bg3ntl
firstly, does anyone know how to set the background color to anything other than black or white during the building of the WNDCLASSEX struct?

There are a bunch of brushes defined as stock objects. See the documentation for GetStockObject() and HBRUSH. Alternatively, use CreateSolidBrush(0 as already mentioned.

quote:
is there an easy way to just append text to the end of text that is already there ? and what about scroll bars down the side of the window for when there is too much text to fit in the screen ?


Place a rich edit control in your window. It can scroll and I believe you can simply append text to it. Look up the Windows Common Controls.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
The list box with be the easiest. An Edit box is limited to 64Kb on W9x. A rich edit control requires special helper functions and there isn''t much documentation for it.

‘But truth's a menace, science a public danger.’ Brave New World, Aldous Huxley

Share this post


Link to post
Share on other sites