C++ and Windows

Started by
12 comments, last by Razza2003 21 years ago
Of course you can use cout in a window in C++ !
There is a simpler hack than the one Magmai Kai Holmlor proposed.
I implemented it while writing a Forth scripting editor.

I create a subclassed Edit control to retrieve the text each time the user presses the return key (see msdn for control subclassing - Codeproject also has an article on win32 encapsulation). I use it that way because the text content of my control only changes when the user enters some commands. But nothing prevents you to get the text from an Edit control with a timer (see msdn and the message WM_TIME).
The text is easily restrieved from an edit control by the message WM_GETTEXT giving as a parameter a char pointer.
You can then process this text within a string stream (look at GameDev articles for strstream ) using Cin and Cout.
When the text is modified, you can set back the text to the Edit control using the message WM_SETTEXT.
You just need to take care of the Caret position (look at Codeproject articles for the prompt edit control object ).

Hope that helps.
Ghostly yours,
Red.
Ghostly yours,Red.
Advertisement
You can learn programming win32 apps at winprog.org.
This is not C++ , but it is enough to get started.
When you understand the basics, encapsulating will be a snap.
If you want to have a look at an implementation of a win32 encapsulation and are not afraid of a little technicality, I would advise you to look at www.relisoft.com.

Hope that helps.
Ghostly yours,
Red.
Ghostly yours,Red.
it would be possible, if you made it a console app that also uses a window. think about it: all the stuff and demos you downloaded from sites like this, a lot of them use both. though you''ll probably be limited in what you do with your window.
f@dzhttp://festini.device-zero.de
Red Ghost, that''s pretty much how I do it, though I hadn''t thought about using it to support cin too (neat idea!) btw, strstring is deprecated, you should use stringstream.

Win32 debug console
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement