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.

Newcomers DBPro Corner / How do you create a box with absolute coordinates inside a window?

Author
Message
Cassi
21
Years of Service
User Offline
Joined: 6th Sep 2003
Location:
Posted: 6th Sep 2003 16:19 Edited at: 6th Sep 2003 18:42
When I enter the following code a get a box inside a window which is what I want.



However, when I resize the window (an option that I want to keep) the box also changes size.

How do I keep the box the same size and the same position relative to the top left corner of the window?

Any ideas?
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 6th Sep 2003 18:43
If you're working on 640x480 and your monitor is not set to 640x480, when you resize the window to a new size then the window contents is resized too.

A solution would be to change the resolution of your app to something higher. However if anybody has a monitore with a resolution higher than that then they will be able to resize your app.

Theres no place like 127.0.0.1
There are 10 people in this world, those who understand binary and those who don't
Bus station = where bus stops. Train station = where train stops. Workstation = ?
Cassi
21
Years of Service
User Offline
Joined: 6th Sep 2003
Location:
Posted: 6th Sep 2003 18:47
My desktop is set to 1600 x 1200 and this is just a window ontop of the desktop.

I want to be able to resize the window (and can) but I also want the box to remain the same size and not resize with the window.
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 6th Sep 2003 22:33
You want the display resolution to change with the window size? That's virtually impossible, along with being slow and clunky... I suggest you just have options to change the display mode; 640x480,800x600, etc.

--Mouse: Famous (Avatarless) Fighting Furball
Read It: http://www.angryflower.com/itsits.gif
Learn It: http://www.angryflower.com/bobsqu.gif
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 6th Sep 2003 22:59
I want to be able to resize the window (and can) but I also want the box to remain the same size and not resize with the window.

Well that means that your screen size must change every time you resize, and it has already been mentioned this would be slow and clunky.

Theres no place like 127.0.0.1
There are 10 people in this world, those who understand binary and those who don't
Bus station = where bus stops. Train station = where train stops. Workstation = ?
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 7th Sep 2003 00:30
in other words DON'T BOTHER.
I had this same issue - it's not worth it

IMHO <---stresses
Good Luck

-RUST-
ifman1
21
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 7th Sep 2003 01:03 Edited at: 7th Sep 2003 01:26
Why not store your screen size in variables...like scrwidth and scrheight... and set your box up using it's own variables and put it all in a routine or function
for example:

rem This isn't actual code, so it might not work!
DO
gosub MAKEBOX
<all kinds of code>
LOOP


MAKEBOX:
rem get screen dimension
scrwidth = screen width()
scrheight = screen height()

rem set up the box variables, play with these to get the affect you want
boxxpos = scrheight/4
boxypos = scrwidth/4
boxwidth = boxypox + 50
boxheight = boxxpos + 50

rem Make the box
BOX boxxpos, boxypos, boxwidth, boxheight
return

I'll actually try it later and post some real code for you, but hey, there's the idea...


Sex Junky... Looking for a Dealer!
ifman1
21
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 7th Sep 2003 01:37
Well, maybe not, the screen commands return resolution, not window size.... my bad, sorry


Sex Junky... Looking for a Dealer!
Cassi
21
Years of Service
User Offline
Joined: 6th Sep 2003
Location:
Posted: 7th Sep 2003 04:43
OK, I think there is some confusion as to what I am asking here.
I do not care about screen resolution. I have no desire or intention to change my screen resolution. It is 1600x1200 and for the purpose of my current project that is how it will stay.

I do, however, have a window that I have created in DBP that is 640x480 I created this with SET WINDOW ON and SET WINDOW SIZE 640,480 now this window opens on my desktop just like the window that you are now viewing this forum in. And like this window it can have its size changed by clicking and draging the lower right corner.

All I am asking is; can I have a box inside the window that will stay (for example) 100x100 pixels in size and 50x50 pixels from the top left corner of the window?
Cassi
21
Years of Service
User Offline
Joined: 6th Sep 2003
Location:
Posted: 7th Sep 2003 04:56
A quick test and I have discovered that it is not just a box that is a problem.

I loaded an image and then pasted it into the window. When I drag the window to resize it my image also changes size. Not a very desirable result.

I know that what I am asking for must be possible because when I resize this window (the forum) my avatar doesn't warp. So is it something that I am doing wrong or is tit a problem with DBP?
andrew11
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 7th Sep 2003 04:58
I had the same problem. It's because no matter what the windows size is, DBP keeps anything inside 640x480, and streches the screen. One way I thought of fixing this was to render the camera to a image, get the window size, and scale a sprite so it looked the same. Unfortunately, it was too slow. The best option would probably be to limit the users ability to resize the window.

"All programmers are playwrites and all computers are lousy actors" -Anon
[img]Visit my site![/img]
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 7th Sep 2003 05:50 Edited at: 7th Sep 2003 20:57
You can do it but there are problems, you may need to reload everything back into video memory afterwards, see sprite in example.

I think this is mostly a directx issue rather than dbpro.

There is a bug with dbpro, using set display mode randomly changes the font.

See code.
andrew11
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 7th Sep 2003 05:51
No, not screen width, window width.

"All programmers are playwrites and all computers are lousy actors" -Anon
[img]Visit my site![/img]
ifman1
21
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 7th Sep 2003 19:21
How are you getting the window width? Is there a command I'm missing or are you using an external DLL?


Sex Junky... Looking for a Dealer!
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 7th Sep 2003 19:54 Edited at: 7th Sep 2003 19:54
Quote: "I know that what I am asking for must be possible because when I resize this window (the forum) my avatar doesn't warp. So is it something that I am doing wrong or is tit a problem with DBP?

All I am asking is; can I have a box inside the window that will stay (for example) 100x100 pixels in size and 50x50 pixels from the top left corner of the window? "


The reason is that when you resize IE the physical container space within the browser increases, from x pixels high / wide to y pixel high / wide.

However a DBP window is always x pixels high and wide, resizing doesn't make any difference. So you box will always be in the same place.

Pixels are not a physical unit, like cm or metres. They do not represent a fixed area on a screen.
You could have a pc set to 640x480 and one set to 1600 x 1200 and the sizes of the pixels on those two screens will be different.

In simpler terms, you can get a 14in monitor at 640x480 and it looks sharp.
You can get the same PC and give it an 18in monitor and a rectangle on the screen looks bigger, even though they are the same size.

Theres no place like 127.0.0.1
There are 10 people in this world, those who understand binary and those who don't
Bus station = where bus stops. Train station = where train stops. Workstation = ?
andrew11
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 7th Sep 2003 23:27 Edited at: 7th Sep 2003 23:36
Quote: "How are you getting the window width? Is there a command I'm missing or are you using an external DLL?"


Here's some example code. It uses user32.dll. The rest is just to seperate the data. Pretty simple.


Notice how the contents of the window are resized when the window is resized, as apposed to Internet Explorer, where the contents stay the same.

@David89
We know that already. You don't understand the question.

"All programmers are playwrites and all computers are lousy actors" -Anon
[img]Visit my site![/img]
Cassi
21
Years of Service
User Offline
Joined: 6th Sep 2003
Location:
Posted: 8th Sep 2003 00:58 Edited at: 8th Sep 2003 01:01
There seems to be a lot of confusion as to what the question is. So I will try again:



The code above is in its entirity there is no more code to it. It really is that simple! If you copy and paste it inot the DBP IDE it can be executed and you will get a window on the desktop with a box in it.

What I want to do is allow the window to be resized (which it can be) but I want the box to stay in exactly the same place (relative to the top left of the window) and exactly the same size regardless of the windows size.
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 8th Sep 2003 02:26 Edited at: 8th Sep 2003 02:35
Combined my code with the code from andrew11 and it works.

You may have problems with using set display mode. The font might change and you will proberly have to load all your media again after it is used.

Edit: this code shows how you will need to reload/create media after the window is resized


See attached code.
andrew11
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 8th Sep 2003 04:19
Nice. I didn't think of set display mode. If it wasn't for those stupid bugs is would work.

"All programmers are playwrites and all computers are lousy actors" -Anon
[img]Visit my site![/img]
ifman1
21
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 8th Sep 2003 05:50 Edited at: 8th Sep 2003 05:51
So did this answer the original question? I'm not seeing the windowed mode here. You know, a window, with title bar and three little boxes in the top right corner?

Although I am learning a bit about memblocks, but I hate Windows programming, it's the whole reason I'm doing all my prototyping in DBPro.
andrew11
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 8th Sep 2003 06:48
You need to select windowed mode. In the Project Manager

"All programmers are playwrites and all computers are lousy actors" -Anon
[img]Visit my site![/img]
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Sep 2003 14:55
OK - so that works (sort of).
There is a blue screen everytime the window is moved or resized and it is very slow but it does work.
Is there a better way?

I'm sorry that I can't help you Cassi but it is something that I would like to be able to do aswell. So, if anyone can help please do.
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 11th Sep 2003 21:30
Quote: "What I want to do is allow the window to be resized (which it can be) but I want the box to stay in exactly the same place (relative to the top left of the window) and exactly the same size regardless of the windows size. "


Impossible without extra code as your box will never be the same size when the window is resized physically (ie. in terms of cm across / height), but in pixels it will be the same size. My post above explained that.

Code posted above from others should work.

c:/dos
c:/dos run
run dos run

Login to post a reply

Server time is: 2024-09-20 21:23:39
Your offset time is: 2024-09-20 21:23:39