Hooks and Callbacks - HTML2EXE Programming

Document Path: Home Page / Programming / HTML2EXE / Hooks & Callbacks  

Shell Tray Icon

Shell Tray Icon callback function protype:

function MyShellTrayCallback(button)
{
	//button=1: left mouse button down; 2=middle mouse button down; 3=right mouse button down
}

Each application can install only one icon on the system tray. To install:

window.external.Application.InstallShellTrayIcon(tip, iconResourceName, MyShellTrayCallback);
Hot Key

Hot key callback function protype:

function MyHotKey(vKey, altKey, ctlKey, shiftKey, winKey)
{
}

Example: How to register a hot key Alt+F12:

var hk=window.external.System.CreateHotKeyObject();
hk.Register(MyHotKey, 0x7b, true, false, false, false);
Message Hook

Message hook callback function protype:

function MyMessageHook(msgobj)
{
}

You can install Message Hooks at three different levels, but don't simply understand this as that a high-level hook covers all messages that a lower-level hook can get:

Popup Menu

The callback function for popup menu is optional. It is called when the user moves the mouse over the menu or leaves the menu. This give you a chance to update the status-text to give the user more information about the menu commands.

Popup menu callback function protype:

function OnMenuSelect(cmdID)
{
	//cmdID 0=mouse pointer not on the menu, -1=the menu is closed, other=command id the mouse pointer is on.
}
Frame Menu

The Frame Menu requires three callback functions:

Frame Menu callback function protypes:

//called when the user clicked the menu command
function OnExecuteMenuCommand(frameMenuObj, cmdID)
{
}
//called when the user is selecting menu command.
function OnMenuSelect(frameMenuObj, cmdID)
{
	//cmdID 0=mouse pointer not on the menu, -1=the menu is closed, other=command id the mouse pointer is on.
}
//called when the user begins to use the menu
function OnInitMenu(frameMenuObj)
{
	//enable/disable menu command items
}
Web Browser Events

Web Browser event callback function protype:

function MyWebEventHanlder(webevent)
{
}

Web Browser Events hook can be installed on two level:

SendMessageCallback

SendMessageCallback callback function protype:

function MyCallback(hwnd, message, lresult)
{
}
RegisterWindowMessage

SendMessageCallback callback function protype:

function MyCallback(hwnd, message, lresult)
{
}
TCP Server

The callback functions must be assigned to a module, instead to a function. In the moudle, the calback functions must be defined as showed by the protypes:

function OnConnectionAccepted(tcpServerObj, tcpClientObject)
{
}
TCP Client

The callback functions must be assigned to a module, instead to a function. In the moudle, the calback functions must be defined as showed by the protypes:

function OnConnected(tcpClientObject)
{
}


function OnConnectFailed(tcpClientObject)
{
}

function OnPeerDisconnected(tcpClientObject)
{
}

function OnDataReceived(tcpClientObject)
{
}


function OnDataSent(tcpClientObject)
{
}

function OnIdle(tcpClientObject)
{
}
UDP

The callback functions must be assigned to a module, instead to a function. In the moudle, the calback functions must be defined as showed by the protypes:

function OnDataReceived(udpObject, ip_b1, ip_b2, ib_b3, ib_b4, port, buffer)
{
}
Download

Download callback function protype:

function MyCallback(progrress, total)
{
	//return false to cancel the job
}

Download is a method of window.external.Application.Internet

HTTPRequest

HTTPRequest callback function protype:

function MyCallback(textInfo, progrress, total)
{
	//return false to cancel the job
}

HTTPRequest is a method of window.external.Application.Internet

ZIP Reader

ZIP Writer callback function protype:

function ProgressCallback(entryName, entryIndex, totalEntries, entryProgress, entrySize)
{
//return value: 1: continue to decompress; 0: skip this entry; -1: abort the process
}
ZIP Writer

ZIP Writer callback function protype:

function ProgressCallback(filePathName, entryName, fileAttributes, progress, total)
{
//return value: 1: continue to decompress; 0: skip this file or folder; -1: abort the process
}
GZIP Reader

ZIP Writer callback function protype:

function ProgressCallback(infoText, progress, total)
{
//return value: <=0 abort the process; >0: continue
}
GZIP Writer

ZIP Writer callback function protype:

function ProgressCallback(infoText, progress, total)
{
//return value: <=0 abort the process; >0: continue
}