WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Windows UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

UDF - Center Window

This code will center a window on the screen without resizing it.
#DefineFunction CenterWindow(title)
   positions=WinPlaceGet(@NORMAL,title)   
   ulx=ItemExtract(1,positions," ")  ; upper left x
   uly=ItemExtract(2,positions," ")  ; upper left y
   lrx=ItemExtract(3,positions," ")  ; lower right x
   lry=ItemExtract(4,positions," ")  ; lower right y   
   height=lry-uly
   width=lrx-ulx
   NewX=(1000-width)/2
   NewY=(1000-Height)/2
   WinPlace(Newx,Newy,@NORESIZE,@NORESIZE,title)
   Return
#EndFunction

Run("notepad.exe","")
title="~Notepad"
CenterWindow(title)


Article ID:   W16236
File Created: 2004:03:30:15:43:32
Last Updated: 2004:03:30:15:43:32