Discussion:
Image Container Size
(too old to reply)
Charles
2008-09-20 19:41:23 UTC
Permalink
Is there a way to automatically resize an image container to the size of the computer monitor screen size?

On my opening form I have an image that serves as a background for the entire app. Due to the various sizes of monitors, the image usually only occupies part of the screen and looks unattactive. If possible, I would like the form and container size to change to fit the full screen size. The hard part is that some monitors are large and square shaped, and others rectangular. Also, visually I need keep the aspect stretch to keep the image shape from distorting.

Is any there possibility for this?

Charles
Ken Mayer [dBVIPS]
2008-09-21 01:22:58 UTC
Permalink
Post by Charles
Is there a way to automatically resize an image container to the size of the computer monitor screen size?
On my opening form I have an image that serves as a background for the entire app. Due to the various sizes of monitors, the image usually only occupies part of the screen and looks unattactive. If possible, I would like the form and container size to change to fit the full screen size. The hard part is that some monitors are large and square shaped, and others rectangular. Also, visually I need keep the aspect stretch to keep the image shape from distorting.
Is any there possibility for this?
Are you using a background form to hold the image? If so, maximize it.

form.windowState := 2 // maximize

Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Charles
2008-09-22 18:00:24 UTC
Permalink
Post by Ken Mayer [dBVIPS]
Post by Ken Mayer [dBVIPS]
Are you using a background form to hold the image? If so, maximize it.
form.windowState := 2 // maximize
Ken
Ken,

Yes, I am using a background form to hold the image. Is there another way to display an image without one?

If not, How do I match the image container size to the form size when the form is maximized? I tried Marilyns suggestion too, but the image container size remains the same without knowing the maximized form size to change it to.

Having the image container anchored to a maximized form and using Mervyns suggestion tells me the resolution size, but then to keep the aspect strech I may have to have the top of the image container at different levels depending on the monitor size. On my 800X1200 resolution laptop, to have the top of the image container at the top of the maximized form (and viewable area) I have to set the image.top to nearly -300, otherwise is sits at about 2 inches below the viewable top edge. I also had to increase the width to 1282 pixels wide to go all the way to the right edge.

Isn't there an easier way to automate this? I don't have access to all the different monitor resolution sizes for testing to be able to write the conditional statements required to compensate for the various screen resolutions.

Charles
Ken Mayer [dBVIPS]
2008-09-23 01:42:07 UTC
Permalink
Post by Charles
Post by Ken Mayer [dBVIPS]
Post by Ken Mayer [dBVIPS]
Are you using a background form to hold the image? If so, maximize it.
form.windowState := 2 // maximize
Ken
Ken,
Yes, I am using a background form to hold the image. Is there another way to display an image without one?
If not, How do I match the image container size to the form size when the form is maximized? I tried Marilyns suggestion too, but the image container size remains the same without knowing the maximized form size to change it to.
Set the image control's ANCHOR property to 6 - Container.

Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Mervyn Bick
2008-09-24 08:28:43 UTC
Permalink
Post by Charles
Having the image container anchored to a maximized form and using
Mervyns suggestion tells me the resolution size, but then to keep the
aspect strech I may have to have the top of the image container at
different levels depending on the monitor size. On my 800X1200
resolution laptop, to have the top of the image container at the top of
the maximized form (and viewable area) I have to set the image.top to
nearly -300, otherwise is sits at about 2 inches below the viewable top
edge. I also had to increase the width to 1282 pixels wide to go all
the way to the right edge.
Isn't there an easier way to automate this? I don't have access to all
the different monitor resolution sizes for testing to be able to write
the conditional statements required to compensate for the various screen
resolutions.
Have you considered having two images, one cropped to 4:3 for "old
fashioned" monitors and one cropped to 16:10 (it may be 16:9 wich is valid
for TV sets but I believe monitors are 16:10) for the newer wide
monitors? A simple test on opening your form will determine which image
to use and the top left will always be 0,0.

The nomadic Spaniard, Emilio VilarĂ³, who can be found in these newsgroups
when he isn't galavanting round the world taking photographs and
distributing dBase <g>, uses something similar in his EVILfoto program.
If the program detects a wide monitor it immediately opens a palette,
which is normally accessed from a menu item, next to the main form which
is always held to 4:3 ratio. I don't have a wide monitor (yet! <g>) so I
haven't tried this but I imagine the palette can be closed if one wanted
to to use the space for something else. The palette is, after all, always
available from the menu. (On a 4:3 monitor the palette overlays the main
screen when it is needed.)

http://www.evilfoto.es A new version has just been published. (Emilio,
we've got to talk about commission. <G> )


Mervyn
Charles
2008-09-24 22:09:21 UTC
Permalink
Post by Mervyn Bick
Post by Charles
Having the image container anchored to a maximized form and using
Mervyns suggestion tells me the resolution size, but then to keep the
aspect strech I may have to have the top of the image container at
different levels depending on the monitor size. On my 800X1200
resolution laptop, to have the top of the image container at the top of
the maximized form (and viewable area) I have to set the image.top to
nearly -300, otherwise is sits at about 2 inches below the viewable top
edge. I also had to increase the width to 1282 pixels wide to go all
the way to the right edge.
Isn't there an easier way to automate this? I don't have access to all
the different monitor resolution sizes for testing to be able to write
the conditional statements required to compensate for the various screen
resolutions.
Have you considered having two images, one cropped to 4:3 for "old
fashioned" monitors and one cropped to 16:10 (it may be 16:9 wich is valid
for TV sets but I believe monitors are 16:10) for the newer wide
monitors? A simple test on opening your form will determine which image
to use and the top left will always be 0,0.
The nomadic Spaniard, Emilio VilarĂ³, who can be found in these newsgroups
when he isn't galavanting round the world taking photographs and
distributing dBase <g>, uses something similar in his EVILfoto program.
If the program detects a wide monitor it immediately opens a palette,
which is normally accessed from a menu item, next to the main form which
is always held to 4:3 ratio. I don't have a wide monitor (yet! <g>) so I
haven't tried this but I imagine the palette can be closed if one wanted
to to use the space for something else. The palette is, after all, always
available from the menu. (On a 4:3 monitor the palette overlays the main
screen when it is needed.)
http://www.evilfoto.es A new version has just been published. (Emilio,
we've got to talk about commission. <G> )
Mervyn
Mervyn,

I'll have to try that.

Charles
evilaro
2008-09-25 03:57:22 UTC
Permalink
Post by Mervyn Bick
The nomadic Spaniard, Emilio VilarĂ³, who can be found in these newsgroups
I love that Mervyn:

Yes... a idea is to detect the ratio of the screen an put a image
accordingly.

4:3 at 16/10 reflex cameras have a ratio of 3:2= 1.5
so to get a 16/10 you would have to cropped a little.


Mervyn ... you can have a 100% commision ...

100% of 0 is 0 ;)


Emilio

Mervyn Bick
2008-09-21 07:18:57 UTC
Permalink
Post by Charles
Is there a way to automatically resize an image container to the size of
the computer monitor screen size?
On my opening form I have an image that serves as a background for the
entire app. Due to the various sizes of monitors, the image usually
only occupies part of the screen and looks unattactive. If possible, I
would like the form and container size to change to fit the full screen
size. The hard part is that some monitors are large and square shaped,
and others rectangular. Also, visually I need keep the aspect stretch
to keep the image shape from distorting.
Is any there possibility for this?
Charles
Sysinfo.cc, by Gary White, which is in sysinfo.zip in the dUFLP, will give
you the screen resolution. See example code below.


Mervyn

***** Start of example code ****
set procedure to sysinfo.cc additive
s = new sysInfo()
// inspect(s)
? s.screenres
***** Endo of example code *****
Marilyn Price
2008-09-21 16:02:59 UTC
Permalink
Post by Charles
Is there a way to automatically resize an image container to the
size of the computer monitor screen size?
The easiest way is to anchor the image container to the full form, then
maximize the form.
Post by Charles
On my opening form I have an image that serves as a background for
the entire app. Due to the various sizes of monitors, the image
usually only occupies part of the screen and looks unattactive.
If possible, I would like the form and container size to change to
fit the full screen size. The hard part is that some monitors are
large and square shaped, and others rectangular. Also, visually
I need keep the aspect stretch to keep the image shape from distorting.
Is any there possibility for this?
I would recommend sizing your image to fit the largest screen you may
encounter. The image container can always adjust the image smaller, but
it does a lousy job of enlarging it. So, consider starting with an
image that's about 1900 or whatever pixels wide to start with.
--
Marilyn Price
M. P. Data
Rich - AutoTraker Inc.
2008-09-22 22:01:24 UTC
Permalink
If you open the form normally then use maximize it in the onOpen, you can
use the form's onSize event to change the image size to the same as the form
size.
Doesn't this work for you?

function onOpen
form.windowState = 2 // Maximized
return

function form_onSize(nSizeType, nWidth, nHeight)
form.image1.top = 0
form.image1.left = 0
form.image1.width = nWidth
form.image1.height = nHeight
return


Or just set the image's anchor = 6 // Container. Then it will always be the
same size as the form. Of course you also have to keep image's alignment = 3
// Keep Aspect Stretch
Maybe I'm missing the problem
Rich...
Post by Charles
Is there a way to automatically resize an image container to the size of
the computer monitor screen size?
On my opening form I have an image that serves as a background for the
entire app. Due to the various sizes of monitors, the image usually only
occupies part of the screen and looks unattactive. If possible, I would
like the form and container size to change to fit the full screen size.
The hard part is that some monitors are large and square shaped, and
others rectangular. Also, visually I need keep the aspect stretch to keep
the image shape from distorting.
Is any there possibility for this?
Charles
Rich - AutoTraker Inc.
2008-09-23 21:37:26 UTC
Permalink
Ok got it...
form should be set for metric = 6 // Pixels
You know the size of the image...
? form.image1.imgPixelHeight
? form.image1.imgPixelWidth

Then you just need the size of the desktop and resize and position the image
accordingly.

#ifndef SM_CXSCREEN
#define SM_CXSCREEN 0 // Screen width in pixels
#endif
#ifndef SM_CYSCREEN
#define SM_CYSCREEN 1 // Screen height in pixels
#endif
if type('GetSystemMetrics') # 'FP'
extern CINT GetSystemMetrics(CINT) user32
endif

? GetSystemMetrics(SM_CYSCREEN)
? GetSystemMetrics(SM_CXSCREEN)

I don't have time right now to figure out the math but this should help.
Let me know how you make out...
Rich...
Post by Rich - AutoTraker Inc.
If you open the form normally then use maximize it in the onOpen, you can
use the form's onSize event to change the image size to the same as the form
size.
Doesn't this work for you?
function onOpen
form.windowState = 2 // Maximized
return
function form_onSize(nSizeType, nWidth, nHeight)
form.image1.top = 0
form.image1.left = 0
form.image1.width = nWidth
form.image1.height = nHeight
return
Rich,
No this doesn't work as written (see my work around below). It is the
image1.alignment.3 (Keep Aspect) property that keeps the image container
from filling the screen when the form is maximized. If I have the image
alignment property set at 0 (Stretch) then it works fine, but due to the
rectangular shape of my laptop, the image is distorted laterally. This
idea would work fine on a regular square(ish) monitor.
With the image property set at image1.alignment.3 (Keep Aspect) the top of
the image container anchors at the top of the form, and the image centers
in the maximized form. This prevents the image from expanding laterally
due to the Keep Aspect image property, and leaves a lot of empty space on
the sides of the image.
With image1.alignment still set at 3 (Keep Aspect), I managed to work with
the numbers as shown below to make it look good on my laptop. With
setting the top of the image container above the top edge of the form, the
image container is allowed to expand laterally enough to fill the
maximized form. I also had to adjust the image1.left property for
balancing the center of the image near the center of the maximized form,
and to remove the blank space at the left. The real test will be on a
clients monitor.
function form_onSize(nSizeType, nWidth, nHeight)
form.image1.top = - 150
form.image1.left = -100
form.image1.width = nWidth + 200
form.image1.height = nHeight +300
return
I suppose that if this was automated, the problem would then be that only
the center section of the image would be visible on the screen unless....
dBI programmed dBASE to allow for a click and drag positiioning of the
image in the container... :)
Thanks for all your help.
Charles
Charles
2008-09-23 17:19:09 UTC
Permalink
Post by Rich - AutoTraker Inc.
If you open the form normally then use maximize it in the onOpen, you can
use the form's onSize event to change the image size to the same as the form
size.
Doesn't this work for you?
function onOpen
form.windowState = 2 // Maximized
return
function form_onSize(nSizeType, nWidth, nHeight)
form.image1.top = 0
form.image1.left = 0
form.image1.width = nWidth
form.image1.height = nHeight
return
Rich,

No this doesn't work as written (see my work around below). It is the image1.alignment.3 (Keep Aspect) property that keeps the image container from filling the screen when the form is maximized. If I have the image alignment property set at 0 (Stretch) then it works fine, but due to the rectangular shape of my laptop, the image is distorted laterally. This idea would work fine on a regular square(ish) monitor.

With the image property set at image1.alignment.3 (Keep Aspect) the top of the image container anchors at the top of the form, and the image centers in the maximized form. This prevents the image from expanding laterally due to the Keep Aspect image property, and leaves a lot of empty space on the sides of the image.

With image1.alignment still set at 3 (Keep Aspect), I managed to work with the numbers as shown below to make it look good on my laptop. With setting the top of the image container above the top edge of the form, the image container is allowed to expand laterally enough to fill the maximized form. I also had to adjust the image1.left property for balancing the center of the image near the center of the maximized form, and to remove the blank space at the left. The real test will be on a clients monitor.

function form_onSize(nSizeType, nWidth, nHeight)
form.image1.top = - 150
form.image1.left = -100
form.image1.width = nWidth + 200
form.image1.height = nHeight +300
return

I suppose that if this was automated, the problem would then be that only the center section of the image would be visible on the screen unless.... dBI programmed dBASE to allow for a click and drag positiioning of the image in the container... :)

Thanks for all your help.

Charles
Loading...