[Implemented] ScreenWidth() and ScreenHeight()
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
[Implemented] ScreenWidth() and ScreenHeight()
Restored from previous forum. Originally posted by tinman.
In the sprite/screen library, for telling you the dimensions of a screen you have opened. No biggie, but it would save having global variables and repeated calculation code in a few places.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.30)
In the sprite/screen library, for telling you the dimensions of a screen you have opened. No biggie, but it would save having global variables and repeated calculation code in a few places.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.30)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by MrVainSCL.
Hi tinman
Have a look to old postings like:
viewtopic.php?t=371
In my opinion this commands are not really needed as basic keywords, because you can use the the very easy win api command for this!
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
Hi tinman
Have a look to old postings like:
viewtopic.php?t=371
In my opinion this commands are not really needed as basic keywords, because you can use the the very easy win api command for this!
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
Sure it's a smallish request and if there is a simple API alternative I'll go for that (but I don't know it - I am no Windows expert).
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.30)
I found that before I posted, and it's not what I asked for. I already use GetSystemMetrics_ for the desktop width, but what I was asking for was something to do this:In my opinion this commands are not really needed as basic keywords, because you can use the the very easy win api command for this!
Code: Select all
Procedure foo()
StartDrawing(ScreenOutput())
; Now I do not need lots of shared or global variables here
; Nor do I need to cut and paste the calculation code for the size (so there is no chance that I can forget to change it here if I change it in the openscreen call)
Line(0,0,ScreenWidth(),ScreenHeight())
StopDrawing()
EndProcedure
If OpenWindowedScreen(...) ; Includes some mad computation for sizes with loads of variables
foo()
EndIf
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.30)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fweil.
Hello tinman,
But when you code :
Result = OpenWindowedScreen(WindowID, x, y, Width, Height, AutoStretch, RightOffset, BottomOffset)
you still have Width and Heigth values in variables or constants. So why not use global
variables Width and Height or whatever you want ?
It is not necessary to make added functions for or I missed something ?
Rgrds
Francois Weil
14, rue Douer
F64100 Bayonne
Hello tinman,
But when you code :
Result = OpenWindowedScreen(WindowID, x, y, Width, Height, AutoStretch, RightOffset, BottomOffset)
you still have Width and Heigth values in variables or constants. So why not use global
variables Width and Height or whatever you want ?
It is not necessary to make added functions for or I missed something ?
Rgrds
Francois Weil
14, rue Douer
F64100 Bayonne
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
I know it's not much and that arrays are global anyway, but it could have been worse and would keep the functions "cleaner" and would mean I could not forget to change one of the sub-functions if I change the OpenWindowScreen command.
In fact, this very minute I found a mistake in one of the other lines with that code in it. I'm amazed it still worked
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.30)
My code looks like this:Originally posted by fweil
Result = OpenWindowedScreen(WindowID, x, y, Width, Height, AutoStretch, RightOffset, BottomOffset)
you still have Width and Heigth values in variables or constants. So why not use global
variables Width and Height or whatever you want ?
Code: Select all
If OpenWindowedScreen(WindowID(#WINDOW_PREVIEW), gadgets_preview(1)\li_XPos, gadgets_preview(1)\li_YPos, gadgets_preview(1)\li_Width, gadgets_preview(1)\li_Height, 0, WindowWidth()-(gadgets_preview(1)\li_XPos+gadgets_preview(1)\li_Width), WindowHeight()-(gadgets_preview(1)\li_YPos+gadgets_preview(1)\li_Height))
In fact, this very minute I found a mistake in one of the other lines with that code in it. I'm amazed it still worked

--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.30)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
> I already use GetSystemMetrics_ for the desktop width
I thought GetSystemMetrics returned the value of the current screen,
not the Desktop. (Usually, the Desktop *is* the current screen).
Can anyone confirm this?
PB - Registered PureBasic Coder
> I already use GetSystemMetrics_ for the desktop width
I thought GetSystemMetrics returned the value of the current screen,
not the Desktop. (Usually, the Desktop *is* the current screen).
Can anyone confirm this?
PB - Registered PureBasic Coder
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
"System metrics are the dimensions (widths and heights) of Windows display elements"
"SM_CXFULLSCREEN, SM_CYFULLSCREEN Width and height of the client area for a full-screen window" (my emphasis)
It seems to be for very general set of sizes (and a full screen window is not the same as a full screen screen, since it depends on the current resolution).
The other problem is that I am using a windowed screen, and there is no way to specify a specific display item in GetSystemMetrics.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.30)
Some snips from the Windows API docs:Originally posted by PB
I thought GetSystemMetrics returned the value of the current screen,
not the Desktop. (Usually, the Desktop *is* the current screen).
Can anyone confirm this?
"System metrics are the dimensions (widths and heights) of Windows display elements"
"SM_CXFULLSCREEN, SM_CYFULLSCREEN Width and height of the client area for a full-screen window" (my emphasis)
It seems to be for very general set of sizes (and a full screen window is not the same as a full screen screen, since it depends on the current resolution).
The other problem is that I am using a windowed screen, and there is no way to specify a specific display item in GetSystemMetrics.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.30)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
Just write a small procedure for now.
Still looks like a weird coding style, IMO.. 
cya,
...Danilo
(registered PureBasic user)
Code: Select all
> My code looks like this:> If OpenWindowedScreen(WindowID(#WINDOW_PREVIEW), gadgets_preview(1)\li_XPos, gadgets_preview(1)\li_YPos, gadgets_preview(1)\li_Width, gadgets_preview(1)\li_Height, 0, WindowWidth()-(gadgets_preview(1)\li_XPos+gadgets_preview(1)\li_Width), WindowHeight()-(gadgets_preview(1)\li_YPos+gadgets_preview(1)\li_Height))
Code: Select all
;
; remove the "a" argument if you always
; use gadgets_preview(1)\...
;
Procedure ScreenWidth(a)
ProcedureReturn gadgets_preview(a)\li_Width
EndProcedure
Procedure ScreenHeight(a)
ProcedureReturn gadgets_preview(a)\li_Height
EndProcedure
Procedure ScreenXPos(a)
ProcedureReturn gadgets_preview(a)\li_XPos
EndProcedure
Procedure ScreenYPos(a)
ProcedureReturn gadgets_preview(a)\li_YPos
EndProcedure
If OpenWindowedScreen(WindowID(#WINDOW_PREVIEW), ScreenXPos(1), ScreenYPos(1), ScreenWidth(1), ScreenHeight(1), 0, WindowWidth()-(ScreenXPos(1)+ScreenWidth(1)), WindowHeight()-(ScreenYPos(1)+ScreenHeight(1)))

cya,
...Danilo
(registered PureBasic user)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.30)
lol, thanks. I had never even thought of that (doh). It's not a weird coding style, it's "extreme" ;POriginally posted by Danilo
Still looks like a weird coding style, IMO..![]()
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.30)