1. moving console window

I experimenting with mic's glue(glut). Since the window caption doesn't update, I'm sending fps data to the console window. Problem is, the console window seems to open at a different screen location every time.

Any way to "glue" it to one spot.

new topic     » topic index » view message » categorize

2. Re: moving console window

It occurred to me if I could get the screen coords of the console window, I could relate the glut window position to them. That doesn't seem possible either.

new topic     » goto parent     » topic index » view message » categorize

3. Re: moving console window

You can move it manually. I've had a lot of fun manipulating the console from Euphoria without using Win32Lib, etc. Here's some sample code...

 
include dll.e 
include get.e 
include machine.e 
 
-- shared libraries 
constant kernel32       = open_dll( "kernel32.dll" ) 
constant user32         = open_dll( "user32.dll" ) 
 
-- console routines 
constant xGetConsoleWindow      = define_c_func( kernel32, "GetConsoleWindow", {}, C_LONG ) 
constant xGetWindowRect         = define_c_func( user32, "GetWindowRect", {C_LONG,C_POINTER}, C_ULONG ) 
constant xMoveWindow            = define_c_func( user32, "MoveWindow", {C_LONG,C_INT,C_INT,C_INT,C_INT,C_ULONG}, C_ULONG ) 
 
-- structures 
constant RECT_left    =  0 
constant RECT_top     =  4 
constant RECT_right   =  8 
constant RECT_bottom  = 12 
constant SIZEOF_RECT  = 16 
 
procedure MoveConsole( integer x, integer y, integer refresh ) 
 
    atom hWnd, pRect 
    integer cx, cy, junk 
     
    -- get the console handle 
    hWnd = c_func( xGetConsoleWindow, {} ) 
     
    -- allocate the structure 
    pRect = allocate( SIZEOF_RECT ) 
     
    -- get the window rect 
    if c_func( xGetWindowRect, {hWnd, pRect} ) = 0 then 
        free( pRect ) 
        return 
    end if 
     
    -- calculate the window size 
    cx = peek4s( pRect + RECT_right ) - peek4s( pRect + RECT_left )  
    cy = peek4s( pRect + RECT_bottom ) - peek4s( pRect + RECT_top ) 
     
    -- free the structure 
    free( SIZEOF_RECT ) 
     
    -- move the window 
    junk = c_func( xMoveWindow, {hWnd, x, y, cx, cy, refresh} ) 
     
end procedure 
 
object junk 
 
puts( 1, "Press any key to move the Window...\n" ) 
junk = wait_key() 
 
-- move to top-left corner 
MoveConsole( 0, 0, 1 ) 
 
puts( 1, "The console was moved!" ) 
junk = wait_key() 

-Greg

new topic     » goto parent     » topic index » view message » categorize

4. Re: moving console window

wow! You'd think they could incorporate that into a few commands in the language.

new topic     » goto parent     » topic index » view message » categorize

5. Re: moving console window

shfrance said...

wow! You'd think they could incorporate that into a few commands in the language.

It souldn't be too hard to put together a library of console routines. I'll see what I can knock out...

-Greg

new topic     » goto parent     » topic index » view message » categorize

6. Re: moving console window

ghaberek said...

It souldn't be too hard to put together a library of console routines. I'll see what I can knock out...

I'm already adding some to win32lib. Can I add your's too?

new topic     » goto parent     » topic index » view message » categorize

7. Re: moving console window

DerekParnell said...
ghaberek said...

It souldn't be too hard to put together a library of console routines. I'll see what I can knock out...

I'm already adding some to win32lib. Can I add your's too?

Well heck, yeah!

console.ew (9 kb)

-Greg

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu