Utilizator:
Parola:
Am uitat parola... | Cont nou!


Articole Resurse Echipe Competiții Proiecte Forum DevBlogs Locuri de muncă GDROMag Issue#1 GDROCon 2007

 
Forum » Programare » Altele » nu mi se compileaza programul




Pagina 1 din 1 [ 1 ]

Mesaj Info autor
    Postat la 26 Dec 2008 13:14:19    Subiect: nu mi se compileaza programul
Fuzzball info:

Fuzzball:

Salutare la toata lumea si "Craciun Fericit!"

Am o problema cu un program luat de pe "http://www.directxtutorial.com/Tutorial9/A-Win32/dx9A3.aspx" in care te invata sa faci o fereastra in windows in the good old fashioned way.
Problema e ca atunci cand il iau pur si simplu cu "copy/paste" de pe site merge fara probleme dar urmatoarea varianta care e copiata "manual" de mine cand incerc sa o compilez imi da eroare C2084 Neutral

1>c:beginning visual c++ 2005real programstesttestmain.cpp(105) : error C2084: function 'int WinMain(HINSTANCE,HINSTANCE,LPSTR,int)' already has a body

Cod sursă:
#include
#include

// #define XPOS 300
// #define YPOS 300
// #define WIDTH 500
// #define HEIGHT 400

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

int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nShowCmd )
{
    HWND hWnd; //the handle for the window, filled by a function
    WNDCLASSEX wc; //structure that holds information for the window class

    ZeroMemory(&wc, sizeof(WNDCLASSEX));

    //fill in the structure
    wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = (WNDPROC)WindowProc;
    wc.hInstance = hInstance;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH) COLOR_WINDOW;
    wc.lpszClassName = L"WindowClass";

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

    //create the window and use the result as the handle
    hWnd = CreateWindow(NULL,
                        L"WindowClass", //name of the class of the window
                        WS_OVERLAPPEDWINDOW, //window style
                        /*XPOS*/300,    //x pos of the window
                        /*YPOS*/300,    //y pos of the window
                        /*WIDTH*/500,    //width of the window
                        /*HEIGHT*/400,    //height of the window
                        NULL,    //no parent window
                        NULL,    //we arent't using menus
                        hInstance, //application handle
                        NULL);    //used with multiple windows
    
    //display the window on the screen
    ShowWindow(hWnd, nShowCmd);

    //enter the main loop

    MSG msg; //this structure contains window messages

    //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);
}

// include the basic windows header file
#include
#include

// 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 = (WNDPROC)WindowProc;
    wc.hInstance = hInstance;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
    wc.lpszClassName = L"WindowClass1";

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

    // create the window and use the result as the handle
    hWnd = CreateWindowEx(NULL,
        L"WindowClass1",    // name of the window class
        L"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 WindowProcEx(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);
}
 


Am verificat de mai multe ori si e exact acelasi lucru. Pur si simplu nu inteleg ce are.

Will code for food.


Status:
Înregistrat pe:
20 Apr 2008 16:32:46
Vârsta: 27 ani
Mesaje: 106
Locatie: Asteroid of neverending rape and faggotry
Programator

 
    Postat la 26 Dec 2008 13:19:57    Subiect: < fara subiect >
Fuzzball info:

Fuzzball:

Scuze de double post dar vad ca nu exista optiunea de a edita mesajul

Am schimbat numele functiilor din WinMain si WindowProc in WinMainEx si WindowProcEx si cand compilez nu imi mai da erori dar cand rulez nu imi apare nicio fereastra.

Will code for food.


Status:
Înregistrat pe:
20 Apr 2008 16:32:46
Vârsta: 27 ani
Mesaje: 106
Locatie: Asteroid of neverending rape and faggotry
Programator

 
    Postat la 26 Dec 2008 13:27:47    Subiect: < fara subiect >
c0mas info:

c0mas:

in loc sa le pui in acelasi fisier, fa doua fisiere separate si compara-le (cu un tool de comparare) si vezi care sunt diferentele ... poate vezi ceva aiurea.

Do what you love, money will follow!


Status:
Înregistrat pe:
19 Apr 2007 13:41:50
Vârsta: 35 ani
Mesaje: 337
Locatie: Bucuresti
Programator
Dream Builder Studios
 
    Postat la 26 Dec 2008 13:28:49    Subiect: < fara subiect >
boboS info:

boboS:

In codul tau original vad functia WinMain de doua ori. Lasa numai una si va merge.

"Noi ne facem ca muncim , ei se fac ca ne platesc"


Status:
Înregistrat pe:
03 Oct 2006 15:53:21
Vârsta: 25 ani
Mesaje: 961
Locatie: Galați
Programator

 
    Postat la 26 Dec 2008 13:35:17    Subiect: < fara subiect >
Fuzzball info:

Fuzzball:

Tot eu sunt

Pana la urma i-am dat de cap . In incercarea mea de a vedea de ce nu merge am copiat versiunea cea buna de pe site in fisier la coada programului si am comentat ce scrisesem eu. Pe urma nu mai stiu ce am facut , cert e ca tot cautand pe internet si incercand sa ii dau de cap am uitat sa comentez una din cele doua versiuni din acelasi fisier (cea scrisa de mine si cea copiata cu copy/paste) Embarassed si tot incercam sa compilez cocomarla de fisier. (cred ca se vede codul in primul post Mr. Green ). Pana la urma mi-am dat seama de prostie si am sters partea de cod copiata cu copy/paste.
Acum merge bine Very Happy

Will code for food.


Status:
Înregistrat pe:
20 Apr 2008 16:32:46
Vârsta: 27 ani
Mesaje: 106
Locatie: Asteroid of neverending rape and faggotry
Programator

 
    Postat la 26 Dec 2008 13:37:51    Subiect: < fara subiect >
Fuzzball info:

Fuzzball:

Mersi de sfaturi. Nu puteti sa-mi dati si mie un exemplu de tool de comparare, va rog!

Will code for food.


Status:
Înregistrat pe:
20 Apr 2008 16:32:46
Vârsta: 27 ani
Mesaje: 106
Locatie: Asteroid of neverending rape and faggotry
Programator

 
    Postat la 26 Dec 2008 13:49:11    Subiect: < fara subiect >
night_hawk info:

night_hawk:

Incearca asta.


Status:
Înregistrat pe:
25 Mar 2007 22:01:13
Vârsta: 21 ani
Mesaje: 506
Locatie: Suceava
Programator junior
Esotheria
 
    Postat la 26 Dec 2008 14:03:59    Subiect: < fara subiect >
boboS info:

boboS:

PS: Acuma am vazut siteul cu tutoriale. Sper sa nu te apuci sa te faci membru Premium (ala cu 25.00 dolari) sa iti dea restu de tutoriale care oricum le gasesti pe net pe alte siteuri poate si mai avansate.

"Noi ne facem ca muncim , ei se fac ca ne platesc"


Status:
Înregistrat pe:
03 Oct 2006 15:53:21
Vârsta: 25 ani
Mesaje: 961
Locatie: Galați
Programator

 
    Postat la 26 Dec 2008 14:13:55    Subiect: < fara subiect >
Fuzzball info:

Fuzzball:

Dintre toate siturile cu tutoriale DX ,asta mi-a placut cel mai mult. Deocamdata nu am nevoie de partea de tutoriale in care trebuie sa platesti. Tutorialele gratis sunt arhisuficiente ca sa intelegi chestiile de baza.

Will code for food.


Status:
Înregistrat pe:
20 Apr 2008 16:32:46
Vârsta: 27 ani
Mesaje: 106
Locatie: Asteroid of neverending rape and faggotry
Programator

 
    Postat la 26 Dec 2008 17:27:30    Subiect: Re:
c0mas info:

c0mas:



Eu folosesc toolul de la Total Commander sau BeyondCompare (de la caz la caz)


Do what you love, money will follow!


Status:
Înregistrat pe:
19 Apr 2007 13:41:50
Vârsta: 35 ani
Mesaje: 337
Locatie: Bucuresti
Programator
Dream Builder Studios
 
    Postat la 26 Dec 2008 23:40:39    Subiect: < fara subiect >
nekitu info:

nekitu:

http://winmerge.org/

SpoOoOoock! Life Is Too Short For Cheap Chocolate


Status:
Înregistrat pe:
29 Sep 2006 11:33:12
Vârsta: 32 ani
Mesaje: 1033
Locatie: Brasov
Programator
7thFACTOR Entertainment Studios
 

Pagina 1 din 1 [ 1 ]


Server time: 08:42:01 19.05.2012



[ Termeni si conditii | Contact | F.A.Q. | Funny Pictures ]

© 2006 - 2012 Copyright 7thFACTOR Entertainment - All rights reserved