1. moving console window
- Posted by shfrance Feb 12, 2009
- 865 views
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.
2. Re: moving console window
- Posted by shfrance Feb 12, 2009
- 852 views
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.
3. Re: moving console window
- Posted by ghaberek (admin) Feb 12, 2009
- 836 views
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
4. Re: moving console window
- Posted by shfrance Feb 12, 2009
- 873 views
wow! You'd think they could incorporate that into a few commands in the language.
5. Re: moving console window
- Posted by ghaberek (admin) Feb 13, 2009
- 881 views
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
6. Re: moving console window
- Posted by DerekParnell (admin) Feb 13, 2009
- 873 views
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?
7. Re: moving console window
- Posted by ghaberek (admin) Feb 13, 2009
- 899 views
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