Unexpected end of File Error

This is a discussion on Unexpected end of File Error within the Windows Programming forums, part of the Platform Specific Boards category; Hey... After numerous checks through the code, I still can't figure out why I'm getting this error: fractal2.cpp(116) : fatal ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    46

    Unexpected end of File Error

    Hey... After numerous checks through the code, I still can't figure out why I'm getting this error: fractal2.cpp(116) : fatal error C1010: unexpected end of file while looking for precompiled header directive

    The code is below-- any and all help would be greatly appreciated!

    Thanks!!

    -maxthecat

    #include <windows.h>

    #define TIMER_ID 1

    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

    int count = 2;
    int cx, cy;
    int dir = 0;
    int SCALE = 10;

    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
    {
    static TCHAR szAppName[] = TEXT("Fractal v2.0");
    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.lpszClassName = szAppName;
    wndclass.lpszMenuName = NULL;

    if (!RegisterClass(&wndclass))
    {
    MessageBox(NULL, TEXT ("Failed to Register Window"), szAppName, MB_ICONERROR);
    return 0;
    }

    hwnd = CreateWindow(szAppName, TEXT("Fractal Program v2.0"), WS_OVERLAPPEDWINDOW | WS_VSCROLL, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);

    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)
    {
    int temp;

    switch (message)
    {
    case WM_CREATE:
    SetTimer(hwnd, TIMER_ID, 1000, NULL);
    return 0;

    case WM_SIZE:
    cx = (LOWORD (lParam)) /2;
    cy = (HIWORD (lParam)) /2;
    InvalidateRect(hwnd, NULL, TRUE);
    return 0;

    case WM_TIMER:
    InvalidateRect(hwnd, NULL, FALSE);
    return 0;

    case WM_PAINT:
    hdc = BeginPaint (hwnd, &ps);

    GetClientRect (hwnd, &rc);
    hBrush = CreateSolidBrush(RGB(0,0,255));

    for (temp=count;temp>0;temp--)
    {
    switch (dir)
    {
    case 0:
    MoveToEx(hdc, cx, cy, NULL);
    LineTo(hdc, cx, (cy + SCALE));
    cy += SCALE;
    dir++;
    break;
    case 1:
    MoveToEx(hdc, cx, cy, NULL);
    LineTo(hdc, (cx - SCALE), cy);
    cx -= SCALE:
    dir++;
    break;
    case 2:
    MoveToEx(hdc, cx, cy, NULL);
    LineTo(hdc, cx, (cy - SCALE));
    cy -= SCALE:
    dir++;
    break;
    case 3:
    MoveToEx(hdc, cx, cy, NULL);
    LineTo(hdc, (cx + SCALE), cy);
    cx += SCALE;
    dir = 0;
    break;
    }
    }
    count = count * count;

    return 0;

    case WM_DESTROY:
    PostQuitMessage(0);
    return 0;
    }

    return DefWindowProc(hwnd, message, wParam, lParam);
    }

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    My guess is that you have a stupid compiler. Anyways, the first error that my compiler noticed was that you had too many arguments in CreateWindow(). You had CW_USEDEFAULT one too many times. You also didn't declare a lot of variables. In fact, you didn't declare enough that I won't fix your code. So maybe this will give you a push in the right direction.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    46
    ack.... after the line "int temp;" in the wndProc function there should also be

    HDC hdc;
    RECT rc;
    PAINTSTRUCT ps;
    HBRUSH hBrush;


    -maxthecat

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    46
    ack... nevermind... i got it to work...

    late night programming + fuzzy eyes + lack of pop = bad....


    thanks anyhow =)

    -maxthecat

  5. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Yeah, i've been there before. It also looks like you got a bit carried away when cutting and pasting code.

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    You create a brush (which allocates GDI memory)

    hBrush = CreateSolidBrush(RGB(0,0,255));

    You MUST

    hBrush=(HBRUSH)SelectObject(hOldBrush);//put the original back
    DeleteObject(hBrush);//then delete the new

    to free the brush (its GDI memory) or your app will crash your PC.

    Remember to do this before each break in your paint switch.

    I also can't see the

    EndPaint()

    call nor the

    hOldBrush=(HBRUSH)SelectObject(hBrush);//select in the new


    (excuse me if these are lines you did not post)
    "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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 09:46 AM
  3. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 03:49 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

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