{ =============================================================================
  Copyright 1995 by Potomac Software, Inc. Use of this material is subject to
  the terms and conditions of the software license agreement.
       
  WEBLIBDP.PAS: Contains Delphi declarations for WebLib (TM).         
  ============================================================================== }
  
unit Weblib;

{ ========== INTERFACE ========== }

interface
	uses WinTypes;

{ ========== Flags that may be passed to API functions ========== }

{ Flags for ConnectBrowser }
const 
	WL_STARTBROWSER	= $1;                  	{ start browser if not running }
	WL_SENDMESSAGE = $2;         			{ notify caller via SendMessage }
	WL_POSTMESSAGE = $4;					{ notify caller via PostMessage }

{ Flags for ListWindows }
const
	WL_FIRSTWINDOW = True;					{ get first window }
	WL_NEXTWINDOW = False;					{ get next window (if any) }

{ Flags for GetWindowInfo, ActivateWindow and OpenURL }
const
	WL_ACTIVEWINDOW	= $FFFFFFFF;			{ operate on active window }
	WL_LASTACTIVEWINDOW = $FFFFFFFF; 		{ activate last active window }
	WL_NEWWINDOW = $0;						{ create new window for URL }

{ Flags for SetWindowPos }
const
	WL_NOCHANGE	= $FFFFFFFF;				{ do not change x, y, width, height }

{ Flags for ShowWindow }
const
	WL_MINIMIZE	= $1;						{ minimize window }
	WL_MAXIMIZE = $2;                    	{ maximize window }
	WL_NORMAL = $3;                   		{ restore window to normal size }

{ Flags for OpenURL, values must conform to DDE API }
const
	WL_NODOCUMENTCACHE = $1;				{ ignore browser's doc cache }
	WL_NOIMAGECACHE	= $2;					{ ignore browser's image cache }
	WL_BACKGROUNDMODE = $4;					{ operate in background mode }

{ Flags that may be passed instead of notification window handle }
const
	WL_DEFAULTNOTIFY = -1;					{ use default from SetDefaultNotify }
	WL_NONOTIFY	= 0;         				{ do not send notification message }

{ Flags for UnRegisterURLEcho and others }
const
	WL_UNREGISTERALL = 0;					{ unregister all windows }

{ Flags for RegisterViewer, values must conform to DDE API }
const
	WL_SHELLEXECUTE	= $1;					{ launch viewer using ShellExecute }
	WL_QUERYVIEWER = $2;					{ send event to query filename }
	WL_VIEWDOCFILE = $4;					{ send event to view filename }

{ Flags for AddToolbarButton }
const
	WL_BITMAPHANDLES = 0;					{ passing bitmaps, not resource IDs }

{ Flags for SetToolbarText }
const
	WL_TOOLBARTEXT = -1;					{ set toolbar text, not button text }

{ Flags for SetToolbarFont }
const
	WL_TOOLBARFONT = $1;					{ set font for toolbar text }
	WL_BUTTONFONT = $2;						{ set font for button text }

{ Flags for SetToolbarTextColor }
const
	WL_TOOLBARTEXTCOLOR = $1;				{ set color for toolbar text }
	WL_BUTTONTEXTCOLOR = $2;				{ set color for button text }

{ ========== Notification events generated by API ========== }

const
	WLN_BEGINPROGRESS = $1;
	WLN_SETPROGRESSRANGE = $2;
	WLN_MAKINGPROGRESS = $3;
	WLN_ENDPROGRESS	= $4;
	WLN_FINISHED = $5;
	WLN_CANCELED = $6;
	WLN_URLECHO	= $7;
	WLN_OPENURL	= $8;
	WLN_CANCELTRX = $9;
	WLN_WINDOWCHANGE = $a;
	WLN_QUERYVIEWER	= $b;
	WLN_VIEWDOCFILE	= $c; 
	WLN_BUTTONCLICKED = $d;
	WLN_BROWSERSTART = $e;
	WLN_BROWSEREXIT	= $f;

{ ========== Flags for WindowChange notification event ========== }

const
	WLF_MOVESIZE = $1;
	WLF_MAXIMIZED = $2;
	WLF_NORMALIZED = $4;
	WLF_MINIMIZED = $8;
	WLF_CLOSED = $10;
	WLF_EXITING	= $10000;
	
{ ========== APIs for extracting values from lParam in notification messages ========== }

function WLNGetTransaction(lp: LongInt) : LongInt; far;
function WLNGetProgressString(lp: LongInt) : PChar; far;
function WLNGetProgressValue(lp: LongInt) : LongInt; far;
function WLNGetProgressMaximum(lp: LongInt) : LongInt; far;
function WLNGetWindow(lp: LongInt) : LongInt; far;
function WLNGetURL(lp: LongInt) : PChar; far;
function WLNGetMIMEType(lp: LongInt) : PChar; far;
function WLNGetReferrer(lp: LongInt) : PChar; far;
function WLNGetFlags(lp: LongInt) : LongInt; far;
function WLNGetSaveFile(lp: LongInt) : PChar; far;
function WLNGetFormData(lp: LongInt) : PChar; far;
function WLNGetX(lp: LongInt) : LongInt; far;
function WLNGetY(lp: LongInt) : LongInt; far;
function WLNGetWidth(lp: LongInt) : LongInt; far;
function WLNGetHeight(lp: LongInt) : LongInt; far;
function WLNGetFileName(lp: LongInt) : PChar; far;
function WLNGetButtonID(lp: LongInt) : Word; far;

{ ========== Pre-defined notification message, included for convenience ========== }

const
	WM_WEBLIB_NOTIFY = 2000;

{ ========== Handles returned by ConnectBrowser, CreateToolbar and AppendFormData ======== }
type
	HBROWSER = THandle;
	HTOOLBAR = THandle; 
	HFORMDATA = THandle; 

{ ========== Housekeeping functions ========== }

function WLStartup : Bool; far;
function WLCleanup : Bool; far;

function WLSetDefaultNotify(hwndNotify: HWnd; 
	nMsg: Word) : Bool; far;

{ ========== Browser API functions ========== }

function WLConnectBrowser(wOptions: Word) : HBROWSER; far;

function WLDisconnectBrowser(hBrowser: HBROWSER; 
	bExit: Bool) : Bool; far;

function WLGetWindowInfo(hBrowser: HBROWSER; 
	dwWindow: LongInt;
	lpszURL: PChar; 
	cbURL: Integer; 
	lpszTitle: PChar;
	cbTitle: Integer) : Bool; far;
	
function WLListWindows(hBrowser: HBROWSER; 
	bFirst: Bool) : LongInt; far;

function WLActivateWindow(hBrowser: HBROWSER; 
	dwWindow: LongInt) : LongInt; far;	
	
function WLCloseWindow(hBrowser: HBROWSER; 
	dwWindow: LongInt) : Bool; far;

function WLSetWindowPos(hBrowser: HBROWSER; 
	dwWindow: LongInt;
	dwX: LongInt;
	dwY: LongInt;
	dwWidth: LongInt;
	dwHeight: LongInt) : Bool; far;
	
function WLShowWindow(hBrowser: HBROWSER; 
	dwWindow: LongInt;
	nShow: Word) : Bool; far;

function WLShowFile(hBrowser: HBROWSER; 
	lpszFile: PChar;
	lpszMIMEType: PChar;
	dwWindow: LongInt;
	lpszURL: PChar;
	hwndNotify: HWnd;
	nMsg: Word) : LongInt; far;
	
function WLOpenURL(hBrowser: HBROWSER; 
	lpszURL: PChar;
	dwWindow: LongInt;
	wOptions: Word;
	hwndNotify: HWnd;
	nMsg: Word) : LongInt; far;
		
function WLSaveURL(hBrowser: HBROWSER; 
	lpszURL: PChar;
	lpszFile: PChar;
	dwWindow: LongInt;
	wOptions: Word;
	hwndNotify: HWnd;
	nMsg: Word) : LongInt; far;

function WLPostFormData(hBrowser: HBROWSER; 
	lpszURL: PChar;
	dwWindow: LongInt;
	lpszFormData: PChar;
	lpszMIMEType: PChar;
	hwndNotify: HWnd;
	nMsg: Word) : Longint; far;
		
function WLSaveFormData(hBrowser: HBROWSER; 
	lpszURL: PChar;
	lpszFile: PChar;
	dwWindow: LongInt;
	lpszFormData: PChar;
	lpszMIMEType: PChar;
	hwndNotify: HWnd;
	nMsg: Word) : LongInt; far;
		
function WLCancel(hBrowser: HBROWSER; 
	dwTransaction: LongInt) : Bool; far;
	
function WLRegisterProtocol(hBrowser: HBROWSER; 
	lpszProtocol: PChar;
	hwndNotify: HWnd;
	nMsg: Word) : Bool; far;
	
function WLUnregisterProtocol(hBrowser: HBROWSER; 
	lpszProtocol: PChar;
	hwndNotify: HWnd) : Bool; far;

function WLRegisterURLEcho(hBrowser: HBROWSER; 
	hwndNotify: HWnd;
	nMsg: Word) : Bool; far;

function WLUnregisterURLEcho(hBrowser: HBROWSER; 
	hwndNotify: HWnd) : Bool; far;

function WLRegisterViewer(hBrowser: HBROWSER; 
	lpszMIMEType: PChar;
	wOptions: Word;
	hwndNotify: HWnd;
	nMsg: Word) : Bool; far;
	
function WLUnregisterViewer(hBrowser: HBROWSER; 
	lpszMIMEType: PChar;
	hwndNotify: HWnd) : Bool; far;

function WLRegisterWindowChange(hBrowser: HBROWSER; 
	dwWindow: LongInt;
	hwndNotify: HWnd;
	nMsg: Word) : Bool; far;
	
function WLUnregisterWindowChange(hBrowser: HBROWSER; 
	dwWindow: LongInt;
	hwndNotify: HWnd) : Bool; far;

function WLParseAnchor(hBrowser: HBROWSER; 
	lpszAbsoluteURL: PChar;
	lpszRelativeURL: PChar) : PChar; far;
	
function WLGetVersion(hBrowser: HBROWSER; 
	wMajor: Word;
	wMinor: Word) : LongInt; far;

function WLQueryURLFile(hBrowser: HBROWSER; 
	lpszFile: PChar) : PChar; far;

function WLSetNotifyMethod(hBrowser: HBROWSER; 
	wMethod: Word) : Bool; far;
	
function WLGetTransactionWindow(hBrowser: HBROWSER; 
	dwTransaction: LongInt) : LongInt; far;

procedure WLNSetFileName(lParam: LongInt;
	lpszFileName: PChar); far;

{ ========== Toolbar API functions ========== }

function WLCreateToolbar(lpszMenu: PChar;
	hwndNotify: HWnd;
	nMsg: Word) : HTOOLBAR; far;
	
function WLDeleteToolbar(hToolbar: HTOOLBAR) : Bool; far;

function WLIsToolbarActive(hToolbar: HTOOLBAR): Bool; far;

function WLSetActiveToolbar(hToolbar: HTOOLBAR) : Bool; far;

function WLAddToolbarButton(hToolbar: HTOOLBAR;
	nID: Word;
	nIdx: Integer;
	lpszText: PChar;
	hInstance : THandle;
	lpszBitmap: PChar;
	lpszBitmapSel: PChar;
	lpszBitmapFocus: PChar;
	lpszBitmapDisabled: PChar) : Bool; far;
		
function WLRemoveToolbarButton(hToolbar: HTOOLBAR;
	nID: Word) : Bool; far;

function WLIsToolbarButtonVisible(hToolbar: HTOOLBAR;
	nID: Word) : Bool; far;

function WLShowToolbarButton(hToolbar: HTOOLBAR;
	nID: Word;
	bShow: Bool) : Bool; far;

function WLEnableToolbarButton(hToolbar: HTOOLBAR;
	nID: Word;
	bEnable: Bool) : Bool; far;

function WLIsToolbarButtonEnabled(hToolbar: HTOOLBAR;
	nID: Word) : Bool; far;

function WLGetToolbarText(hToolbar: HTOOLBAR;
	nID: Word) : PChar; far;

function WLSetToolbarText(hToolbar: HTOOLBAR;
	nID: Word;
	lpszText: PChar) : Bool; far;

function WLGetToolbarFont(hToolbar: HTOOLBAR;
	wType: Word) : HFont; far;

function WLSetToolbarFont(hToolbar: HTOOLBAR;
	wType: Word;
	hFont: HFont) : Bool; far;

function WLGetToolbarBkgnd(hToolbar: HTOOLBAR) : TColorRef; far;

function WLSetToolbarBkgnd(hToolbar: HTOOLBAR;
	crBackground: TColorRef) : Bool; far;

function WLGetToolbarTextColor(hToolbar: HTOOLBAR;
	wType: Word) : TColorRef; far;

function WLSetToolbarTextColor(hToolbar: HTOOLBAR;
	wType: Word;
	crText: TColorRef) : Bool; far;

{ ========== Utility functions for building form data buffer for posting to URL ======== }

function WLAppendFormData(hFormData: HFORMDATA;
	lpszName: PChar;
	lpszData: PChar;
	cbData: Word) : HFORMDATA; far;
	
function WLGetFormDataLength(hFormData: HFORMDATA) : Word; far;

function WLAccessFormData(hFormData: HFORMDATA;
	lpszRetBuf: PChar;
	cbRetBuf: Word) : Bool; far;
	
{ ========== Weblib extension APIs for adding a toolbar button ========== }

function WLAddToolbarButtonByHandle(hToolbar: HTOOLBAR;
	nID: Word;
	nIdx: Integer;
	lpszText: PChar;
	hBitmap : HBitmap;
	hBitmapSel : HBitmap;
	hBitmapFocus : HBitmap;
	hBitmapDisabled : HBitmap;
	bCopy: Bool) : Bool; far;

function WLAddToolbarButtonByFile(hToolbar: HTOOLBAR;
	nID: Word;
	nIdx: Integer;
	lpszText: PChar;
	lpszBitmapFile: PChar;
	lpszBitmapSelFile: PChar;
	lpszBitmapFocusFile: PChar;
	lpszBitmapDisabledFile: PChar) : Bool; far;

function WLAddToolbarButtonByID(hToolbar: HTOOLBAR;
	nID: Word;
	nIdx: Integer;
	lpszText : PChar;
	hInstance: THandle;
	nBitmap: Word;
	nBitmapSel: Word;
	nBitmapFocus: Word;
	nBitmapDisabled: Word) : Bool; far;

function WLAddToolbarButtonByName(hToolbar: HTOOLBAR;
	nID: Word;
	nIdx: Integer;
	lpszText: PChar;
	hInstance: THandle;
	lpszBitmap: PChar;
	lpszBitmapSel: PChar;
	lpszBitmapFocus: PChar;
	lpszBitmapDisabled: PChar) : Bool; far;

{ ========== IMPLEMENTATION ========== }

implementation 

function WLNGetTransaction; external 'WEBLIBEX';
function WLNGetProgressString; external 'WEBLIBEX';
function WLNGetProgressValue; external 'WEBLIBEX';
function WLNGetProgressMaximum; external 'WEBLIBEX';
function WLNGetWindow; external 'WEBLIBEX';
function WLNGetURL; external 'WEBLIBEX';
function WLNGetMIMEType; external 'WEBLIBEX';
function WLNGetReferrer; external 'WEBLIBEX';
function WLNGetFlags; external 'WEBLIBEX';
function WLNGetSaveFile; external 'WEBLIBEX';
function WLNGetFormData; external 'WEBLIBEX';
function WLNGetX; external 'WEBLIBEX';
function WLNGetY; external 'WEBLIBEX';
function WLNGetWidth; external 'WEBLIBEX';
function WLNGetHeight; external 'WEBLIBEX';
function WLNGetFileName; external 'WEBLIBEX';
function WLNGetButtonID; external 'WEBLIBEX';

function WLStartup; external 'WEBLIB';
function WLCleanup; external 'WEBLIB';
function WLSetDefaultNotify; external 'WEBLIB';

function WLConnectBrowser; external 'WEBLIB';
function WLDisconnectBrowser; external 'WEBLIB';
function WLGetWindowInfo; external 'WEBLIB';
function WLListWindows; external 'WEBLIB';
function WLActivateWindow	; external 'WEBLIB';
function WLCloseWindow; external 'WEBLIB';
function WLSetWindowPos; external 'WEBLIB';
function WLShowWindow; external 'WEBLIB';
function WLShowFile; external 'WEBLIB';
function WLOpenURL; external 'WEBLIB';
function WLSaveURL; external 'WEBLIB';
function WLPostFormData; external 'WEBLIB';
function WLSaveFormData; external 'WEBLIB';
function WLCancel; external 'WEBLIB';
function WLRegisterProtocol; external 'WEBLIB';
function WLUnregisterProtocol; external 'WEBLIB';
function WLRegisterURLEcho; external 'WEBLIB';
function WLUnregisterURLEcho; external 'WEBLIB';
function WLRegisterViewer; external 'WEBLIB';
function WLUnregisterViewer; external 'WEBLIB';
function WLRegisterWindowChange; external 'WEBLIB';
function WLUnregisterWindowChange; external 'WEBLIB';
function WLParseAnchor; external 'WEBLIB';
function WLGetVersion; external 'WEBLIB';
function WLQueryURLFile; external 'WEBLIB';
function WLSetNotifyMethod; external 'WEBLIB';
function WLGetTransactionWindow; external 'WEBLIB';
procedure WLNSetFileName; external 'WEBLIB';

function WLCreateToolbar; external 'WEBLIB';
function WLDeleteToolbar; external 'WEBLIB';
function WLIsToolbarActive; external 'WEBLIB';
function WLSetActiveToolbar; external 'WEBLIB';
function WLAddToolbarButton; external 'WEBLIB';
function WLRemoveToolbarButton; external 'WEBLIB';
function WLIsToolbarButtonVisible; external 'WEBLIB';
function WLShowToolbarButton; external 'WEBLIB';
function WLEnableToolbarButton; external 'WEBLIB';
function WLIsToolbarButtonEnabled; external 'WEBLIB';
function WLGetToolbarText; external 'WEBLIB';
function WLSetToolbarText; external 'WEBLIB';
function WLGetToolbarFont; external 'WEBLIB';
function WLSetToolbarFont; external 'WEBLIB';
function WLGetToolbarBkgnd; external 'WEBLIB';
function WLSetToolbarBkgnd; external 'WEBLIB';
function WLGetToolbarTextColor; external 'WEBLIB';
function WLSetToolbarTextColor; external 'WEBLIB';

function WLAppendFormData; external 'WEBLIB';
function WLGetFormDataLength; external 'WEBLIB';
function WLAccessFormData; external 'WEBLIB';

function WLAddToolbarButtonByHandle; external 'WEBLIBEX';
function WLAddToolbarButtonByFile; external 'WEBLIBEX';
function WLAddToolbarButtonByID; external 'WEBLIBEX';
function WLAddToolbarButtonByName; external 'WEBLIBEX';

end.

