Dev-c++

Sven

Member of Honour
HI Leute, habe heute mal mit C Programmieren angefangen, mit dem Compiler DEV-C++, nur wenn ich es schaffe, das Prog. zu compilieren, dann hab ich, nur en DOS fenster, was mache ich falsch??

Das DOS fenster ist komplett leer.

Vielen DAnk im Vorraus

mfg
SVen
 
wahrscheinlich hast du auch ne konsolen anwendung programmiert
und dann kommt ne dos box
wenn du ein windows fenster (das willst du doch oder?) haben willst dann musst du dieses auch programmieren - das kommt nich so von alleine

und wenn du in dem deinem konsolen-prog keine ausgaben machst dann bleibt das dos fenster auch leer

also ich denke du hast nichts falsch gemacht sondern einfach nur ne falsche vorstellung gehabt von dem was dich erwartet

wenn ich jetzt total daneben liege mit meiner vermutung dann erklär mal genauer was du überhaupt möchtest
 
wenn du kein Oberfläche programierst, dann kannst du auch keine bekommen. Falls du eine Oberfläche im code hast, dann check mal als was für ein projekt du es gestarted und dann auch compilieren wirst.
 
svenyboy:
Es ist schon alles ok, so wie es ist, aber die Ausgabe deiner Programme landet eben nur in der Konsole.
Falls du die Ausgabe nicht siehst, weil die Konsole zu schnell wieder zu geht.
solltest du mit einer Eingabeabfrage am Ende des Programmes das Fenster offen halten.
 
DEV C++ gibt dir bei Wunsch auch ein Windowsfenster vor. Dies kann man beim erstellen einer neuen Datei auswählen.
 
Also, ich poste mal den Programm Code:

Code:
/* bspl0001.c */
#include <stdio.h>
main ( ) {
  printf("\nDies ist ein erstes C-Programm.\n");
  printf("\nWie du siehst, kann 'printf' ");
  printf("nicht nur Texte drucken,\n");
  printf("sondern auch rechnen.\n\n");
  printf("13 * 7 = %i \n",13 * 7);
}

So siehts aus, is mein erstes Progi,...

@ Brabax
soll der Code dann so aussehen, oder wie??

Code:
#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;
}

/* bspl0001.c */
#include <stdio.h>
main ( ) {
  printf("\nDies ist ein erstes C-Programm.\n");
  printf("\nWie du siehst, kann 'printf' ");
  printf("nicht nur Texte drucken,\n");
  printf("sondern auch rechnen.\n\n");
  printf("13 * 7 = %i \n",13 * 7);
}


oder gibts en TUT zu DEV-C++ ??
bzw. en einfacheres Progi??

mfg
Sven


Sorry, das ich euch mit dem Code hier belaste
 
Wie schon gesagt wurde schließt sich die Konsole einfach zu schnell.
Daher am Anfang die Bibliothek <cstdio> includen und dann vor dem 'return 0;' ein
'getchar();' einfügen.
Dann wird das Programm erst nach dem Drücken einer Taste beendet.
 
Nein, das wird sicherlich nicht funktionieren. Du musst zunächst einmal wissen, dass eine Windowsanwendung ganz anders programmiert wird, als eine Konsolenanwendung. Ein Windowsprogramm hat eine andere Struktur und es werden zum Grossteil auch andere Funktionen genutzt. Du kannst mit prinf z.b. nicht in ein WIndowsfenster schreiben und die Ausgaben müssen sich im Programm auch an einer ganz anderen Position befinden. Ich kann dir das alles jetzt nicht mal eben erklären. Deswegen gebe ich dir den Rat dich mit der API-Programmieung in C zu beschäftigen. Einfach bei Google eingeben oder ein Buch zum Thema lesen. Allerdings würde ich dir auch dazu raten, deine C++ Kenntnisse erstmal zu vertiefen indem du einige Konsolenanwendungen schreibst, bevor du dich mit API-Programmen beschäftigst.

mfg, softrunner
 
Ich habe schon einmal unter dem Topic "Windows SDK Help" gepostet,
http://www.hackerboard.de/thread.php?threadid=8608&sid=
ob jemand weiß wo es eine Dokumentation von Microsoft gibt, die ein Programm, wie das von svenyboy erklaert.
Code:
#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;
}

/* bspl0001.c */
#include <stdio.h>
main ( ) {
  printf("\nDies ist ein erstes C-Programm.\n");
  printf("\nWie du siehst, kann 'printf' ");
  printf("nicht nur Texte drucken,\n");
 
Zurück
Oben