Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How can I find the programs window size

Author
Message
Shard Lights
18
Years of Service
User Offline
Joined: 30th Oct 2007
Location: Out on the wires
Posted: 14th May 2010 14:12
Hi everyone,

I am attempting to find the size of the programs window. This is so I can recalculate the size of any objects held within it should the user re-size it.

I have searched both the forums and the help files in an attempt to get a solution to this, and even just bought the Enhancements expansion pack in the mistaken belief it would address this issue(it doesn't so I have just wasted £19.96 )

Any help would be greatly appreciated.
Shard Lights
18
Years of Service
User Offline
Joined: 30th Oct 2007
Location: Out on the wires
Posted: 14th May 2010 16:07
Sorted - I found the appropriate commands in IanM's superb Matrix1Util collection. This stuff is a real gold mine so for anyone who doesn't know about it, it is really worth checking it out here.
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 14th May 2010 17:20
Just watch over screen width() and screen height()?

Where there is a will, there is a way.
I often edit my posts, that`s who i am
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 14th May 2010 22:55
...or Desktop Width() and Desktop Height(), if you meant the monitor's current display size...

As great as IanM's plugin is you don't need it for this.

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 16th May 2010 14:39
they return the resolution not the actual size?

Rawwrr. Sig Fail.
Newcastle is awesome
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th May 2010 18:58
Quote: "they return the resolution not the actual size?"

True but I've yet to see the command that returns whether you're using a 17inch or 19inch screen...

Shard Lights
18
Years of Service
User Offline
Joined: 30th Oct 2007
Location: Out on the wires
Posted: 16th May 2010 21:02
The standard DBP commands do not provide an update after the window has been resized. i.e., if I have a 1024 x 768 window and then resize it, then "SCREEN WIDTH()" still returns 1024 x 768 irrespective of the real size whereas "GET WINDOW CLIENT WIDTH()" returns the new size correctly.

However, what neither command does is provide the information as the window is actually being updated, which is a bit of a pain as one only gets the new size once the user has completed the operation.

What would be really nice would be an option to stop DBP scaling things at all, as this is what I am really fighting against here.

Oh well, on with the battle.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 17th May 2010 10:42
I see your problem. If you reset the display size to match the window size you'll loose all your D3D data including loaded objects...

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 17th May 2010 10:45
Quote: "What would be really nice would be an option to stop DBP scaling things at all, as this is what I am really fighting against here. "


Just include this statement in you main loop...

Bam! You can resize the window and the object will all have the correct aspect ratio.

My signature is NOT a moderator plaything! Stop changing it!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 17th May 2010 10:56
Nice, I'll add that into my editor...

Why do you add "0.0" to each value? Why not just write it like this?:


Shard Lights
18
Years of Service
User Offline
Joined: 30th Oct 2007
Location: Out on the wires
Posted: 17th May 2010 12:58
Thanks for all your help guys, I really appreciate it.

The 'set camera aspect' command is certainly one that I will remember for future, but unfortunately it is not really what I want in this case. I think that I had better clarify;

I am looking a coding a layout application. For this, I want to show a background representing (say) an actual sized piece of A4 or letter with a coloured surround. Should the user re-size the window, I want the A4 image to remain the same size (i.e. the image would be clipped or the surround made bigger)rather than scaled.

What I would hope to do is to get the window information as it is being resized, so that I can recalc the image info to prevent it being scaled in any way.

I had intended to use sprites as the actual objects that would be dragged onto the background.

Anyway, what I am finding is;

a) The window size information is not updated by DBPro until after the operation has been completed.

b) While the operation is in progress, the client area of the screen turns blue, with the redraw not happening until the operation is complete.

c) There appears no way to find what the dpi settings are for the screen. (this would be required so that I could map the background image to an actual physical size).

It may be that what I am attempting to do cannot be done using DBPro, but I will continue trying for the moment.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 18th May 2010 16:01
Quote: "Why do you add 0.0 to each value? Why not just write it like this?:"

Integer division produces incorrect results. By adding the 0.0 to the width and height turns it into a float for correct divisions.

Quote: "It may be that what I am attempting to do cannot be done using DBPro"

Doesn't look that way as when you move the window, focus shifts to windows rather than to the application. (Or something) 3D objects will display correctly, but 2d will not.

My signature is NOT a moderator plaything! Stop changing it!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th May 2010 23:03
Quote: "Integer division produces incorrect results. By adding the 0.0 to the width and height turns it into a float for correct divisions."

I didn't realise you had to be so explicit for returns from functions, I just assumed they came back as floats naturally, my bad.

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 18th May 2010 23:04
Screen resolution is an integer, you can't have a screen set to 639.98 x 479.87 can you! lol

My signature is NOT a moderator plaything! Stop changing it!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th May 2010 23:09
Mine is 1397.6 pixels by 2365.4... so there... Ok maybe not but I thought by using division it would somehow make the conversion...

Login to post a reply

Server time is: 2026-07-25 23:10:38
Your offset time is: 2026-07-25 23:10:38