Help

This is a discussion on Help within the C++ Programming forums, part of the General Programming Boards category; I got this from one of the tutorials on this site. Code: /* Trim fat from windows*/ #define WIN32_LEAN_AND_MEAN #pragma ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    40

    Help

    I got this from one of the tutorials on this site.
    Code:
    /*	Trim fat from windows*/
    #define WIN32_LEAN_AND_MEAN	
    #pragma comment(linker, "/subsystem:windows")
    /*	Pre-processor directives*/
    #include "stdafx.h"
    #include <windows.h>
    /*	Windows Procedure Event Handler*/
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	PAINTSTRUCT paintStruct;
    	/*	Device Context*/
    	HDC hDC; 
    	/*	Text for display*/
    	char string[] = "Hello, World!"; 
    	/*	Switch message, condition that is met will execute*/
    	switch(message)
    	{
    		/*	Window is being created*/
    		case WM_CREATE: 
    			return 0;
    			break;
    		/*	Window is closing*/
    		case WM_CLOSE: 
    			PostQuitMessage(0);
    			return 0;
    			break;
    		/*	Window needs update*/
    		case WM_PAINT: 
    			hDC = BeginPaint(hwnd,&paintStruct);
    			/*	Set txt color to blue*/
    			SetTextColor(hDC, COLORREF(0x00FF0000));
    			/*	Display text in middle of window*/
    			TextOut(hDC,150,150,string,sizeof(string)-1);
    			EndPaint(hwnd, &paintStruct);
    			return 0;
    			break;
    		default:
    			break;
    	}
    	return (DefWindowProc(hwnd,message,wParam,lParam));
    }
    /*	Main function*/
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
    	WNDCLASSEX  windowClass;		//window class
    	HWND		hwnd;				//window handle
    	MSG			msg;				//message
    	bool		done;				//flag saying when app is complete
    	/*	Fill out the window class structure*/
    	windowClass.cbSize = sizeof(WNDCLASSEX);
    	windowClass.style = CS_HREDRAW | CS_VREDRAW;
    	windowClass.lpfnWndProc = WndProc;
    	windowClass.cbClsExtra = 0;
    	windowClass.cbWndExtra = 0;
    	windowClass.hInstance = hInstance;
    	windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    	windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
    	windowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    	windowClass.lpszMenuName = NULL;
    	windowClass.lpszClassName = "MyClass";
    	windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
    	/*	Register window class*/
    	if (!RegisterClassEx(&windowClass))
    	{
    		return 0;
    	}
    	/*	Class registerd, so now create window*/
    	hwnd = CreateWindowEx(NULL,		//extended style
    		"MyClass",			//class name
    		"A Real Win App",		//app name
    		WS_OVERLAPPEDWINDOW |		//window style
    		WS_VISIBLE |
    		WS_SYSMENU,
    		100,100,			//x/y coords
    		400,400,			//width,height
    		NULL,				//handle to parent
    		NULL,				//handle to menu
    		hInstance,			//application instance
    		NULL);				//no extra parameter's
    	/*	Check if window creation failed*/
    	if (!hwnd)
    		return 0;
    	done = false; //initialize loop condition variable
    	/*	main message loop*/
    	while(!done)
    	{
    		PeekMessage(&msg,hwnd,NULL,NULL,PM_REMOVE);
    		if (msg.message == WM_QUIT) //check for a quit message
    		{
    			done = true; //if found, quit app
    		}
    		else
    		{
    			/*	Translate and dispatch to event queue*/
    			TranslateMessage(&msg); 
    			DispatchMessage(&msg);
    		}
    	}
    	return msg.wParam;
    }

    I get an error saying that stdafx.h is invalid or doesn't exist or something like that. Is it my compiler or is there an error in the code? I use Dev-C++.

    I'm not a complete n00b to C++ but I'm no where near being a pro so go easy on me.
    Code:
    #include <iostream.h>
    int var;
    int test();
    int main() { 
     cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n";
     cin >> var;
     return test(); }
    int test() {  
     if(var == 1) {
      cout << "Y0u 4r3 t3h 1337\n";
      system("PAUSE");
      return main(); }
     else if(var == 2) {
      cout << "N00B3R!\n";
      system("PAUSE");
      return main(); }
     else if(var == 3) {
      cout << "You were not thought of.\n";
      system("PAUSE");
      return main(); }
     else {      
      return 0; }}

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    97
    awww......sumthin i ran into also. add a c to the starting of the library that supposedly doesnt exist also, i think thats the opengl tut. go to http://nehe.gamedev.net for sum much better tuts. goodluck

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    40
    thx man. I'm going to read that one after I read this one. I like shorter.
    Code:
    #include <iostream.h>
    int var;
    int test();
    int main() { 
     cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n";
     cin >> var;
     return test(); }
    int test() {  
     if(var == 1) {
      cout << "Y0u 4r3 t3h 1337\n";
      system("PAUSE");
      return main(); }
     else if(var == 2) {
      cout << "N00B3R!\n";
      system("PAUSE");
      return main(); }
     else if(var == 3) {
      cout << "You were not thought of.\n";
      system("PAUSE");
      return main(); }
     else {      
      return 0; }}

  4. #4
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    oobootsy1,

    Going off of some of your topics and statements as of late, i dont think you are in any position to try and slip an insult at any other programmers, particuarly when you dont know what you are doing or talking about.

    That said, there are a few errors in that code, all of which have been sent to the webmaster some time ago, and due to current and not-so in the past website issues they arent a priority for updating.

    I apologize for your problems, and if you contact me at rod@cprogramming.com i will gladly supply you with the correct cpp file, and need be the newer opengl tutorials not yet posted to the website.

    As for previously mentioned members, turn on your flashlight, it will help you see.

    RoD

  5. #5
    Registered User
    Join Date
    Mar 2004
    Posts
    40
    How about an email link that works? I tried that one at the tutorial to no avail.
    Code:
    #include <iostream.h>
    int var;
    int test();
    int main() { 
     cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n";
     cin >> var;
     return test(); }
    int test() {  
     if(var == 1) {
      cout << "Y0u 4r3 t3h 1337\n";
      system("PAUSE");
      return main(); }
     else if(var == 2) {
      cout << "N00B3R!\n";
      system("PAUSE");
      return main(); }
     else if(var == 3) {
      cout << "You were not thought of.\n";
      system("PAUSE");
      return main(); }
     else {      
      return 0; }}

  6. #6
    Registered User
    Join Date
    Mar 2004
    Posts
    40
    If you really want to help me figure it out you can try explaining it. OpenGL seems very complicated and reading the tutorials has gotten me little knowledge and much frustration. I continually get errors from everything and I'm getting nowhere. The only thing I had any luck with was that "My first windows app" thing, and that didn't even teach me anything. How about you post some tutorials? That way you can get feedback more easily and people can learn from the mistakes of others as they post them in the topic.
    Code:
    #include <iostream.h>
    int var;
    int test();
    int main() { 
     cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n";
     cin >> var;
     return test(); }
    int test() {  
     if(var == 1) {
      cout << "Y0u 4r3 t3h 1337\n";
      system("PAUSE");
      return main(); }
     else if(var == 2) {
      cout << "N00B3R!\n";
      system("PAUSE");
      return main(); }
     else if(var == 3) {
      cout << "You were not thought of.\n";
      system("PAUSE");
      return main(); }
     else {      
      return 0; }}

  7. #7
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Each lesson i have written lands me about 25 emails a day. Most good, some bad, mostly just to thank me or ask for a little guidence.

    Its important to realize that i work fulltime, i have a social life, and i have alot of things going on for me at the moment. That said im sure you can understand why it would be impossible for me to offer a widespread support like you suggest.

    This thread/topic would turn into a big pool of different users asking a million different things at once, which makes for a difficult learning structure.

    I believe in learning through experience and challenge, which is why i do not help those who do not help themselves. Email me with a specific question, and you will get a specific answer.

    All of the links in my signature, tutorials, and my email are all in working order. I offer a level of help and support that is extremely rare in opengl tutorials, and for that i have gained a small amount of respect from those who have found great use in my tutorials.

    The fact that you seem angry with me leads me to believe you dont grasp the full concept of how these lessons are created. Each is meant to be a very general grasp of each topic, in the hopes that you will be inspired to challenge yourself and have problems as this helps you learn.

    Any author can tell you step by step everything you need to know, but retention is more often that not the product of ones own lessons.

    I will help you in anyway that i can, but you need to be specific and patient. If you dont feel my methods right for you, than i apologize and wish you luck in finding a author who can help you. I have helped almost 150 people learn OpenGL, many of which now know alot more than i do. This figure may seem small, but to me those are 150 very big achievements.

    I only hope that one of you will claim 151, good luck.

    RoD
    rod@cprogramming.com

  8. #8
    Registered User
    Join Date
    Mar 2004
    Posts
    40
    I don't get mad; I get even. If I was discontent there would be a kitten's head in your mail box ( scary ). My problem is that when I first started C++ I noticed how similar it is to PHP ( PHP is based partly off of C++ ). The syntax is about the only similarity. It's impossible to find any good support for learning C++. It's like anyone who's truly good at it thinks they're too 1337 to share with some n00b.
    I don't even know where to start to look. I go to google and I find two semi-good sites, both of which ........ me off when I try to compile their examples only to find that my compiler must be crap. DOES ANYONE KNOW A BETTER FREE COMPILER THAN DEV-C++?!?!?!?!?!!
    Code:
    #include <iostream.h>
    int var;
    int test();
    int main() { 
     cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n";
     cin >> var;
     return test(); }
    int test() {  
     if(var == 1) {
      cout << "Y0u 4r3 t3h 1337\n";
      system("PAUSE");
      return main(); }
     else if(var == 2) {
      cout << "N00B3R!\n";
      system("PAUSE");
      return main(); }
     else if(var == 3) {
      cout << "You were not thought of.\n";
      system("PAUSE");
      return main(); }
     else {      
      return 0; }}

  9. #9
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Originally posted by ShadowMetis
    I don't get mad; I get even. If I was discontent there would be a kitten's head in your mail box ( scary ). My problem is that when I first started C++ I noticed how similar it is to PHP ( PHP is based partly off of C++ ). The syntax is about the only similarity. It's impossible to find any good support for learning C++. It's like anyone who's truly good at it thinks they're too 1337 to share with some n00b.
    I don't even know where to start to look. I go to google and I find two semi-good sites, both of which ........ me off when I try to compile their examples only to find that my compiler must be crap. DOES ANYONE KNOW A BETTER FREE COMPILER THAN DEV-C++?!?!?!?!?!!
    First off, that sounds like a threat, so you may now learn on your own because i dont have time for your crap. I invest my time in those who take these things seriously.

    Secondly, to say its impossible to find support to learn C++ is an incredibly ignorant statement. Its easier than brushing your teeth, if it was that hard so many people wouldnt know it.

    I dont feel im to "1337", i help newbies every day. And finally, its not your compiler.

  10. #10
    Registered User
    Join Date
    Mar 2004
    Posts
    536
    The header <stdafx.h> is used by Microsoft Visual C++ to build applications using the MFC (Microsoft Foundation Class) library. There are lots of other files that are required as will. Not supplied with Dev-Cpp.

    Dave

  11. #11
    Registered User
    Join Date
    Mar 2004
    Posts
    40
    It wasn't a threat; it was a joke. I figured that was implied by the way I said "( scary )". I wasn't saying that you didn't help either. I was saying that others don't. And not as many people know C++ as you think. Comparitively speaking for the amount of time it's been out, if you compare it to something like php it doesn't come close. Besides, alot of people choose Visual Basics over C++ because of its simplicity and the fact that most high schools teach it.

    Dave, thank you for trying to help instead of getting mad because I'm confused. I appreciate it.
    Code:
    #include <iostream.h>
    int var;
    int test();
    int main() { 
     cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n";
     cin >> var;
     return test(); }
    int test() {  
     if(var == 1) {
      cout << "Y0u 4r3 t3h 1337\n";
      system("PAUSE");
      return main(); }
     else if(var == 2) {
      cout << "N00B3R!\n";
      system("PAUSE");
      return main(); }
     else if(var == 3) {
      cout << "You were not thought of.\n";
      system("PAUSE");
      return main(); }
     else {      
      return 0; }}

  12. #12
    Registered User
    Join Date
    Mar 2004
    Posts
    536
    "You can tell the size of a man by the size of the things that make him mad.

    ---Adlai Stevenson

  13. #13
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Dave Evans
    "You can tell the size of a man by the size of the things that make him mad.

    ---Adlai Stevenson
    I usually just use:

    Code:
    size_t foo = sizeof( man );
    Quzah.
    Hope is the first step on the road to disappointment.

  14. #14
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Originally posted by Dave Evans
    "You can tell the size of a man by the size of the things that make him mad.

    ---Adlai Stevenson
    I'm not mad, im defensive, theres a difference. In reply, implication is dependent on interpertation.

  15. #15
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Lightbulb I think you are going to need a book or two...

    [Disclamer] - I don't know OpenGL.

    This is from the NeHe introduction:
    ...I am merely trying to make the learning process a little easier for those people new to OpenGL. If you are serious about learning OpenGL, you should spend the money and invest in the OpenGL Red Book (ISBN 0-201-46138-2) and OpenGL Blue Book (ISBN 0-201-46140-4)....
    OpenGl and (C++ graphics in general) is an advanced and complex topic. I'll bet that none of RoD's OpenGL books are skinny! If you were studying programming in college, you would take a full year of standard C++, and then maybe a semester of Windows or other GUI before taking a full semester OpenGL class.

    I'm not saying that you can't start learning this stuff if you're not a C++ expert, or that you can't learn from online tutorials and references, but a solid C++ background and some good books might help.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21