positioning the console ?

Just starting out? Need help? Post your questions and find answers here.
bernardfrancois
User
User
Posts: 47
Joined: Tue Sep 02, 2003 9:17 am
Location: Belgium
Contact:

positioning the console ?

Post by bernardfrancois »

Hello,

Is it possible to place the console window at a certain screen position? Maybe with an API command?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: positioning the console ?

Post 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
bernardfrancois
User
User
Posts: 47
Joined: Tue Sep 02, 2003 9:17 am
Location: Belgium
Contact:

Post by bernardfrancois »

is it also possible to set it's size?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> is it also possible to set it's size?

Not that I know of... maybe someone else knows.
legider_pb
User
User
Posts: 39
Joined: Tue Nov 25, 2003 12:28 pm

Post 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
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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
legider_pb
User
User
Posts: 39
Joined: Tue Nov 25, 2003 12:28 pm

Post 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.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> He only asked how to set the size. Was a broad question so i answered as such.

No problem. :)
bernardfrancois
User
User
Posts: 47
Joined: Tue Sep 02, 2003 9:17 am
Location: Belgium
Contact:

Post 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.
bernardfrancois
User
User
Posts: 47
Joined: Tue Sep 02, 2003 9:17 am
Location: Belgium
Contact:

Post by bernardfrancois »

crap I cant find it in the help: how do I get the windows desktop resolution?
Proteus
Enthusiast
Enthusiast
Posts: 113
Joined: Wed Sep 17, 2003 8:04 pm
Location: The Netherlands

Post by Proteus »

Here's how to get the resolution:

Code: Select all

Width = GetSystemMetrics_(#SM_CXSCREEN)
Height= GetSystemMetrics_(#SM_CYSCREEN)
P4 2.4GHz, 256 MB, WinXP Pro, onboard video&audio.
The Programmer's Drinking Song:
"99 little bugs in the code,
99 little bugs.
Fix one bug, recompile
100 little bugs in the code."
bernardfrancois
User
User
Posts: 47
Joined: Tue Sep 02, 2003 9:17 am
Location: Belgium
Contact:

Post by bernardfrancois »

thanks!
Post Reply