WinGui C Problem (WndProc not recognized?)

This is a discussion on WinGui C Problem (WndProc not recognized?) within the C Programming forums, part of the General Programming Boards category; Hey, I just started to learn how to program in Windows and have a problem with the very first program. ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    3

    WinGui C Problem (WndProc not recognized?)

    Hey,

    I just started to learn how to program in Windows and have a problem with the very first program. It's from a C Book I have, so i guess the code is alright.

    Error: undefined reference to `_Z7WndProcP6HWND__jjl@16'

    I'm using the Eclipse C/C++ IDE; libraries (gdi32.lib) are linked, -mwindows is set.

    Whats the problem? Thanks in advance!

    Code:
    #include <windows.h>
    // Globale Variablen
    HINSTANCE hInst  	= 0;		// Programm-Handle
    char szAppName[] 	= "Basis"; 	// Name der Anwendung
    char szTitle[100]	= "Hallo Windows";	// Fenstertitel
    
    
    	
    // Prototypen eigener Funktionen
    	
    BOOL InitApplication();
    BOOL InitInstance(int);
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    
    // Der Programm Einstiegspunkt
    int WINAPI WinMain(	HINSTANCE hInstance,
    					HINSTANCE hPrevInstance,
    					LPSTR	  lpCmdLine,
    					int		  nCmdShow)
    {
    	MSG msg;				// Platz für eine Message
    	hInst = hInstance; 		// Handle der Instanz an eine globale Variable zuweisen
    	if(!InitApplication())	// Fenster registrieren
    		return FALSE;
    	if(!InitInstance(nCmdShow))	// Hauptfenster erzeugen
    		return FALSE;
    	while(GetMessage(&msg,NULL,0,0)) //Meldungsschleife
    	{
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    	}
    	return (msg.wParam);
    }
    
    //--------------------Fortsetzung----------------------
    
    BOOL InitApplication()
    {
    	WNDCLASSEX wc;							//Fensterklasse
    	
    //Die Eigenschaften der Fensterklasse festlegen:
    	
    	wc.cbSize 	= sizeof(WNDCLASSEX);								//Anzahl Byte dieser Struktur
    	wc.style 			= CS_HREDRAW | CS_VREDRAW;				// Fensterstile
    	wc.lpfnWndProc 		= (WNDPROC) WndProc;						// Fensterprozedur
    	wc.cbClsExtra 		= 0;									//Hier kann zusätzlicher Speicher reserviert werden
    	wc.cbWndExtra 		= 0;									//den das Programm für eigene Zwecke nutzt.
    	wc.hInstance 		= hInst;								//Handle dieser Instanz											
    	wc.hIcon			= LoadIcon( NULL, IDI_APPLICATION); 	//Standard Icon
    	wc.hCursor			= LoadCursor(NULL, IDC_ARROW);			// Standard Cursor Pfeil
    	wc.hbrBackground	= (HBRUSH)GetStockObject(WHITE_BRUSH); 	//Hintergrund der Client Area
    	wc.lpszMenuName 	= NULL;
    	wc.lpszClassName	= szAppName;
    	wc.hIconSm 			= LoadIcon( NULL, IDI_APPLICATION);
    	
    	return RegisterClassEx(&wc);
    }
    
    BOOL InitInstance(int nCmdShow)
    {
    	HWND hWnd;
    	hWnd = CreateWindow(
    				szAppName,		 		//Name der Fensterklasse
    				szTitle,				//Titel des Fensters
    				WS_OVERLAPPEDWINDOW,	//Fensterstil //Lage des Fensters:					
    				CW_USEDEFAULT,			//x-Koordinate
    				0,						//y-Koordinate
    				CW_USEDEFAULT,			//Fensterbreite
    				0,						//Fensterhöhe
    				NULL,					//Handle: Elternfenster
    				NULL,					//Handle: Menue
    				hInst,					//Handle des Programms
    			NULL);					//Zeiger auf zusätzliche Daten
    	if( !hWnd)
    		return (FALSE);
    	ShowWindow(hWnd, nCmdShow);		//Fenster anzeigen.
    	UpdateWindow(hWnd);				//WM_PAINT-Meldung
    	return(TRUE);
    }

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    It doesn't look like you have a WndProc function - at least not in the source you posted.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,651
    You need to implement the WndProc callback function. This link looks good.

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    3
    Well, it's this line the compiler does not agree with. It's in the initApplication() function.

    Code:
    wc.lpfnWndProc 		= (WNDPROC) WndProc;
    I've had the same error with WinMain - solved it with -mwindows and gdi32.lib.

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    3
    Oh well, skipped some 15 pages in my book and what do I have here; "The function WndProc()".

    I assumed that function is imported or something - don't know the conventions that well yet.

    Thanks anyways!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM
  2. Replies: 5
    Last Post: 11-07-2005, 10:34 PM
  3. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  5. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM

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