The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Roger on June 13, 2006, 08:57:55 PM

Title: Console substitute wanted
Post by: Roger on June 13, 2006, 08:57:55 PM
Hi All,

Is there a GUI window/contol which performs the output functionality of the console?

I have console programmes which work well enough that I now want to intigrate into the main part of my project.

I don't expect it to be quite as simple as calling GetStdHandle followed by WriteFile but everything I try either dosn't work or appears to need so much formatting, juggling with buffers and other asorted messing about that I feel sure that there must be an easy way that I have not found.

BTW one of the problems is that the text comes from different threads and not necessarily from the keyboard.

Regards Roger
Title: Re: Console substitute wanted
Post by: raymond on June 14, 2006, 02:18:38 AM
Have you looked at the TextOut function, or is that insufficient.

Raymond
Title: Re: Console substitute wanted
Post by: Tedd on June 14, 2006, 03:46:47 AM
Create a popup window with a richedit (or just simple edit) control as its child, then send the text to that. It may need a little formatting, depending on what you want, but most of that can be taken care of with wsprintf.
This is what I tend to use when I want a debug type window.
Try it and shout if you get stuck :U
Title: Re: Console substitute wanted
Post by: hutch-- on June 14, 2006, 03:55:37 AM
I agree with Tedd here, if you use a rich text edit control, all you need to do is set the selection to the end of the current buffer and append the data you like after it and its easy enough to do.
Title: Re: Console substitute wanted
Post by: MichaelW on June 14, 2006, 05:05:34 AM
The attachment uses a rich edit control and macros for the print and cls functions. Using a simple edit control I could not find any border style that looked reasonable.





[attachment deleted by admin]
Title: Re: Console substitute wanted
Post by: P1 on June 14, 2006, 03:11:52 PM
If you use the RichEdit control, but sure to use a monospace font, otherwise your formatting may not look like console output.

Regards,  P1  :8)
Title: Re: Console substitute wanted
Post by: Roger on June 16, 2006, 09:51:11 PM
Hi All,

Thank you for your suggestions. I have tried an edit control and it worked in the serial link prog so I used it to intigrate the serial link into the main grapical display prog.

Well at least I have all my bugs in one place now! Unfortunatly they have brought a few frends along for the ride.

One of them concerns setting the focus. I am tryng to put the serial data and keyboard data in using WM_CHAR and EM_REPLACESEL which seems to work some of the time. However at times the keyboard talks directly to the edit control bypassing WM_CHAR and the carefully crafted ( :lol ) parser that it should talk to. Using the mouse on the graphics takes the focus which can only be restored by clicking on the edit control and this is the quickest way of bypassing the parser.

Is there a way of seperating mouse and keyboard focus or the equvalent of  'UnsetFocus' ?

Regards Roger
Title: Re: Console substitute wanted
Post by: MichaelW on June 17, 2006, 03:14:26 AM
You could add ES_READONLY to the dwStyle parameter of CreateWindowEX. I meant to do this in my example, but forgot.

MSDN:Edit Control Styles (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/editcontrols/editcontrolreference/editcontrolstyles.asp)

MSDN:Rich Edit Control Styles (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/RichEdit/RichEditControls/RichEditControlReference/RichEditConstants/RichEditControlStyles.asp)
Title: Re: Console substitute wanted
Post by: Roger on June 17, 2006, 11:57:54 PM
Michael,

I have tried that. It makes it ReadOnly. So EM_REPLACESEL can't write to it.

Regards Roger

EDIT
Of course there is nothing like anouncing to the world that something won't work to make it run like a dream!
Title: Re: Console substitute wanted
Post by: MichaelW on June 18, 2006, 07:58:24 AM
So I take it that it does work (actually, I tested it before I posted to verify that the read only was just from the user's perspective ).


Title: Re: Console substitute wanted
Post by: Roger on June 18, 2006, 01:14:59 PM
Michael,

Yes it works thank you.

I am finding it a bit slow to test anything because the programme doesn't always exit cleanly so sometimes when I try out a change GoLink finds that it can't write the new .exe.

Regards Roger