How do I open a new window on start up using C++? - 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.

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.

WXwidgets for GUI in C++:

I am totally beginner in creating GUIS and I am using wxwidgets to create GUI programs in CodeBlocks. I am following this tutorials here:
http://wiki.codeblocks.org/index.php?title=WxSmith_tutorials
I have figured out how to create dialog boxes and frames. Now, I have created in C++ a program that reads information from a .txt file and calls a method displayInfo() that prints this information using cout. What I would like to do is to print this information on a single window, by clicking a button, say: "Print Information".
The part that I am finding hard, is how to call my displayInfo() method from the main.cpp of the frame, and how to display that information on a window, instead of the terminal. I tried to import the header file of my class in the main.cpp of the frame, and called displayInfo(), but I do not think this is the right way to do it.
Any help would be appreciated.
wxWidgets has some predefined dialog boxes for display small quantities of text.
See wxMessageBox description
Otherwise you will have to use a DrawText method on the panel or window.
I reccomend using a text control and then redirecting cout to the text control
Like this:
#include <iostream>
wxTextCtrl *control = new wxTextCtrl(...);
wxStreamToTextRedirector redirect(control);
// all output to cout goes into the text control until the exit from current
// scope
For more discussion of neat variations on this trick, take a look at:
http://docs.wxwidgets.org/2.8/wx_wxtextctrl.html
Scroll down to the section titled: wxTextCtrl and C++ streams

How to send input to hidden program c++?

So my question is how to send some comands or input from one (c++) program to another if hi is on hidden mode? For example I want to open some text file in notepad with function WinExec("notepad", 0); and than want to print conetent of file, I make handle to that file, make sendinput with CTRL+P, and the window of printig show up,.... I want to make all that proces hidden from user, is it possible?
There're many ways to do it. You can open notepad on a separate desktop. If you run notepad with SW_HIDDEN it would also not show the window, and then you can use windows hooks to hook the creation of print window and ShowWindow() it to hidden.
But why all the hassle? If you don't need notepad's UI, why not just print the file yourself?

Creating an OS close button? (WinAPI)

I want to create a button that is basically Windows' close button. How could I do this? I want to avoid drawing this myself because I want it to look like that version of Windows' close button. Firefox's tabs do something like this. Thanks
You can get at Windows XP+ theme specific UI elements via the DrawThemeBackground API.
Use WP_CLOSEBUTTON for the window X button (and one of CBS_NORMAL/HOT/PUSHED/DISABLED for its state) and you can draw one wherever you like.
The close buttons on the tabs in Firefox are part of its theme.
If you look in Program Files\Mozilla Firefox\chrome\ there's a zip file called classic.jar.
Inside this zip file is a png file skin\classic\global\icons\close.png.
This png file has the icons for the various states of the close buttons on the tabs:
from hg.mozilla.org

want to open text file in some text editor programmatically in c/c++

I want to open a text file into some text editor say notepad programmatically in c/c++.
Also i want to see real time updation of text into that text file while opening in a editor.
Please suggest.
Most editors accepts the path of the file-to-be-opened as 1st argument. E.g.
notepad.exe c:/foo.txt
Just execute it as a shell/runtime command in your program.
If you're doing something as simple as monitoring a log file, you want a unix program called "tail", or its Windows equivalent.
It will give you a simple Notepad-like Window which displays the contents of a log file in (more or less) real time.
Having the editor (notepad, tail, whatever) continually monitor the file for changes isn't your job as the C++ developer, it's up to the program.
To get the file to open in the default application specified, try this (C#):
System.Diagnostics.Process.Start("text.txt");
To specify an application, try this:
System.Diagnostics.Process.Start( "notepad.exe", "text.txt");
I'm not aware of any way to handle real time updation of the file in the editor however.
After you have it running, see above. you can possibly keep the file updated using SendMessage from the Windows API and sending Ctrl+S(save) to the notepad window.
To see real time update in your editor window try to find editor's window handle (you may use EnumWindows() function). Insert text in the editor's textfield or reread it from the file and call RedrawWindow() after that. However calling it after each letter could give some nasty flickering if the text come from a program.