Closed Thread
Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 31

Thread: random quote generator

  1. #11
    Join Date
    May 2008
    Posts
    2,126
    Blog Entries
    1
    Rep Power
    33

    Re: random quote generator

    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

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #12
    vocalstud69 is offline Newbie
    Join Date
    Sep 2008
    Posts
    11
    Rep Power
    0

    Re: random quote generator

    Quote Originally Posted by MeTh0Dz|Reb0rn View Post
    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.

  4. #13
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,496
    Blog Entries
    8
    Rep Power
    58

    Re: random quote generator

    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

  5. #14
    vocalstud69 is offline Newbie
    Join Date
    Sep 2008
    Posts
    11
    Rep Power
    0

    Re: random quote generator

    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.

  6. #15
    vocalstud69 is offline Newbie
    Join Date
    Sep 2008
    Posts
    11
    Rep Power
    0

    Re: random quote generator

    Quote Originally Posted by dargueta View Post
    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
    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);
    			}
    	}

  7. #16
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,496
    Blog Entries
    8
    Rep Power
    58

    Re: random quote generator

    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.

  8. #17
    Join Date
    May 2008
    Posts
    2,126
    Blog Entries
    1
    Rep Power
    33

    Re: random quote generator

    You really need to learn the language. This just looks like straight skiddied code.

  9. #18
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,496
    Blog Entries
    8
    Rep Power
    58

    Re: random quote generator

    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.

  10. #19
    Join Date
    May 2008
    Posts
    2,126
    Blog Entries
    1
    Rep Power
    33

    Re: random quote generator

    It's because he didn't learn the language properly.

  11. #20
    vocalstud69 is offline Newbie
    Join Date
    Sep 2008
    Posts
    11
    Rep Power
    0

    Re: random quote generator

    Yeah, just started Tuesday, actually, two days ago. I'm going through Accelerated C++ now, and experimenting with stuff when that books gets annoying.

Closed Thread
Page 2 of 4 FirstFirst 1234 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Java: Random Name Generator
    By Sinipull in forum Classes and Code Snippets
    Replies: 2
    Last Post: 05-05-2011, 07:26 AM
  2. Random number generator?
    By sjshacker93 in forum Visual Basic Programming
    Replies: 5
    Last Post: 09-03-2010, 09:27 PM
  3. Random Password Generator
    By Sauce in forum Visual Basic Programming
    Replies: 13
    Last Post: 06-25-2009, 02:57 PM
  4. Need Help Creating A Random Generator
    By KingCrimson250 in forum PHP Development
    Replies: 4
    Last Post: 06-21-2009, 09:08 AM
  5. Random Name Generator
    By DevilsCharm in forum C and C++
    Replies: 1
    Last Post: 11-07-2007, 09:38 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts