Using Images in Screen Programs
Using Images in Screen Programs
There are several ways that you can use images in
4C screen programs:
-
Use a screen field type of label or cmdbtn and specify
the image info data in the display fields.
The image type must be either Bitmap or Icon and you must specify the image
size in pixels.
The path should be relative to the FC_IMAGE directory on the server.
If the image does not exist on the client or the copy on the server
is more recent than the copy on the client, then the image will be copied
to the client before it is used.
The image will be stored permanently on the client machine.
This type of image is most useful when you want to use a bitmap
for a button rather than text.
You can change the image of the label or cmdbtn with:
sys.set_dfimage()
The label or cmdbtn size will not change even if the new image
is larger than the original image.
If you use sys.set_dfimage() to set many images, your
client image directory will get cluttered.
In this case one of the other methods that allows you to specify
how to manage the persistence of the image on the client will
work better.
The demo program, demo.image.1 has several images, both labels
and cmdbtns, defined in this way.
-
Use a screen field type of image and specify the image info data.
Image formats supported are Bitmap,
Icon, GIF, and JPEG.
The 4C client will figure out the image type when it displays the
image.
The image data that you can specify for an image screen field type is:
-
Image Path -
This can be a relative path from the FC_IMAGE directory on the server,
an absolute path on the server, or a url.
-
Persistence -
This specifies how the image persists on the client.
This can be either Permanent, Session, or Instance.
-
Background RGB -
The RGB for the background of the image window when the image window
is larger than the image.
-
MinWidth, MinHeight, PrefWidth, PrefHeight -
These are the dimensions to be used for the image window and
can be specified in Pixels, Points, Inches, or Millimeters.
-
FitImageToWindow -
If checked, then the image will stretch or shrink to fit the available space.
-
Scale Image -
If FitImageToWindow is checked and Scale Image is checked, then the image
will resize proportionately to best fit the display area.
-
ImageXPos, IMageYPos -
If FitImageToWindow is not checked,
then this means where the image is positioned in the image window
when the window is larger than the image.
The values can range from 0 - 100 with 0 meaning either top or left,
50 meaning center and 100 meaning either right or bottom.
ImageXPos and IMageYpos are also used when the image is scaled proportioanately.
In this case using ImageXPos=50 and ImageYPos=50 probably work best.
-
WindowXPos, WindowYPos -
If FitImageToWindow is not checked,
then this means where the image window is positioned over the image
when the image is larger than the image window.
The values can range from 0 - 100 with 0 meaning either top or left,
50 meaning center and 100 meaning either right or bottom.
You can change the path of the image with:
sys.set_dfimage()
demo.image.2 and demo.image.3 show some of the ways you can use the
image screen display field type.
You can easily see the difference when FitImageToWindow is checked and
when it is not.
You can also see how using a url for the path works.
Before you can use the image screen field type in your application
you need to make sure you have defined the image screen field
type in the sdft.fm program.
You can easily copy and paste it from the 4cSys application.
In order to use image screen field types, both 4csrvr and 4cclient
need minimum version 4.4.4.
-
Specify a background image for a panel.
Image formats supported are: Icon, Bitmap, GIF, and JPEG.
The image data you can specify for panel background images is:
-
Image Path -
This can be a relative path from the FC_IMAGE directory on the server,
an absolute path on the server, or a url.
-
Persistence -
This specifies how the image persists on the client.
This can be either Permanent, Session, or Instance.
-
FitImageToWindow -
If checked, then the image will stretch or shrink to fit the panel window.
-
Scale Image -
If FitImageToWindow is checked and Scale Image is checked, then the image
will resize proportionately to best fit the display area.
-
TileImage -
If checked, then the image will be tiled across the panel window.
-
ImageXPos, IMageYPos -
If neither FitImageToWindow nor TileImage is checked,
then this means where the image is positioned in the panel window
when the panel window is larger than the image.
The values can range from 0 - 100 with 0 meaning either top or left,
50 meaning center and 100 meaning either right or bottom.
ImageXPos and IMageYpos are also used when the image is scaled proportioanately.
In this case using ImageXPos=50 and ImageYPos=50 probably work best.
-
WindowXPos, WindowYPos -
If neither FitImageToWindow nor TileImage is checked,
then this means where the panel window is positioned over the image
when the image is larger than the panel window.
The values can range from 0 - 100 with 0 meaning either top or left,
50 meaning center and 100 meaning either right or bottom.
You can specify panel background image info using either
the panel definition development program or the
panel screen painter.
You can change the background image of the panel using:
sys.set_pnlimage()
demo.image.5 and demo.tile.1 show some of the ways you can use
background images in panels.
Misc Notes
-
Images that are used as part of the GUI interface of a 4C program
should be stored on the server in a directory relative to the FC_IMAGE
directory.
These images should also be defined as persisting permanently on the
client.
-
Images that are not part of the GUI interface,
but instead are data for the program, should be stored on the
server wherever it makes most sense for the application.
-
When using images that are not stored relative to the FC_IMAGE directory
on the client, you need to use a full path to image on the server when
using it.
-
Images that represent sensitive data should never persist permanently on the
client.
Use either Session or Instance persistence.
-
Images that are data for the application but are not sensitive data
can persist permanently or temporarily.
Choose what's best for your application.
-
Use Unix style paths for specifying the image path.
-
Images that are stored permanently on the client machine are stored
in a subdirectory of FC_COMAPPDATA/images.
Each server that you connect to will have it's own subdirectorr
for storing permanent images.
-
Images that are stored only for the duration of the client session or
only for a single instance are stored in a subdirectory of
FC_APPDATA unique per client session.
This session directory and all files in it is removed when the
4c client session ends.
Bugs and Misc Issues
-
Only the following panel types can have a background image:
-
ListView
-
HRowCol
-
VRowCol
-
Form
-
Grid
-
Single
-
Overlay
-
HSplitPane
-
VSplitPane
-
Currently, image info for image screen field types cannot be specified
using the Panel Screen Painter.
You must use the display fields development program.
-
The 4C Panel Screen painter does not currently display images.
For display fields they display as a label or cmdbtn.
For panel background images they are ignored.
-
Tiff images are not supported.
-
Layouts now allow background images and use most of the same options
that you can specify for panel background images.
Back to Top