Problem z kompilacją okna w WINAPI

0

Witam mam dziwny problem. W visualu 2010 gdy chcę skompilować kod, to wyskakuje mi dziwny komunikat który znajdziecie poniżej. Proszę o pomoc i pozdrawiam.

1>------ Build started: Project: D3D - kurs, Configuration: Release Win32 ------
1>  DX 11 - code.cpp
1>MSVCRT.lib(crtexe.obj) : error LNK2001: unresolved external symbol _main
1>c:\users\radosław\documents\visual studio 2010\Projects\D3D - kurs\Release\D3D - kurs.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 

A poniżej kod programu. Jest on na pewno poprawny. Sztampowy schemat.

 #include <windows.h>

 using namespace std;

 // the WindowProc function prototype
 LRESULT CALLBACK WindowProc(HWND hWnd,
                          UINT message,
                          WPARAM wParam,
                          LPARAM lParam);

 // the entry point for any Windows program
 int WINAPI WinMain(HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpCmdLine,
                    int nCmdShow)
 {
     // the handle for the window, filled by a function
     HWND hWnd;
     // this struct holds information for the window class
     WNDCLASSEX wc;

     // clear out the window class for use
     ZeroMemory(&wc, sizeof(WNDCLASSEX));

     // fill in the struct with the needed information
     wc.cbSize = sizeof(WNDCLASSEX);
     wc.style = CS_HREDRAW | CS_VREDRAW;
     wc.lpfnWndProc = WindowProc;
     wc.hInstance = hInstance;
     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
     wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
     wc.lpszClassName = "WindowClass1";

     // register the window class
     RegisterClassEx(&wc);

     // create the window and use the result as the handle
     hWnd = CreateWindowEx(NULL,
                           "WindowClass1",    // name of the window class
                           "Our First Windowed Program",   // title of the window
                           WS_OVERLAPPEDWINDOW,    // window style
                           300,    // x-position of the window
                           300,    // y-position of the window
                           500,    // width of the window
                           400,    // height of the window
                           NULL,    // we have no parent window, NULL
                           NULL,    // we aren't using menus, NULL
                           hInstance,    // application handle
                           NULL);    // used with multiple windows, NULL

     // display the window on the screen
     ShowWindow(hWnd, nCmdShow);

     // enter the main loop:

     // this struct holds Windows event messages
     MSG msg;

     // wait for the next message in the queue, store the result in 'msg'
     while(GetMessage(&msg, NULL, 0, 0))
     {
         // translate keystroke messages into the right format
         TranslateMessage(&msg);

         // send the message to the WindowProc function
         DispatchMessage(&msg);
     }

     // return this part of the WM_QUIT message to Windows
     return msg.wParam;
 }

 // this is the main message handler for the program
 LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
     // sort through and find what code to run for the message given
     switch(message)
     {
         // this message is read when the window is closed
         case WM_DESTROY:
             {
                 // close the application entirely
                 PostQuitMessage(0);
                 return 0;
             } break;
     }

     // Handle any messages the switch statement didn't
     return DefWindowProc (hWnd, message, wParam, lParam);
 }
0

W C++ nie programuję, ale czy nie powinno być funkcji main?

1

źle utworzyłeś projekt. stwórz raz jeszcze, i wybierz Win32 application (nie Console application).

0

Mam problem, kiedy kompiluje ten kod nie mam błędów, okno pokazuje mi błąd i się zamyka jaka jest tego przyczyna i mozna to poprawić w opcjach VS??

0

W sumie to nie o ten kod mi chodzilo jest podobny, nie mam w nim zadnych errorów, wszystko gra (1 succeeded) pózniej wyskakuje mi okno i blad okna, ze program zostanie zamkniety i jest lipa

0

to da sie w opcjach VS2008 zrobic czy nie da??!!

0

jak nie powiesz co, to sie nie da, la.

0

http://www.gamedev.net/topic/460445-book-game-programming-all-in-one-2002/

w tym linku jest kod, którego przepisalem z książki, chyba wszystkim znanej tu, czyli Programowanie gier. Kompedium. Mój kod wyglada identycznie tylko zamiast directx9 uzywam directx8 tak jak w ksiazce, zreszta nie ma to wiekszego znaczenia bo w jednym jak i w drugim przypadku jest ten sam blad, czyli kiedy kompiluje ten kod jest wszystko ok, ale wyskakuje blad okna, tak jak pisalem wyzej i zamiast wyswietlac grafike wylacza to okno . I chcialem sie dowiedziec czy wina jest w kompilatorze, ktorego uzywam (Visual studio 2008), jezeli tak to czy mozna to w opcjach jakos ustawic, czy w gdzies w kodzie??

1 użytkowników online, w tym zalogowanych: 0, gości: 1