ScreenRes - more info needed [SOLVED]

New to FreeBASIC? Post your questions here.
Trinity
Posts: 214
Joined: Sep 16, 2017 17:07

ScreenRes - more info needed [SOLVED]

Postby Trinity » Sep 25, 2017 14:29

Hello ,
Thanks to a line of code kindly given to me by forum user "dodicat" , this line : screenres W,H,,, &h08 '&h08 is no frame (see fbgfx.bi in the inc folder)
I got spurred into checking up and try to to learn more about ScreenRes .
So I played around a little with a few lines of code , read some manual and also in the end also peeked into the fbgfx.bi in the inc folder of FreeBasic on my harddrive.

So I have two questions in that connection , first question :

This code will create a frame less window

Code: Select all

dim as integer W,H
screeninfo W,H
screenres W-200,H-200,,, &h08 
Sleep


So my question would be is there anyway to control where on my screen that the window is generated ? The window is generated centered mid-screen on my "monitor" and question is if I can move the point of generation of the generated Window up,down,right and left ?

------------------------------------------------

Second question :

This code compiles without problems :

Code: Select all

dim as integer W,H
screeninfo W,H 
screenres W,H,,, &h08 

but if I change the &h08 with GFX_NO_FRAME then not only do I have to #include "fbgfx.bi" but state a Using FB :

Code: Select all

#include "fbgfx.bi"
Using FB
dim as integer W,H
screeninfo W,H 
screenres W,H,,, GFX_NO_FRAME 

So let me see if I got it right (?) : The GFX_NO_FRAME is defined in the FB 'namespace and then because the GFX_NO_FRAME is used then compiler have to fetch info from the fbgfx.bi ?
Further more , from studying the manual section for ScreenRes then I have seen that the &h08 must be a flag that is referred to by flag name GFX_NO_FRAME , which makes me think that the &h08 must be some internal reference or something for compiler since it do not require any include or namespace reference (?)

So then my question is : But then where are the list of other stuff like &h08 and the proper description (I mean apart from what is listed in and related to the fbgfx.bi ) ???
Last edited by Trinity on Sep 25, 2017 15:28, edited 1 time in total.
vdecampo
Posts: 2979
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Re: ScreenRes - more info needed

Postby vdecampo » Sep 25, 2017 15:02

Check out the ScreenControl function.

-Vince
MrSwiss
Posts: 2105
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: ScreenRes - more info needed

Postby MrSwiss » Sep 25, 2017 15:09

@Trinity,

namespaces usage (not only screen related, general ...)
requires to either:
Using "Namespace Identifier" (one word no double quotes)
or:
prepend "Namespace Identifier".GFX_NO_FRAME --- in this case:
FB.GFX_NO_FRAME (using ... --- not needed in this case)

Second point (Window centered), is default behaviour.
AFAIK, it can only be changed by digging into "Windows API" (might be wrong, on that one).
Or, check out Vince's suggestion ... (I'm not really familiar with it)
Trinity
Posts: 214
Joined: Sep 16, 2017 17:07

Re: ScreenRes - more info needed

Postby Trinity » Sep 25, 2017 15:27

vdecampo wrote:Check out the ScreenControl function.

-Vince

Thank you very much Vince / vdecampo , very kind of you :-)
And I am sorry that I did not read enough in the manual , it's just when I read that reference to the section said something about "Select driver and more " then I thought that it were something completely un-related.
With your help here this problem were solved so easy , thanks again :-)

Code to play with :

Code: Select all

#include "fbgfx.bi"
Using FB ' namespace
dim as integer W,H
screeninfo W,H
screenres W-200,H-200,,, &h08 
Sleep
ScreenControl SET_WINDOW_POS, 0, 0
Sleep
Last edited by Trinity on Sep 25, 2017 15:29, edited 1 time in total.
Trinity
Posts: 214
Joined: Sep 16, 2017 17:07

Re: ScreenRes - more info needed

Postby Trinity » Sep 25, 2017 15:27

MrSwiss wrote:@Trinity,
namespaces usage

@ MrSwiss , those explanations I will have to ponder on but thank you :-)
MrSwiss wrote:Second point (Window centered), is default behaviour.
AFAIK, it can only be changed by digging into "Windows API" (might be wrong, on that one).
Or, check out Vince's suggestion ... (I'm not really familiar with it)

@ MrSwiss
You learn something today ;-) :
Use this code to play with (sometimes one learns from people innocently asking "stupid questions" ;-) :-D ) :

Code: Select all

#include "fbgfx.bi"
Using FB ' namespace
dim as integer W,H
screeninfo W,H
screenres W-200,H-200,,, &h08 
Sleep
ScreenControl SET_WINDOW_POS, 0, 0
Sleep 
Last edited by Trinity on Sep 25, 2017 15:41, edited 1 time in total.
Trinity
Posts: 214
Joined: Sep 16, 2017 17:07

Re: ScreenRes - more info needed

Postby Trinity » Sep 25, 2017 15:28

[SOLVED]
Thanks to all who generously helps and have helped :-)
MrSwiss
Posts: 2105
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: ScreenRes - more info needed [SOLVED]

Postby MrSwiss » Sep 25, 2017 15:38

Code: Select all

screenres W-200,H-200,,, &h08  ' your code
screenres W-200,H-200,,, FB.GFX_NO_FRAME  ' use namespace, without "Using"
But, since you have it in your code:

Code: Select all

screenres W-200,H-200,,, GFX_NO_FRAME  ' use of "included" namespace
Trinity
Posts: 214
Joined: Sep 16, 2017 17:07

Re: ScreenRes - more info needed [SOLVED]

Postby Trinity » Sep 25, 2017 15:45

MrSwiss wrote:

Code: Select all

screenres W-200,H-200,,, &h08  ' your code
screenres W-200,H-200,,, FB.GFX_NO_FRAME  ' use namespace, without "Using"
But, since you have it in your code:

Code: Select all

screenres W-200,H-200,,, GFX_NO_FRAME  ' use of "included" namespace

Oh! , now I get it - I was a little dense there :-D
Thank you :-)
fxm
Posts: 7477
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: ScreenRes - more info needed [SOLVED]

Postby fxm » Sep 25, 2017 16:36

You can also call ScreenControl before calling ScreenRes so that the settings are immediately applied at graphics window creation.
Trinity
Posts: 214
Joined: Sep 16, 2017 17:07

Re: ScreenRes - more info needed [SOLVED]

Postby Trinity » Sep 25, 2017 16:42

fxm wrote:You can also call ScreenControl before calling ScreenRes so that the settings are immediately applied at graphics window creation.

Great , thank you , very cool :-)

B.t.w. , do you know where all the internal codes are documented (other than if one looks into .bi files) , ref. : &h08 ?
St_W
Posts: 1166
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: ScreenRes - more info needed [SOLVED]

Postby St_W » Sep 25, 2017 16:51

Trinity wrote:B.t.w. , do you know where all the internal codes are documented (other than if one looks into .bi files) , ref. : &h08 ?
The internal values are usually not documented as they should not be used. It is considered bad practice to use constant values directly instead of the according constant name, because it makes code harder to read and understand. Rather use the constant names listed in the wiki e.g. for Screen/Screenres: https://freebasic.net/wiki/wikka.php?wa ... gScreenres
If you're wondering about the &h prefix, that is just denoting the number being in hexadecimal format. &h8 just equals 8 in decimal format (and you could also use that). See https://freebasic.net/wiki/wikka.php?wa ... PgLiterals for number formats supported by FB as literals.
Trinity
Posts: 214
Joined: Sep 16, 2017 17:07

Re: ScreenRes - more info needed [SOLVED]

Postby Trinity » Sep 25, 2017 16:54

fxm wrote:You can also call ScreenControl before calling ScreenRes so that the settings are immediately applied at graphics window creation.


P.S.
Sorry I can not get it to work FXM ? , How do you use ScreenControl before ScreenRes as you say ?

This works fine (ScreenREs first )(Window is positioned at 0, 0 using ScreenControl after creation when made smaller ;

Code: Select all

#include "fbgfx.bi"
dim as integer W,H
screeninfo W,H 
screenres W,H,,, &h08 
screenres W,H,,, &h08 : ScreenControl FB.SET_WINDOW_POS, 0, 0
Sleep
screenres W-200,H-200,,, &h08 : ScreenControl FB.SET_WINDOW_POS, 0, 0
Sleep

This do not work (ScreenControl first)(Window is not positioned at 0, 0 at creation when made smaller) :

Code: Select all

#include "fbgfx.bi"
dim as integer W,H
screeninfo W,H 
screenres W,H,,, &h08 
ScreenControl FB.SET_WINDOW_POS, 0, 0 : screenres W,H,,, &h08
Sleep
ScreenControl FB.SET_WINDOW_POS, 0, 0 : screenres W-200,H-200,,, &h08
Sleep


I mean , I totally understand if one have to make screen page swaps , which I have already read about though not started to use , but that is to me another ball game (+a can of worms) ;-) And that's not how I interpreted your statement .
Last edited by Trinity on Sep 25, 2017 17:08, edited 3 times in total.
Trinity
Posts: 214
Joined: Sep 16, 2017 17:07

Re: ScreenRes - more info needed [SOLVED]

Postby Trinity » Sep 25, 2017 16:56

St_W wrote:The internal values are usually not documented as they should not be used.

OK , thank you :-)
fxm
Posts: 7477
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: ScreenRes - more info needed [SOLVED]

Postby fxm » Sep 25, 2017 17:47

Trinity wrote:
fxm wrote:You can also call ScreenControl before calling ScreenRes so that the settings are immediately applied at graphics window creation.


P.S.
Sorry I can not get it to work FXM ? , How do you use ScreenControl before ScreenRes as you say ?

Yes, you are right, that does not work.
Some operations are not allowed while a graphics mode has not yet been set.
(see ScreenControl page where all this is well detailed)
Trinity
Posts: 214
Joined: Sep 16, 2017 17:07

Re: ScreenRes - more info needed [SOLVED]

Postby Trinity » Sep 25, 2017 18:16

fxm wrote:(see ScreenControl page where all this is well detailed)


Ah! , yes! , I see , one must *really* pay attention to the small detail when reading the manual (*) ;-)
But to get from this in manual : "Supported operations : "Note: * denotes operations that are allowed while a graphics mode has not yet been set via Screen (Graphics) or ScreenRes." To deduct that it influences the *next* Window (if I have understood you an manual correct) also takes a little getting to know the manual / the language I think. You could rightfully argue : What else ? , but still , one needs to learn to read inwards..
:-)

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 4 guests