TIcon

Source: source/classes/icon.prg

Inherits from: TControl

TIcon is a control for displaying Windows icons (.ico) from files or program resources. It supports click actions, dynamic icon switching, border display, and proper resource cleanup. TIcon is commonly used for toolbar indicators, status icons, and decorative elements in windows and dialogs.

Key DATA Members

DATATypeDescription
hIconNumeric (Handle)Windows icon handle (HICON)
cIcoFileCharacterPath to the .ico file
cResNameCharacterName of the icon resource in the executable

Methods

MethodDescription
New( nRow, nCol, cRes, cFile, lBorder, bClick, oWnd )Create an icon control. Provide either cRes (resource name) or cFile (.ico file path).
ReDefine( nId, cRes, cFile, bClick, lUpdate, oDlg )Redefine from a dialog resource template
SetName( cResName )Switch to a different icon resource by name. Destroys the old icon handle.
SetFile( cIcoFile )Switch to a different .ico file. Destroys the old icon handle.
End()Destroy the icon handle and call the superclass End()

ICON Command

@ nRow, nCol ICON oIcon OF oWnd FILE cFile

Example

#include "FiveWin.ch"

function Main()

   local oWnd, oIcon

   DEFINE WINDOW oWnd TITLE "Icon Demo" SIZE 300, 200

   // Display an icon from a file
   @ 10, 10 ICON oIcon OF oWnd FILE "myapp.ico"

   // Make the icon clickable
   oIcon:bLClicked := {|| MsgInfo( "Icon clicked!" ) }

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

See Also