Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Strange behavior with my newest machine

May
12,845
164
My CONSIZE command (4CONSOLE) is old and has always worked well. But it behaves oddly on my new machine (2.66 GHz, Core2 Quad). This routine is called twice in succession, once for horizontal resizing and once for vertical. Without the (odd-looking, "s(100)") Sleep() it misbehaves when resizing vertically, the second SetConsoleWindowInfo() undoing what the first one did.

Code:
INT s(DWORD n)
{
    Sleep(n);
    return 1;
}

VOID ResizeUtil(HANDLE hCon, SMALL_RECT* psr, COORD cd, BOOL bDoWindow, BOOL bWindowFirst, BOOL bDoBuffer) {
    if (   ( bDoWindow && bWindowFirst && !SetConsoleWindowInfo(hCon, TRUE, psr) )
        || ( s(100) && bDoBuffer && !SetConsoleScreenBufferSize(hCon, cd) )
        || ( bDoWindow && !bWindowFirst && !SetConsoleWindowInfo(hCon, TRUE, psr) )
    );
}

Have you ever run into such a phenomenon? Do you have any guesses why that might happen?
 
vefatica wrote:

> My CONSIZE command (4CONSOLE) is old and has always worked well. But it behaves oddly on my new machine (2.66 GHz, Core2 Quad). This routine is called twice in succession, once for horizontal resizing and once for vertical. Without the (odd-looking, "s(100)") Sleep() it misbehaves when resizing vertically, the second SetConsoleWindowInfo() undoing what the first one did.
>
>
> Code:
> ---------
> INT s(DWORD n)
> {
> Sleep(n);
> return 1;
> }
>
> VOID ResizeUtil(HANDLE hCon, SMALL_RECT* psr, COORD cd, BOOL bDoWindow, BOOL bWindowFirst, BOOL bDoBuffer) {
> if ( ( bDoWindow && bWindowFirst && !SetConsoleWindowInfo(hCon, TRUE, psr) )
> || ( s(100) && bDoBuffer && !SetConsoleScreenBufferSize(hCon, cd) )
> || ( bDoWindow && !bWindowFirst && !SetConsoleWindowInfo(hCon, TRUE, psr) )
> );
> }
> ---------
> Have you ever run into such a phenomenon? Do you have any guesses why that might happen?

I run into that sort of thing constantly -- the Windows console manager
has problems when you send commands to it too quickly. (They get
executed out of order or dropped completely.)

Rex Conn
JP Software
 
I run into that sort of thing constantly -- the Windows console manager has problems when you send commands to it too quickly. (They get executed out of order or dropped completely.

Do you have any better way of dealing with it than little timing kludges like mine? Any Sleep() (except Sleep(0)) makes my example work correctly.
 
vefatica wrote:

> ---Quote (Originally by rconn)---
> I run into that sort of thing constantly -- the Windows console manager has problems when you send commands to it too quickly. (They get executed out of order or dropped completely.
> ---End Quote---
> Do you have any better way of dealing with it than little timing kludges like mine? Any Sleep() (except Sleep(0)) makes my example work correctly.

No; I add delays of various lengths.

Rex Conn
JP Software
 
Back
Top