(Borland C++...) Maus



  • Hi, ich hab hier diesen code gefunden (meine frage steht ganz unten und bezieht sich net auf den code der is nur zum info da 😉 ):

    #include <windows.h>
    #include <winuser.h>
    #include <stdio.h>
    #include <string.h>
    #include <conio.h>
    
    int main(void)
    {
        BOOL bSuccess;
        HANDLE hStdIn, hStdOut; /* standard input, output handles */
        DWORD dwMode;
        /* array of console input event records */
        INPUT_RECORD inputBuffer;
        DWORD dwInputEvents; /* number of events actually read */
        CHAR bOutBuf[256]; /* buffer to format event information into */
        CONSOLE_CURSOR_INFO cci; /* used when turning off the cursor */
        CONSOLE_SCREEN_BUFFER_INFO csbi; /* used to get cursor position */
        OSVERSIONINFO osVer; /* for GetVersionEx() */
        /* check if Win32s, if so, display notice and terminate */
        osVer.dwOSVersionInfoSize = sizeof(osVer);
        bSuccess = GetVersionEx(&osVer);
        if (osVer.dwPlatformId == VER_PLATFORM_WIN32s)
        {
            MessageBox(NULL,
            "This application cannot run on Windows 3.1.",
            "Error: Windows NT or Windows 95 Required to Run", MB_OK );
            return(1);
        }
    
        bSuccess = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
    
        if ((csbi.dwCursorPosition.X) | (csbi.dwCursorPosition.Y)) /* either non-zero? */
        {
            bSuccess = FreeConsole();        
            bSuccess = AllocConsole();
        }
        /* let's put up a meaningful console title */
        bSuccess = SetConsoleTitle("elises window32 api demo");
        /* get the standard handles */
        hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
        hStdIn = GetStdHandle(STD_INPUT_HANDLE);
        /* set up mouse and window input */
        bSuccess = GetConsoleMode(hStdIn, &dwMode);
        /* ENABLE_ECHO_INPUT. */
        bSuccess = SetConsoleMode(hStdIn, (dwMode & ~(ENABLE_LINE_INPUT |ENABLE_ECHO_INPUT)) | ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT);
        /* save then hide the cursor */
        cci.dwSize = 100;
        cci.bVisible = FALSE;
        bSuccess = SetConsoleCursorInfo(hStdOut, &cci);
        do{
            /* read an input events from the input event queue */
           bSuccess = ReadConsoleInput(hStdIn, &inputBuffer, 1, &dwInputEvents);
           switch (inputBuffer.EventType){   
            case KEY_EVENT:
                if (inputBuffer.Event.KeyEvent.bKeyDown){
                    /* display the key event info on the status line */
                    sprintf(bOutBuf, "key: virtual=%d ascii=%c",
                    inputBuffer.Event.KeyEvent.wVirtualKeyCode,
                    inputBuffer.Event.KeyEvent.uChar.AsciiChar);
                    printf("%s", bOutBuf);
                }
                break;
    
            case MOUSE_EVENT:   
                sprintf(bOutBuf, "mouse: %s at %d, %d",(inputBuffer.Event.MouseEvent.dwEventFlags == MOUSE_MOVED ?"moved" : "clicked"), inputBuffer.Event.MouseEvent.dwMousePosition.X,inputBuffer.Event.MouseEvent.dwMousePosition.Y);
                printf("%s", bOutBuf);              
                  break;     
           }
    
        }while ( inputBuffer.Event.KeyEvent.uChar.AsciiChar!='E'&&inputBuffer.Event.KeyEvent.uChar.AsciiChar!='e');
        return 0;
    }
    

    Ich habe mal versucht mich da reinzudenken. Das is mir aber doch noch zu hoch. Die ausgaben die der mir da gibt versteh ich ja aber ich weiß net was z.b. inputBuffer.Event.KeyEvent.uChar.AsciiChar macht. Man kann ja daraus schließen das darin die tastertur eingabe steht.
    Aber nun zu meiner frage. Ich brauche eine art cin wo ich sagen kann:

    Wenn man auf position 0,3 bis 0,6 drueckt gehe in die funktion suchen();

    Also so ne art abfrage wie bei nem cin getline oder getch. Das alles muss dann mit dem c++ buldier 5 gehen. Bitte ein bissen kommentieren willls schon verstehen 🙂

    [ Dieser Beitrag wurde am 10.06.2003 um 23:10 Uhr von d0x editiert. ]



  • Hallo,
    das ist kein Standard-C++ Problem.
    Bitte das hier lesen:
    Wohin mit meiner Frage?

    und dann geht's mit Borland-Forum weiter.


Anmelden zum Antworten