Disable a Console Scrollbar

This is a discussion on Disable a Console Scrollbar within the Windows Programming forums, part of the Platform Specific Boards category; Hi all, Can someone point me towards a Win32 API function for disabling the scrollbar in a windows console app? ...

  1. #1
    Registered User dalek's Avatar
    Join Date
    May 2003
    Posts
    135

    Disable a Console Scrollbar

    Hi all,

    Can someone point me towards a Win32 API function for disabling the scrollbar in a windows console app?

    Thanks.

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    The scroll bar(s) appear automatically when the window size in either direction is smaller than the console screen buffer. To get rid of the scroll bar(s) reduce the screen buffer size in the required direction. Part 6 of my console tutorial shows how to do this.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User dalek's Avatar
    Join Date
    May 2003
    Posts
    135
    Cheers.

    edit: Nice tutorials by the way, it has pretty much everything I need for my project. Thanks!

  4. #4
    Registered User dalek's Avatar
    Join Date
    May 2003
    Posts
    135
    Ugh.. having a problem resizing the console buffer to a smaller size.
    Code:
    #include <windows.h>
    #include <iostream>
    using namespace std;
    
    int main()
    {
        HANDLE hOut;
        CONSOLE_SCREEN_BUFFER_INFO SBInfo;
        COORD NewSBSize;
        int Status;
    
        hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    
        GetConsoleScreenBufferInfo(hOut, &SBInfo);
        NewSBSize.X = SBInfo.dwSize.X - 2;
        NewSBSize.Y = SBInfo.dwSize.Y;
    
        Status = SetConsoleScreenBufferSize(hOut, NewSBSize);
        if (Status == 0)
        {
            Status = GetLastError();
            cout << "SetConsoleScreenBufferSize() failed! Reason : " << Status << endl;
            exit(Status);
        }
    
        GetConsoleScreenBufferInfo(hOut, &SBInfo);
    
        cout << "Screen Buffer Size : ";
        cout << SBInfo.dwSize.X << " x ";
        cout << SBInfo.dwSize.Y << endl;
    
        return 0;
    }
    The call to SetConsoleScreenBuffer fails, with error message "87" which is as far as I can tell "Incorrect parameter". I am guessing it is due to an implicit type conversion on NewSBSize.X struct member, but no matter how I try I can't fix it. Any ideas?

  5. #5
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    I think it is more likely that you are trying to reduce the screen buffer to a size smaller than the window, you can't do that. The tutorial does mention this.

    If you change the '- 2' to '+ 2' for example, the program runs, so it is not the type of argument, rather it's value that the call is objecting to.

    If you want to make the screen buffer smaller, shrink the window first.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #6
    Registered User dalek's Avatar
    Join Date
    May 2003
    Posts
    135
    Your right it does. It's probably a good idea to read everything isn't it. :/

    Thanks.

  7. #7
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    The error you get back from GetLastError() is not really right because it implies a type error. It is something I raised with MS about 10 years ago, I doubt it'll change however.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  8. #8
    Registered User dalek's Avatar
    Join Date
    May 2003
    Posts
    135
    The error you get back from GetLastError() is not really right because it implies a type error
    Yeah, I got suspicious when it couldn't be fixed with a typecast.

    Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Full Screen Console
    By St0rmTroop3er in forum C++ Programming
    Replies: 1
    Last Post: 09-26-2005, 09:59 PM
  2. Console Functions Help
    By Artist_of_dream in forum C++ Programming
    Replies: 9
    Last Post: 12-04-2004, 02:44 AM
  3. Disable scrollbar in a listview
    By knutso in forum Windows Programming
    Replies: 1
    Last Post: 11-11-2003, 04:22 PM
  4. How to disable a mouse in a console
    By GaPe in forum C Programming
    Replies: 7
    Last Post: 05-26-2002, 05:45 AM
  5. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 09:19 AM

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