GET_X_LPARAM: identifier not found

This is a discussion on GET_X_LPARAM: identifier not found within the Windows Programming forums, part of the Platform Specific Boards category; As the title says i get a bunch of errors saying that GET_X_LPARAM cannot be found, not even with argument-dependent ...

  1. #1
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483

    GET_X_LPARAM: identifier not found

    As the title says i get a bunch of errors saying that GET_X_LPARAM cannot be found, not even with argument-dependent lookup

    Code:
    #include <windows.h>
    
    
    LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
    
    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                        PSTR szCmdLine, int iCmdShow)
    {
    	static TCHAR szAppName[] = TEXT ("HelloWin") ;
    	HWND         hwnd ;
    	MSG          msg ;
    	WNDCLASS     wndclass ;
    
    	wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
    	wndclass.lpfnWndProc   = WndProc ;
    	wndclass.cbClsExtra    = 0 ;
    	wndclass.cbWndExtra    = 0 ;
    	wndclass.hInstance     = hInstance ;
    	wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
    	wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
    	wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
    	wndclass.lpszMenuName  = NULL ;
    	wndclass.lpszClassName = szAppName ;
    
    	if (!RegisterClass (&wndclass))
    	{
    		MessageBox (NULL, TEXT ("This program requires Windows NT!"), 
    					szAppName, MB_ICONERROR) ;
    	return 0 ;
    	}
    	hwnd = CreateWindow (szAppName,                  // window class name
    						TEXT ("Hello Windows"),     // window caption
    						WS_OVERLAPPEDWINDOW,        // window style
    						CW_USEDEFAULT,              // initial x position
    						CW_USEDEFAULT,              // initial y position
    						CW_USEDEFAULT,              // initial x size
    						CW_USEDEFAULT,              // initial y size
    						NULL,                       // parent window handle
    						NULL,                       // window menu handle
    						hInstance,                  // program instance handle
    						NULL) ;                     // creation parameters
    
    
    	ShowWindow (hwnd, iCmdShow) ;
    	UpdateWindow (hwnd) ;
         
    	while (GetMessage (&msg, NULL, 0, 0))
    	{
    		TranslateMessage (&msg) ;
    		DispatchMessage (&msg) ;
    	}
    	return msg.wParam ;
    }
    
    LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	HDC         hdc ;
    	PAINTSTRUCT ps ;
    	RECT        rect;
    	POINT pt;
    	static bool LButtonDown;
    	switch (message)
    	{
    	case WM_CREATE:
    		return 0 ;
    	case WM_LBUTTONDOWN:
    			LButtonDown = true;
    			pt.x = GET_X_LPARAM(lParam);
    			pt.y = GET_Y_LPARAM(lParam);
    			return 0;
    	case WM_LBUTTONUP:
    			LButtonDown = false;
    			return 0;
    	case WM_MOUSEMOVE:
    			if(LButtonDown == true)
    			{
    				hdc = GetDC (hwnd);
    				MoveToEx(hdc, pt.x, pt.y, NULL);
    				LineTo(hdc, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
    				pt.x = GET_X_LPARAM(lParam);
    				pt.y = GET_Y_LPARAM(lParam);
    				ReleaseDC(hwnd, hdc);
    				return 0;
    			}
    			else
    				return 0;
    						
    	case WM_PAINT:
    		 
    		hdc = BeginPaint (hwnd, &ps) ;
    		EndPaint (hwnd, &ps) ;
    		return 0 ;
              
    	case WM_DESTROY:
    		PostQuitMessage (0) ;
    		return 0 ;
    	}
    	return DefWindowProc (hwnd, message, wParam, lParam) ;
    }
    Quite simple code...
    My Website
    010000110010101100101011
    Add Color To Your Code!

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,264
    Use LOWORD() instead of GET_X_LPARAM() and use HIWORD instead of GET_Y_LPARAM.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    GET_X_LPARAM is in Windowsx.h
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Thanks guys, works pefrectly.

    Just another thing, why does it say that it cant find sprintf?
    My Website
    010000110010101100101011
    Add Color To Your Code!

  5. #5
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    sprintf is in <stdio.h>

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Just one more thing I noticed.....

    You use the point to hold the location clicked. Make the point a static or it will have lost scope (the value will change) once the WM_LBUTTONDOWN msg has been processed.

    You may also have problems with the drawing (speed and shearing). Search here for code (on drawing lines and 'double buffering').
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  7. #7
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Quote Originally Posted by novacain
    Just one more thing I noticed.....

    You use the point to hold the location clicked. Make the point a static or it will have lost scope (the value will change) once the WM_LBUTTONDOWN msg has been processed.

    You may also have problems with the drawing (speed and shearing). Search here for code (on drawing lines and 'double buffering').
    Yearh i realized that ones i tested, and fixed it.

    Thanks though.
    My Website
    010000110010101100101011
    Add Color To Your Code!

  8. #8
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Somthing else that you could have done to fix it without editing any code is by including the header file windowsx.h

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 07-19-2007, 01:29 AM
  2. arrays with elements
    By bradleyd in forum C Programming
    Replies: 5
    Last Post: 04-10-2007, 01:00 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 10:23 PM
  5. error: identifier "byte" is undefined.
    By Hulag in forum C++ Programming
    Replies: 4
    Last Post: 12-10-2003, 05:46 PM

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