RE: Console window size: rows and columns

new topic     » goto parent     » topic index » view thread      » older message » newer message

Terry Constant wrote:
>
> Brian,
> 
> You are correct. I will be looking into the specifics 
> (such as those you mention) in a little while. I will 
> let you know what I determine.
> 
> Terry Constant

Well, I'm not sure this is going to help you either since the info 
returned pertains strictly to the console buffer.  If you run the 
program below a few times you'll see what I mean (notice the changing 
values).  But between this code and Ken's you might be able to get 
something going.  I typically take weekends away from the computer so 
I'll just give you my code.  To fix Ken's code, just make note of my use 
of peek2u() instead of his simple peek()'s... 

include dll.e
include machine.e
without warning

constant
   STD_INPUT_HANDLE  = -10,  --((DWORD)-10)
   STD_OUTPUT_HANDLE = -11,  --((DWORD)-11)
   STD_ERROR_HANDLE  = -12   --((DWORD)-12)
  
constant
   SBI_BYTES = 22,
   SBI_SIZEX = 0,
   SBI_SIZEY = 2,
   SBI_CPOSX = 4,
   SBI_CPOSY = 6,
   SBI_ATTR  = 8,
   SBI_WINX1 = 10,
   SBI_WINY1 = 12,
   SBI_WINX2 = 14,
   SBI_WINY2 = 16,
   SBI_MAXX  = 18,
   SBI_MAXY  = 20

constant
   kernel32 = open_dll( "kernel32.dll" ),

   xGetStdHandle = define_c_func( kernel32, "GetStdHandle", {C_UINT}, 
C_POINTER ),
   xGetConsoleScreenBufferInfo =
    define_c_func( kernel32, "GetConsoleScreenBufferInfo", 
{C_POINTER,C_POINTER}, C_INT )

constant
   Info = allocate( SBI_BYTES*8 )

constant
   hStdHandle = c_func( xGetStdHandle, { STD_OUTPUT_HANDLE } )

  ------------------------------

function peek2u( atom address )
   sequence bytes
  
   bytes = peek({address,2})
   return bytes[2]*256+bytes[1]
end function

  ------------------------------

if not c_func( xGetConsoleScreenBufferInfo, { hStdHandle, Info } ) then
   puts(1,"Doh!!!")
   abort(1)
end if

  ------------------------------

printf(1,"Console screen buffer size: %d x %d\n", 
{peek2u(Info+SBI_SIZEX),peek2u(Info+SBI_SIZEY)})
printf(1,"Current buffer cursor postion: (%d,%d)\n", 
{peek2u(Info+SBI_CPOSX),peek2u(Info+SBI_CPOSY)})
printf(1,"Console screen buffer coordinates: (%d,%d)-(%d,%d)\n",
          
{peek2u(Info+SBI_WINX1),peek2u(Info+SBI_WINY1),peek2u(Info+SBI_WINX2),peek2u(Info+SBI_WINY1)})

printf(1,"Maximum size of the console window: %d x %d\n", 
{peek2u(Info+SBI_MAXX),peek2u(Info+SBI_MAXY)})


-- Good Luck!!!
-- Brian

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu