Page 1 of 1

positioning the console ?

Posted: Mon Jan 26, 2004 3:47 pm
by bernardfrancois
Hello,

Is it possible to place the console window at a certain screen position? Maybe with an API command?

Re: positioning the console ?

Posted: Mon Jan 26, 2004 4:37 pm
by PB
Sure, but only after it's opened. Try this (to position the window at 10,10 on the Desktop):

Code: Select all

If OpenConsole() 
  ConsoleTitle("Test Console") : x=10 : y=10 ; Pixel position on screen. 
  SetWindowPos_(FindWindow_(0,"Test Console"),0,x,y,0,0,#SWP_NOSIZE) 
  Delay(5000) ; Wait for 5 seconds so you can see the result. 
EndIf 
And here's how you'd center the console window on the Desktop:

Code: Select all

If OpenConsole()
  dtw=GetSystemMetrics_(#SM_CXSCREEN) : dth=GetSystemMetrics_(#SM_CYSCREEN)
  ConsoleTitle("Test Console") : con=FindWindow_(0,"Test Console")
  GetWindowRect_(con,win.RECT) : w=win\right-win\left : h=win\bottom-win\top
  SetWindowPos_(con,0,(dtw-w)/2,(dth-h)/2,0,0,#SWP_NOSIZE)
  Delay(5000) ; Wait for 5 seconds so you can see the result.
EndIf

Posted: Mon Jan 26, 2004 6:26 pm
by bernardfrancois
is it also possible to set it's size?

Posted: Tue Jan 27, 2004 10:25 am
by PB
> is it also possible to set it's size?

Not that I know of... maybe someone else knows.

Posted: Tue Jan 27, 2004 1:15 pm
by legider_pb
You can set size of the window using the same method.

Code: Select all

If OpenConsole() 
    ConsoleTitle("Test Console")
    x=200
    y=200
    width=500
    height=500
    
    SetWindowPos_(FindWindow_(0,"Test Console"), 0, x, y, width, height, #SWP_SHOWWINDOW) 
    Delay(5000) ; Wait for 5 seconds so you can see the result. 
EndIf

Posted: Tue Jan 27, 2004 4:27 pm
by PB
> You can set size of the window using the same method.

No -- the console's actual window may be larger, but the output isn't,
which is why I answered no to resizing. Try doing this in the bigger
window and you'll see what I mean:

Code: Select all

If OpenConsole() 
    ConsoleTitle("Test Console") 
    x=200 
    y=200 
    width=500 
    height=500 
    SetWindowPos_(FindWindow_(0,"Test Console"), 0, x, y, width, height, #SWP_SHOWWINDOW) 
    For r=1 To 500 : PrintN(Str(r)) : Next
    Delay(5000) ; Wait for 5 seconds so you can see the result. 
EndIf

Posted: Tue Jan 27, 2004 4:41 pm
by legider_pb
He only asked how to set the size. Was a broad question so i answered as such. But you are correct that it only resizes the window itself not its contents.

Posted: Tue Jan 27, 2004 5:03 pm
by PB
> He only asked how to set the size. Was a broad question so i answered as such.

No problem. :)

Posted: Tue Jan 27, 2004 8:16 pm
by bernardfrancois
so making it bigger has no sense, but making it smaller does :)

that's what i'm going to do :)

I haven't tried these two methods yet but I'll do this evening.

Posted: Tue Jan 27, 2004 8:42 pm
by bernardfrancois
crap I cant find it in the help: how do I get the windows desktop resolution?

Posted: Tue Jan 27, 2004 8:55 pm
by Proteus
Here's how to get the resolution:

Code: Select all

Width = GetSystemMetrics_(#SM_CXSCREEN)
Height= GetSystemMetrics_(#SM_CYSCREEN)

Posted: Tue Jan 27, 2004 9:10 pm
by bernardfrancois
thanks!