Forums

Controlling the position of a new window

Started by rickman January 18, 2009
I am using a terminal emulator program (PuTTY) with a Forth program in
a development cycle.  Because of problems reloading the program being
debugged, Each cycle around the code-test loop, I close Win32Forth and
use a Windows batch file to start Forth, load the Forth program,
invoke the Forth application and to start PuTTY in a new window using
the Windows START command.  Win32Forth starts up in the same window
size and location it was last closed.  But PuTTY starts in a window
that moves each time it is opened.  Is there a way to open the PuTTY
window at a fixed location?  The default terminal parameters set the
window size ok, I just need to control the location.

I am open to using a different terminal emulator if that would help.
PuTTY is the best one I have found, but I am not wedded to it.
Windows telnet and Hyperterm and Realterm are the other ones I have
looked at.  I just need it to be able to start up automatically in the
state I am using, 85 columns, 29 rows, a easily readable font and to
start a telnet connection to localhost, port 23.  PuTTY seems to do
all of this except for the window position.

Rick
On Sun, 18 Jan 2009 10:59:07 -0800 (PST), rickman <gnuarm@gmail.com>
wrote:

>I am using a terminal emulator program (PuTTY) with a Forth program in >a development cycle. Because of problems reloading the program being >debugged, Each cycle around the code-test loop, I close Win32Forth and >use a Windows batch file to start Forth, load the Forth program, >invoke the Forth application and to start PuTTY in a new window using >the Windows START command. Win32Forth starts up in the same window >size and location it was last closed. But PuTTY starts in a window >that moves each time it is opened. Is there a way to open the PuTTY >window at a fixed location? The default terminal parameters set the >window size ok, I just need to control the location. > >I am open to using a different terminal emulator if that would help. >PuTTY is the best one I have found, but I am not wedded to it. >Windows telnet and Hyperterm and Realterm are the other ones I have >looked at. I just need it to be able to start up automatically in the >state I am using, 85 columns, 29 rows, a easily readable font and to >start a telnet connection to localhost, port 23. PuTTY seems to do >all of this except for the window position.
I can't judge the value of it for you, but I often reach for the uCon Embedded Console. It provides a TFTP client/server, a DHCP server, and more, plus serial command scripting, and a terminal server that allows you to access the PC's serial port remotely via telnet. It's free and it runs on Windows, though I think the author is maybe working on a Wine version or something to go beyond Windows. It's been continuously updated over the years, as well. The last one I found was from September 2008. http://microcross.com/ucon_install.zip Also, see this page -- partway down -- for the same link: http://microcross.com/html/micromonitor.html Also, it starts up really fast. I use it regularly on old beater machines -- I'm talking about 80486 machines operating Win98SE at 33MHz, for example. None of that .NET crap to slow things down. I also use PuTTY, though, for some things. I like them both. Jon
On Sun, 18 Jan 2009 10:59:07 -0800 (PST), rickman <gnuarm@gmail.com>
wrote:

>I am using a terminal emulator program (PuTTY) with a Forth program in >a development cycle. Because of problems reloading the program being >debugged, Each cycle around the code-test loop, I close Win32Forth and >use a Windows batch file to start Forth, load the Forth program, >invoke the Forth application and to start PuTTY in a new window using >the Windows START command. Win32Forth starts up in the same window >size and location it was last closed. But PuTTY starts in a window >that moves each time it is opened. Is there a way to open the PuTTY >window at a fixed location? The default terminal parameters set the >window size ok, I just need to control the location.
Hi, Rick. You might code up a Win32Forth word to call the MoveWindow API function to move PuTTY. I'm afraid my C is better than my Forth, so that's what my sample is written in. See below: // moveputty.c #include <windows.h> #pragma comment(lib,"user32.lib") int main(int argc,char **argv) { HANDLE hwnd; hwnd=FindWindow("PuTTY",NULL); if(hwnd==NULL) { printf("Unable to find PuTTY"); return 1; } // x,y,width, height, repaint-flag MoveWindow(hwnd,10,15,800,200,TRUE); return 0; } // end The first thing to do is find the handle of the PuTTY window by calling FindWindow with a windows-classname of "PuTTY". If a handle is returned, move it ( which also resizes it ... so you may need to tinker with the width, height values. ) The EXE and source for the above can be found here: http://www.mailsend-online.com/samp/moveputty.zip Jim Lawless
On Feb 7, 11:58=A0am, ji...@radiks.net (Jim Lawless) wrote:
> On Sun, 18 Jan 2009 10:59:07 -0800 (PST), rickman <gnu...@gmail.com> > wrote: > > >I am using a terminal emulator program (PuTTY) with a Forth program in > >a development cycle. =A0Because of problems reloading the program being > >debugged, Each cycle around the code-test loop, I close Win32Forth and > >use a Windows batch file to start Forth, load the Forth program, > >invoke the Forth application and to start PuTTY in a new window using > >the Windows START command. =A0Win32Forth starts up in the same window > >size and location it was last closed. =A0But PuTTY starts in a window > >that moves each time it is opened. =A0Is there a way to open the PuTTY > >window at a fixed location? =A0The default terminal parameters set the > >window size ok, I just need to control the location. > > Hi, Rick. =A0You might code up a Win32Forth word to call the MoveWindow > API function to move PuTTY. > > I'm afraid my C is better than my Forth, so =A0that's what my sample is > written in. =A0See below: > > // moveputty.c > #include <windows.h> > > #pragma comment(lib,"user32.lib") > > int main(int argc,char **argv) { > =A0 =A0HANDLE hwnd; > =A0 =A0hwnd=3DFindWindow("PuTTY",NULL); > =A0 =A0if(hwnd=3D=3DNULL) { > =A0 =A0 =A0 printf("Unable to find PuTTY"); > =A0 =A0 =A0 return 1; > =A0 =A0} > =A0 =A0 =A0 // x,y,width, height, repaint-flag > =A0 =A0MoveWindow(hwnd,10,15,800,200,TRUE); =A0 =A0 =A0 =A0 > =A0 =A0return 0;} > > // end > > The first thing to do is find the handle of the PuTTY window by > calling FindWindow with a windows-classname of "PuTTY". =A0If a handle > is returned, move it ( which also resizes it ... so you may need to > tinker with the width, height values. ) > > The EXE and source for the above can be found here: > > http://www.mailsend-online.com/samp/moveputty.zip
Jim, Thanks. I am currently using ExtraPuTTY which allows the location of the window to be set. However, it opens an extra side window along with PuTTY, which then needs to be closed for my purposes. But I can live with that. I am going to focus on the other aspects of my program. But when I get back to this, I may try your suggestions. Rick
On Sat, 7 Feb 2009 16:10:37 -0800 (PST), rickman <gnuarm@gmail.com>
wrote:

> But when I get back to this, I may try your suggestions.
I downloaded Win32Forth today just to see how difficult it might be to implement. Here's the word I came up with. : moveputty 0 z" PuTTY" FindWindow dup 0= if drop else >R 1 200 800 15 10 R> MoveWindow then ; I'm afraid that it should really read the existing Windows dimensions and simply move it rather than forcing it to 800x200, but I hope this gets you into the ballpark should you need to revisit this issue. Jim Lawless
On Feb 8, 5:31=A0pm, ji...@radiks.net (Jim Lawless) wrote:
> On Sat, 7 Feb 2009 16:10:37 -0800 (PST), rickman <gnu...@gmail.com> > wrote: > > > =A0But when I get back to this, I may try your suggestions. > > I downloaded Win32Forth today just to see how difficult it might be to > implement. =A0Here's the word I came up with. > > : moveputty 0 z" PuTTY" FindWindow dup 0=3D if drop else >R 1 200 800 15 =
10 R> MoveWindow then ;
> > I'm afraid that it should really read the existing Windows dimensions > and simply move it rather than forcing it to 800x200, but I hope this > gets you into the ballpark should you need to revisit this issue.
Thanks. I can figure out what dimensions to use. Right now the program will remember the window size, so I should be able to read that from the init dialog. Rick