Vuoi reagire a questo messaggio? Crea un account in pochi click o accedi per continuare.

Spiegazione su utilizzo Dev-C++

3 partecipanti

Andare in basso

Spiegazione su utilizzo Dev-C++ Empty Spiegazione su utilizzo Dev-C++

Messaggio Da ilchiuri Ven Ott 29, 2010 11:22 am

Ho scaricato l'IDE Dev-C++ per iniziare i miei studi su C e c'è già una cosa che non capisco...se voglio fare un programma per windows (c'è la scelta in apertura di un nuovo progetto) mi compare tutto questo codice che apre una finestra vuota e grigia

Codice:
#include <windows.h>

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;              /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
          0,                  /* Extended possibilites for variation */
          szClassName,        /* Classname */
          "Windows App",      /* Title Text */
          WS_OVERLAPPEDWINDOW, /* default window */
          CW_USEDEFAULT,      /* Windows decides the position */
          CW_USEDEFAULT,      /* where the window ends up on the screen */
          544,                /* The programs width */
          375,                /* and height in pixels */
          HWND_DESKTOP,        /* The window is a child-window to desktop */
          NULL,                /* No menu */
          hThisInstance,      /* Program Instance handler */
          NULL                /* No Window Creation data */
          );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage (0);      /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}

Domanda: che significa tutta questa pappardella?

Ps: per ora per programmare uso windows perchè il mio portatile ancora non è resuscitato sta aspettando la fenice Laughing
ilchiuri
ilchiuri

Messaggi : 49
Data d'iscrizione : 11.10.10

http://www.breachofsecurity.it

Torna in alto Andare in basso

Spiegazione su utilizzo Dev-C++ Empty Re: Spiegazione su utilizzo Dev-C++

Messaggio Da vikkio88 Ven Ott 29, 2010 4:29 pm

non ti conviene fare: nuovo progetto, fai: nuovo sorgente...e lo salvi come .c e con F9 esegui e compili
vikkio88
vikkio88
Admin
Admin

Messaggi : 792
Data d'iscrizione : 14.09.09
Età : 35
Località : Palermo

http://vikkio88.altervista.org

Torna in alto Andare in basso

Spiegazione su utilizzo Dev-C++ Empty Re: Spiegazione su utilizzo Dev-C++

Messaggio Da floatman Ven Ott 29, 2010 6:24 pm

...a dire il vero non concordo con vikkio (ora mi tratterà male :-O )
nel senso che sotto Windows si devi abituare a pappardelle pesanti (su VisualStudio serve anche per un hello world!...)

Quella pappardella è una finestra di Windows, se scegli un progetto da console dovrebbe comparire il classico 'int main'.
Maggiori info su WinMain, WinProc, GetMessage & Co. a partire da qui:
http://msdn.microsoft.com/en-us/library/ms633559%28VS.85%29.aspx
floatman
floatman

Messaggi : 844
Data d'iscrizione : 14.09.09

http://myville.altervista.org

Torna in alto Andare in basso

Spiegazione su utilizzo Dev-C++ Empty Re: Spiegazione su utilizzo Dev-C++

Messaggio Da vikkio88 Ven Ott 29, 2010 7:04 pm

io intendevo che se deve fare:
scanf("%d",&suca);
printf("suca: %d",suca);

non ha bisogno di pappardella...ma solo di un sorgente vacum
vikkio88
vikkio88
Admin
Admin

Messaggi : 792
Data d'iscrizione : 14.09.09
Età : 35
Località : Palermo

http://vikkio88.altervista.org

Torna in alto Andare in basso

Spiegazione su utilizzo Dev-C++ Empty Re: Spiegazione su utilizzo Dev-C++

Messaggio Da Contenuto sponsorizzato


Contenuto sponsorizzato


Torna in alto Andare in basso

Torna in alto


 
Permessi in questa sezione del forum:
Non puoi rispondere agli argomenti in questo forum.