Thread: Performing actions with message loop

  1. #1
    Registered User
    Join Date
    Jul 2006

    Performing actions with message loop

    LRESULT CALLBACK WndProc ( ...
        case WM_KEYDOWN:
            switch (wParam)
    	        case VK_ESCAPE:
    	        	return 0;
    		case VK_NUMPAD1:
    			AwesomeVar++; // <-- This is what I need help with *
            return 0;
    "AwesomeVar" is sitting within - int WINAPI WinMain ( ...

    Could someone explain how exactly I would go about making the above hypothetical situation work?

  2. #2

  3. #3
    Join Date
    Jun 2004
    Make a variable global, then you can share it between functions.
    But what I prefer doing is making either a struct or Class that has public variables in it that i use regularly, and then just pass around a pointer to that struct/class. Its much cleaner then using global variables.
    Founder and avid member of the Internationsl Typo Associateion

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  2. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM
  3. Message loop not working...
    By Hunter2 in forum Windows Programming
    Replies: 24
    Last Post: 07-03-2003, 02:17 PM
  4. Help, the window gets killed......
    By incognito in forum Game Programming
    Replies: 2
    Last Post: 05-28-2002, 02:22 PM