weird compile error

This is a discussion on weird compile error within the Windows Programming forums, part of the Platform Specific Boards category; i'm not brilliant at Windiws progrsmming but i am getting a weird error Code: #include <windows.h> LRESULT CALLBACK WndProc (HWND, ...

  1. #1
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161

    weird compile error

    i'm not brilliant at Windiws progrsmming but i am getting a weird error

    Code:
    #include <windows.h>
    
    LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
    
    HINSTANCE hInstGlobal;
    
    int APIENTRY WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance,
                           LPSTR lpCmdLine, int nCmdShow )
    {
                           
        hInstGlobal = hInstance;
        
        WNDCLASS wc;
        wc.style                 = 0;
        wc.cbClsExtra            = 0;
        wc.cbWndExtra            = 0;
        wc.lpfnWndProc           = WndProc;
        wc.hInstance             = hInstance;
        wc.hbrBackground         = (HBRUSH) (COLOR_WINDOW+1);
        wc.hCursor               = LoadCursor (NULL, IDC_ARROW);
        wc.hIcon                 = LoadIcon (NULL, IDI_APPLICATION);
        wc.lpszMenuName          = 0;
        wc.lpszClassName         = "Dog Simulator 2";
        RegisterClass (&wc);
        
        HWND hWindow;
        hWindow = CreateWindow ( "Kazalio Studios", "Dog Simulator 2",
                                 WS_OVERLAPPEDWINDOW,
                                 0, 0, 400, 400, NULL, NULL,
                                 hInstance, NULL );
        
        ShowWindow (hWindow, nCmdShow);
        UpdateWindow (hWindow);
        
        MSG Message;
        while (GetMessage(&Message, NULL, 0, 0))
        {
              DispatchMessage(&Message);
              }
        return (Message.wParam);
    }
    
        LRESULT CALLBACK WndProcedure (HWND hWnd, UINT uiMessage, WPARAM wParam,
                                       LPARAM lParam)
    {
        switch (uiMessage)
        {
               case WM_CREATE:
                    HWND hContinue, hExit;
                    hContinue = CreateWindow ( "Button", "Continue",
                                               WS_CHILD | WS_VISIBLE |
                                               BS_PUSHBUTTON,
                                               10, 340, 140, 20,
                                               hWnd, (HMENU) 1,
                                               hInstGlobal, NULL);
                    
                    hExit = CreateWindow     ( "Button", "Continue",
                                               WS_CHILD | WS_VISIBLE |
                                               BS_PUSHBUTTON,
                                               10, 340, 140, 20,
                                               hWnd, (HMENU) 2,
                                               hInstGlobal, NULL);
                                               return 0;
                                               
               
               
               case WM_COMMAND:
                    if (HIWORD(wParam) == BN_CLICKED)
                    {
                         if (LOWORD(wParam) == 1)
                         {
                             HDC hdc;
                             hdc = GetDC (GetParent((HWND) lParam));
                             PAINTSTRUCT ps;
                             HFONT font;
                             
                              hdc = BeginPaint(hWnd, &ps);
    		
             font = CreateFont(80, 0, 0, 0,
                               FW_BOLD, FALSE, FALSE, FALSE,
                               ANSI_CHARSET, OUT_DEFAULT_PRECIS,
    		         CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY,
    		         DEFAULT_PITCH | FF_ROMAN,
    			"XPress SF");
    
            SelectObject(hdc, font);
            TextOut(hdc, 70, 20, "Dog Simulator 2", 15);
            DeleteObject(font);
            }
            
            if (LOWORD(wParam) == 2)
            {
                SendMessage (GetParent((HWND)lParam),
                WM_DESTROY, 0, 0);
                }
                }
                
            return 0;
            case WM_DESTROY:
                 PostQuitMessage(0);
                 return 0;
            default:
                    return DefWindowProc (hWnd, uiMessage, wParam, lParam);
                    }
                    }
    and it comes up with the error[link error] undefined reference to 27WndProcp6hwnd__jjl@16
    id returned 1 exit status
    build error project 1 error
    I started out with nothing and I still have most of it left.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Because you prototype it as WndProc, then later you define it as WndProcedure. You need to change it to WndProc.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 11:17 AM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 02:17 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-30-2005, 12:21 AM

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