Strange behavior with my newest machine

May 20, 2008
9,290
62
Syracuse, NY, USA
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?
 

rconn

Administrator
Staff member
May 14, 2008
10,975
98
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
 
May 20, 2008
9,290
62
Syracuse, NY, USA
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.
 

rconn

Administrator
Staff member
May 14, 2008
10,975
98
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