nochmal Chatconsole



  • hallo..

    also ich habe folgendes problem immernoch nich gelöst bekommen...:

    ich verwende unter anderem die funktionen aus der improved console..
    nun hab ichs ja schon geschafft strings per sockets zu senden und zu empfangen.
    aber ich hänge immernoch an folgendem problem , dass ich die empfangenen strings
    nich an der richtigen stelle ausgeben kann:
    also ich hab mir das so vorgestellt:

    im moment isses noch so, dass ich den string zum senden per gets(string) einlese.. nun is ja diese funktion blockierend, dh ich kann nichts empfangen und ausgeben, wenn ich grad am tippen bin.. also hab ich einen thread erstellt, der dann aufgerufen wird, sobald ein string vom anderen pc ankommt.. dieser thread schreibt dann per printf() den string hin ..
    ich glaub das hab ich doch schonmal erzählt 🙄 , naja egal :

    so nun will ich aber den string vom thread überhalb der zeile angezeigt bekommen, in der ich grad am tippen war.. das kann ich mit der funktion
    gotoxy() sehr schick lösen, naja aber er überschreibt ja die zeile obendrüber..
    also wieder nix gut.. jetz fällt mir nur eine lösung ein:

    da ich ja die zeichen, die mal ausgegeben worden sind nicht wieder einlesen kann, muss ich den string den ich bisher immer mit gets() einlesen tu , echtzeit einlesen, sodass nach jedem tippen das zeichen sofort in den string geschrieben wird und nicht erst mit enter .
    damit könnte ich beim empfangen die zeile mit printf(" ") löschen, in der ich grad tipp, dort dann die empfangene message ausgeben und den string, wo ich grad am einlesen war grad drunter wieder ausgeben, bis zu der stelle wo ich aufgehört hab..
    hmm gibts sone funktion ??

    kann mir jemand da helfen ? oder fällt jemanden ne bessere idee ein ?

    naja ich hab mal bisle mit der conio.h gespielt, aber kann mit den funktionen irgendwie noch nich richtig umgehen.. am liebsten wäre es mir, wenn ich das ganze in ansi c gelöst bekomm

    mfg haMMer



  • Darüber einfügen? Also soll die Eingabezeile um eins nach unten verschoben werden - nicht so schwer - oder alles eins nach oben - schon komplizierter?

    Also soll die Eingabezeile einfach um eins nach unten wandern:

    ReadConsoleOutput
    The ReadConsoleOutput function reads character and color attribute data from a rectangular block of character cells in a console screen buffer, and the function writes the data to a rectangular block at a specified location in the destination buffer.

    BOOL ReadConsoleOutput(
    HANDLE hConsoleOutput, // handle to a console screen buffer
    PCHAR_INFO lpBuffer, // address of buffer that receives data
    COORD dwBufferSize, // column-row size of destination buffer
    COORD dwBufferCoord, // upper-left cell to write to
    PSMALL_RECT lpReadRegion // address of rectangle to read from
    );

    Parameters
    hConsoleOutput
    Handle to the screen buffer. The handle must have GENERIC_READ access.
    lpBuffer
    Pointer to a destination buffer that receives the data read from the screen buffer. This pointer is treated as the origin of a two-dimensional array of CHAR_INFO structures whose size is specified by the dwBufferSize parameter.
    dwBufferSize
    Specifies the size, in character cells, of the lpBuffer parameter. The X member of the COORD structure is the number of columns; the Y member is the number of rows.
    dwBufferCoord
    Specifies the coordinates of the upper-left cell in the lpBuffer parameter that receives the data read from the screen buffer. The X member of the COORD structure is the column, and the Y member is the row.
    lpReadRegion
    Pointer to a SMALL_RECT structure. On input, the structure members specify the upper-left and lower-right coordinates of the screen buffer rectangle from which the function is to read. On output, the structure members specify the actual rectangle that the function copied from.
    Return Values
    If the function succeeds, the return value is nonzero.

    If the function fails, the return value is zero. To get extended error information, call GetLastError.

    Remarks
    ReadConsoleOutput treats the screen buffer and the destination buffer as two-dimensional arrays (columns and rows of character cells). The rectangle pointed to by the lpReadRegion parameter specifies the size and location of the block to be read from the screen buffer. A destination rectangle of the same size is located with its upper-left cell at the coordinates of the dwBufferCoord parameter in the lpBuffer array. Data read from the cells in the screen buffer source rectangle is copied to the corresponding cells in the destination buffer. If the corresponding cell is outside the boundaries of the destination buffer rectangle (whose dimensions are specified by the dwBufferSize parameter), the data is not copied.

    Cells in the destination buffer corresponding to coordinates that are not within the boundaries of the screen buffer are left unchanged. In other words, these are the cells for which no screen buffer data is available to be read.

    Before ReadConsoleOutput returns, it sets the members of the structure pointed to by the lpReadRegion parameter to the actual screen buffer rectangle whose cells were copied into the destination buffer. This rectangle reflects the cells in the source rectangle for which there existed a corresponding cell in the destination buffer, because ReadConsoleOutput clips the dimensions of the source rectangle to fit the boundaries of the screen buffer.

    If the rectangle specified by lpReadRegion lies completely outside the boundaries of the screen buffer, or if the corresponding rectangle is positioned completely outside the boundaries of the destination buffer, no data is copied. In this case, the function returns with the members of the structure pointed to by the lpReadRegion parameter set such that the Right member is less than the Left, or the Bottom member is less than the Top. To determine the size of the screen buffer, use the GetConsoleScreenBufferInfo function.

    The ReadConsoleOutput function has no effect on the screen buffer's cursor position. The contents of the screen buffer are not changed by the function.

    Windows NT: This function uses either Unicode characters or 8-bit characters from the console's current code page. The console's code page defaults initially to the system's OEM code page. To change the console's code page, use the SetConsoleCP or SetConsoleOutputCP functions, or use the chcp or mode con cp select= commands.

    ----
    Wie der Text da offiziell hinkam - ich habe keine Ahnung.

    Naja, also du kannst schon erfahren was du zurzeit am Bildschirm hast, da verschiebst du eben die richtige Zeile um eins nach unten und schreibst an den entstandenen Platz die Message die angekommen ist.

    MfG SideWinder



  • ey dankeee !!

    das öffnet jetz ganz neue wege für mein problem .. ! 🙂

    mfg haMMer


Anmelden zum Antworten