TextOut to a debug window ?

Started by
7 comments, last by bg3ntl 22 years, 3 months ago
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
regards,bg3ntl' That's a nice little nothing you are almost wearing. '
Advertisement
You could create a non-editable text-box in the debug-window and use it to show the debug text; or why not open a console window and write to that.
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
-Brannon
quote:Original post by Brannon
automagically
-Brannon


hehehe. That''s a great word!!

Use OutputDebugString() or TRACE or ATLTRACE versions if you are in win32 environment.
To see the debug strings run dbmon.exe.
dbmon.exe is shiped with win32 SDK.
MCO


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.
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!
thnx for all the help guys

bg3ntl
regards,bg3ntl' That's a nice little nothing you are almost wearing. '
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
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

This topic is closed to new replies.

Advertisement