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

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.

Related

How do you code merging different executables into a single window frame? Like browsers do?

OK, so a noob question here: How do you code this functionality that browsers have for example? You open a chrome browser for example and you can open multiple tabs open. Then you can move one tab out of the window and it becomes another window, having its own separate process. Then you can drag that tab into another window and they become one frame? Similar to docking in windows applications, but how do you do it with executables?
Windows-specific answer, though I think other OSs work pretty much the same: the HWND handle that you get for a window is global. If you send its numeric value to a different process, that process can use it to do things with the window: get its information, resize it, even draw on it. What it can't do is replace its event handler function.
To get process separation like browsers have nowadays, the key is to create a container window and send the handle to the child. The child then creates its own window as a child of the container. The child window simply fills out the entire content area of the container.
This way, the content process is contained within the parent's window, but can handle events.
Now, if you want to drag out a tab into its own top-level window, the parent process creates a new top-level window with all the UI inside, and then re-parents the content container to this new top-level window. The content child follows along.
I can't tell you how to code it, you should search the feature inside the chromium code to know how it's coded but I can tell you how it works:
Inside chromium every tab, extension, utility, etc is a process, each one of these processes is child of the "Browser" process, the "Browser" process manages everything (creating new windows, opening new tabs, closing tabs, destroying windows etc) so, for example, whenever you open a new instance of chromium you are telling the "Browser" process to create a new tab and put it inside a new window.
Every window is managed by the "Browser" process and every tab is managed by a process that is child of the main process.
Now to reply your question: when you drag & drop a tab outside a window you're triggering an event that is caught by the "Browser" process which then create a new window and assign the tab to the new window.
Those informations should give you a hint on how you could develop this feature yourself.
If you want to know more about the chromium architecture I suggest you to read how chromium is designed at https://www.chromium.org/developers/design-documents

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

C++ output information to a new window

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

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.

How do I link C++ (Visual Studio 2010) to an image-outputting event listener?

I am writing a very simple program in C++ that listens to keyboard input, but what I want to output is much more difficult than I expected. For every key I press, I want an image (specific to the key) to appear on the screen. For example, let's say if I press the "O" key, an image of Earth appears on my screen.
What's the best way to achieve this? Thanks!
This is possible with layered windows. I have created a Win32 project as a demo. You can find the code and explanations here.
Basically you have to:
handle the WM_CHAR message and load the appropriate image (from resources or from disk)
create a layered window and display the loaded image in that window
if you want to automatically close the window after an given interval after the last key was pressed you have to create a timer and in the timed procedure destroy the window
Check my link for a solution to your problem.