Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Resize C++ console Window

  • 08-03-2003 04:02PM
    #1
    Closed Accounts Posts: 18


    Hello there,

    Can anyone tell me if its posible to resize the console window in Borland C++ Builder 4 from within the code. I'm trying to make it bigger than the default size.


    Thanks in advance.


Comments

  • Closed Accounts Posts: 189 ✭✭Kenshin


    I don't think you can do that from your code.


  • Registered Users, Registered Users 2 Posts: 1,372 ✭✭✭silverside


    I Remember reading about this in one of Mike Blazcksak's books. I don't think there is a simple way; you may be able to kludge it by doing a FindWindow() call using the command window title which will be something like c:\\mydir\\myapp.exe and sending a series of WM_COMMAND messages to emulate the menu items which do the same thing, there may be some other specific windows APIs to do the same thing.

    Just curious, why do you want to anyway?


  • Closed Accounts Posts: 18 Fergal20


    I have to display a graph on the console screen and I want the screen to be bigger!


  • Registered Users, Registered Users 2 Posts: 6 Martial_Law


    Hiya,

    I use VC++, a little different than Borland C++ 4.0 but it may be done in a similar manner...

    This is how you resize the window in VC++

    LRESULT CALLBACK WndProc(HWND hWnd,UINT Message,WPARAM wParam,LPARAM lParam)
    {
    static HDC hDC;
    static HGLRC hRC;
    int width,height;

    switch(Message)
    {
    case WM_CREATE://create your window
    hDC = GetDC(hWnd);
    g_HDC = hDC;
    SetUpPixelFormat(hDC);
    //set up pixel format need to write this yourself

    hRC = wglCreateContext(hDC);
    wglMakeCurrent(hDC,hRC);
    Initialize(); //set up what is in the window

    return 0;
    break;

    case WM_CLOSE://when the window is closed
    wglMakeCurrent(hDC,NULL);
    wglDeleteContext(hRC);

    PostQuitMessage(0);
    return 0;
    break;

    case WM_SIZE:

    height = HIWORD(lParam);
    width = LOWORD(lParam);

    if(height == 0)
    height = 1;

    return 0;
    break;
    return(DefWindowProc(hWnd,Message,wParam,lParam));
    }

    That is for VC++ using a windows application...
    I'm sure it is something similar in borland

    Martial Law


Advertisement