Controlling the position of a new window

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

Reply to
rickman
Loading thread data ...

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.

formatting link

Also, see this page -- partway down -- for the same link:

formatting link

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

Reply to
Jon Kirwan

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

#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:

formatting link

Jim Lawless

Reply to
Jim Lawless

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

Reply to
rickman

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

Reply to
Jim Lawless

10 R> MoveWindow then ;

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

Reply to
rickman

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.