C++ output information to a new window - c++

So I want to run a code and output the information to a new window to have a clean window with only the information I want.
I am using Angstrom linux system and I have a code that if I run, there are too many information showing on the terminal.
Is there a way for me to create a new window or terminal with the information I want?
Thank you

There is a workaround you can do. just print the info you need to a file (for instance log.txt) and then open a new terminal window and use:
tail -f log.txt
this will display the info you need on the terminal window as it comes up

Related

Image Magick++ close .display() Popup window by command

in documentation of Magick++ I found the command to display an image
Image temp_image(my_image);temp_image.display(); // display 'my_image' in a pop-up window
this works quite well, but I can find a command to close this window by code.
My goal is to open a window with the image, give image new name by commandline input, then automatically close the window, and show next image to rename.
Although the new popup-window sets the "active window" to it's self.
For entering some input to command line (e.g. new_name), I have to click again at the terminal window.
My (pseudo)code at the moment:
for(all_images){temp_image.display(); renaming_method();}
just now I have to close the upcoming window manualy by hand, better would be something like
for(all_images){temp_image.display(); renaming_method(); temp_image.display_close();}
do you have any ideas how to do this?
Magick++, and ImageMagick, doesn't have any methods to manage active display windows. You can roll your own XWindow method, but most projects I've seen just do the following routine...
Write temporary image
Ask OS to open temporary file by forking a process & calling xdg-open, open, or start commands (depending on OS).
Send SIGINT to pid when user wishes to close child process.
Clean-up any resources
Not ideal, but will get you roughly there.

Outputting from a .exe to cmd

I am writing a little program in c++ which creates an .exe which i then run by calling it with parameters in cmd. I want to be able to display output from the .exe into the cmd that I ran it from. I currently have this code which opens a new cmd window to display output which is close but not what i want. any help with this would be great! thanks.
AllocConsole();
DWORD NumberOfBytesWritten = 0;
WriteFile( GetStdHandle(STD_OUTPUT_HANDLE), strLog1, lstrlen(strLog1), &NumberOfBytesWritten, 0);
Update:
I have also been able to write to a text file using dir > log.txt in the command window when calling the program, is there a way I can change this so that it directs outputs to the console window? Thanks,
My psychic debugging powers tell me that your build tools are configured to create your application in GUI rather than console mode.
If you reconfigure the build so that it generates a console mode application, you won't need to call AllocConsole or do anything special; you'll automatically be assigned to the console of the parent process.
Did you try simple operations, such as:
std::cout << "Print me" ;
or
std::cerr << "Print me too";
?
(I hope I understood correctly that you want to print to the same console where you started your app)
That question has already been asked: How to output to the console in C++/Windows. Here is an answer that seems to be useful in your case: https://stackoverflow.com/a/587792/1728537

Get output of c++ program in fullscreen.It is a console output window targeted code

I use Windows 7 Ultimate.I set the CMD on pc to almost fullscreen(changed the properties from cmd title bar).Though taskbar is visible , it is the maximum fullscreen possible on Windows 7,I suppose.
I wrote code for a small command line user interface game.I've made a mistake by assuming the output screen to be maximized on every user's PC.
So,when I run it on another windows 7 machine,I'm getting weird output as the cmd screen is not maximized on their PC.
How can I ensure that I get the cmd screen set to fullscreen(almost fullscreen) on every PC it runs?
Can I call some functions in my code?
Or any other way?
I like to share it(the .exe file of my code) on the internet.So, how I can I fix this.
What you have to do is run the program and change the settings in that specific command window, not the default settings for your command window. You could do this with code as well, although I don't know how, but this is much easier. Then whenever that program is ran it should override the users default command settings and adhere to your program's.
Here's a similar answer of mine to another question about command colors. Same solution should work here.

Win32 application with console output and without new window

I'd like to create a tool that can either act as command line (display some console output based on input parameters), or display a window, based on input parameters.
I'm using MSV2012 with C++, and it seems you have to 'choose' between console and window app.
I know the net is filled with samples which use AllocConsole() and redirect std::out, but it doesn't make it feel like a command line application : calling the exe from the windows console will open a new window with the console output...
Is there a way to have it use the current console window instead of allocating a new one?
If not possible, I'll make 2 applications instead, but that's a pity..
Someone else may have a more authoritative answer, but I don't believe it's supported.
The usual workaround is to create a Windows app, but have a command-line wrapper that launches it from the CLI (and provides a channel for communicating with the original console).
It's not technically supported but I found a good solution by getting a snapshot for the current process, finding the parent process, attaching to it's console if it's a console app or creating one with AllocConsole, redirecting the output, getting the thread of the parent process if it's cmd.exe and suspending it, resuming it just before I exit my app

How do I open a new window on start up using C++?

I don't know how to make a window when I start up Windows. I just want a simple window that has some text in it, such as a reminder. I don't want to download anything, and I think C++ is the easiest way to do it.
The easiest way to display a window with a message in Windows would be use use VBScript. Create a text file with the following in it.
msgbox("hello world")
Now, name the file MyProgram.vbs or anything else with a .vbs extension.
Double click on the file to run it. The message "hello world" should be shown in a small window on your screen. As seen in the image below.
To run it at start up, just drag it in your Startup folder in your Start Menu.