- Displaying an image file in an Image control
- In a window
- Retrieving the name of the image file displayed in the Image control
- In a window
- Retrieving the position of the mouse in a clickable image
- Clearing or reinitializing the content of an Image control
- Properties specific to Image controls
Handling an Image control through programming
WINDEV, WEBDEV and WINDEV Mobile allow you to handle an Image control through programming. 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
In a window
To display an image file in an Image control, a simple assignment is sufficient.
- direct assignment:
IMG_MyImage = "C:\Temp\MyImage.gif"
- assignment by variable:
ImagePath = fCurrentDir() + "\MyImage.gif"
IMG_MyImage = ImagePath
Remark: An Image control can also be initialized from a buffer variable or from a text variable containing the image value in binary format.
Retrieving the name of the image file displayed in the Image control
In a window
To retrieve the name of the image displayed in an Image control:
- perform a simple assignment. For example:
EDT_CurrentImageContent = IMG_Image1
- retrieve part of the name, with fExtractPath. For example:
NameImageFile = fExtractPath(IMG_Image1, fFile + fExtension)
- use the Value property
Remark: To retrieve the image (or its name) in the item associated with the Image control:
- 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.
- If the control is associated with a binary memo, use HLinkMemo to associate the image file with the item.
- 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.
Retrieving the position of the mouse in a clickable image
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:
Properties specific to Image controls
The following properties are used to manage the characteristics of an Image control by programming.
|Animation||Gets the current status of the animated image or starts/stops the animation of an image (e.g., animated GIF).|
|HorizontalAlignment||Gets and sets the horizontal alignment of the image caption.|
|ImageMode||Used to find out and modify the display mode of an image in an Image control.|
|InitialAnimation||Used to find out the initial status of the animation in an Image control.|
|VerticalAlignment||Gets and sets the vertical alignment of the image caption.|
For a complete list of WLanguage properties that can be used with an Image control, see Properties associated with an Image control
This page is also available for…