Fenstergerüst?



  • ich hab hier einen kleinen quellcode aber funkt nich immer wenn ich ihn starten will kommt einfach nichts guck ihn euch mal an:(ich benutze dev)

    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    #pragma comment (lib, "winmm.lib")
    
    int Spielen (int Level);
    int WaehleLevel (int Level);
    int TesteHighscore (int Punkte, int Highscore);
    
    int main ()
    {
    
    	char Auswahl;          
    	int Level = 5;         
    	int Highscore = 100;   
    
    	srand((unsigned)time(NULL));
    
    	do
    	{
    
    		cout << "Zahlenraten - Menue" << endl;
    		cout << "-------------------" << endl;
    		cout << "(N)eues Spiel starten" << endl;
    		cout << "(L)evel waehlen" << endl;
    		cout << "(H)ighscore anzeigen" << endl;
    		cout << "(B)eenden\n\n";
    
    		cout << "Auswahl: ";
    		cin >> Auswahl;
    
    		switch (Auswahl)
    		{
    
    			case ('n'):
    			case ('N'):
    			{
    
    				int Punkte;
    				Punkte = Spielen (Level);
    
    				Highscore = TesteHighscore (Punkte, Highscore);
    
    			} break;
    
    			case ('l'):
    			case ('L'):
    			{
    				Level = WaehleLevel (Level);
    
    			} break;
    
    			case ('h'):
    			case ('H'):
    			{
    				cout << "Der aktuelle Highscore liegt bei ";
    				cout << Highscore << " Punkten\n\n";
    
    			} break;
    
    			case ('b'):
    			case ('B'):
    			{
    				cout << "Spiel beendet." << endl;
    
    			} break;
    
    			default:
    			{
    				cout << "Falsche Eingabe!\n\n";
    
    			}
    		}
    
    	} while (Auswahl != 'b' && Auswahl != 'B'); 
    
    	cout << "Bis zum nächsten Mal" << endl;
    
    	return 0;
    } 
    
    int WaehleLevel (int Level)
    {
    	int NeuerLevel;
    
    	do
    	{
    
    		cout << "Aktueller Level: " << Level << endl;
    		cout << "Neuer Level (1 - 10): ";
    		cin >> NeuerLevel;
    
    		if (NeuerLevel < 1 || NeuerLevel > 10)
    		{
    
    			cout << "Ungueltiger Level-Wert" << endl;
    		}
    
    	} while (NeuerLevel < 1 || NeuerLevel > 10);
    
    	return NeuerLevel;
    }
    
    int Spielen (int Level)
    {
    	int Zufallszahl;         
    	int GerateneZahl = 0;    
    	int Bereich = Level*10;  
    	int Versuche = 0;        
    	int Punkte = 0;          
    
    	Zufallszahl = (rand()%Bereich)+1;
    
    	cout << "\nDie gesuchte Zahl liegt zwischen 1 und ";
    	cout << Bereich << endl;
    
    	while (GerateneZahl != Zufallszahl)
    	{
    		cout << "Dein Tipp: ";
    		cin >> GerateneZahl;
    
    		Versuche++;
    
    		if (GerateneZahl < Zufallszahl)
    			cout << "Die gesuchte Zahl ist groesser" << endl;
    		if (GerateneZahl > Zufallszahl)
    			cout << "Die gesuchte Zahl ist kleiner" << endl;
    	}
    
    	cout << "\nGeschafft ! " << endl;
    	cout << "Du hast die Zahl nach " << Versuche;
    	cout << " Versuchen erraten !\n\n";
    
    	Punkte = Bereich - Versuche + 1;
    	Punkte *= Level;
    
    	if (Punkte < 0)
    		Punkte = 0;
    
    	cout << "Punkte: " << Punkte << endl;
    
    	return Punkte;
    } 
    
    int TesteHighscore (int Punkte, int Highscore)
    {
    
    	if (Punkte > Highscore)
    	{
    		cout << "Glueckwunsch. Neuer Highscore !\n\n";
    		Highscore = Punkte;
    	}
    	else
    	{
    		cout << "Leider kein neuer Highscore\n\n";
    	}
    
    	return Highscore;
    } //bis hier her hab ich es gemacht den rest war unter windows aplikation schon //drin
    
    /*  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;
    }
    

    /edit: Code-Tags repariert



  • ich benutze dev

    Da haben wir doch schon das Problem *gg* 🤡 💡 ⚠



  • es ist ein zahlenraten ohne das fenstergerüst funktz



  • Dieser Thread wurde von Moderator/in davie aus dem Forum C++ in das Forum WinAPI verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.



  • Man kann nicht einfach so die main und winmain zusammenbringen, aber wenn du willst erkläre ich dir, wie du das Progrmm mit der WinApi fensterfähig bekommst.



  • jo plz
    hast du icq? meine nummer is 198-487464



  • kann mir sonst wer helfen?
    plz



  • Du hast ersma folgendes Problem: Du möchtest von der Konsole ins Fenster, dass ist auch gar nicht so einfach...

    Wie hättest du es gerne: mit Button, Eingabefelder oder lieber die zeichnerische Variante?



  • Was isn das für ne Blöde Frage ob ich icq hätte???
    Und warum fragst du den nächsten, ob er dir hilft.
    Die meisten sind erst abends im Forum



  • Erstellst Du jetzt eine Windows-App oder eine Consolen-App. Das solltest Du mal zuerst entscheiden...



  • hast du jetzt icq oder nich?



  • Nö, hab ich nicht.



  • sonst irgendwas?(msn.....)



  • nö, hab auch nicht wirklich eine Ahnung, was das sein soll.



  • das sind chat-programme



  • plz download es hier:
    [url]
    http://www.download.com/3000-2150-10174442.html?part=dl-icq5&subj=dl_german&tag=button

    wenn du dich regestriert hast und so dann schreib mir deinen namen und dann können
    wir chaten und du kannst mir es erklärren
    plz



  • So, ich habs installiert...



  • sag mal ist das hier nen chat oder was?



  • ne dafür haben wir ja icq 😃



  • Chat is schon gut, ich will doch nicht immer eine Minute und mehr auf eine Antwort warten.



  • keiner antwortet mehr auf dein problem. lenk doch nicht mit icq von deinem problem ab.


Anmelden zum Antworten