1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WinGui C Problem (WndProc not recognized?)

Discussion in 'C' started by Floh85, Mar 11, 2008.

  1. Floh85

    Floh85 New Member

    Joined:
    Mar 11, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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!

    (Toggle Plain Text)

    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);
    }
     
    Last edited by a moderator: Mar 11, 2008

Share This Page