Console Buffers, Why doesnt this work ?

This is a discussion on Console Buffers, Why doesnt this work ? within the C++ Programming forums, part of the General Programming Boards category; Can anyone tell me why this doesnt work, It's supposed to load an image into each buffer and then flick ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    3

    Console Buffers, Why doesnt this work ?

    Can anyone tell me why this doesnt work, It's supposed to load an image into each buffer and then flick between the buffers to make it look animated.

    HANDLE buffer1;
    HANDLE buffer2;

    buffer1=CreateConsoleScreenBuffer(GENERIC_READ,FIL E_SHARE_READ,0,CONSOLE_TEXTMODE_BUFFER,NULL);
    buffer2=CreateConsoleScreenBuffer(GENERIC_READ,FIL E_SHARE_READ,0,CONSOLE_TEXTMODE_BUFFER,NULL);

    SetConsoleActiveScreenBuffer(buffer2);
    readfile("a:\\intro screen1.bmp");
    SetConsoleActiveScreenBuffer(buffer1);
    readfile("a:\\intro screen.bmp");
    while(!kbhit())
    {
    SetConsoleActiveScreenBuffer(buffer2);
    for (int wait=0;wait<390000000;wait++);
    SetConsoleActiveScreenBuffer(buffer1);
    for (wait=0;wait<390000000;wait++);
    }

    All I get is the same image on both buffers.

    thanks for your help in advance people.

    rich :-)

  2. #2
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    somebody probably knows on the windows board...
    Blue

  3. #3
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    If you're writing to a buffer you'll need to give it a GENERIC_WRITE flag. I think the source of your error is your readfile() function which isn't an API function (I assume the bmps aren't real bmps). Apart from this your code appears fine. This works -

    HANDLE buffer1;
    HANDLE buffer2;
    DWORD written;
    buffer1=CreateConsoleScreenBuffer(GENERIC_WRITE,FI LE_SHARE_READ,0,CONSOLE_TEXTMODE_BUFFER,NULL);
    buffer2=CreateConsoleScreenBuffer(GENERIC_WRITE,FI LE_SHARE_READ,0,CONSOLE_TEXTMODE_BUFFER,NULL);
    WriteConsole(buffer1,"1",1,&written,0);
    WriteConsole(buffer2,"2",1,&written,0);

    while(!kbhit())
    {
    SetConsoleActiveScreenBuffer(buffer2);
    for (int wait=0;wait<390000000;wait++);
    SetConsoleActiveScreenBuffer(buffer1);
    for (wait=0;wait<390000000;wait++);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 11-17-2008, 11:36 AM
  2. Console App w/ Threads and Events?
    By sean in forum C# Programming
    Replies: 1
    Last Post: 07-02-2004, 12:16 AM
  3. Linux console window questions
    By GaPe in forum Linux Programming
    Replies: 1
    Last Post: 12-28-2002, 11:18 AM
  4. Sprites In Console
    By c++_n00b in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 04-13-2002, 07:02 AM
  5. win32 apps compiled with GCC start console window!
    By Citrus538 in forum Windows Programming
    Replies: 5
    Last Post: 02-18-2002, 09:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21