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

    WinGui C Problem (WndProc not recognized?)


    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!

    #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);
    // 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
    	return (msg.wParam);
    BOOL InitApplication()
    	WNDCLASSEX wc;							//Fensterklasse
    //Die Eigenschaften der Fensterklasse festlegen:
    	wc.cbSize 	= sizeof(WNDCLASSEX);								//Anzahl Byte dieser Struktur 			= 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

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

    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
    Join Date
    Dec 2007
    You need to implement the WndProc callback function. This link looks good.

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

    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
    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, 06:24 PM
  2. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  3. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 02:04 AM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 09:37 AM
  5. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 06:18 AM

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