Dude C++ works on Windows, what are you talking about?
And because I felt like being nice I found you a link that shows you exactly how to do it.
C++/Win32: The System Tray and Balloon Tips : Stromcode
Awesome! Thanks so much. That makes my life so much easier. This was the thing I was worried about most. I really appreciate the help.
Also, that tells me that I can minimize my program to the system tray, but can I just have it running in the system tray and not have a GUI at all? Also--sorry if I'm annoying--I wanted to be able to right click on the icon in the system tray and have the menu be:
Add Quotes (opens .txt file with the quotes)
Exit (shuts down program)
How hard would that be, and would I have to shut down the program to edit the file, then restart the program? If I could make it that I wouldn't have to start the program to edit the file, that'd be good. Thanks again in advance.
Use WinMain instead of main if you don't want a GUI. You'll need to create a menu resource and compile it with your program. The menu is really easy to make (you can do it by hand), but you'll need to code a message loop, which isn't that bad either. Here's a tutorial to get you started with WinMain and message loops:
Win32 Introduction
Great! That answers another question I had, but it raises another question. When I start the compiled .exe, it brings up both the window with the message, and a command prompt. The tutorial doesn't give any idea how to get rid of that command prompt and just bring up the window. Any help with that? Thanks in advance.
I was playing around and thought up this. However, when I put it in Eclipse, I get this error:
expected constructor, deconstructor, or type conversion before "get_random_quote"
(marked in the code by two asterisks)
I'm thinking I need to define what "get_random_quote" does, but I'm not sure. Any help would be greatly appreciated.
Code:#include <iostream> #include <string> using string int main() { std::cout << string << std::endl return o; ** {std::string get_random_quote(); } { std::vector<std::string> quotes; std::istream in("quotes.txt"); //Available on demand in.exceptions(std::ios::failbit | std::ios::badbit); while(in) { std::string line; std::getline(in, line); if(line.size() > 0) quotes.push_back(line); } int idx = int(float(std::rand())/RAND_MAX*quotes.size()); return quotes.at(idx); } }
You messed up the using line. Either get rid of it or change it to using std::string and get change std::string to string in the following code. You didn't use WinMain, which is why you keep getting the console window. Make sure you're compiling your code as a Win32 project and not a console program.
You really need to learn the language. This just looks like straight skiddied code.
To be honest, I have no idea what you're doing with the file. I usually use ifstream. If you're not making a large project, you can just put in using namespace std; after your includes and get rid of all the std:: stuff. Easier to read, in my opinion.
It's because he didn't learn the language properly.
Yeah, just started Tuesday, actually, two days ago. I'm going through Accelerated C++ now, and experimenting with stuff when that books gets annoying.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks