ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Image control
  • Overview
  • Displaying an image file in an Image control
  • In a window
  • In a page
  • Retrieving the name of the image file displayed in the Image control
  • In a window
  • In a page
  • Retrieving the position of the mouse in a clickable image
  • Clearing or reinitializing the content of an Image control
  • Properties specific to Image controls
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Manipulating Image controls programmatically
Overview
WINDEV, WEBDEV and WINDEV Mobile allow you to manipulate an Image control programmatically. To do so, use the variable of the Image control in the code.
The variable of Image control corresponds to the name of Image control. This variable is a text variable.
Displaying an image file in an Image control
WINDEVAndroidAndroid Widget iPhone/iPadJava

In a window

To display an image file in an Image control, a simple assignment is sufficient.
For example:
  • direct assignment:
    IMG_MonImage = "C:\Temp\MonImage.gif"
  • assignment using a variable:
    CheminImage = fCurrentDir() + "\MonImage.gif"
    IMG_MonImage = CheminImage

    Note: An Image field can also be initialized from a buffer or Text variable containing the image value in binary.
Remark: if the field is associated with an item in a data file, assignment is automatically performed using the FileToScreen function.. For more details, see Linking an Image control to an item.
WEBDEV - Server code

In a page

To display an image file in an Image control, a simple assignment is sufficient.
If the image is available in the "<ProjectName>_WEB", directory, you have the ability to use the following syntaxes:
  • WEBDEV - Server code Server code:
    <Champ Image> = <Nom image>

    Note: In server code, if the image is available in a directory other than "<NomProjet>_WEB", it is necessary to:
    • specify the full path of image.
    • have read rights in this directory.
  • WEBDEV - Browser code Browser code:
    <Champ Image> = RépertoireWeb() + <Nom image>

    Remark: In the "Detail" tab of the Image field description window, you can define the type of browser code assignment for compatibility.. If this option corresponds to "Path in _WEB directory", FolderWeb has no effect. The following syntax can be used:
    <Champ image> = <Nom image>
    Remark: If the field is associated with an item in a data file, assignment is automatically performed using the FileToPage function.. For more details, see Linking an Image control to an item.
Retrieving the name of the image file displayed in the Image control
WINDEVAndroidAndroid Widget iPhone/iPadJava

In a window

To retrieve the name of the image displayed in an Image control:
  • perform a simple assignment. For example:
    SAI_ContenuActuelImage = IMG_Image1
  • retrieve part of the name, with fExtractPath. For example:
    NomFichierImage = fExtractPath(IMG_Image1, fFile + fExtension)
  • use the Value property
Remark: To retrieve the image (or its name) in the item associated with the Image field:
  1. If the control is associated with a text item, the entered value is automatically retrieved via ScreenToFile. You also have the ability to use the following notation: CUSTOMER.NAME = EDT_Edit1.
  2. If the control is associated with a binary memo, use HLinkMemo to associate the image file with the item.
  3. If the Image control was assigned from a buffer variable or from a string variable, Value returns an empty string.
    For more details, see Linking an Image control to an item.
WEBDEV - Server code

In a page

To retrieve the name of the image displayed in an Image control:
  • perform a simple assignment. For example:
    SAI_ContenuActuelImage = IMG_Image1
  • use the Value property.
  • use the Caption property (server code only).
WEBDEV - Server code In server code, these syntaxes are used to get the name of the image defined in the "General" tab of the control. Example: ./background.gif
WEBDEV - Browser code In browser code, these syntaxes are used to retrieve the full image name on the server.
Example: http://localhost/addressbook_Web/background_fr.gif
Note: To retrieve the image (or its name) in the item associated with the Image field,
  1. If the control is associated with a text item, the entered value is automatically retrieved via PageToFile. You also have the ability to use the following notation: CUSTOMER.NAME = EDT_Edit1.
  2. If the control is associated with a binary memo, use HLinkMemo to associate the image file with the item.
    For more details, see Linking an Image control to an item.
Retrieving the position of the mouse in a clickable image
WINDEVAndroidiPhone/iPadJava To retrieve the position of the mouse in a click area, the following functions must be used in the click code of the image:
MouseXPosReturns the horizontal coordinate of the mouse click.
MouseYPosReturns the vertical coordinate of the mouse click.
Clearing or reinitializing the content of an Image control
To clear or reinitialize an Image control, all you have to do is assign an empty string to the Image control. For example:
IMG_MonImage = ""

Note: You can also use the dStartDrawing/dEndDrawing functions on the Image field..
Properties specific to Image controls
WINDEVAndroidiPhone/iPadJava The following properties are specific to the programmed management of Image field characteristics.
AnimationGets the current status of the animated image or starts/stops the animation of an image (e.g., animated GIF).
HorizontalAlignmentGets and sets the horizontal alignment of the image caption.
ImageModeUsed to find out and modify the display mode of an image in an Image control.
InitialAnimationUsed to find out the initial status of the animation in an Image control.
VerticalAlignmentGets and sets the vertical alignment of the image caption.

For a complete list of WLanguage properties that can be used with Image controls, see Image control properties.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/20/2024

Send a report | Local help