News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Console

Started by oex, April 13, 2011, 10:12:03 PM

Previous topic - Next topic

oex

Are there any negative aspects to calling AllocConsole rather than creating a Console application?
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

qWord

Quote from: oex on April 13, 2011, 10:12:03 PM
Are there any negative aspects to calling AllocConsole rather than creating a Console application?
when using CRT functions, you must assign the console, create by AllocConsole, 'by hand' to the CRT.
Some time ago I've upload some macos doing these job: CRT redirect of stdin/out/err

qWord
FPU in a trice: SmplMath
It's that simple!

redskull

Starting an app from the command line will only inherit the same console if you link it as such. Otherwise you get a new window that will dissapear afterwards, along with your output
Strange women, lying in ponds, distributing swords, is no basis for a system of government

oex

OK that sounds nasty.... I think that trashes that idea right off :lol.... I dont call any other application atm however I cant guarentee I never will.... If that application will destroy my command window I guess I'll just continue creating console apps for now....

Is there any way to (temporarily) hide the console in a console application?
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

qWord

Quote from: oex on April 13, 2011, 10:40:58 PM
Is there any way to (temporarily) hide the console in a console application?
yes: GetConsoleWindow() + ShowWidow()
however, the console will be visible for a short time at start up of your program.
FPU in a trice: SmplMath
It's that simple!

oex

:lol ty qword, you beat me to my edit.... I used FindWindow as a test so your method is much better though :)

Edit: Aha I see there is.... Any inherent issues with using:
invoke ShowWindow, ConsolehWnd, SW_HIDE/SHOW?

Quote from: qWord on April 13, 2011, 10:46:48 PM
however, the console will be visible for a short time at start up of your program.

Would this be considered 'unprofessional'? I have seen this flash before on professional applications but a developer's take on it would be interesting....

PS. Thanks guys, this is much better for me than what I had before.... Having the Console perminently showing was really annoying me.... I had thought about sorting this for ages but never gotten around to it :lol....
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

qWord

Quote from: oex on April 13, 2011, 10:48:17 PMWould this be considered 'unprofessional'?
IMO yes - but I've also seen some professional programs using these technique.
FPU in a trice: SmplMath
It's that simple!

redskull

Quote from: oex on April 13, 2011, 10:40:58 PM
OK that sounds nasty.... I think that trashes that idea right off :lol.... I dont call any other application atm however I cant guarentee I never will.... If that application will destroy my command window I guess I'll just continue creating console apps for now....

It won't destroy your command window, it will simply bring up it's own, and then return to the original once it terminates.  Depending on what you are planning on doing, this could be either totally wrong (for instance, if you are displaying to stdout), or completly appropriate (if you are starting your own text-mode editor, etc).  For instance, that's why there is both cdb.exe and ntsd.exe; exactly identical debuggers, except one makes it's own window, and the other just continues within the cmd window

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

oex

Well pretty simply I want duel edit ability into my application so either I want Console or a Window displaying for input but obviously I dont want or need both at the same time.... I have a basic toggle already but Console was always displaying....

I think SW_HIDE/SW_SHOW fixes my problem.... From your description I think loading an external program with Console requirement could make my application inaccessible to certain functionality....
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv


redskull

jj beat me to it....You should assemble/link as as WINDOWS app, then use GetStartupInfo() to determine whether or not you should use the handles provided, and take the appropriate conditional action.
Strange women, lying in ponds, distributing swords, is no basis for a system of government

oex

OK.... I will delve into this however one thing bothers me.... What happens with a multi-threaded application? Maybe I'm not understanding the description properly, something I'll doubtless get when I start with the trial and error but....

hmm lost my train of thought at this point :lol.... If you know what I was thinking feel free to answer.... Otherwise if I remember I'll update this post :bg

Ah I remember.... What I meant was what happens if you need to use the console of the calling process when using another process with a console opened in a thread? From how I understand the description at this point there can be only one console for the calling process and it's child processes at any one time (Unless it's a console app)

Edit: It's late.... Excuse this post if it makes no sense I wil work opn this further in the morning....
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

well, i am kinda scratchin' my head trying to figure out what it is you're trying to accomplish   :P

i have seen some installers that open a console window briefly
i guess they are too lazy to write the code - they use DOS commands to perform registration, etc

oex

Quote from: dedndave on April 14, 2011, 03:28:34 AM
well, i am kinda scratchin' my head trying to figure out what it is you're trying to accomplish   :P

i have seen some installers that open a console window briefly
i guess they are too lazy to write the code - they use DOS commands to perform registration, etc

:lol atm I'm writing an admin app which uses both Console and Windows, it's a little weighty and unruly to post (over 500Kb) but I was kinda interested in the methodology generally also :bg
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

 :bg
i feel like i know even less, now, than i did before