From c101d9726733d4923fd2d5ad56c48de0704df4e8 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Mon, 26 Nov 2007 15:53:03 +0000 Subject: [PATCH] 2007-11-26 07:50 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/what32 * wininet.ch * winerror.prg * windebug.prg * wintabs.prg * wintbar.prg svn:eol-style = native svn:keywords = Id --- harbour/ChangeLog | 10 + harbour/contrib/what32/windebug.prg | 318 ++-- harbour/contrib/what32/winerror.prg | 1240 +++++++-------- harbour/contrib/what32/wininet.ch | 2164 +++++++++++++-------------- harbour/contrib/what32/wintabs.prg | 1070 ++++++------- harbour/contrib/what32/wintbar.prg | 904 +++++------ 6 files changed, 2858 insertions(+), 2848 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a5a9fa3b5d..97ec64f7e3 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,16 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-11-26 07:50 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/contrib/what32 + * wininet.ch + * winerror.prg + * windebug.prg + * wintabs.prg + * wintbar.prg + svn:eol-style = native + svn:keywords = Id + 2007-11-26 14:50 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/bin/hb-mkslib.sh * harbour/bin/postinst.sh diff --git a/harbour/contrib/what32/windebug.prg b/harbour/contrib/what32/windebug.prg index c86dd0c4c3..e85ed70d31 100644 --- a/harbour/contrib/what32/windebug.prg +++ b/harbour/contrib/what32/windebug.prg @@ -1,159 +1,159 @@ -/* - * $Id: debug.prg 8045 2007-11-25 18:36:59Z vouchcac $ - */ - -#INCLUDE "SET.CH" - -#define CRLF chr(13)+chr(10) - -STATIC row_counter := 0 - - - -*-----------------------------------------------------------------------------* -function _trace(c) - - local cn - - if valtype(c)=='C' - cn:=c //:classname() - endif - - - OutputDebugString(if(empty(cn),'',cn+':')+procname(1)+'('+alltrim(str(procline(1)))+')'+; - ' <- '+procname(2)+'('+alltrim(str(procline(2)))+')'+; - ' <- '+procname(3)+'('+alltrim(str(procline(3)))+')'+; - ' <- '+procname(4)+'('+alltrim(str(procline(4)))+')'+; - ' <- '+procname(5)+'('+alltrim(str(procline(5)))+')'+; - CRLF) - - return(NIL) - - - -*------------------------------------------------------------------------------* -* PARAM is used here on purpose to allow for macro expansion of the -* parameters which are passed here as private !!!!!!!!! -*------------------------------------------------------------------------------* -FUNCTION _DVIEW - PARAM p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18 - - LOCAL no_of_param, x, dbg_array, description, half - LOCAL t_call_status - - no_of_param := PCOUNT( ) - half := no_of_param / 2 - - OutputDebugString( '------------------------------' +CRLF) - BEGIN SEQUENCE - FOR x := 1 TO half - dbg_array = "p" + lTrim( STR( x, 2, 0 ) ) - description = "p" + lTrim( STR( x + half, 2, 0 ) ) - DLIST( &dbg_array, &description ) - NEXT - END - - RETURN NIL - -*------------------------------------------------------------------------------* -STATIC FUNCTION DLIST( dbg_array, description ) -*------------------------------------------------------------------------------* - LOCAL heading, x, a_len, data_type, value - - IF ValType( dbg_array ) $ 'AOS' - a_len = Len( dbg_array ) - DQOUT( ' Array:', description, '', IF( a_len == 0, '', dbg_array ) , Len( dbg_array ) ) - FOR x := 1 TO a_len - heading := description + "[" + STR( x, 3, 0 ) + "]" - data_type := ValType( dbg_array[ x ] ) - value := dbg_array[ x ] - DSINGLE_VIEW( heading, data_type, value ) - NEXT - ELSE - heading := description - data_type := ValType( dbg_array ) - value := dbg_array - DSINGLE_VIEW( heading, data_type, value ) - ENDIF - RETURN NIL - -*------------------------------------------------------------------------------* -STATIC FUNCTION DSINGLE_VIEW( heading, data_type, value ) -*------------------------------------------------------------------------------* - DO CASE - CASE data_type == "A" - DLIST( value, heading ) - CASE data_type == "B" - DQOUT( "Code Block:", heading, " => ", value ) - CASE data_type == "C" - DQOUT( " Character:", heading, " => ", value, .T. ) - CASE data_type == "D" - DQOUT( " Date:", heading, " => ", value ) - CASE data_type == "L" - DQOUT( " Logical:", heading, " => ", value ) - CASE data_type == "M" - DQOUT( " Memo:", heading, " => ", value ) - CASE data_type == "N" - DQOUT( " Numeric:", heading, " => ", value ) - CASE data_type == "O" - OutputDebugString( " Object vv" +CRLF) // arrows don't show in Windows - DLIST( value, heading ) - OutputDebugString( " Object ^^" +CRLF) // arrows don't show in windows - CASE data_type == "N" - DQOUT( " Numeric:", heading, " => ", value ) - CASE data_type == "U" - DQOUT( "Undefinded:", heading, " => ", value ) - OTHERWISE - OutputDebugString( "Unknown data type returned by VALTYPE()" +CRLF) - ENDCASE - RETURN NIL - -*------------------------------------------------------------------------------* -STATIC FUNCTION DQOUT( a, b, c, d, show_len ) -*------------------------------------------------------------------------------* - LOCAL e := '' - - IF ValType( show_len ) == 'L' .AND. show_len - e := ' (' + LEFT(ALLTRIM(a),1)+ ALLTRIM(STR( Len( d ) , 4, 0 ))+')' - ELSEIF ValType( show_len ) == 'N' - e := ' ('+ LEFT(ALLTRIM(a),1) + AllTrim( STR( show_len, 10, 0 ) )+')' - // ENDIF - ELSE - e:=' ('+LEFT(ALLTRIM(a),1)+')' - ENDIF - - e:="" - - OutputDebugString( b + e + c + asstring( d ) +CRLF) - RETURN NIL - -*-----------------------------------------------------------------------------* -STATIC FUNCTION asString( x ) - local v := ValType( x ) - - DO CASE - CASE v == "C" - RETURN '"' + x + '"' - CASE v == "N" - RETURN AllTrim( str( x ) ) - CASE v == "L" - IF x - RETURN ".T." - ELSE - RETURN ".F." - ENDIF - CASE v == "D" - RETURN dtoc( x ) - CASE v == "U" - RETURN "NIL" - CASE v == "A" - RETURN "" - CASE v == "O" - RETURN "" - CASE v == "B" - RETURN "" - OTHERWISE - RETURN "" - END CASE - - RETURN( x ) +/* + * $Id$ + */ + +#INCLUDE "SET.CH" + +#define CRLF chr(13)+chr(10) + +STATIC row_counter := 0 + + + +*-----------------------------------------------------------------------------* +function _trace(c) + + local cn + + if valtype(c)=='C' + cn:=c //:classname() + endif + + + OutputDebugString(if(empty(cn),'',cn+':')+procname(1)+'('+alltrim(str(procline(1)))+')'+; + ' <- '+procname(2)+'('+alltrim(str(procline(2)))+')'+; + ' <- '+procname(3)+'('+alltrim(str(procline(3)))+')'+; + ' <- '+procname(4)+'('+alltrim(str(procline(4)))+')'+; + ' <- '+procname(5)+'('+alltrim(str(procline(5)))+')'+; + CRLF) + + return(NIL) + + + +*------------------------------------------------------------------------------* +* PARAM is used here on purpose to allow for macro expansion of the +* parameters which are passed here as private !!!!!!!!! +*------------------------------------------------------------------------------* +FUNCTION _DVIEW + PARAM p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18 + + LOCAL no_of_param, x, dbg_array, description, half + LOCAL t_call_status + + no_of_param := PCOUNT( ) + half := no_of_param / 2 + + OutputDebugString( '------------------------------' +CRLF) + BEGIN SEQUENCE + FOR x := 1 TO half + dbg_array = "p" + lTrim( STR( x, 2, 0 ) ) + description = "p" + lTrim( STR( x + half, 2, 0 ) ) + DLIST( &dbg_array, &description ) + NEXT + END + + RETURN NIL + +*------------------------------------------------------------------------------* +STATIC FUNCTION DLIST( dbg_array, description ) +*------------------------------------------------------------------------------* + LOCAL heading, x, a_len, data_type, value + + IF ValType( dbg_array ) $ 'AOS' + a_len = Len( dbg_array ) + DQOUT( ' Array:', description, '', IF( a_len == 0, '', dbg_array ) , Len( dbg_array ) ) + FOR x := 1 TO a_len + heading := description + "[" + STR( x, 3, 0 ) + "]" + data_type := ValType( dbg_array[ x ] ) + value := dbg_array[ x ] + DSINGLE_VIEW( heading, data_type, value ) + NEXT + ELSE + heading := description + data_type := ValType( dbg_array ) + value := dbg_array + DSINGLE_VIEW( heading, data_type, value ) + ENDIF + RETURN NIL + +*------------------------------------------------------------------------------* +STATIC FUNCTION DSINGLE_VIEW( heading, data_type, value ) +*------------------------------------------------------------------------------* + DO CASE + CASE data_type == "A" + DLIST( value, heading ) + CASE data_type == "B" + DQOUT( "Code Block:", heading, " => ", value ) + CASE data_type == "C" + DQOUT( " Character:", heading, " => ", value, .T. ) + CASE data_type == "D" + DQOUT( " Date:", heading, " => ", value ) + CASE data_type == "L" + DQOUT( " Logical:", heading, " => ", value ) + CASE data_type == "M" + DQOUT( " Memo:", heading, " => ", value ) + CASE data_type == "N" + DQOUT( " Numeric:", heading, " => ", value ) + CASE data_type == "O" + OutputDebugString( " Object vv" +CRLF) // arrows don't show in Windows + DLIST( value, heading ) + OutputDebugString( " Object ^^" +CRLF) // arrows don't show in windows + CASE data_type == "N" + DQOUT( " Numeric:", heading, " => ", value ) + CASE data_type == "U" + DQOUT( "Undefinded:", heading, " => ", value ) + OTHERWISE + OutputDebugString( "Unknown data type returned by VALTYPE()" +CRLF) + ENDCASE + RETURN NIL + +*------------------------------------------------------------------------------* +STATIC FUNCTION DQOUT( a, b, c, d, show_len ) +*------------------------------------------------------------------------------* + LOCAL e := '' + + IF ValType( show_len ) == 'L' .AND. show_len + e := ' (' + LEFT(ALLTRIM(a),1)+ ALLTRIM(STR( Len( d ) , 4, 0 ))+')' + ELSEIF ValType( show_len ) == 'N' + e := ' ('+ LEFT(ALLTRIM(a),1) + AllTrim( STR( show_len, 10, 0 ) )+')' + // ENDIF + ELSE + e:=' ('+LEFT(ALLTRIM(a),1)+')' + ENDIF + + e:="" + + OutputDebugString( b + e + c + asstring( d ) +CRLF) + RETURN NIL + +*-----------------------------------------------------------------------------* +STATIC FUNCTION asString( x ) + local v := ValType( x ) + + DO CASE + CASE v == "C" + RETURN '"' + x + '"' + CASE v == "N" + RETURN AllTrim( str( x ) ) + CASE v == "L" + IF x + RETURN ".T." + ELSE + RETURN ".F." + ENDIF + CASE v == "D" + RETURN dtoc( x ) + CASE v == "U" + RETURN "NIL" + CASE v == "A" + RETURN "" + CASE v == "O" + RETURN "" + CASE v == "B" + RETURN "" + OTHERWISE + RETURN "" + END CASE + + RETURN( x ) diff --git a/harbour/contrib/what32/winerror.prg b/harbour/contrib/what32/winerror.prg index e0f45d25e3..5aa521d31d 100644 --- a/harbour/contrib/what32/winerror.prg +++ b/harbour/contrib/what32/winerror.prg @@ -1,620 +1,620 @@ -/* - * $Id: errorsys.prg 8045 2007-11-25 18:36:59Z vouchcac $ - */ - - -// WHAT32 ErrorSys -// A.J. Wos 08/06/2002 -// Scaled down and adapted for Harbour + What32.Lib - - -#include "what32.ch" -#include "winuser.ch" -#include "error.ch" -#include "debug.ch" - -#xtranslate NTRIM( < n > ) = > lTrim( Str( < n > ) ) -//#define LOGFILE error.log // don't use quotes - -*------------------------------------------------------------------------------* - -PROCEDURE ErrorSys( ) - - ErrorBlock( { | e | DefError( e ) } ) - - RETURN - -*------------------------------------------------------------------------------* - -STATIC FUNCTION DefError( e ) - - LOCAL cMessage, aOptions, nChoice - LOCAL cErr, SourceLine - LOCAL cProcStack := '' - LOCAL i - - IF e:genCode == EG_PRINT - RETURN PrintError( ) - ENDIF - IF ( e:genCode == EG_ZERODIV ) - RETURN ( 0 ) - ENDIF - IF ( e:genCode == EG_OPEN .AND. e:osCode == 32 .AND. e:canDefault ) - NetErr( .T. ) - RETURN ( .F. ) // NOTE - ENDIF - IF ( e:genCode == EG_APPENDLOCK .AND. e:canDefault ) - NetErr( .T. ) - RETURN ( .F. ) // NOTE - ENDIF - - i := 2 - DO WHILE ( ! Empty( ProcName( i ) ) ) - cProcStack += ( CRLF + ProcFile( i ) + "->" + ProcName( i ) + "(" + NTRIM( ProcLine( i ++ ) ) + ")" ) - IF ProcName( i ) == 'DEFERROR' // Oops, recursive arror, cannot continue ! - OutputDebugString( "" ) - OutputDebugString( "===============" + CRLF ) - OutputDebugString( "RECURSIVE ERROR" + CRLF ) - OutputDebugString( "===============" + CRLF ) - OutputDebugString( e:description + CHR( 13 ) + "Procedure Stack Depth:" + ntrim( getprocstack( ) ) + CRLF ) - OutputDebugString( cProcStack + CRLF ) - PostQuitMessage( 0 ) - Errorlevel( 1 ) - // quit - RETURN( .F. ) - ENDIF - ENDDO - - //OutputDebugString( cProcStack + CRLF ) - - cErr := LogError( e, cProcStack ) - OutputDebugString( cErr ) - cMessage := ErrorMessage( e ) - - aOptions := { "Quit" } - IF ( e:canRetry ) - aAdd( aOptions, "Retry" ) - END - IF ( e:canDefault ) - aAdd( aOptions, "Default" ) - END - - nChoice := 0 - - IF ( Empty( e:osCode ) ) - nChoice := eAlert( cMessage, aOptions, cErr ) - ELSE - nChoice := eAlert( cMessage + ; - ";(OS Error " + NTRIM( e:osCode ) + ")", ; - aOptions, cErr ) - END - - IF ( ! Empty( nChoice ) ) - - // do as instructed - IF ( aOptions[ nChoice ] == "Break" ) - SET DELETED ON - BREAK( e ) - RETURN( .F. ) - ELSEIF ( aOptions[ nChoice ] == "Retry" ) - RETURN ( .T. ) - ELSEIF ( aOptions[ nChoice ] == "Default" ) - SET DELETED ON - RETURN ( .F. ) - END - - END - - PostQuitMessage( 0 ) - ErrorLevel( 1 ) - Quit - //CLOSE ALL - //PGMEXIT() - - RETURN ( .F. ) - - -*------------------------------------------------------------------------------* - -STATIC FUNCTION ErrorMessage( e ) - - LOCAL cMessage - - // start error message - cMessage := IF( e:severity > ES_WARNING, "Error", "Warning" ) - - // add error description if available - IF ( ValType( e:description ) == "C" ) - cMessage += ';' + e:description - END - - // add either filename or operation - IF ( ! Empty( e:filename ) ) - cMessage += ( ';' + e:filename ) - ELSEIF ( ! Empty( e:operation ) ) - cMessage += ( ';' + e:operation ) - END - - // add subsystem name if available - IF ( ValType( e:subsystem ) == "C" ) - cMessage += ';ERROR: ' + e:subsystem( ) + ' ' - ELSE - cMessage += ";ERROR: ??? " - END - - // add subsystem's error code if available - IF ( ValType( e:subCode ) == "N" ) - cMessage += ( NTRIM( e:subCode ) ) - END - cMessage += ';Called from ' + ProcFile(3) + "->" + procname( 3 ) + ' (' + AllTrim( Str( procline( 3 ) ) ) + '), ' + ; - + ProcFile(4) + "->" + procname( 4 ) + ' (' + AllTrim( Str( procline( 4 ) ) ) + ')' - cMessage += ';Error logged in file '+GetModuleFileName()+'\ERROR.LOG' - - RETURN ( cMessage ) - - -*------------------------------------------------------------------------------* - -STATIC FUNCTION LogError( e, cProcStack ) - - LOCAL r, c - LOCAL h - LOCAL Args := convertargs( e:args ) - LOCAL i := 3 - LOCAL cErr := '' - LOCAL dVer - - cErr += 'SYSTEM' - cErr += ( CRLF + '------' ) - cErr += ( CRLF + 'Error date:' + dtoc( date( ) ) + ' time:' + time( ) ) - cErr += ( CRLF + 'Application: ' + GetModuleFileName( ) ) - cErr += ( CRLF + 'What32.Lib ver.' + WhatVersion( @dVer ) + ", " + DTOC( dVer ) ) - - // T.B.D.: - // add here Windows version, memory info, diskspace info, free resources info - // add computer name and operator name - - cErr += ( CRLF ) - cErr += ( CRLF + "ERROR INFORMATION" ) - cErr += ( CRLF + "-----------------" ) - cErr += ( CRLF + "Arguments " + Args ) - cErr += ( CRLF + "Description " + e:description ) - cErr += ( CRLF + "Filename " + IfEmpty( e:filename ) ) - cErr += ( CRLF + "GenCode " + gencodetext( e:genCode ) ) - cErr += ( CRLF + "Operation " + IfEmpty( e:operation ) ) - cErr += ( CRLF + "Severity " + NTRIM( e:severity ) ) - cErr += ( CRLF + "SubCode " + NTRIM( e:subCode ) ) - cErr += ( CRLF + "SubSystem " + e:subSystem ) - cErr += ( CRLF + "Tries " + NTRIM( e:tries ) ) - cErr += ( CRLF + "Alias() " + IfEmpty( ALIAS( ) ) ) - cErr += ( CRLF + "Open DBFs " + ntrim( GetAliasCount( ) ) ) - cErr += ( CRLF + "DOS Error " + DosErrCode( e ) ) - cErr += ( CRLF + "Windows Error " + NTRIM( GetLastError( ) ) ) - cErr += ( CRLF ) - cErr += ( CRLF ) - cErr += ( CRLF + "PROCEDURE STACK" ) - cErr += ( CRLF + "---------------" ) - - cErr += cProcStack - - SET PRINTER TO "Error.Log" ADDITIVE - SET CONSOLE OFF - SET PRINTER ON - - QOut( " Please mail or fax this error report to:" ) - /* - ? ' +---------------------------+' - ? ' | YOUR BUSINESS NAME HERE |' - ? ' | P.O.Box 123 |' - ? ' |Some Prestigeous Town, 1234|' - ? ' | Fax: (01) 1234 1234 |' - */ - QOut( " +---------------------------+" ) - QOut( cErr ) - - QOut(Replicate( "=", 70 )) - - EJECT - SET PRINTER OFF - SET PRINTER TO - SET CONSOLE ON - - RETURN cErr - - -*------------------------------------------------------------------------------* - -STATIC FUNCTION IfEmpty( Msg ) - - LOCAL Ret_Val := "" - - IF ! Empty( msg ) - Ret_Val := Left( msg, 68 ) - ENDIF - - RETURN Ret_Val - - -*------------------------------------------------------------------------------* - -STATIC FUNCTION PrintError - - BREAK - - RETURN ( .F. ) - - -*------------------------------------------------------------------------------* - -STATIC FUNCTION ConvertArgs( a ) - - LOCAL Ret_Val - LOCAL x, cType - LOCAL NumArgs := IF( ValType( a ) == "A", Len( a ) , IF( ValType( a ) == "C", ( a := { a } , 1 ) , 0 ) ) - - IF NumArgs > 0 - Ret_Val := '{ ' - FOR x := 1 TO NumArgs - cType := ValType( a[ x ] ) - DO CASE - CASE cType == "C" - Ret_Val += a[ x ] - CASE cType == "N" - Ret_Val += NTRIM( a[ x ] ) - CASE cType == "D" - Ret_Val += dtoc( a[ x ] ) - CASE cType == "L" - Ret_Val += IF( a[ x ] , ".T.", ".F." ) - CASE cType == "O" - Ret_Val += a[ x ] :className + " Object" - CASE cType == "U" - Ret_Val += "NIL" - ENDCASE - //ÄÄÄÄÄ Next block added 1/8/92 To separate arguments - IF x < NumArgs - Ret_Val += ', ' - ENDIF - NEXT - Ret_Val += ' }' - ENDIF - - RETURN ifempty( Ret_Val ) - - -*------------------------------------------------------------------------------* - -STATIC FUNCTION GetAliasCount( ) - - LOCAL Counter := 0 - LOCAL nCounter := 0 - - FOR Counter := 1 TO 255 - IF ! Empty( alias( Counter ) ) - nCounter ++ - ENDIF - NEXT - - RETURN( nCounter ) - - -*------------------------------------------------------------------------------* - -STATIC FUNCTION getprocstack( ) - - LOCAL i := 2 - - DO WHILE ! Empty( procname( i ) ) - i ++ - ENDDO - - RETURN( i - 3 ) - - -*------------------------------------------------------------------------------* - -STATIC FUNCTION DosErrCode( e ) - - LOCAL Msg - - IF e:osCode > 0 - Msg := NTRIM( e:osCode ) + ": " + Left( DosErrText( e:osCode ) , 37 ) - ELSE - Msg := "(not an operating system error)" - ENDIF - - RETURN Msg - - -*------------------------------------------------------------------------------* - -/* - Function: DosErrText( ) - Author: Craig Yellick - Purpose: Provide full description of DOS error code ( see table D - 1 - in the Clipper 5.0 "Programming & Utilities Guide" ) - Returns: character string -*/ - -STATIC FUNCTION DosErrText( n ) - - LOCAL desc_ := { "Invalid function number" , ; // 1 - "File not found" , ; // 2 - "Path not found" , ; // 3 - "Too many files open (no handles left)" , ; // 4 - "Access denied" , ; // 5 - "Invalid handle" , ; // 6 - "Memory control blocks destroyed (oh, my)", ; // 7 - "Insufficient memory" , ; // 8 - "Invalid memory block address" , ; // 9 - "Invalid environment" , ; // 10 - "Invalid format" , ; // 11 - "Invalid access code" , ; // 12 - "Invalid data" , ; // 13 - , ; // 14 - "Invalid drive was specified" , ; // 15 - "Attempt to remove the current directory" , ; // 16 - "Not same device" , ; // 17 - "No more files" , ; // 18 - "Attempt to write on write-protected diskette", ; // 19 - "Unknown unit" , ; // 20 - "Drive not ready" , ; // 21 - "Unknown command" , ; // 22 - "Data error (CRC)" , ; // 23 - "Bad request structure length" , ; // 24 - "Seek error" , ; // 25 - "Unknown media type" , ; // 26 - "Sector not found" , ; // 27 - "Printer out of paper" , ; // 28 - "Write fault" , ; // 29 - "Read fault" , ; // 30 - "General failure" , ; // 31 - "Sharing violation" , ; // 32 - "Lock violation" , ; // 33 - "Invalid disk change" , ; // 34 - "FCB unavailable" , ; // 35 - "Sharing buffer overflow" , ; // 36 - , , , , , , , , , , , , , ; // 37-49 - "Network request not supported" , ; // 50 - "Remote computer not listening" , ; // 51 - "Duplicate name on network" , ; // 52 - "Network name not found" , ; // 53 - "Network busy" , ; // 54 - "Network device no longer exists" , ; // 55 - "Network BIOS command limit exceeded" , ; // 56 - "Network adapter hardware error" , ; // 57 - "Incorrect response from network" , ; // 58 - "Unexpected network error" , ; // 59 - "Incompatible remote adapter" , ; // 60 - "Print queue full" , ; // 61 - "Not enough space for print file" , ; // 62 - "Print file deleted (not enough space)" , ; // 63 - "Network name deleted" , ; // 64 - "Access denied" , ; // 65 - "Network device type incorrect" , ; // 66 - "Network name not found" , ; // 67 - "Network name limit exceeded" , ; // 68 - "Network BIOS session limit exceeded" , ; // 69 - "Temporarily paused" , ; // 70 - "Network request not accepted" , ; // 71 - "Print or disk redirection paused" , ; // 72 - , , , , , , , ; // 73-79 - "File already exists" , ; // 80 - , ; // 81 - "Cannot make directory entry" , ; // 82 - "Fail on INT 24h" , ; // 83 - "Too many redirections" , ; // 84 - "Duplicate redirection" , ; // 85 - "Invalid password" , ; // 86 - "Invalid parameter" , ; // 87 - "Network device fault" , ; // 88 - ; - "Undefined or reserved error code!" ; // +1 - } - - /* - Check that code number is within known upper limit, - AND that a description is available For it. - */ -/* - IF ( n > ( Len( desc_ ) - 1 ) ) .OR. ( desc_[ n ] == NIL ) - n := Len( desc_ ) - ENDIF -*/ - IF ( ( n < 1 ) .OR. n > ( Len( desc_ ) - 1 ) ) .OR. ( desc_[ n ] == NIL ) - n := Len( desc_ ) - ENDIF - - RETURN desc_[ n ] - - -*------------------------------------------------------------------------------* - -STATIC FUNCTION GenCodeText( n ) - - LOCAL desc_ := { "EG_ARG", ; // 1 - "EG_BOUND" , ; // 2 - "EG_STROVERFLOW" , ; // 3 - "EG_NUMOVERFLOW" , ; // 4 - "EG_ZERODIV" , ; // 5 - "EG_NUMERR" , ; // 6 - "EG_SYNTAX" , ; // 7 - "EG_COMPLEXITY" , ; // 8 - , , ; // 9-10 - "EG_MEM" , ; // 11 - "EG_NOFUNC" , ; // 12 - "EG_NOMETHOD" , ; // 13 - "EG_NOVAR" , ; // 14 - "EG_NOALIAS" , ; // 15 - "EG_NOVARMETHOD" , ; // 16 - "EG_BADALIAS" , ; // 17 (new w/ 5.01a) - "EG_DUPALIAS" , ; // 18 (new w/ 5.01a) - , ; // 19 - "EG_CREATE" , ; // 20 - "EG_OPEN" , ; // 21 - "EG_CLOSE" , ; // 22 - "EG_READ" , ; // 23 - "EG_WRITE" , ; // 24 - "EG_PRINT" , ; // 25 - , , , , ; // 26-29 - "EG_UNSUPPORTED" , ; // 30 - "EG_LIMIT" , ; // 31 - "EG_CORRUPTION" , ; // 32 - "EG_DATATYPE" , ; // 33 - "EG_DATAWIDTH" , ; // 34 - "EG_NOTABLE" , ; // 35 - "EG_NOORDER" , ; // 36 - "EG_SHARED" , ; // 37 - "EG_UNLOCKED" , ; // 38 - "EG_READONLY" , ; // 39 - "EG_APPENDLOCK" , ; // 40 - ; - "Unknown or reserved" ; // +1 - } - - /* - Check that code number is within known upper limit, - AND that a description is available For it. - */ -/* - IF ( n > ( Len( desc_ ) - 1 ) ) .OR. ( desc_[ n ] == NIL ) - n := Len( desc_ ) - ENDIF -*/ - IF ( ( n < 1 ) .OR. n > ( Len( desc_ ) - 1 ) ) .OR. ( desc_[ n ] == NIL ) - n := Len( desc_ ) - ENDIF - - - RETURN NTRIM( n ) + ": " + desc_[ n ] - - -*------------------------------------------------------------------------------* - -STATIC FUNCTION eAlert( cMsg, aChoices, cDetail ) - - LOCAL aDlg, i, j, n, aWid, aChoose, aMsg - LOCAL hWnd, hDC - LOCAL lErr := .F., e, w , h, t := 0, cTitle, Msgh, ButWidth - LOCAL crPos := 0, txth := 0, atm := { } - LOCAL isDetail := .F. - - IF ValType( cMsg ) != "C" - cMsg := asString( cMsg ) - ENDIF - cTitle := 'Alert' - - IF aChoices == NIL - aChoices := { "&Ok" } - ENDIF - - aAdd( achoices, "&Details >>" ) - - cMsg := StrTran( cMsg, ";", CR ) - - IF ( crPos := at( CR, cMsg ) ) > 0 - cTitle := Left( cMsg, crPos - 1 ) - cMsg := SubStr( cMsg, crPos + 1 ) - ENDIF - - hWnd := GetDesktopWindow( ) // default parent - hDC := GetDC( hWnd ) - - //------------- total width without buttons - - w := GetTextExtentPoint32( hDC, AllTrim( cTitle ) ) [ 1 ] - aMsg := str2a( cMsg, CR ) - AEVAL( aMsg, { | x, Y | w := Max( w, GetTextExtentPoint32( hDC, AllTrim( x ) ) [ 1 ] ) } ) - w += 20 - - //--------- total width of choices, also add "&" to the choices (if needed) - - n := Len( aChoices ) - aChoose := array( n ) - - txth := 8 //ATM[TM_Height] - Msgh := Len( aMsg ) * txth - FOR i = 1 TO n - ButWidth := Max( 20, GetTextExtentpoint32( hDC, aChoices[ i ] ) [ 1 ] + 6 ) - t := Max( t, ButWidth ) - aChoose[ i ] := IF( at( "&", aChoices[ i ] ) == 0, "&" + aChoices[ i ] , aChoices[ i ] ) - NEXT i - - ReleaseDC( , hDC ) - - ButWidth := t / 2 - t *= ( n + 1 ) - w := Max( Max( w, t ) + 40, 500 ) // minimum dlg width - h := Msgh + 33 - w /= 2 - - //----------- create dialog - - aDlg = MakeDlgTemplate( cTitle, ; - WS_CAPTION + DS_MODALFRAME + WS_VISIBLE + 4 + WS_POPUP + DS_SETFONT , ; - 0, 0, w, h, 8, 'MS Sans Serif' ) - - FOR i := 1 TO n - aDlg = AddDlgItem( aDlg, i, "BUTTON", ; - BS_PUSHBUTTON + WS_TABSTOP + WS_CHILD + WS_VISIBLE, ; - w - ( n - i ) * ( ButWidth + 5 ) - ButWidth - 5, h - 18, ButWidth, 14, ; - aChoose[ i ] ) - NEXT i - - aDlg = AddDlgItem( aDlg, - 1, "STATIC", ; - SS_CENTER + WS_CHILD + WS_VISIBLE, ; - 10, 8, w - 20, Msgh, ; - cMsg ) - - aDlg = AddDlgItem( aDlg, - 1, "BUTTON", ; - BS_GROUPBOX + WS_CHILD + WS_VISIBLE, ; - 5, 1, w - 10, Msgh + 10, ; - "" ) - - aDlg = AddDlgItem( aDlg, 101, "EDIT", ; - WS_CHILD + WS_VISIBLE + WS_BORDER + ES_MULTILINE + ES_READONLY + WS_VSCROLL + WS_TABSTOP, ; - 5, h + 1, w - 10, 115, ; - cDetail ) - - MessageBeep( MB_ICONHAND ) - i := DialogBox( , aDlg, hWnd, { | hDlg, nMsg, nwParam, nlParam | ; - eAlertProc( hDlg, nMsg, nwParam, nlParam, @isDetail, hWnd, n ) } ) - SetFocus( hWnd ) - - RETURN i - - -*------------------------------------------------------------------------------* - -STATIC FUNCTION eAlertProc( hDlg, nMsg, nwParam, nlParam, isDetail, hWnd, n ) - - LOCAL aRect - - DO CASE - CASE nMsg == WM_INITDIALOG - CenterWindow( hDlg, , , hWnd ) - SetOnTop( hDlg, HWND_TOPMOST ) - RETURN( 1 ) - - CASE nMsg == WM_COMMAND - IF 'Detail' $ GetDlgItemText( hDlg, nwParam ) - aRect := getwindowrect( hDlg ) - IF isDetail - SetDlgItemText( hDlg, nwParam, '&Detail >>' ) - MoveWindow( hDlg, aRect[ 1 ] , aRect[ 2 ] , aRect[ 3 ] - aRect[ 1 ] , aRect[ 4 ] - aRect[ 2 ] - 200, .T. ) - isDetail := .F. - ELSE - SetDlgItemText( hDlg, nwParam, '<< &Detail' ) - MoveWindow( hDlg, aRect[ 1 ] , aRect[ 2 ] , aRect[ 3 ] - aRect[ 1 ] , aRect[ 4 ] - aRect[ 2 ] + 200, .T. ) - isDetail := .T. - ENDIF - ELSE - IF nwParam > 0 .AND. nwParam < n - EndDialog( hDlg, nwParam ) - ENDIF - ENDIF - - ENDCASE - - RETURN( 0 ) - - +/* + * $Id$ + */ + + +// WHAT32 ErrorSys +// A.J. Wos 08/06/2002 +// Scaled down and adapted for Harbour + What32.Lib + + +#include "what32.ch" +#include "winuser.ch" +#include "error.ch" +#include "debug.ch" + +#xtranslate NTRIM( < n > ) = > lTrim( Str( < n > ) ) +//#define LOGFILE error.log // don't use quotes + +*------------------------------------------------------------------------------* + +PROCEDURE ErrorSys( ) + + ErrorBlock( { | e | DefError( e ) } ) + + RETURN + +*------------------------------------------------------------------------------* + +STATIC FUNCTION DefError( e ) + + LOCAL cMessage, aOptions, nChoice + LOCAL cErr, SourceLine + LOCAL cProcStack := '' + LOCAL i + + IF e:genCode == EG_PRINT + RETURN PrintError( ) + ENDIF + IF ( e:genCode == EG_ZERODIV ) + RETURN ( 0 ) + ENDIF + IF ( e:genCode == EG_OPEN .AND. e:osCode == 32 .AND. e:canDefault ) + NetErr( .T. ) + RETURN ( .F. ) // NOTE + ENDIF + IF ( e:genCode == EG_APPENDLOCK .AND. e:canDefault ) + NetErr( .T. ) + RETURN ( .F. ) // NOTE + ENDIF + + i := 2 + DO WHILE ( ! Empty( ProcName( i ) ) ) + cProcStack += ( CRLF + ProcFile( i ) + "->" + ProcName( i ) + "(" + NTRIM( ProcLine( i ++ ) ) + ")" ) + IF ProcName( i ) == 'DEFERROR' // Oops, recursive arror, cannot continue ! + OutputDebugString( "" ) + OutputDebugString( "===============" + CRLF ) + OutputDebugString( "RECURSIVE ERROR" + CRLF ) + OutputDebugString( "===============" + CRLF ) + OutputDebugString( e:description + CHR( 13 ) + "Procedure Stack Depth:" + ntrim( getprocstack( ) ) + CRLF ) + OutputDebugString( cProcStack + CRLF ) + PostQuitMessage( 0 ) + Errorlevel( 1 ) + // quit + RETURN( .F. ) + ENDIF + ENDDO + + //OutputDebugString( cProcStack + CRLF ) + + cErr := LogError( e, cProcStack ) + OutputDebugString( cErr ) + cMessage := ErrorMessage( e ) + + aOptions := { "Quit" } + IF ( e:canRetry ) + aAdd( aOptions, "Retry" ) + END + IF ( e:canDefault ) + aAdd( aOptions, "Default" ) + END + + nChoice := 0 + + IF ( Empty( e:osCode ) ) + nChoice := eAlert( cMessage, aOptions, cErr ) + ELSE + nChoice := eAlert( cMessage + ; + ";(OS Error " + NTRIM( e:osCode ) + ")", ; + aOptions, cErr ) + END + + IF ( ! Empty( nChoice ) ) + + // do as instructed + IF ( aOptions[ nChoice ] == "Break" ) + SET DELETED ON + BREAK( e ) + RETURN( .F. ) + ELSEIF ( aOptions[ nChoice ] == "Retry" ) + RETURN ( .T. ) + ELSEIF ( aOptions[ nChoice ] == "Default" ) + SET DELETED ON + RETURN ( .F. ) + END + + END + + PostQuitMessage( 0 ) + ErrorLevel( 1 ) + Quit + //CLOSE ALL + //PGMEXIT() + + RETURN ( .F. ) + + +*------------------------------------------------------------------------------* + +STATIC FUNCTION ErrorMessage( e ) + + LOCAL cMessage + + // start error message + cMessage := IF( e:severity > ES_WARNING, "Error", "Warning" ) + + // add error description if available + IF ( ValType( e:description ) == "C" ) + cMessage += ';' + e:description + END + + // add either filename or operation + IF ( ! Empty( e:filename ) ) + cMessage += ( ';' + e:filename ) + ELSEIF ( ! Empty( e:operation ) ) + cMessage += ( ';' + e:operation ) + END + + // add subsystem name if available + IF ( ValType( e:subsystem ) == "C" ) + cMessage += ';ERROR: ' + e:subsystem( ) + ' ' + ELSE + cMessage += ";ERROR: ??? " + END + + // add subsystem's error code if available + IF ( ValType( e:subCode ) == "N" ) + cMessage += ( NTRIM( e:subCode ) ) + END + cMessage += ';Called from ' + ProcFile(3) + "->" + procname( 3 ) + ' (' + AllTrim( Str( procline( 3 ) ) ) + '), ' + ; + + ProcFile(4) + "->" + procname( 4 ) + ' (' + AllTrim( Str( procline( 4 ) ) ) + ')' + cMessage += ';Error logged in file '+GetModuleFileName()+'\ERROR.LOG' + + RETURN ( cMessage ) + + +*------------------------------------------------------------------------------* + +STATIC FUNCTION LogError( e, cProcStack ) + + LOCAL r, c + LOCAL h + LOCAL Args := convertargs( e:args ) + LOCAL i := 3 + LOCAL cErr := '' + LOCAL dVer + + cErr += 'SYSTEM' + cErr += ( CRLF + '------' ) + cErr += ( CRLF + 'Error date:' + dtoc( date( ) ) + ' time:' + time( ) ) + cErr += ( CRLF + 'Application: ' + GetModuleFileName( ) ) + cErr += ( CRLF + 'What32.Lib ver.' + WhatVersion( @dVer ) + ", " + DTOC( dVer ) ) + + // T.B.D.: + // add here Windows version, memory info, diskspace info, free resources info + // add computer name and operator name + + cErr += ( CRLF ) + cErr += ( CRLF + "ERROR INFORMATION" ) + cErr += ( CRLF + "-----------------" ) + cErr += ( CRLF + "Arguments " + Args ) + cErr += ( CRLF + "Description " + e:description ) + cErr += ( CRLF + "Filename " + IfEmpty( e:filename ) ) + cErr += ( CRLF + "GenCode " + gencodetext( e:genCode ) ) + cErr += ( CRLF + "Operation " + IfEmpty( e:operation ) ) + cErr += ( CRLF + "Severity " + NTRIM( e:severity ) ) + cErr += ( CRLF + "SubCode " + NTRIM( e:subCode ) ) + cErr += ( CRLF + "SubSystem " + e:subSystem ) + cErr += ( CRLF + "Tries " + NTRIM( e:tries ) ) + cErr += ( CRLF + "Alias() " + IfEmpty( ALIAS( ) ) ) + cErr += ( CRLF + "Open DBFs " + ntrim( GetAliasCount( ) ) ) + cErr += ( CRLF + "DOS Error " + DosErrCode( e ) ) + cErr += ( CRLF + "Windows Error " + NTRIM( GetLastError( ) ) ) + cErr += ( CRLF ) + cErr += ( CRLF ) + cErr += ( CRLF + "PROCEDURE STACK" ) + cErr += ( CRLF + "---------------" ) + + cErr += cProcStack + + SET PRINTER TO "Error.Log" ADDITIVE + SET CONSOLE OFF + SET PRINTER ON + + QOut( " Please mail or fax this error report to:" ) + /* + ? ' +---------------------------+' + ? ' | YOUR BUSINESS NAME HERE |' + ? ' | P.O.Box 123 |' + ? ' |Some Prestigeous Town, 1234|' + ? ' | Fax: (01) 1234 1234 |' + */ + QOut( " +---------------------------+" ) + QOut( cErr ) + + QOut(Replicate( "=", 70 )) + + EJECT + SET PRINTER OFF + SET PRINTER TO + SET CONSOLE ON + + RETURN cErr + + +*------------------------------------------------------------------------------* + +STATIC FUNCTION IfEmpty( Msg ) + + LOCAL Ret_Val := "" + + IF ! Empty( msg ) + Ret_Val := Left( msg, 68 ) + ENDIF + + RETURN Ret_Val + + +*------------------------------------------------------------------------------* + +STATIC FUNCTION PrintError + + BREAK + + RETURN ( .F. ) + + +*------------------------------------------------------------------------------* + +STATIC FUNCTION ConvertArgs( a ) + + LOCAL Ret_Val + LOCAL x, cType + LOCAL NumArgs := IF( ValType( a ) == "A", Len( a ) , IF( ValType( a ) == "C", ( a := { a } , 1 ) , 0 ) ) + + IF NumArgs > 0 + Ret_Val := '{ ' + FOR x := 1 TO NumArgs + cType := ValType( a[ x ] ) + DO CASE + CASE cType == "C" + Ret_Val += a[ x ] + CASE cType == "N" + Ret_Val += NTRIM( a[ x ] ) + CASE cType == "D" + Ret_Val += dtoc( a[ x ] ) + CASE cType == "L" + Ret_Val += IF( a[ x ] , ".T.", ".F." ) + CASE cType == "O" + Ret_Val += a[ x ] :className + " Object" + CASE cType == "U" + Ret_Val += "NIL" + ENDCASE + //ÄÄÄÄÄ Next block added 1/8/92 To separate arguments + IF x < NumArgs + Ret_Val += ', ' + ENDIF + NEXT + Ret_Val += ' }' + ENDIF + + RETURN ifempty( Ret_Val ) + + +*------------------------------------------------------------------------------* + +STATIC FUNCTION GetAliasCount( ) + + LOCAL Counter := 0 + LOCAL nCounter := 0 + + FOR Counter := 1 TO 255 + IF ! Empty( alias( Counter ) ) + nCounter ++ + ENDIF + NEXT + + RETURN( nCounter ) + + +*------------------------------------------------------------------------------* + +STATIC FUNCTION getprocstack( ) + + LOCAL i := 2 + + DO WHILE ! Empty( procname( i ) ) + i ++ + ENDDO + + RETURN( i - 3 ) + + +*------------------------------------------------------------------------------* + +STATIC FUNCTION DosErrCode( e ) + + LOCAL Msg + + IF e:osCode > 0 + Msg := NTRIM( e:osCode ) + ": " + Left( DosErrText( e:osCode ) , 37 ) + ELSE + Msg := "(not an operating system error)" + ENDIF + + RETURN Msg + + +*------------------------------------------------------------------------------* + +/* + Function: DosErrText( ) + Author: Craig Yellick + Purpose: Provide full description of DOS error code ( see table D - 1 + in the Clipper 5.0 "Programming & Utilities Guide" ) + Returns: character string +*/ + +STATIC FUNCTION DosErrText( n ) + + LOCAL desc_ := { "Invalid function number" , ; // 1 + "File not found" , ; // 2 + "Path not found" , ; // 3 + "Too many files open (no handles left)" , ; // 4 + "Access denied" , ; // 5 + "Invalid handle" , ; // 6 + "Memory control blocks destroyed (oh, my)", ; // 7 + "Insufficient memory" , ; // 8 + "Invalid memory block address" , ; // 9 + "Invalid environment" , ; // 10 + "Invalid format" , ; // 11 + "Invalid access code" , ; // 12 + "Invalid data" , ; // 13 + , ; // 14 + "Invalid drive was specified" , ; // 15 + "Attempt to remove the current directory" , ; // 16 + "Not same device" , ; // 17 + "No more files" , ; // 18 + "Attempt to write on write-protected diskette", ; // 19 + "Unknown unit" , ; // 20 + "Drive not ready" , ; // 21 + "Unknown command" , ; // 22 + "Data error (CRC)" , ; // 23 + "Bad request structure length" , ; // 24 + "Seek error" , ; // 25 + "Unknown media type" , ; // 26 + "Sector not found" , ; // 27 + "Printer out of paper" , ; // 28 + "Write fault" , ; // 29 + "Read fault" , ; // 30 + "General failure" , ; // 31 + "Sharing violation" , ; // 32 + "Lock violation" , ; // 33 + "Invalid disk change" , ; // 34 + "FCB unavailable" , ; // 35 + "Sharing buffer overflow" , ; // 36 + , , , , , , , , , , , , , ; // 37-49 + "Network request not supported" , ; // 50 + "Remote computer not listening" , ; // 51 + "Duplicate name on network" , ; // 52 + "Network name not found" , ; // 53 + "Network busy" , ; // 54 + "Network device no longer exists" , ; // 55 + "Network BIOS command limit exceeded" , ; // 56 + "Network adapter hardware error" , ; // 57 + "Incorrect response from network" , ; // 58 + "Unexpected network error" , ; // 59 + "Incompatible remote adapter" , ; // 60 + "Print queue full" , ; // 61 + "Not enough space for print file" , ; // 62 + "Print file deleted (not enough space)" , ; // 63 + "Network name deleted" , ; // 64 + "Access denied" , ; // 65 + "Network device type incorrect" , ; // 66 + "Network name not found" , ; // 67 + "Network name limit exceeded" , ; // 68 + "Network BIOS session limit exceeded" , ; // 69 + "Temporarily paused" , ; // 70 + "Network request not accepted" , ; // 71 + "Print or disk redirection paused" , ; // 72 + , , , , , , , ; // 73-79 + "File already exists" , ; // 80 + , ; // 81 + "Cannot make directory entry" , ; // 82 + "Fail on INT 24h" , ; // 83 + "Too many redirections" , ; // 84 + "Duplicate redirection" , ; // 85 + "Invalid password" , ; // 86 + "Invalid parameter" , ; // 87 + "Network device fault" , ; // 88 + ; + "Undefined or reserved error code!" ; // +1 + } + + /* + Check that code number is within known upper limit, + AND that a description is available For it. + */ +/* + IF ( n > ( Len( desc_ ) - 1 ) ) .OR. ( desc_[ n ] == NIL ) + n := Len( desc_ ) + ENDIF +*/ + IF ( ( n < 1 ) .OR. n > ( Len( desc_ ) - 1 ) ) .OR. ( desc_[ n ] == NIL ) + n := Len( desc_ ) + ENDIF + + RETURN desc_[ n ] + + +*------------------------------------------------------------------------------* + +STATIC FUNCTION GenCodeText( n ) + + LOCAL desc_ := { "EG_ARG", ; // 1 + "EG_BOUND" , ; // 2 + "EG_STROVERFLOW" , ; // 3 + "EG_NUMOVERFLOW" , ; // 4 + "EG_ZERODIV" , ; // 5 + "EG_NUMERR" , ; // 6 + "EG_SYNTAX" , ; // 7 + "EG_COMPLEXITY" , ; // 8 + , , ; // 9-10 + "EG_MEM" , ; // 11 + "EG_NOFUNC" , ; // 12 + "EG_NOMETHOD" , ; // 13 + "EG_NOVAR" , ; // 14 + "EG_NOALIAS" , ; // 15 + "EG_NOVARMETHOD" , ; // 16 + "EG_BADALIAS" , ; // 17 (new w/ 5.01a) + "EG_DUPALIAS" , ; // 18 (new w/ 5.01a) + , ; // 19 + "EG_CREATE" , ; // 20 + "EG_OPEN" , ; // 21 + "EG_CLOSE" , ; // 22 + "EG_READ" , ; // 23 + "EG_WRITE" , ; // 24 + "EG_PRINT" , ; // 25 + , , , , ; // 26-29 + "EG_UNSUPPORTED" , ; // 30 + "EG_LIMIT" , ; // 31 + "EG_CORRUPTION" , ; // 32 + "EG_DATATYPE" , ; // 33 + "EG_DATAWIDTH" , ; // 34 + "EG_NOTABLE" , ; // 35 + "EG_NOORDER" , ; // 36 + "EG_SHARED" , ; // 37 + "EG_UNLOCKED" , ; // 38 + "EG_READONLY" , ; // 39 + "EG_APPENDLOCK" , ; // 40 + ; + "Unknown or reserved" ; // +1 + } + + /* + Check that code number is within known upper limit, + AND that a description is available For it. + */ +/* + IF ( n > ( Len( desc_ ) - 1 ) ) .OR. ( desc_[ n ] == NIL ) + n := Len( desc_ ) + ENDIF +*/ + IF ( ( n < 1 ) .OR. n > ( Len( desc_ ) - 1 ) ) .OR. ( desc_[ n ] == NIL ) + n := Len( desc_ ) + ENDIF + + + RETURN NTRIM( n ) + ": " + desc_[ n ] + + +*------------------------------------------------------------------------------* + +STATIC FUNCTION eAlert( cMsg, aChoices, cDetail ) + + LOCAL aDlg, i, j, n, aWid, aChoose, aMsg + LOCAL hWnd, hDC + LOCAL lErr := .F., e, w , h, t := 0, cTitle, Msgh, ButWidth + LOCAL crPos := 0, txth := 0, atm := { } + LOCAL isDetail := .F. + + IF ValType( cMsg ) != "C" + cMsg := asString( cMsg ) + ENDIF + cTitle := 'Alert' + + IF aChoices == NIL + aChoices := { "&Ok" } + ENDIF + + aAdd( achoices, "&Details >>" ) + + cMsg := StrTran( cMsg, ";", CR ) + + IF ( crPos := at( CR, cMsg ) ) > 0 + cTitle := Left( cMsg, crPos - 1 ) + cMsg := SubStr( cMsg, crPos + 1 ) + ENDIF + + hWnd := GetDesktopWindow( ) // default parent + hDC := GetDC( hWnd ) + + //------------- total width without buttons + + w := GetTextExtentPoint32( hDC, AllTrim( cTitle ) ) [ 1 ] + aMsg := str2a( cMsg, CR ) + AEVAL( aMsg, { | x, Y | w := Max( w, GetTextExtentPoint32( hDC, AllTrim( x ) ) [ 1 ] ) } ) + w += 20 + + //--------- total width of choices, also add "&" to the choices (if needed) + + n := Len( aChoices ) + aChoose := array( n ) + + txth := 8 //ATM[TM_Height] + Msgh := Len( aMsg ) * txth + FOR i = 1 TO n + ButWidth := Max( 20, GetTextExtentpoint32( hDC, aChoices[ i ] ) [ 1 ] + 6 ) + t := Max( t, ButWidth ) + aChoose[ i ] := IF( at( "&", aChoices[ i ] ) == 0, "&" + aChoices[ i ] , aChoices[ i ] ) + NEXT i + + ReleaseDC( , hDC ) + + ButWidth := t / 2 + t *= ( n + 1 ) + w := Max( Max( w, t ) + 40, 500 ) // minimum dlg width + h := Msgh + 33 + w /= 2 + + //----------- create dialog + + aDlg = MakeDlgTemplate( cTitle, ; + WS_CAPTION + DS_MODALFRAME + WS_VISIBLE + 4 + WS_POPUP + DS_SETFONT , ; + 0, 0, w, h, 8, 'MS Sans Serif' ) + + FOR i := 1 TO n + aDlg = AddDlgItem( aDlg, i, "BUTTON", ; + BS_PUSHBUTTON + WS_TABSTOP + WS_CHILD + WS_VISIBLE, ; + w - ( n - i ) * ( ButWidth + 5 ) - ButWidth - 5, h - 18, ButWidth, 14, ; + aChoose[ i ] ) + NEXT i + + aDlg = AddDlgItem( aDlg, - 1, "STATIC", ; + SS_CENTER + WS_CHILD + WS_VISIBLE, ; + 10, 8, w - 20, Msgh, ; + cMsg ) + + aDlg = AddDlgItem( aDlg, - 1, "BUTTON", ; + BS_GROUPBOX + WS_CHILD + WS_VISIBLE, ; + 5, 1, w - 10, Msgh + 10, ; + "" ) + + aDlg = AddDlgItem( aDlg, 101, "EDIT", ; + WS_CHILD + WS_VISIBLE + WS_BORDER + ES_MULTILINE + ES_READONLY + WS_VSCROLL + WS_TABSTOP, ; + 5, h + 1, w - 10, 115, ; + cDetail ) + + MessageBeep( MB_ICONHAND ) + i := DialogBox( , aDlg, hWnd, { | hDlg, nMsg, nwParam, nlParam | ; + eAlertProc( hDlg, nMsg, nwParam, nlParam, @isDetail, hWnd, n ) } ) + SetFocus( hWnd ) + + RETURN i + + +*------------------------------------------------------------------------------* + +STATIC FUNCTION eAlertProc( hDlg, nMsg, nwParam, nlParam, isDetail, hWnd, n ) + + LOCAL aRect + + DO CASE + CASE nMsg == WM_INITDIALOG + CenterWindow( hDlg, , , hWnd ) + SetOnTop( hDlg, HWND_TOPMOST ) + RETURN( 1 ) + + CASE nMsg == WM_COMMAND + IF 'Detail' $ GetDlgItemText( hDlg, nwParam ) + aRect := getwindowrect( hDlg ) + IF isDetail + SetDlgItemText( hDlg, nwParam, '&Detail >>' ) + MoveWindow( hDlg, aRect[ 1 ] , aRect[ 2 ] , aRect[ 3 ] - aRect[ 1 ] , aRect[ 4 ] - aRect[ 2 ] - 200, .T. ) + isDetail := .F. + ELSE + SetDlgItemText( hDlg, nwParam, '<< &Detail' ) + MoveWindow( hDlg, aRect[ 1 ] , aRect[ 2 ] , aRect[ 3 ] - aRect[ 1 ] , aRect[ 4 ] - aRect[ 2 ] + 200, .T. ) + isDetail := .T. + ENDIF + ELSE + IF nwParam > 0 .AND. nwParam < n + EndDialog( hDlg, nwParam ) + ENDIF + ENDIF + + ENDCASE + + RETURN( 0 ) + + diff --git a/harbour/contrib/what32/wininet.ch b/harbour/contrib/what32/wininet.ch index 290191af9e..fde29c5e5a 100644 --- a/harbour/contrib/what32/wininet.ch +++ b/harbour/contrib/what32/wininet.ch @@ -1,1082 +1,1082 @@ -/* - * $Id: wininet.CH 8045 2007-11-25 18:36:59Z vouchcac $ - */ - -// -// Internet APIs -// - -// -// manifests -// - -#define INTERNET_INVALID_PORT_NUMBER 0 // use the protocol-specific default - -#define INTERNET_DEFAULT_FTP_PORT 21 // default for FTP servers -#define INTERNET_DEFAULT_GOPHER_PORT 70 // " " gopher " -#define INTERNET_DEFAULT_HTTP_PORT 80 // " " HTTP " -#define INTERNET_DEFAULT_HTTPS_PORT 443 // " " HTTPS " -#define INTERNET_DEFAULT_SOCKS_PORT 1080 // default for SOCKS firewall servers. - - -// -// maximum field lengths (arbitrary) -// - -#define INTERNET_MAX_HOST_NAME_LENGTH 256 -#define INTERNET_MAX_USER_NAME_LENGTH 128 -#define INTERNET_MAX_PASSWORD_LENGTH 128 -#define INTERNET_MAX_PORT_NUMBER_LENGTH 5 // INTERNET_PORT is unsigned short -#define INTERNET_MAX_PORT_NUMBER_VALUE 65535 // maximum unsigned short value -#define INTERNET_MAX_PATH_LENGTH 2048 -#define INTERNET_MAX_SCHEME_LENGTH 32 // longest protocol name length - - - -// -// values returned by InternetQueryOption() with INTERNET_OPTION_KEEP_CONNECTION: -// - -#define INTERNET_KEEP_ALIVE_UNKNOWN ((DWORD)-1) -#define INTERNET_KEEP_ALIVE_ENABLED 1 -#define INTERNET_KEEP_ALIVE_DISABLED 0 - -// -// flags returned by InternetQueryOption() with INTERNET_OPTION_REQUEST_FLAGS -// - -#define INTERNET_REQFLAG_FROM_CACHE 0x00000001 // response came from cache -#define INTERNET_REQFLAG_ASYNC 0x00000002 // request was made asynchronously -#define INTERNET_REQFLAG_VIA_PROXY 0x00000004 // request was made via a proxy -#define INTERNET_REQFLAG_NO_HEADERS 0x00000008 // orginal response contained no headers -#define INTERNET_REQFLAG_PASSIVE 0x00000010 // FTP: passive-mode connection -#define INTERNET_REQFLAG_CACHE_WRITE_DISABLED 0x00000040 // HTTPS: this request not cacheable -#define INTERNET_REQFLAG_NET_TIMEOUT 0x00000080 // w/ _FROM_CACHE: net request timed out - -// -// flags common to open functions (not InternetOpen()): -// - -#define INTERNET_FLAG_RELOAD 0x80000000 // retrieve the original item - -// -// flags for InternetOpenUrl(): -// - -#define INTERNET_FLAG_RAW_DATA 0x40000000 // FTP/gopher find: receive the item as raw (structured) data -#define INTERNET_FLAG_EXISTING_CONNECT 0x20000000 // FTP: use existing InternetConnect handle for server if possible - -// -// flags for InternetOpen(): -// - -#define INTERNET_FLAG_ASYNC 0x10000000 // this request is asynchronous (where supported) - -// -// protocol-specific flags: -// - -#define INTERNET_FLAG_PASSIVE 0x08000000 // used for FTP connections - -// -// additional cache flags -// - -#define INTERNET_FLAG_NO_CACHE_WRITE 0x04000000 // don't write this item to the cache -#define INTERNET_FLAG_DONT_CACHE INTERNET_FLAG_NO_CACHE_WRITE -#define INTERNET_FLAG_MAKE_PERSISTENT 0x02000000 // make this item persistent in cache -#define INTERNET_FLAG_FROM_CACHE 0x01000000 // use offline semantics -#define INTERNET_FLAG_OFFLINE INTERNET_FLAG_FROM_CACHE - -// -// additional flags -// - -#define INTERNET_FLAG_SECURE 0x00800000 // use PCT/SSL if applicable (HTTP) -#define INTERNET_FLAG_KEEP_CONNECTION 0x00400000 // use keep-alive semantics -#define INTERNET_FLAG_NO_AUTO_REDIRECT 0x00200000 // don't handle redirections automatically -#define INTERNET_FLAG_READ_PREFETCH 0x00100000 // do background read prefetch -#define INTERNET_FLAG_NO_COOKIES 0x00080000 // no automatic cookie handling -#define INTERNET_FLAG_NO_AUTH 0x00040000 // no automatic authentication handling -#define INTERNET_FLAG_CACHE_IF_NET_FAIL 0x00010000 // return cache file if net request fails - -// -// Security Ignore Flags, Allow HttpOpenRequest to overide -// Secure Channel (SSL/PCT) failures of the following types. -// - -#define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP 0x00008000 // ex: https:// to http:// -#define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS 0x00004000 // ex: http:// to https:// -#define INTERNET_FLAG_IGNORE_CERT_DATE_INVALID 0x00002000 // expired X509 Cert. -#define INTERNET_FLAG_IGNORE_CERT_CN_INVALID 0x00001000 // bad common name in X509 Cert. - -// -// more caching flags -// - -#define INTERNET_FLAG_RESYNCHRONIZE 0x00000800 // asking wininet to update an item if it is newer -#define INTERNET_FLAG_HYPERLINK 0x00000400 // asking wininet to do hyperlinking semantic which works right for scripts -#define INTERNET_FLAG_NO_UI 0x00000200 // no cookie popup -#define INTERNET_FLAG_PRAGMA_NOCACHE 0x00000100 // asking wininet to add "pragma: no-cache" -#define INTERNET_FLAG_CACHE_ASYNC 0x00000080 // ok to perform lazy cache-write -#define INTERNET_FLAG_FORMS_SUBMIT 0x00000040 // this is a forms submit -#define INTERNET_FLAG_FWD_BACK 0x00000020 // fwd-back button op -#define INTERNET_FLAG_NEED_FILE 0x00000010 // need a file for this request -#define INTERNET_FLAG_MUST_CACHE_REQUEST INTERNET_FLAG_NEED_FILE - -// -// flags for FTP -// - -#define INTERNET_FLAG_TRANSFER_ASCII FTP_TRANSFER_TYPE_ASCII // 0x00000001 -#define INTERNET_FLAG_TRANSFER_BINARY FTP_TRANSFER_TYPE_BINARY // 0x00000002 - -#define INTERNET_ERROR_MASK_INSERT_CDROM 0x1 -#define INTERNET_ERROR_MASK_COMBINED_SEC_CERT 0x2 -#define INTERNET_ERROR_MASK_NEED_MSN_SSPI_PKG 0X4 -#define INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY 0x8 - -#define INTERNET_OPTIONS_MASK (~INTERNET_FLAGS_MASK) - -// -// common per-API flags (new APIs) -// - -#define WININET_API_FLAG_ASYNC 0x00000001 // force async operation -#define WININET_API_FLAG_SYNC 0x00000004 // force sync operation -#define WININET_API_FLAG_USE_CONTEXT 0x00000008 // use value supplied in dwContext (even if 0) - -// -// INTERNET_NO_CALLBACK - if this value is presented as the dwContext parameter -// then no call-backs will be made for that API -// - -#define INTERNET_NO_CALLBACK 0 - - -// -// Options used in INTERNET_PER_CONN_OPTON struct -// -#define INTERNET_PER_CONN_FLAGS 1 -#define INTERNET_PER_CONN_PROXY_SERVER 2 -#define INTERNET_PER_CONN_PROXY_BYPASS 3 -#define INTERNET_PER_CONN_AUTOCONFIG_URL 4 -#define INTERNET_PER_CONN_AUTODISCOVERY_FLAGS 5 - -// -// PER_CONN_FLAGS -// -#define PROXY_TYPE_DIRECT 0x00000001 // direct to net -#define PROXY_TYPE_PROXY 0x00000002 // via named proxy -#define PROXY_TYPE_AUTO_PROXY_URL 0x00000004 // autoproxy URL -#define PROXY_TYPE_AUTO_DETECT 0x00000008 // use autoproxy detection - -// -// PER_CONN_AUTODISCOVERY_FLAGS -// -#define AUTO_PROXY_FLAG_USER_SET 0x00000001 // user changed this setting -#define AUTO_PROXY_FLAG_ALWAYS_DETECT 0x00000002 // force detection even when its not needed -#define AUTO_PROXY_FLAG_DETECTION_RUN 0x00000004 // detection has been run -#define AUTO_PROXY_FLAG_MIGRATED 0x00000008 // migration has just been done -#define AUTO_PROXY_FLAG_DONT_CACHE_PROXY_RESULT 0x00000010 // don't cache result of host=proxy name -#define AUTO_PROXY_FLAG_CACHE_INIT_RUN 0x00000020 // don't initalize and run unless URL expired -#define AUTO_PROXY_FLAG_DETECTION_SUSPECT 0x00000040 // if we're on a LAN & Modem, with only one IP, bad?!? - -// -// ISO_FORCE_DISCONNECTED - if set when putting Wininet into disconnected mode, -// all outstanding requests will be aborted with a cancelled error -// - -#define ISO_FORCE_DISCONNECTED 0x00000001 - - -#define INTERNET_RFC1123_FORMAT 0 -#define INTERNET_RFC1123_BUFSIZE 30 - -// -// flags for InternetCrackUrl() and InternetCreateUrl() -// - -#define ICU_ESCAPE 0x80000000 // (un)escape URL characters -#define ICU_USERNAME 0x40000000 // use internal username & password - -// -// flags for InternetCanonicalizeUrl() and InternetCombineUrl() -// - -#define ICU_NO_ENCODE 0x20000000 // Don't convert unsafe characters to escape sequence -#define ICU_DECODE 0x10000000 // Convert %XX escape sequences to characters -#define ICU_NO_META 0x08000000 // Don't convert .. etc. meta path sequences -#define ICU_ENCODE_SPACES_ONLY 0x04000000 // Encode spaces only -#define ICU_BROWSER_MODE 0x02000000 // Special encode/decode rules for browser -#define ICU_ENCODE_PERCENT 0x00001000 // Encode any percent (ASCII25) - // signs encountered, default is to not encode percent. - -// -// access types for InternetOpen() -// - -#define INTERNET_OPEN_TYPE_PRECONFIG 0 // use registry configuration -#define INTERNET_OPEN_TYPE_DIRECT 1 // direct to net -#define INTERNET_OPEN_TYPE_PROXY 3 // via named proxy -#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 // prevent using java/script/INS - -// -// old names for access types -// - -#define PRE_CONFIG_INTERNET_ACCESS INTERNET_OPEN_TYPE_PRECONFIG -#define LOCAL_INTERNET_ACCESS INTERNET_OPEN_TYPE_DIRECT -#define CERN_PROXY_INTERNET_ACCESS INTERNET_OPEN_TYPE_PROXY - - -// -// service types for InternetConnect() -// - -#define INTERNET_SERVICE_FTP 1 -#define INTERNET_SERVICE_GOPHER 2 -#define INTERNET_SERVICE_HTTP 3 - -// -// flags for InternetReadFileEx() -// - -#define IRF_ASYNC WININET_API_FLAG_ASYNC -#define IRF_SYNC WININET_API_FLAG_SYNC -#define IRF_USE_CONTEXT WININET_API_FLAG_USE_CONTEXT -#define IRF_NO_WAIT 0x00000008 - -// -// flags for InternetSetOptionEx() -// - -#define ISO_GLOBAL 0x00000001 // modify option globally -#define ISO_REGISTRY 0x00000002 // write option to registry (where applicable) - -#define ISO_VALID_FLAGS (ISO_GLOBAL | ISO_REGISTRY) - -// -// options manifests for Internet{Query|Set}Option -// - -#define INTERNET_OPTION_CALLBACK 1 -#define INTERNET_OPTION_CONNECT_TIMEOUT 2 -#define INTERNET_OPTION_CONNECT_RETRIES 3 -#define INTERNET_OPTION_CONNECT_BACKOFF 4 -#define INTERNET_OPTION_SEND_TIMEOUT 5 -#define INTERNET_OPTION_CONTROL_SEND_TIMEOUT INTERNET_OPTION_SEND_TIMEOUT -#define INTERNET_OPTION_RECEIVE_TIMEOUT 6 -#define INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT INTERNET_OPTION_RECEIVE_TIMEOUT -#define INTERNET_OPTION_DATA_SEND_TIMEOUT 7 -#define INTERNET_OPTION_DATA_RECEIVE_TIMEOUT 8 -#define INTERNET_OPTION_HANDLE_TYPE 9 -#define INTERNET_OPTION_LISTEN_TIMEOUT 11 -#define INTERNET_OPTION_READ_BUFFER_SIZE 12 -#define INTERNET_OPTION_WRITE_BUFFER_SIZE 13 - -#define INTERNET_OPTION_ASYNC_ID 15 -#define INTERNET_OPTION_ASYNC_PRIORITY 16 - -#define INTERNET_OPTION_PARENT_HANDLE 21 -#define INTERNET_OPTION_KEEP_CONNECTION 22 -#define INTERNET_OPTION_REQUEST_FLAGS 23 -#define INTERNET_OPTION_EXTENDED_ERROR 24 - -#define INTERNET_OPTION_OFFLINE_MODE 26 -#define INTERNET_OPTION_CACHE_STREAM_HANDLE 27 -#define INTERNET_OPTION_USERNAME 28 -#define INTERNET_OPTION_PASSWORD 29 -#define INTERNET_OPTION_ASYNC 30 -#define INTERNET_OPTION_SECURITY_FLAGS 31 -#define INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT 32 -#define INTERNET_OPTION_DATAFILE_NAME 33 -#define INTERNET_OPTION_URL 34 -#define INTERNET_OPTION_SECURITY_CERTIFICATE 35 -#define INTERNET_OPTION_SECURITY_KEY_BITNESS 36 -#define INTERNET_OPTION_REFRESH 37 -#define INTERNET_OPTION_PROXY 38 -#define INTERNET_OPTION_SETTINGS_CHANGED 39 -#define INTERNET_OPTION_VERSION 40 -#define INTERNET_OPTION_USER_AGENT 41 -#define INTERNET_OPTION_END_BROWSER_SESSION 42 -#define INTERNET_OPTION_PROXY_USERNAME 43 -#define INTERNET_OPTION_PROXY_PASSWORD 44 -#define INTERNET_OPTION_CONTEXT_VALUE 45 -#define INTERNET_OPTION_CONNECT_LIMIT 46 -#define INTERNET_OPTION_SECURITY_SELECT_CLIENT_CERT 47 -#define INTERNET_OPTION_POLICY 48 -#define INTERNET_OPTION_DISCONNECTED_TIMEOUT 49 -#define INTERNET_OPTION_CONNECTED_STATE 50 -#define INTERNET_OPTION_IDLE_STATE 51 -#define INTERNET_OPTION_OFFLINE_SEMANTICS 52 -#define INTERNET_OPTION_SECONDARY_CACHE_KEY 53 -#define INTERNET_OPTION_CALLBACK_FILTER 54 -#define INTERNET_OPTION_CONNECT_TIME 55 -#define INTERNET_OPTION_SEND_THROUGHPUT 56 -#define INTERNET_OPTION_RECEIVE_THROUGHPUT 57 -#define INTERNET_OPTION_REQUEST_PRIORITY 58 -#define INTERNET_OPTION_HTTP_VERSION 59 -#define INTERNET_OPTION_RESET_URLCACHE_SESSION 60 -#define INTERNET_OPTION_ERROR_MASK 62 -#define INTERNET_OPTION_FROM_CACHE_TIMEOUT 63 -#define INTERNET_OPTION_BYPASS_EDITED_ENTRY 64 -#define INTERNET_OPTION_CODEPAGE 68 -#define INTERNET_OPTION_CACHE_TIMESTAMPS 69 -#define INTERNET_OPTION_DISABLE_AUTODIAL 70 -#define INTERNET_OPTION_MAX_CONNS_PER_SERVER 73 -#define INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER 74 -#define INTERNET_OPTION_PER_CONNECTION_OPTION 75 -#define INTERNET_OPTION_DIGEST_AUTH_UNLOAD 76 -#define INTERNET_OPTION_IGNORE_OFFLINE 77 - -#define INTERNET_FIRST_OPTION INTERNET_OPTION_CALLBACK -#define INTERNET_LAST_OPTION INTERNET_OPTION_IGNORE_OFFLINE - -// -// values for INTERNET_OPTION_PRIORITY -// - -#define INTERNET_PRIORITY_FOREGROUND 1000 - -// -// handle types -// - -#define INTERNET_HANDLE_TYPE_INTERNET 1 -#define INTERNET_HANDLE_TYPE_CONNECT_FTP 2 -#define INTERNET_HANDLE_TYPE_CONNECT_GOPHER 3 -#define INTERNET_HANDLE_TYPE_CONNECT_HTTP 4 -#define INTERNET_HANDLE_TYPE_FTP_FIND 5 -#define INTERNET_HANDLE_TYPE_FTP_FIND_HTML 6 -#define INTERNET_HANDLE_TYPE_FTP_FILE 7 -#define INTERNET_HANDLE_TYPE_FTP_FILE_HTML 8 -#define INTERNET_HANDLE_TYPE_GOPHER_FIND 9 -#define INTERNET_HANDLE_TYPE_GOPHER_FIND_HTML 10 -#define INTERNET_HANDLE_TYPE_GOPHER_FILE 11 -#define INTERNET_HANDLE_TYPE_GOPHER_FILE_HTML 12 -#define INTERNET_HANDLE_TYPE_HTTP_REQUEST 13 -#define INTERNET_HANDLE_TYPE_FILE_REQUEST 14 - -// -// values for INTERNET_OPTION_SECURITY_FLAGS -// - -// query only -#define SECURITY_FLAG_SECURE 0x00000001 // can query only -#define SECURITY_FLAG_STRENGTH_WEAK 0x10000000 -#define SECURITY_FLAG_STRENGTH_MEDIUM 0x40000000 -#define SECURITY_FLAG_STRENGTH_STRONG 0x20000000 -#define SECURITY_FLAG_UNKNOWNBIT 0x80000000 -#define SECURITY_FLAG_FORTEZZA 0x08000000 -#define SECURITY_FLAG_NORMALBITNESS SECURITY_FLAG_STRENGTH_WEAK - - - -// The following are unused -#define SECURITY_FLAG_SSL 0x00000002 -#define SECURITY_FLAG_SSL3 0x00000004 -#define SECURITY_FLAG_PCT 0x00000008 -#define SECURITY_FLAG_PCT4 0x00000010 -#define SECURITY_FLAG_IETFSSL4 0x00000020 - -// The following are for backwards compatability only. -#define SECURITY_FLAG_40BIT SECURITY_FLAG_STRENGTH_WEAK -#define SECURITY_FLAG_128BIT SECURITY_FLAG_STRENGTH_STRONG -#define SECURITY_FLAG_56BIT SECURITY_FLAG_STRENGTH_MEDIUM - -// setable flags -#define SECURITY_FLAG_IGNORE_REVOCATION 0x00000080 -#define SECURITY_FLAG_IGNORE_UNKNOWN_CA 0x00000100 -#define SECURITY_FLAG_IGNORE_WRONG_USAGE 0x00000200 - -#define SECURITY_FLAG_IGNORE_CERT_CN_INVALID INTERNET_FLAG_IGNORE_CERT_CN_INVALID -#define SECURITY_FLAG_IGNORE_CERT_DATE_INVALID INTERNET_FLAG_IGNORE_CERT_DATE_INVALID - - -#define SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTPS INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS -#define SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTP INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP - - - -// -// status manifests for Internet status callback -// - -#define INTERNET_STATUS_RESOLVING_NAME 10 -#define INTERNET_STATUS_NAME_RESOLVED 11 -#define INTERNET_STATUS_CONNECTING_TO_SERVER 20 -#define INTERNET_STATUS_CONNECTED_TO_SERVER 21 -#define INTERNET_STATUS_SENDING_REQUEST 30 -#define INTERNET_STATUS_REQUEST_SENT 31 -#define INTERNET_STATUS_RECEIVING_RESPONSE 40 -#define INTERNET_STATUS_RESPONSE_RECEIVED 41 -#define INTERNET_STATUS_CTL_RESPONSE_RECEIVED 42 -#define INTERNET_STATUS_PREFETCH 43 -#define INTERNET_STATUS_CLOSING_CONNECTION 50 -#define INTERNET_STATUS_CONNECTION_CLOSED 51 -#define INTERNET_STATUS_HANDLE_CREATED 60 -#define INTERNET_STATUS_HANDLE_CLOSING 70 -#define INTERNET_STATUS_DETECTING_PROXY 80 -#define INTERNET_STATUS_REQUEST_COMPLETE 100 -#define INTERNET_STATUS_REDIRECT 110 -#define INTERNET_STATUS_INTERMEDIATE_RESPONSE 120 -#define INTERNET_STATUS_USER_INPUT_REQUIRED 140 -#define INTERNET_STATUS_STATE_CHANGE 200 - -// -// the following can be indicated in a state change notification: -// - -#define INTERNET_STATE_CONNECTED 0x00000001 // connected state (mutually exclusive with disconnected) -#define INTERNET_STATE_DISCONNECTED 0x00000002 // disconnected from network -#define INTERNET_STATE_DISCONNECTED_BY_USER 0x00000010 // disconnected by user request -#define INTERNET_STATE_IDLE 0x00000100 // no network requests being made (by Wininet) -#define INTERNET_STATE_BUSY 0x00000200 // network requests being made (by Wininet) - - -// -// FTP -// - -// -// manifests -// - -#define FTP_TRANSFER_TYPE_UNKNOWN 0x00000000 -#define FTP_TRANSFER_TYPE_ASCII 0x00000001 -#define FTP_TRANSFER_TYPE_BINARY 0x00000002 - -#define FTP_TRANSFER_TYPE_MASK (FTP_TRANSFER_TYPE_ASCII | FTP_TRANSFER_TYPE_BINARY) - -// -// Gopher -// - -// -// manifests -// - -// -// string field lengths (in characters, not bytes) -// - -#define MAX_GOPHER_DISPLAY_TEXT 128 -#define MAX_GOPHER_SELECTOR_TEXT 256 -#define MAX_GOPHER_HOST_NAME INTERNET_MAX_HOST_NAME_LENGTH - -// -// manifests for GopherType -// - -#define GOPHER_TYPE_TEXT_FILE 0x00000001 -#define GOPHER_TYPE_DIRECTORY 0x00000002 -#define GOPHER_TYPE_CSO 0x00000004 -#define GOPHER_TYPE_ERROR 0x00000008 -#define GOPHER_TYPE_MAC_BINHEX 0x00000010 -#define GOPHER_TYPE_DOS_ARCHIVE 0x00000020 -#define GOPHER_TYPE_UNIX_UUENCODED 0x00000040 -#define GOPHER_TYPE_INDEX_SERVER 0x00000080 -#define GOPHER_TYPE_TELNET 0x00000100 -#define GOPHER_TYPE_BINARY 0x00000200 -#define GOPHER_TYPE_REDUNDANT 0x00000400 -#define GOPHER_TYPE_TN3270 0x00000800 -#define GOPHER_TYPE_GIF 0x00001000 -#define GOPHER_TYPE_IMAGE 0x00002000 -#define GOPHER_TYPE_BITMAP 0x00004000 -#define GOPHER_TYPE_MOVIE 0x00008000 -#define GOPHER_TYPE_SOUND 0x00010000 -#define GOPHER_TYPE_HTML 0x00020000 -#define GOPHER_TYPE_PDF 0x00040000 -#define GOPHER_TYPE_CALENDAR 0x00080000 -#define GOPHER_TYPE_INLINE 0x00100000 -#define GOPHER_TYPE_UNKNOWN 0x20000000 -#define GOPHER_TYPE_ASK 0x40000000 -#define GOPHER_TYPE_GOPHER_PLUS 0x80000000 - - -#define MAX_GOPHER_CATEGORY_NAME 128 // arbitrary -#define MAX_GOPHER_ATTRIBUTE_NAME 128 // " -#define MIN_GOPHER_ATTRIBUTE_LENGTH 256 // " - -// -// known gopher attribute categories. See below for ordinals -// - -#define GOPHER_INFO_CATEGORY TEXT("+INFO") -#define GOPHER_ADMIN_CATEGORY TEXT("+ADMIN") -#define GOPHER_VIEWS_CATEGORY TEXT("+VIEWS") -#define GOPHER_ABSTRACT_CATEGORY TEXT("+ABSTRACT") -#define GOPHER_VERONICA_CATEGORY TEXT("+VERONICA") - -// -// known gopher attributes. These are the attribute names as defined in the -// gopher+ protocol document -// - -#define GOPHER_ADMIN_ATTRIBUTE TEXT("Admin") -#define GOPHER_MOD_DATE_ATTRIBUTE TEXT("Mod-Date") -#define GOPHER_TTL_ATTRIBUTE TEXT("TTL") -#define GOPHER_SCORE_ATTRIBUTE TEXT("Score") -#define GOPHER_RANGE_ATTRIBUTE TEXT("Score-range") -#define GOPHER_SITE_ATTRIBUTE TEXT("Site") -#define GOPHER_ORG_ATTRIBUTE TEXT("Org") -#define GOPHER_LOCATION_ATTRIBUTE TEXT("Loc") -#define GOPHER_GEOG_ATTRIBUTE TEXT("Geog") -#define GOPHER_TIMEZONE_ATTRIBUTE TEXT("TZ") -#define GOPHER_PROVIDER_ATTRIBUTE TEXT("Provider") -#define GOPHER_VERSION_ATTRIBUTE TEXT("Version") -#define GOPHER_ABSTRACT_ATTRIBUTE TEXT("Abstract") -#define GOPHER_VIEW_ATTRIBUTE TEXT("View") -#define GOPHER_TREEWALK_ATTRIBUTE TEXT("treewalk") - -// -// identifiers for attribute strings -// - -#define GOPHER_ATTRIBUTE_ID_BASE 0xabcccc00 - -#define GOPHER_CATEGORY_ID_ALL (GOPHER_ATTRIBUTE_ID_BASE + 1) - -#define GOPHER_CATEGORY_ID_INFO (GOPHER_ATTRIBUTE_ID_BASE + 2) -#define GOPHER_CATEGORY_ID_ADMIN (GOPHER_ATTRIBUTE_ID_BASE + 3) -#define GOPHER_CATEGORY_ID_VIEWS (GOPHER_ATTRIBUTE_ID_BASE + 4) -#define GOPHER_CATEGORY_ID_ABSTRACT (GOPHER_ATTRIBUTE_ID_BASE + 5) -#define GOPHER_CATEGORY_ID_VERONICA (GOPHER_ATTRIBUTE_ID_BASE + 6) -#define GOPHER_CATEGORY_ID_ASK (GOPHER_ATTRIBUTE_ID_BASE + 7) - -#define GOPHER_CATEGORY_ID_UNKNOWN (GOPHER_ATTRIBUTE_ID_BASE + 8) - -#define GOPHER_ATTRIBUTE_ID_ALL (GOPHER_ATTRIBUTE_ID_BASE + 9) - -#define GOPHER_ATTRIBUTE_ID_ADMIN (GOPHER_ATTRIBUTE_ID_BASE + 10) -#define GOPHER_ATTRIBUTE_ID_MOD_DATE (GOPHER_ATTRIBUTE_ID_BASE + 11) -#define GOPHER_ATTRIBUTE_ID_TTL (GOPHER_ATTRIBUTE_ID_BASE + 12) -#define GOPHER_ATTRIBUTE_ID_SCORE (GOPHER_ATTRIBUTE_ID_BASE + 13) -#define GOPHER_ATTRIBUTE_ID_RANGE (GOPHER_ATTRIBUTE_ID_BASE + 14) -#define GOPHER_ATTRIBUTE_ID_SITE (GOPHER_ATTRIBUTE_ID_BASE + 15) -#define GOPHER_ATTRIBUTE_ID_ORG (GOPHER_ATTRIBUTE_ID_BASE + 16) -#define GOPHER_ATTRIBUTE_ID_LOCATION (GOPHER_ATTRIBUTE_ID_BASE + 17) -#define GOPHER_ATTRIBUTE_ID_GEOG (GOPHER_ATTRIBUTE_ID_BASE + 18) -#define GOPHER_ATTRIBUTE_ID_TIMEZONE (GOPHER_ATTRIBUTE_ID_BASE + 19) -#define GOPHER_ATTRIBUTE_ID_PROVIDER (GOPHER_ATTRIBUTE_ID_BASE + 20) -#define GOPHER_ATTRIBUTE_ID_VERSION (GOPHER_ATTRIBUTE_ID_BASE + 21) -#define GOPHER_ATTRIBUTE_ID_ABSTRACT (GOPHER_ATTRIBUTE_ID_BASE + 22) -#define GOPHER_ATTRIBUTE_ID_VIEW (GOPHER_ATTRIBUTE_ID_BASE + 23) -#define GOPHER_ATTRIBUTE_ID_TREEWALK (GOPHER_ATTRIBUTE_ID_BASE + 24) - -#define GOPHER_ATTRIBUTE_ID_UNKNOWN (GOPHER_ATTRIBUTE_ID_BASE + 25) - - -// -// HTTP -// - -// -// manifests -// - -// -// the default major/minor HTTP version numbers -// - -#define HTTP_MAJOR_VERSION 1 -#define HTTP_MINOR_VERSION 0 - -#define HTTP_VERSIONA "HTTP/1.0" -#define HTTP_VERSIONW L"HTTP/1.0" - -#ifdef UNICODE -#define HTTP_VERSION HTTP_VERSIONW -#else -#define HTTP_VERSION HTTP_VERSIONA -#endif - -// -// HttpQueryInfo info levels. Generally, there is one info level -// for each potential RFC822/HTTP/MIME header that an HTTP server -// may send as part of a request response. -// -// The HTTP_QUERY_RAW_HEADERS info level is provided for clients -// that choose to perform their own header parsing. -// - - -#define HTTP_QUERY_MIME_VERSION 0 -#define HTTP_QUERY_CONTENT_TYPE 1 -#define HTTP_QUERY_CONTENT_TRANSFER_ENCODING 2 -#define HTTP_QUERY_CONTENT_ID 3 -#define HTTP_QUERY_CONTENT_DESCRIPTION 4 -#define HTTP_QUERY_CONTENT_LENGTH 5 -#define HTTP_QUERY_CONTENT_LANGUAGE 6 -#define HTTP_QUERY_ALLOW 7 -#define HTTP_QUERY_PUBLIC 8 -#define HTTP_QUERY_DATE 9 -#define HTTP_QUERY_EXPIRES 10 -#define HTTP_QUERY_LAST_MODIFIED 11 -#define HTTP_QUERY_MESSAGE_ID 12 -#define HTTP_QUERY_URI 13 -#define HTTP_QUERY_DERIVED_FROM 14 -#define HTTP_QUERY_COST 15 -#define HTTP_QUERY_LINK 16 -#define HTTP_QUERY_PRAGMA 17 -#define HTTP_QUERY_VERSION 18 // special: part of status line -#define HTTP_QUERY_STATUS_CODE 19 // special: part of status line -#define HTTP_QUERY_STATUS_TEXT 20 // special: part of status line -#define HTTP_QUERY_RAW_HEADERS 21 // special: all headers as ASCIIZ -#define HTTP_QUERY_RAW_HEADERS_CRLF 22 // special: all headers -#define HTTP_QUERY_CONNECTION 23 -#define HTTP_QUERY_ACCEPT 24 -#define HTTP_QUERY_ACCEPT_CHARSET 25 -#define HTTP_QUERY_ACCEPT_ENCODING 26 -#define HTTP_QUERY_ACCEPT_LANGUAGE 27 -#define HTTP_QUERY_AUTHORIZATION 28 -#define HTTP_QUERY_CONTENT_ENCODING 29 -#define HTTP_QUERY_FORWARDED 30 -#define HTTP_QUERY_FROM 31 -#define HTTP_QUERY_IF_MODIFIED_SINCE 32 -#define HTTP_QUERY_LOCATION 33 -#define HTTP_QUERY_ORIG_URI 34 -#define HTTP_QUERY_REFERER 35 -#define HTTP_QUERY_RETRY_AFTER 36 -#define HTTP_QUERY_SERVER 37 -#define HTTP_QUERY_TITLE 38 -#define HTTP_QUERY_USER_AGENT 39 -#define HTTP_QUERY_WWW_AUTHENTICATE 40 -#define HTTP_QUERY_PROXY_AUTHENTICATE 41 -#define HTTP_QUERY_ACCEPT_RANGES 42 -#define HTTP_QUERY_SET_COOKIE 43 -#define HTTP_QUERY_COOKIE 44 -#define HTTP_QUERY_REQUEST_METHOD 45 // special: GET/POST etc. -#define HTTP_QUERY_REFRESH 46 -#define HTTP_QUERY_CONTENT_DISPOSITION 47 - -// -// HTTP 1.1 defined headers -// - -#define HTTP_QUERY_AGE 48 -#define HTTP_QUERY_CACHE_CONTROL 49 -#define HTTP_QUERY_CONTENT_BASE 50 -#define HTTP_QUERY_CONTENT_LOCATION 51 -#define HTTP_QUERY_CONTENT_MD5 52 -#define HTTP_QUERY_CONTENT_RANGE 53 -#define HTTP_QUERY_ETAG 54 -#define HTTP_QUERY_HOST 55 -#define HTTP_QUERY_IF_MATCH 56 -#define HTTP_QUERY_IF_NONE_MATCH 57 -#define HTTP_QUERY_IF_RANGE 58 -#define HTTP_QUERY_IF_UNMODIFIED_SINCE 59 -#define HTTP_QUERY_MAX_FORWARDS 60 -#define HTTP_QUERY_PROXY_AUTHORIZATION 61 -#define HTTP_QUERY_RANGE 62 -#define HTTP_QUERY_TRANSFER_ENCODING 63 -#define HTTP_QUERY_UPGRADE 64 -#define HTTP_QUERY_VARY 65 -#define HTTP_QUERY_VIA 66 -#define HTTP_QUERY_WARNING 67 -#define HTTP_QUERY_EXPECT 68 -#define HTTP_QUERY_PROXY_CONNECTION 69 -#define HTTP_QUERY_UNLESS_MODIFIED_SINCE 70 - - - -#define HTTP_QUERY_ECHO_REQUEST 71 -#define HTTP_QUERY_ECHO_REPLY 72 - -// These are the set of headers that should be added back to a request when -// re-doing a request after a RETRY_WITH response. -#define HTTP_QUERY_ECHO_HEADERS 73 -#define HTTP_QUERY_ECHO_HEADERS_CRLF 74 - -#define HTTP_QUERY_MAX 74 - -// -// HTTP_QUERY_CUSTOM - if this special value is supplied as the dwInfoLevel -// parameter of HttpQueryInfo() then the lpBuffer parameter contains the name -// of the header we are to query -// - -#define HTTP_QUERY_CUSTOM 65535 - -// -// HTTP_QUERY_FLAG_REQUEST_HEADERS - if this bit is set in the dwInfoLevel -// parameter of HttpQueryInfo() then the request headers will be queried for the -// request information -// - -#define HTTP_QUERY_FLAG_REQUEST_HEADERS 0x80000000 - -// -// HTTP_QUERY_FLAG_SYSTEMTIME - if this bit is set in the dwInfoLevel parameter -// of HttpQueryInfo() AND the header being queried contains date information, -// e.g. the "Expires:" header then lpBuffer will contain a SYSTEMTIME structure -// containing the date and time information converted from the header string -// - -#define HTTP_QUERY_FLAG_SYSTEMTIME 0x40000000 - -// -// HTTP_QUERY_FLAG_NUMBER - if this bit is set in the dwInfoLevel parameter of -// HttpQueryInfo(), then the value of the header will be converted to a number -// before being returned to the caller, if applicable -// - -#define HTTP_QUERY_FLAG_NUMBER 0x20000000 - -// -// HTTP_QUERY_FLAG_COALESCE - combine the values from several headers of the -// same name into the output buffer -// - -#define HTTP_QUERY_FLAG_COALESCE 0x10000000 - - -#define HTTP_QUERY_HEADER_MASK (~HTTP_QUERY_MODIFIER_FLAGS_MASK) - -// -// HTTP Response Status Codes: -// - -#define HTTP_STATUS_CONTINUE 100 // OK to continue with request -#define HTTP_STATUS_SWITCH_PROTOCOLS 101 // server has switched protocols in upgrade header - -#define HTTP_STATUS_OK 200 // request completed -#define HTTP_STATUS_CREATED 201 // object created, reason = new URI -#define HTTP_STATUS_ACCEPTED 202 // async completion (TBS) -#define HTTP_STATUS_PARTIAL 203 // partial completion -#define HTTP_STATUS_NO_CONTENT 204 // no info to return -#define HTTP_STATUS_RESET_CONTENT 205 // request completed, but clear form -#define HTTP_STATUS_PARTIAL_CONTENT 206 // partial GET furfilled - -#define HTTP_STATUS_AMBIGUOUS 300 // server couldn't decide what to return -#define HTTP_STATUS_MOVED 301 // object permanently moved -#define HTTP_STATUS_REDIRECT 302 // object temporarily moved -#define HTTP_STATUS_REDIRECT_METHOD 303 // redirection w/ new access method -#define HTTP_STATUS_NOT_MODIFIED 304 // if-modified-since was not modified -#define HTTP_STATUS_USE_PROXY 305 // redirection to proxy, location header specifies proxy to use -#define HTTP_STATUS_REDIRECT_KEEP_VERB 307 // HTTP/1.1: keep same verb - -#define HTTP_STATUS_BAD_REQUEST 400 // invalid syntax -#define HTTP_STATUS_DENIED 401 // access denied -#define HTTP_STATUS_PAYMENT_REQ 402 // payment required -#define HTTP_STATUS_FORBIDDEN 403 // request forbidden -#define HTTP_STATUS_NOT_FOUND 404 // object not found -#define HTTP_STATUS_BAD_METHOD 405 // method is not allowed -#define HTTP_STATUS_NONE_ACCEPTABLE 406 // no response acceptable to client found -#define HTTP_STATUS_PROXY_AUTH_REQ 407 // proxy authentication required -#define HTTP_STATUS_REQUEST_TIMEOUT 408 // server timed out waiting for request -#define HTTP_STATUS_CONFLICT 409 // user should resubmit with more info -#define HTTP_STATUS_GONE 410 // the resource is no longer available -#define HTTP_STATUS_LENGTH_REQUIRED 411 // the server refused to accept request w/o a length -#define HTTP_STATUS_PRECOND_FAILED 412 // precondition given in request failed -#define HTTP_STATUS_REQUEST_TOO_LARGE 413 // request entity was too large -#define HTTP_STATUS_URI_TOO_LONG 414 // request URI too long -#define HTTP_STATUS_UNSUPPORTED_MEDIA 415 // unsupported media type -#define HTTP_STATUS_RETRY_WITH 449 // retry after doing the appropriate action. - -#define HTTP_STATUS_SERVER_ERROR 500 // internal server error -#define HTTP_STATUS_NOT_SUPPORTED 501 // required not supported -#define HTTP_STATUS_BAD_GATEWAY 502 // error response received from gateway -#define HTTP_STATUS_SERVICE_UNAVAIL 503 // temporarily overloaded -#define HTTP_STATUS_GATEWAY_TIMEOUT 504 // timed out waiting for gateway -#define HTTP_STATUS_VERSION_NOT_SUP 505 // HTTP version not supported - -#define HTTP_STATUS_FIRST HTTP_STATUS_CONTINUE -#define HTTP_STATUS_LAST HTTP_STATUS_VERSION_NOT_SUP - - -// -// values for dwModifiers parameter of HttpAddRequestHeaders() -// - -#define HTTP_ADDREQ_INDEX_MASK 0x0000FFFF -#define HTTP_ADDREQ_FLAGS_MASK 0xFFFF0000 - -// -// HTTP_ADDREQ_FLAG_ADD_IF_NEW - the header will only be added if it doesn't -// already exist -// - -#define HTTP_ADDREQ_FLAG_ADD_IF_NEW 0x10000000 - -// -// HTTP_ADDREQ_FLAG_ADD - if HTTP_ADDREQ_FLAG_REPLACE is set but the header is -// not found then if this flag is set, the header is added anyway, so long as -// there is a valid header-value -// - -#define HTTP_ADDREQ_FLAG_ADD 0x20000000 - -// -// HTTP_ADDREQ_FLAG_COALESCE - coalesce headers with same name. e.g. -// "Accept: text/*" and "Accept: audio/*" with this flag results in a single -// header: "Accept: text/*, audio/*" -// - -#define HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA 0x40000000 -#define HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON 0x01000000 -#define HTTP_ADDREQ_FLAG_COALESCE HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA - -// -// HTTP_ADDREQ_FLAG_REPLACE - replaces the specified header. Only one header can -// be supplied in the buffer. If the header to be replaced is not the first -// in a list of headers with the same name, then the relative index should be -// supplied in the low 8 bits of the dwModifiers parameter. If the header-value -// part is missing, then the header is removed -// - -#define HTTP_ADDREQ_FLAG_REPLACE 0x80000000 - -// -// flags for HttpSendRequestEx(), HttpEndRequest() -// - -#define HSR_ASYNC WININET_API_FLAG_ASYNC // force async -#define HSR_SYNC WININET_API_FLAG_SYNC // force sync -#define HSR_USE_CONTEXT WININET_API_FLAG_USE_CONTEXT // use dwContext value -#define HSR_INITIATE 0x00000008 // iterative operation (completed by HttpEndRequest) -#define HSR_DOWNLOAD 0x00000010 // download to file -#define HSR_CHUNKED 0x00000020 // operation is send of chunked data - - -#define FLAG_ICC_FORCE_CONNECTION 0x00000001 - -// -// Internet UI -// - -// -// InternetErrorDlg - Provides UI for certain Errors. -// - -#define FLAGS_ERROR_UI_FILTER_FOR_ERRORS 0x01 -#define FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS 0x02 -#define FLAGS_ERROR_UI_FLAGS_GENERATE_DATA 0x04 -#define FLAGS_ERROR_UI_FLAGS_NO_UI 0x08 -#define FLAGS_ERROR_UI_SERIALIZE_DIALOGS 0x10 - -// -// If SERIALIZE_DIALOGS flag set, client should implement thread-safe non-blocking callback... -// - -// -// Internet API error returns -// - -#define INTERNET_ERROR_BASE 12000 - -#define ERROR_INTERNET_OUT_OF_HANDLES (INTERNET_ERROR_BASE + 1) -#define ERROR_INTERNET_TIMEOUT (INTERNET_ERROR_BASE + 2) -#define ERROR_INTERNET_EXTENDED_ERROR (INTERNET_ERROR_BASE + 3) -#define ERROR_INTERNET_INTERNAL_ERROR (INTERNET_ERROR_BASE + 4) -#define ERROR_INTERNET_INVALID_URL (INTERNET_ERROR_BASE + 5) -#define ERROR_INTERNET_UNRECOGNIZED_SCHEME (INTERNET_ERROR_BASE + 6) -#define ERROR_INTERNET_NAME_NOT_RESOLVED (INTERNET_ERROR_BASE + 7) -#define ERROR_INTERNET_PROTOCOL_NOT_FOUND (INTERNET_ERROR_BASE + 8) -#define ERROR_INTERNET_INVALID_OPTION (INTERNET_ERROR_BASE + 9) -#define ERROR_INTERNET_BAD_OPTION_LENGTH (INTERNET_ERROR_BASE + 10) -#define ERROR_INTERNET_OPTION_NOT_SETTABLE (INTERNET_ERROR_BASE + 11) -#define ERROR_INTERNET_SHUTDOWN (INTERNET_ERROR_BASE + 12) -#define ERROR_INTERNET_INCORRECT_USER_NAME (INTERNET_ERROR_BASE + 13) -#define ERROR_INTERNET_INCORRECT_PASSWORD (INTERNET_ERROR_BASE + 14) -#define ERROR_INTERNET_LOGIN_FAILURE (INTERNET_ERROR_BASE + 15) -#define ERROR_INTERNET_INVALID_OPERATION (INTERNET_ERROR_BASE + 16) -#define ERROR_INTERNET_OPERATION_CANCELLED (INTERNET_ERROR_BASE + 17) -#define ERROR_INTERNET_INCORRECT_HANDLE_TYPE (INTERNET_ERROR_BASE + 18) -#define ERROR_INTERNET_INCORRECT_HANDLE_STATE (INTERNET_ERROR_BASE + 19) -#define ERROR_INTERNET_NOT_PROXY_REQUEST (INTERNET_ERROR_BASE + 20) -#define ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND (INTERNET_ERROR_BASE + 21) -#define ERROR_INTERNET_BAD_REGISTRY_PARAMETER (INTERNET_ERROR_BASE + 22) -#define ERROR_INTERNET_NO_DIRECT_ACCESS (INTERNET_ERROR_BASE + 23) -#define ERROR_INTERNET_NO_CONTEXT (INTERNET_ERROR_BASE + 24) -#define ERROR_INTERNET_NO_CALLBACK (INTERNET_ERROR_BASE + 25) -#define ERROR_INTERNET_REQUEST_PENDING (INTERNET_ERROR_BASE + 26) -#define ERROR_INTERNET_INCORRECT_FORMAT (INTERNET_ERROR_BASE + 27) -#define ERROR_INTERNET_ITEM_NOT_FOUND (INTERNET_ERROR_BASE + 28) -#define ERROR_INTERNET_CANNOT_CONNECT (INTERNET_ERROR_BASE + 29) -#define ERROR_INTERNET_CONNECTION_ABORTED (INTERNET_ERROR_BASE + 30) -#define ERROR_INTERNET_CONNECTION_RESET (INTERNET_ERROR_BASE + 31) -#define ERROR_INTERNET_FORCE_RETRY (INTERNET_ERROR_BASE + 32) -#define ERROR_INTERNET_INVALID_PROXY_REQUEST (INTERNET_ERROR_BASE + 33) -#define ERROR_INTERNET_NEED_UI (INTERNET_ERROR_BASE + 34) - -#define ERROR_INTERNET_HANDLE_EXISTS (INTERNET_ERROR_BASE + 36) -#define ERROR_INTERNET_SEC_CERT_DATE_INVALID (INTERNET_ERROR_BASE + 37) -#define ERROR_INTERNET_SEC_CERT_CN_INVALID (INTERNET_ERROR_BASE + 38) -#define ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR (INTERNET_ERROR_BASE + 39) -#define ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR (INTERNET_ERROR_BASE + 40) -#define ERROR_INTERNET_MIXED_SECURITY (INTERNET_ERROR_BASE + 41) -#define ERROR_INTERNET_CHG_POST_IS_NON_SECURE (INTERNET_ERROR_BASE + 42) -#define ERROR_INTERNET_POST_IS_NON_SECURE (INTERNET_ERROR_BASE + 43) -#define ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED (INTERNET_ERROR_BASE + 44) -#define ERROR_INTERNET_INVALID_CA (INTERNET_ERROR_BASE + 45) -#define ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP (INTERNET_ERROR_BASE + 46) -#define ERROR_INTERNET_ASYNC_THREAD_FAILED (INTERNET_ERROR_BASE + 47) -#define ERROR_INTERNET_REDIRECT_SCHEME_CHANGE (INTERNET_ERROR_BASE + 48) -#define ERROR_INTERNET_DIALOG_PENDING (INTERNET_ERROR_BASE + 49) -#define ERROR_INTERNET_RETRY_DIALOG (INTERNET_ERROR_BASE + 50) -#define ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR (INTERNET_ERROR_BASE + 52) -#define ERROR_INTERNET_INSERT_CDROM (INTERNET_ERROR_BASE + 53) -#define ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED (INTERNET_ERROR_BASE + 54) -#define ERROR_INTERNET_SEC_CERT_ERRORS (INTERNET_ERROR_BASE + 55) -#define ERROR_INTERNET_SEC_CERT_NO_REV (INTERNET_ERROR_BASE + 56) -#define ERROR_INTERNET_SEC_CERT_REV_FAILED (INTERNET_ERROR_BASE + 57) - -// -// FTP API errors -// - -#define ERROR_FTP_TRANSFER_IN_PROGRESS (INTERNET_ERROR_BASE + 110) -#define ERROR_FTP_DROPPED (INTERNET_ERROR_BASE + 111) -#define ERROR_FTP_NO_PASSIVE_MODE (INTERNET_ERROR_BASE + 112) - -// -// gopher API errors -// - -#define ERROR_GOPHER_PROTOCOL_ERROR (INTERNET_ERROR_BASE + 130) -#define ERROR_GOPHER_NOT_FILE (INTERNET_ERROR_BASE + 131) -#define ERROR_GOPHER_DATA_ERROR (INTERNET_ERROR_BASE + 132) -#define ERROR_GOPHER_END_OF_DATA (INTERNET_ERROR_BASE + 133) -#define ERROR_GOPHER_INVALID_LOCATOR (INTERNET_ERROR_BASE + 134) -#define ERROR_GOPHER_INCORRECT_LOCATOR_TYPE (INTERNET_ERROR_BASE + 135) -#define ERROR_GOPHER_NOT_GOPHER_PLUS (INTERNET_ERROR_BASE + 136) -#define ERROR_GOPHER_ATTRIBUTE_NOT_FOUND (INTERNET_ERROR_BASE + 137) -#define ERROR_GOPHER_UNKNOWN_LOCATOR (INTERNET_ERROR_BASE + 138) - -// -// HTTP API errors -// - -#define ERROR_HTTP_HEADER_NOT_FOUND (INTERNET_ERROR_BASE + 150) -#define ERROR_HTTP_DOWNLEVEL_SERVER (INTERNET_ERROR_BASE + 151) -#define ERROR_HTTP_INVALID_SERVER_RESPONSE (INTERNET_ERROR_BASE + 152) -#define ERROR_HTTP_INVALID_HEADER (INTERNET_ERROR_BASE + 153) -#define ERROR_HTTP_INVALID_QUERY_REQUEST (INTERNET_ERROR_BASE + 154) -#define ERROR_HTTP_HEADER_ALREADY_EXISTS (INTERNET_ERROR_BASE + 155) -#define ERROR_HTTP_REDIRECT_FAILED (INTERNET_ERROR_BASE + 156) -#define ERROR_HTTP_NOT_REDIRECTED (INTERNET_ERROR_BASE + 160) -#define ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION (INTERNET_ERROR_BASE + 161) -#define ERROR_HTTP_COOKIE_DECLINED (INTERNET_ERROR_BASE + 162) -#define ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION (INTERNET_ERROR_BASE + 168) - -// -// additional Internet API error codes -// - -#define ERROR_INTERNET_SECURITY_CHANNEL_ERROR (INTERNET_ERROR_BASE + 157) -#define ERROR_INTERNET_UNABLE_TO_CACHE_FILE (INTERNET_ERROR_BASE + 158) -#define ERROR_INTERNET_TCPIP_NOT_INSTALLED (INTERNET_ERROR_BASE + 159) -#define ERROR_INTERNET_DISCONNECTED (INTERNET_ERROR_BASE + 163) -#define ERROR_INTERNET_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 164) -#define ERROR_INTERNET_PROXY_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 165) - -#define ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT (INTERNET_ERROR_BASE + 166) -#define ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT (INTERNET_ERROR_BASE + 167) -#define ERROR_INTERNET_SEC_INVALID_CERT (INTERNET_ERROR_BASE + 169) -#define ERROR_INTERNET_SEC_CERT_REVOKED (INTERNET_ERROR_BASE + 170) - -// InternetAutodial specific errors - -#define ERROR_INTERNET_FAILED_DUETOSECURITYCHECK (INTERNET_ERROR_BASE + 171) -#define ERROR_INTERNET_NOT_INITIALIZED (INTERNET_ERROR_BASE + 172) -#define ERROR_INTERNET_NEED_MSN_SSPI_PKG (INTERNET_ERROR_BASE + 173) -#define ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY (INTERNET_ERROR_BASE + 174) - - -#define INTERNET_ERROR_LAST ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY - - -// -// URLCACHE APIs -// - -// -// datatype definitions. -// - -// -// cache entry type flags. -// - -#define NORMAL_CACHE_ENTRY 0x00000001 -#define STICKY_CACHE_ENTRY 0x00000004 -#define EDITED_CACHE_ENTRY 0x00000008 -#define TRACK_OFFLINE_CACHE_ENTRY 0x00000010 -#define TRACK_ONLINE_CACHE_ENTRY 0x00000020 -#define SPARSE_CACHE_ENTRY 0x00010000 -#define COOKIE_CACHE_ENTRY 0x00100000 -#define URLHISTORY_CACHE_ENTRY 0x00200000 - - -// -// INTERNET_CACHE_ENTRY_INFO - -// - - -// -// Cache Group Flags -// -#define CACHEGROUP_ATTRIBUTE_GET_ALL 0xffffffff -#define CACHEGROUP_ATTRIBUTE_BASIC 0x00000001 -#define CACHEGROUP_ATTRIBUTE_FLAG 0x00000002 -#define CACHEGROUP_ATTRIBUTE_TYPE 0x00000004 -#define CACHEGROUP_ATTRIBUTE_QUOTA 0x00000008 -#define CACHEGROUP_ATTRIBUTE_GROUPNAME 0x00000010 -#define CACHEGROUP_ATTRIBUTE_STORAGE 0x00000020 - -#define CACHEGROUP_FLAG_NONPURGEABLE 0x00000001 -#define CACHEGROUP_FLAG_GIDONLY 0x00000004 - -#define CACHEGROUP_FLAG_FLUSHURL_ONDELETE 0x00000002 - -#define CACHEGROUP_SEARCH_ALL 0x00000000 -#define CACHEGROUP_SEARCH_BYURL 0x00000001 - -#define CACHEGROUP_TYPE_INVALID 0x00000001 - -// -// INTERNET_CACHE_GROUP_INFO -// - -#define GROUPNAME_MAX_LENGTH 120 -#define GROUP_OWNER_STORAGE_SIZE 4 - - -#define CACHE_ENTRY_ATTRIBUTE_FC 0x00000004 -#define CACHE_ENTRY_HITRATE_FC 0x00000010 -#define CACHE_ENTRY_MODTIME_FC 0x00000040 -#define CACHE_ENTRY_EXPTIME_FC 0x00000080 -#define CACHE_ENTRY_ACCTIME_FC 0x00000100 -#define CACHE_ENTRY_SYNCTIME_FC 0x00000200 -#define CACHE_ENTRY_HEADERINFO_FC 0x00000400 -#define CACHE_ENTRY_EXEMPT_DELTA_FC 0x00000800 - - -// Flags for InternetAutodial -#define INTERNET_AUTODIAL_FORCE_ONLINE 1 -#define INTERNET_AUTODIAL_FORCE_UNATTENDED 2 -#define INTERNET_AUTODIAL_FAILIFSECURITYCHECK 4 - - -// Flags for InternetGetConnectedState and Ex -#define INTERNET_CONNECTION_MODEM 0x01 -#define INTERNET_CONNECTION_LAN 0x02 -#define INTERNET_CONNECTION_PROXY 0x04 -#define INTERNET_CONNECTION_MODEM_BUSY 0x08 /* no longer used */ -#define INTERNET_RAS_INSTALLED 0x10 -#define INTERNET_CONNECTION_OFFLINE 0x20 -#define INTERNET_CONNECTION_CONFIGURED 0x40 - -// Flags for custom dial handler -#define INTERNET_CUSTOMDIAL_CONNECT 0 -#define INTERNET_CUSTOMDIAL_UNATTENDED 1 -#define INTERNET_CUSTOMDIAL_DISCONNECT 2 -#define INTERNET_CUSTOMDIAL_SHOWOFFLINE 4 - -// Custom dial handler supported functionality flags -#define INTERNET_CUSTOMDIAL_SAFE_FOR_UNATTENDED 1 -#define INTERNET_CUSTOMDIAL_WILL_SUPPLY_STATE 2 -#define INTERNET_CUSTOMDIAL_CAN_HANGUP 4 - +/* + * $Id$ + */ + +// +// Internet APIs +// + +// +// manifests +// + +#define INTERNET_INVALID_PORT_NUMBER 0 // use the protocol-specific default + +#define INTERNET_DEFAULT_FTP_PORT 21 // default for FTP servers +#define INTERNET_DEFAULT_GOPHER_PORT 70 // " " gopher " +#define INTERNET_DEFAULT_HTTP_PORT 80 // " " HTTP " +#define INTERNET_DEFAULT_HTTPS_PORT 443 // " " HTTPS " +#define INTERNET_DEFAULT_SOCKS_PORT 1080 // default for SOCKS firewall servers. + + +// +// maximum field lengths (arbitrary) +// + +#define INTERNET_MAX_HOST_NAME_LENGTH 256 +#define INTERNET_MAX_USER_NAME_LENGTH 128 +#define INTERNET_MAX_PASSWORD_LENGTH 128 +#define INTERNET_MAX_PORT_NUMBER_LENGTH 5 // INTERNET_PORT is unsigned short +#define INTERNET_MAX_PORT_NUMBER_VALUE 65535 // maximum unsigned short value +#define INTERNET_MAX_PATH_LENGTH 2048 +#define INTERNET_MAX_SCHEME_LENGTH 32 // longest protocol name length + + + +// +// values returned by InternetQueryOption() with INTERNET_OPTION_KEEP_CONNECTION: +// + +#define INTERNET_KEEP_ALIVE_UNKNOWN ((DWORD)-1) +#define INTERNET_KEEP_ALIVE_ENABLED 1 +#define INTERNET_KEEP_ALIVE_DISABLED 0 + +// +// flags returned by InternetQueryOption() with INTERNET_OPTION_REQUEST_FLAGS +// + +#define INTERNET_REQFLAG_FROM_CACHE 0x00000001 // response came from cache +#define INTERNET_REQFLAG_ASYNC 0x00000002 // request was made asynchronously +#define INTERNET_REQFLAG_VIA_PROXY 0x00000004 // request was made via a proxy +#define INTERNET_REQFLAG_NO_HEADERS 0x00000008 // orginal response contained no headers +#define INTERNET_REQFLAG_PASSIVE 0x00000010 // FTP: passive-mode connection +#define INTERNET_REQFLAG_CACHE_WRITE_DISABLED 0x00000040 // HTTPS: this request not cacheable +#define INTERNET_REQFLAG_NET_TIMEOUT 0x00000080 // w/ _FROM_CACHE: net request timed out + +// +// flags common to open functions (not InternetOpen()): +// + +#define INTERNET_FLAG_RELOAD 0x80000000 // retrieve the original item + +// +// flags for InternetOpenUrl(): +// + +#define INTERNET_FLAG_RAW_DATA 0x40000000 // FTP/gopher find: receive the item as raw (structured) data +#define INTERNET_FLAG_EXISTING_CONNECT 0x20000000 // FTP: use existing InternetConnect handle for server if possible + +// +// flags for InternetOpen(): +// + +#define INTERNET_FLAG_ASYNC 0x10000000 // this request is asynchronous (where supported) + +// +// protocol-specific flags: +// + +#define INTERNET_FLAG_PASSIVE 0x08000000 // used for FTP connections + +// +// additional cache flags +// + +#define INTERNET_FLAG_NO_CACHE_WRITE 0x04000000 // don't write this item to the cache +#define INTERNET_FLAG_DONT_CACHE INTERNET_FLAG_NO_CACHE_WRITE +#define INTERNET_FLAG_MAKE_PERSISTENT 0x02000000 // make this item persistent in cache +#define INTERNET_FLAG_FROM_CACHE 0x01000000 // use offline semantics +#define INTERNET_FLAG_OFFLINE INTERNET_FLAG_FROM_CACHE + +// +// additional flags +// + +#define INTERNET_FLAG_SECURE 0x00800000 // use PCT/SSL if applicable (HTTP) +#define INTERNET_FLAG_KEEP_CONNECTION 0x00400000 // use keep-alive semantics +#define INTERNET_FLAG_NO_AUTO_REDIRECT 0x00200000 // don't handle redirections automatically +#define INTERNET_FLAG_READ_PREFETCH 0x00100000 // do background read prefetch +#define INTERNET_FLAG_NO_COOKIES 0x00080000 // no automatic cookie handling +#define INTERNET_FLAG_NO_AUTH 0x00040000 // no automatic authentication handling +#define INTERNET_FLAG_CACHE_IF_NET_FAIL 0x00010000 // return cache file if net request fails + +// +// Security Ignore Flags, Allow HttpOpenRequest to overide +// Secure Channel (SSL/PCT) failures of the following types. +// + +#define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP 0x00008000 // ex: https:// to http:// +#define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS 0x00004000 // ex: http:// to https:// +#define INTERNET_FLAG_IGNORE_CERT_DATE_INVALID 0x00002000 // expired X509 Cert. +#define INTERNET_FLAG_IGNORE_CERT_CN_INVALID 0x00001000 // bad common name in X509 Cert. + +// +// more caching flags +// + +#define INTERNET_FLAG_RESYNCHRONIZE 0x00000800 // asking wininet to update an item if it is newer +#define INTERNET_FLAG_HYPERLINK 0x00000400 // asking wininet to do hyperlinking semantic which works right for scripts +#define INTERNET_FLAG_NO_UI 0x00000200 // no cookie popup +#define INTERNET_FLAG_PRAGMA_NOCACHE 0x00000100 // asking wininet to add "pragma: no-cache" +#define INTERNET_FLAG_CACHE_ASYNC 0x00000080 // ok to perform lazy cache-write +#define INTERNET_FLAG_FORMS_SUBMIT 0x00000040 // this is a forms submit +#define INTERNET_FLAG_FWD_BACK 0x00000020 // fwd-back button op +#define INTERNET_FLAG_NEED_FILE 0x00000010 // need a file for this request +#define INTERNET_FLAG_MUST_CACHE_REQUEST INTERNET_FLAG_NEED_FILE + +// +// flags for FTP +// + +#define INTERNET_FLAG_TRANSFER_ASCII FTP_TRANSFER_TYPE_ASCII // 0x00000001 +#define INTERNET_FLAG_TRANSFER_BINARY FTP_TRANSFER_TYPE_BINARY // 0x00000002 + +#define INTERNET_ERROR_MASK_INSERT_CDROM 0x1 +#define INTERNET_ERROR_MASK_COMBINED_SEC_CERT 0x2 +#define INTERNET_ERROR_MASK_NEED_MSN_SSPI_PKG 0X4 +#define INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY 0x8 + +#define INTERNET_OPTIONS_MASK (~INTERNET_FLAGS_MASK) + +// +// common per-API flags (new APIs) +// + +#define WININET_API_FLAG_ASYNC 0x00000001 // force async operation +#define WININET_API_FLAG_SYNC 0x00000004 // force sync operation +#define WININET_API_FLAG_USE_CONTEXT 0x00000008 // use value supplied in dwContext (even if 0) + +// +// INTERNET_NO_CALLBACK - if this value is presented as the dwContext parameter +// then no call-backs will be made for that API +// + +#define INTERNET_NO_CALLBACK 0 + + +// +// Options used in INTERNET_PER_CONN_OPTON struct +// +#define INTERNET_PER_CONN_FLAGS 1 +#define INTERNET_PER_CONN_PROXY_SERVER 2 +#define INTERNET_PER_CONN_PROXY_BYPASS 3 +#define INTERNET_PER_CONN_AUTOCONFIG_URL 4 +#define INTERNET_PER_CONN_AUTODISCOVERY_FLAGS 5 + +// +// PER_CONN_FLAGS +// +#define PROXY_TYPE_DIRECT 0x00000001 // direct to net +#define PROXY_TYPE_PROXY 0x00000002 // via named proxy +#define PROXY_TYPE_AUTO_PROXY_URL 0x00000004 // autoproxy URL +#define PROXY_TYPE_AUTO_DETECT 0x00000008 // use autoproxy detection + +// +// PER_CONN_AUTODISCOVERY_FLAGS +// +#define AUTO_PROXY_FLAG_USER_SET 0x00000001 // user changed this setting +#define AUTO_PROXY_FLAG_ALWAYS_DETECT 0x00000002 // force detection even when its not needed +#define AUTO_PROXY_FLAG_DETECTION_RUN 0x00000004 // detection has been run +#define AUTO_PROXY_FLAG_MIGRATED 0x00000008 // migration has just been done +#define AUTO_PROXY_FLAG_DONT_CACHE_PROXY_RESULT 0x00000010 // don't cache result of host=proxy name +#define AUTO_PROXY_FLAG_CACHE_INIT_RUN 0x00000020 // don't initalize and run unless URL expired +#define AUTO_PROXY_FLAG_DETECTION_SUSPECT 0x00000040 // if we're on a LAN & Modem, with only one IP, bad?!? + +// +// ISO_FORCE_DISCONNECTED - if set when putting Wininet into disconnected mode, +// all outstanding requests will be aborted with a cancelled error +// + +#define ISO_FORCE_DISCONNECTED 0x00000001 + + +#define INTERNET_RFC1123_FORMAT 0 +#define INTERNET_RFC1123_BUFSIZE 30 + +// +// flags for InternetCrackUrl() and InternetCreateUrl() +// + +#define ICU_ESCAPE 0x80000000 // (un)escape URL characters +#define ICU_USERNAME 0x40000000 // use internal username & password + +// +// flags for InternetCanonicalizeUrl() and InternetCombineUrl() +// + +#define ICU_NO_ENCODE 0x20000000 // Don't convert unsafe characters to escape sequence +#define ICU_DECODE 0x10000000 // Convert %XX escape sequences to characters +#define ICU_NO_META 0x08000000 // Don't convert .. etc. meta path sequences +#define ICU_ENCODE_SPACES_ONLY 0x04000000 // Encode spaces only +#define ICU_BROWSER_MODE 0x02000000 // Special encode/decode rules for browser +#define ICU_ENCODE_PERCENT 0x00001000 // Encode any percent (ASCII25) + // signs encountered, default is to not encode percent. + +// +// access types for InternetOpen() +// + +#define INTERNET_OPEN_TYPE_PRECONFIG 0 // use registry configuration +#define INTERNET_OPEN_TYPE_DIRECT 1 // direct to net +#define INTERNET_OPEN_TYPE_PROXY 3 // via named proxy +#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 // prevent using java/script/INS + +// +// old names for access types +// + +#define PRE_CONFIG_INTERNET_ACCESS INTERNET_OPEN_TYPE_PRECONFIG +#define LOCAL_INTERNET_ACCESS INTERNET_OPEN_TYPE_DIRECT +#define CERN_PROXY_INTERNET_ACCESS INTERNET_OPEN_TYPE_PROXY + + +// +// service types for InternetConnect() +// + +#define INTERNET_SERVICE_FTP 1 +#define INTERNET_SERVICE_GOPHER 2 +#define INTERNET_SERVICE_HTTP 3 + +// +// flags for InternetReadFileEx() +// + +#define IRF_ASYNC WININET_API_FLAG_ASYNC +#define IRF_SYNC WININET_API_FLAG_SYNC +#define IRF_USE_CONTEXT WININET_API_FLAG_USE_CONTEXT +#define IRF_NO_WAIT 0x00000008 + +// +// flags for InternetSetOptionEx() +// + +#define ISO_GLOBAL 0x00000001 // modify option globally +#define ISO_REGISTRY 0x00000002 // write option to registry (where applicable) + +#define ISO_VALID_FLAGS (ISO_GLOBAL | ISO_REGISTRY) + +// +// options manifests for Internet{Query|Set}Option +// + +#define INTERNET_OPTION_CALLBACK 1 +#define INTERNET_OPTION_CONNECT_TIMEOUT 2 +#define INTERNET_OPTION_CONNECT_RETRIES 3 +#define INTERNET_OPTION_CONNECT_BACKOFF 4 +#define INTERNET_OPTION_SEND_TIMEOUT 5 +#define INTERNET_OPTION_CONTROL_SEND_TIMEOUT INTERNET_OPTION_SEND_TIMEOUT +#define INTERNET_OPTION_RECEIVE_TIMEOUT 6 +#define INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT INTERNET_OPTION_RECEIVE_TIMEOUT +#define INTERNET_OPTION_DATA_SEND_TIMEOUT 7 +#define INTERNET_OPTION_DATA_RECEIVE_TIMEOUT 8 +#define INTERNET_OPTION_HANDLE_TYPE 9 +#define INTERNET_OPTION_LISTEN_TIMEOUT 11 +#define INTERNET_OPTION_READ_BUFFER_SIZE 12 +#define INTERNET_OPTION_WRITE_BUFFER_SIZE 13 + +#define INTERNET_OPTION_ASYNC_ID 15 +#define INTERNET_OPTION_ASYNC_PRIORITY 16 + +#define INTERNET_OPTION_PARENT_HANDLE 21 +#define INTERNET_OPTION_KEEP_CONNECTION 22 +#define INTERNET_OPTION_REQUEST_FLAGS 23 +#define INTERNET_OPTION_EXTENDED_ERROR 24 + +#define INTERNET_OPTION_OFFLINE_MODE 26 +#define INTERNET_OPTION_CACHE_STREAM_HANDLE 27 +#define INTERNET_OPTION_USERNAME 28 +#define INTERNET_OPTION_PASSWORD 29 +#define INTERNET_OPTION_ASYNC 30 +#define INTERNET_OPTION_SECURITY_FLAGS 31 +#define INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT 32 +#define INTERNET_OPTION_DATAFILE_NAME 33 +#define INTERNET_OPTION_URL 34 +#define INTERNET_OPTION_SECURITY_CERTIFICATE 35 +#define INTERNET_OPTION_SECURITY_KEY_BITNESS 36 +#define INTERNET_OPTION_REFRESH 37 +#define INTERNET_OPTION_PROXY 38 +#define INTERNET_OPTION_SETTINGS_CHANGED 39 +#define INTERNET_OPTION_VERSION 40 +#define INTERNET_OPTION_USER_AGENT 41 +#define INTERNET_OPTION_END_BROWSER_SESSION 42 +#define INTERNET_OPTION_PROXY_USERNAME 43 +#define INTERNET_OPTION_PROXY_PASSWORD 44 +#define INTERNET_OPTION_CONTEXT_VALUE 45 +#define INTERNET_OPTION_CONNECT_LIMIT 46 +#define INTERNET_OPTION_SECURITY_SELECT_CLIENT_CERT 47 +#define INTERNET_OPTION_POLICY 48 +#define INTERNET_OPTION_DISCONNECTED_TIMEOUT 49 +#define INTERNET_OPTION_CONNECTED_STATE 50 +#define INTERNET_OPTION_IDLE_STATE 51 +#define INTERNET_OPTION_OFFLINE_SEMANTICS 52 +#define INTERNET_OPTION_SECONDARY_CACHE_KEY 53 +#define INTERNET_OPTION_CALLBACK_FILTER 54 +#define INTERNET_OPTION_CONNECT_TIME 55 +#define INTERNET_OPTION_SEND_THROUGHPUT 56 +#define INTERNET_OPTION_RECEIVE_THROUGHPUT 57 +#define INTERNET_OPTION_REQUEST_PRIORITY 58 +#define INTERNET_OPTION_HTTP_VERSION 59 +#define INTERNET_OPTION_RESET_URLCACHE_SESSION 60 +#define INTERNET_OPTION_ERROR_MASK 62 +#define INTERNET_OPTION_FROM_CACHE_TIMEOUT 63 +#define INTERNET_OPTION_BYPASS_EDITED_ENTRY 64 +#define INTERNET_OPTION_CODEPAGE 68 +#define INTERNET_OPTION_CACHE_TIMESTAMPS 69 +#define INTERNET_OPTION_DISABLE_AUTODIAL 70 +#define INTERNET_OPTION_MAX_CONNS_PER_SERVER 73 +#define INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER 74 +#define INTERNET_OPTION_PER_CONNECTION_OPTION 75 +#define INTERNET_OPTION_DIGEST_AUTH_UNLOAD 76 +#define INTERNET_OPTION_IGNORE_OFFLINE 77 + +#define INTERNET_FIRST_OPTION INTERNET_OPTION_CALLBACK +#define INTERNET_LAST_OPTION INTERNET_OPTION_IGNORE_OFFLINE + +// +// values for INTERNET_OPTION_PRIORITY +// + +#define INTERNET_PRIORITY_FOREGROUND 1000 + +// +// handle types +// + +#define INTERNET_HANDLE_TYPE_INTERNET 1 +#define INTERNET_HANDLE_TYPE_CONNECT_FTP 2 +#define INTERNET_HANDLE_TYPE_CONNECT_GOPHER 3 +#define INTERNET_HANDLE_TYPE_CONNECT_HTTP 4 +#define INTERNET_HANDLE_TYPE_FTP_FIND 5 +#define INTERNET_HANDLE_TYPE_FTP_FIND_HTML 6 +#define INTERNET_HANDLE_TYPE_FTP_FILE 7 +#define INTERNET_HANDLE_TYPE_FTP_FILE_HTML 8 +#define INTERNET_HANDLE_TYPE_GOPHER_FIND 9 +#define INTERNET_HANDLE_TYPE_GOPHER_FIND_HTML 10 +#define INTERNET_HANDLE_TYPE_GOPHER_FILE 11 +#define INTERNET_HANDLE_TYPE_GOPHER_FILE_HTML 12 +#define INTERNET_HANDLE_TYPE_HTTP_REQUEST 13 +#define INTERNET_HANDLE_TYPE_FILE_REQUEST 14 + +// +// values for INTERNET_OPTION_SECURITY_FLAGS +// + +// query only +#define SECURITY_FLAG_SECURE 0x00000001 // can query only +#define SECURITY_FLAG_STRENGTH_WEAK 0x10000000 +#define SECURITY_FLAG_STRENGTH_MEDIUM 0x40000000 +#define SECURITY_FLAG_STRENGTH_STRONG 0x20000000 +#define SECURITY_FLAG_UNKNOWNBIT 0x80000000 +#define SECURITY_FLAG_FORTEZZA 0x08000000 +#define SECURITY_FLAG_NORMALBITNESS SECURITY_FLAG_STRENGTH_WEAK + + + +// The following are unused +#define SECURITY_FLAG_SSL 0x00000002 +#define SECURITY_FLAG_SSL3 0x00000004 +#define SECURITY_FLAG_PCT 0x00000008 +#define SECURITY_FLAG_PCT4 0x00000010 +#define SECURITY_FLAG_IETFSSL4 0x00000020 + +// The following are for backwards compatability only. +#define SECURITY_FLAG_40BIT SECURITY_FLAG_STRENGTH_WEAK +#define SECURITY_FLAG_128BIT SECURITY_FLAG_STRENGTH_STRONG +#define SECURITY_FLAG_56BIT SECURITY_FLAG_STRENGTH_MEDIUM + +// setable flags +#define SECURITY_FLAG_IGNORE_REVOCATION 0x00000080 +#define SECURITY_FLAG_IGNORE_UNKNOWN_CA 0x00000100 +#define SECURITY_FLAG_IGNORE_WRONG_USAGE 0x00000200 + +#define SECURITY_FLAG_IGNORE_CERT_CN_INVALID INTERNET_FLAG_IGNORE_CERT_CN_INVALID +#define SECURITY_FLAG_IGNORE_CERT_DATE_INVALID INTERNET_FLAG_IGNORE_CERT_DATE_INVALID + + +#define SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTPS INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS +#define SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTP INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP + + + +// +// status manifests for Internet status callback +// + +#define INTERNET_STATUS_RESOLVING_NAME 10 +#define INTERNET_STATUS_NAME_RESOLVED 11 +#define INTERNET_STATUS_CONNECTING_TO_SERVER 20 +#define INTERNET_STATUS_CONNECTED_TO_SERVER 21 +#define INTERNET_STATUS_SENDING_REQUEST 30 +#define INTERNET_STATUS_REQUEST_SENT 31 +#define INTERNET_STATUS_RECEIVING_RESPONSE 40 +#define INTERNET_STATUS_RESPONSE_RECEIVED 41 +#define INTERNET_STATUS_CTL_RESPONSE_RECEIVED 42 +#define INTERNET_STATUS_PREFETCH 43 +#define INTERNET_STATUS_CLOSING_CONNECTION 50 +#define INTERNET_STATUS_CONNECTION_CLOSED 51 +#define INTERNET_STATUS_HANDLE_CREATED 60 +#define INTERNET_STATUS_HANDLE_CLOSING 70 +#define INTERNET_STATUS_DETECTING_PROXY 80 +#define INTERNET_STATUS_REQUEST_COMPLETE 100 +#define INTERNET_STATUS_REDIRECT 110 +#define INTERNET_STATUS_INTERMEDIATE_RESPONSE 120 +#define INTERNET_STATUS_USER_INPUT_REQUIRED 140 +#define INTERNET_STATUS_STATE_CHANGE 200 + +// +// the following can be indicated in a state change notification: +// + +#define INTERNET_STATE_CONNECTED 0x00000001 // connected state (mutually exclusive with disconnected) +#define INTERNET_STATE_DISCONNECTED 0x00000002 // disconnected from network +#define INTERNET_STATE_DISCONNECTED_BY_USER 0x00000010 // disconnected by user request +#define INTERNET_STATE_IDLE 0x00000100 // no network requests being made (by Wininet) +#define INTERNET_STATE_BUSY 0x00000200 // network requests being made (by Wininet) + + +// +// FTP +// + +// +// manifests +// + +#define FTP_TRANSFER_TYPE_UNKNOWN 0x00000000 +#define FTP_TRANSFER_TYPE_ASCII 0x00000001 +#define FTP_TRANSFER_TYPE_BINARY 0x00000002 + +#define FTP_TRANSFER_TYPE_MASK (FTP_TRANSFER_TYPE_ASCII | FTP_TRANSFER_TYPE_BINARY) + +// +// Gopher +// + +// +// manifests +// + +// +// string field lengths (in characters, not bytes) +// + +#define MAX_GOPHER_DISPLAY_TEXT 128 +#define MAX_GOPHER_SELECTOR_TEXT 256 +#define MAX_GOPHER_HOST_NAME INTERNET_MAX_HOST_NAME_LENGTH + +// +// manifests for GopherType +// + +#define GOPHER_TYPE_TEXT_FILE 0x00000001 +#define GOPHER_TYPE_DIRECTORY 0x00000002 +#define GOPHER_TYPE_CSO 0x00000004 +#define GOPHER_TYPE_ERROR 0x00000008 +#define GOPHER_TYPE_MAC_BINHEX 0x00000010 +#define GOPHER_TYPE_DOS_ARCHIVE 0x00000020 +#define GOPHER_TYPE_UNIX_UUENCODED 0x00000040 +#define GOPHER_TYPE_INDEX_SERVER 0x00000080 +#define GOPHER_TYPE_TELNET 0x00000100 +#define GOPHER_TYPE_BINARY 0x00000200 +#define GOPHER_TYPE_REDUNDANT 0x00000400 +#define GOPHER_TYPE_TN3270 0x00000800 +#define GOPHER_TYPE_GIF 0x00001000 +#define GOPHER_TYPE_IMAGE 0x00002000 +#define GOPHER_TYPE_BITMAP 0x00004000 +#define GOPHER_TYPE_MOVIE 0x00008000 +#define GOPHER_TYPE_SOUND 0x00010000 +#define GOPHER_TYPE_HTML 0x00020000 +#define GOPHER_TYPE_PDF 0x00040000 +#define GOPHER_TYPE_CALENDAR 0x00080000 +#define GOPHER_TYPE_INLINE 0x00100000 +#define GOPHER_TYPE_UNKNOWN 0x20000000 +#define GOPHER_TYPE_ASK 0x40000000 +#define GOPHER_TYPE_GOPHER_PLUS 0x80000000 + + +#define MAX_GOPHER_CATEGORY_NAME 128 // arbitrary +#define MAX_GOPHER_ATTRIBUTE_NAME 128 // " +#define MIN_GOPHER_ATTRIBUTE_LENGTH 256 // " + +// +// known gopher attribute categories. See below for ordinals +// + +#define GOPHER_INFO_CATEGORY TEXT("+INFO") +#define GOPHER_ADMIN_CATEGORY TEXT("+ADMIN") +#define GOPHER_VIEWS_CATEGORY TEXT("+VIEWS") +#define GOPHER_ABSTRACT_CATEGORY TEXT("+ABSTRACT") +#define GOPHER_VERONICA_CATEGORY TEXT("+VERONICA") + +// +// known gopher attributes. These are the attribute names as defined in the +// gopher+ protocol document +// + +#define GOPHER_ADMIN_ATTRIBUTE TEXT("Admin") +#define GOPHER_MOD_DATE_ATTRIBUTE TEXT("Mod-Date") +#define GOPHER_TTL_ATTRIBUTE TEXT("TTL") +#define GOPHER_SCORE_ATTRIBUTE TEXT("Score") +#define GOPHER_RANGE_ATTRIBUTE TEXT("Score-range") +#define GOPHER_SITE_ATTRIBUTE TEXT("Site") +#define GOPHER_ORG_ATTRIBUTE TEXT("Org") +#define GOPHER_LOCATION_ATTRIBUTE TEXT("Loc") +#define GOPHER_GEOG_ATTRIBUTE TEXT("Geog") +#define GOPHER_TIMEZONE_ATTRIBUTE TEXT("TZ") +#define GOPHER_PROVIDER_ATTRIBUTE TEXT("Provider") +#define GOPHER_VERSION_ATTRIBUTE TEXT("Version") +#define GOPHER_ABSTRACT_ATTRIBUTE TEXT("Abstract") +#define GOPHER_VIEW_ATTRIBUTE TEXT("View") +#define GOPHER_TREEWALK_ATTRIBUTE TEXT("treewalk") + +// +// identifiers for attribute strings +// + +#define GOPHER_ATTRIBUTE_ID_BASE 0xabcccc00 + +#define GOPHER_CATEGORY_ID_ALL (GOPHER_ATTRIBUTE_ID_BASE + 1) + +#define GOPHER_CATEGORY_ID_INFO (GOPHER_ATTRIBUTE_ID_BASE + 2) +#define GOPHER_CATEGORY_ID_ADMIN (GOPHER_ATTRIBUTE_ID_BASE + 3) +#define GOPHER_CATEGORY_ID_VIEWS (GOPHER_ATTRIBUTE_ID_BASE + 4) +#define GOPHER_CATEGORY_ID_ABSTRACT (GOPHER_ATTRIBUTE_ID_BASE + 5) +#define GOPHER_CATEGORY_ID_VERONICA (GOPHER_ATTRIBUTE_ID_BASE + 6) +#define GOPHER_CATEGORY_ID_ASK (GOPHER_ATTRIBUTE_ID_BASE + 7) + +#define GOPHER_CATEGORY_ID_UNKNOWN (GOPHER_ATTRIBUTE_ID_BASE + 8) + +#define GOPHER_ATTRIBUTE_ID_ALL (GOPHER_ATTRIBUTE_ID_BASE + 9) + +#define GOPHER_ATTRIBUTE_ID_ADMIN (GOPHER_ATTRIBUTE_ID_BASE + 10) +#define GOPHER_ATTRIBUTE_ID_MOD_DATE (GOPHER_ATTRIBUTE_ID_BASE + 11) +#define GOPHER_ATTRIBUTE_ID_TTL (GOPHER_ATTRIBUTE_ID_BASE + 12) +#define GOPHER_ATTRIBUTE_ID_SCORE (GOPHER_ATTRIBUTE_ID_BASE + 13) +#define GOPHER_ATTRIBUTE_ID_RANGE (GOPHER_ATTRIBUTE_ID_BASE + 14) +#define GOPHER_ATTRIBUTE_ID_SITE (GOPHER_ATTRIBUTE_ID_BASE + 15) +#define GOPHER_ATTRIBUTE_ID_ORG (GOPHER_ATTRIBUTE_ID_BASE + 16) +#define GOPHER_ATTRIBUTE_ID_LOCATION (GOPHER_ATTRIBUTE_ID_BASE + 17) +#define GOPHER_ATTRIBUTE_ID_GEOG (GOPHER_ATTRIBUTE_ID_BASE + 18) +#define GOPHER_ATTRIBUTE_ID_TIMEZONE (GOPHER_ATTRIBUTE_ID_BASE + 19) +#define GOPHER_ATTRIBUTE_ID_PROVIDER (GOPHER_ATTRIBUTE_ID_BASE + 20) +#define GOPHER_ATTRIBUTE_ID_VERSION (GOPHER_ATTRIBUTE_ID_BASE + 21) +#define GOPHER_ATTRIBUTE_ID_ABSTRACT (GOPHER_ATTRIBUTE_ID_BASE + 22) +#define GOPHER_ATTRIBUTE_ID_VIEW (GOPHER_ATTRIBUTE_ID_BASE + 23) +#define GOPHER_ATTRIBUTE_ID_TREEWALK (GOPHER_ATTRIBUTE_ID_BASE + 24) + +#define GOPHER_ATTRIBUTE_ID_UNKNOWN (GOPHER_ATTRIBUTE_ID_BASE + 25) + + +// +// HTTP +// + +// +// manifests +// + +// +// the default major/minor HTTP version numbers +// + +#define HTTP_MAJOR_VERSION 1 +#define HTTP_MINOR_VERSION 0 + +#define HTTP_VERSIONA "HTTP/1.0" +#define HTTP_VERSIONW L"HTTP/1.0" + +#ifdef UNICODE +#define HTTP_VERSION HTTP_VERSIONW +#else +#define HTTP_VERSION HTTP_VERSIONA +#endif + +// +// HttpQueryInfo info levels. Generally, there is one info level +// for each potential RFC822/HTTP/MIME header that an HTTP server +// may send as part of a request response. +// +// The HTTP_QUERY_RAW_HEADERS info level is provided for clients +// that choose to perform their own header parsing. +// + + +#define HTTP_QUERY_MIME_VERSION 0 +#define HTTP_QUERY_CONTENT_TYPE 1 +#define HTTP_QUERY_CONTENT_TRANSFER_ENCODING 2 +#define HTTP_QUERY_CONTENT_ID 3 +#define HTTP_QUERY_CONTENT_DESCRIPTION 4 +#define HTTP_QUERY_CONTENT_LENGTH 5 +#define HTTP_QUERY_CONTENT_LANGUAGE 6 +#define HTTP_QUERY_ALLOW 7 +#define HTTP_QUERY_PUBLIC 8 +#define HTTP_QUERY_DATE 9 +#define HTTP_QUERY_EXPIRES 10 +#define HTTP_QUERY_LAST_MODIFIED 11 +#define HTTP_QUERY_MESSAGE_ID 12 +#define HTTP_QUERY_URI 13 +#define HTTP_QUERY_DERIVED_FROM 14 +#define HTTP_QUERY_COST 15 +#define HTTP_QUERY_LINK 16 +#define HTTP_QUERY_PRAGMA 17 +#define HTTP_QUERY_VERSION 18 // special: part of status line +#define HTTP_QUERY_STATUS_CODE 19 // special: part of status line +#define HTTP_QUERY_STATUS_TEXT 20 // special: part of status line +#define HTTP_QUERY_RAW_HEADERS 21 // special: all headers as ASCIIZ +#define HTTP_QUERY_RAW_HEADERS_CRLF 22 // special: all headers +#define HTTP_QUERY_CONNECTION 23 +#define HTTP_QUERY_ACCEPT 24 +#define HTTP_QUERY_ACCEPT_CHARSET 25 +#define HTTP_QUERY_ACCEPT_ENCODING 26 +#define HTTP_QUERY_ACCEPT_LANGUAGE 27 +#define HTTP_QUERY_AUTHORIZATION 28 +#define HTTP_QUERY_CONTENT_ENCODING 29 +#define HTTP_QUERY_FORWARDED 30 +#define HTTP_QUERY_FROM 31 +#define HTTP_QUERY_IF_MODIFIED_SINCE 32 +#define HTTP_QUERY_LOCATION 33 +#define HTTP_QUERY_ORIG_URI 34 +#define HTTP_QUERY_REFERER 35 +#define HTTP_QUERY_RETRY_AFTER 36 +#define HTTP_QUERY_SERVER 37 +#define HTTP_QUERY_TITLE 38 +#define HTTP_QUERY_USER_AGENT 39 +#define HTTP_QUERY_WWW_AUTHENTICATE 40 +#define HTTP_QUERY_PROXY_AUTHENTICATE 41 +#define HTTP_QUERY_ACCEPT_RANGES 42 +#define HTTP_QUERY_SET_COOKIE 43 +#define HTTP_QUERY_COOKIE 44 +#define HTTP_QUERY_REQUEST_METHOD 45 // special: GET/POST etc. +#define HTTP_QUERY_REFRESH 46 +#define HTTP_QUERY_CONTENT_DISPOSITION 47 + +// +// HTTP 1.1 defined headers +// + +#define HTTP_QUERY_AGE 48 +#define HTTP_QUERY_CACHE_CONTROL 49 +#define HTTP_QUERY_CONTENT_BASE 50 +#define HTTP_QUERY_CONTENT_LOCATION 51 +#define HTTP_QUERY_CONTENT_MD5 52 +#define HTTP_QUERY_CONTENT_RANGE 53 +#define HTTP_QUERY_ETAG 54 +#define HTTP_QUERY_HOST 55 +#define HTTP_QUERY_IF_MATCH 56 +#define HTTP_QUERY_IF_NONE_MATCH 57 +#define HTTP_QUERY_IF_RANGE 58 +#define HTTP_QUERY_IF_UNMODIFIED_SINCE 59 +#define HTTP_QUERY_MAX_FORWARDS 60 +#define HTTP_QUERY_PROXY_AUTHORIZATION 61 +#define HTTP_QUERY_RANGE 62 +#define HTTP_QUERY_TRANSFER_ENCODING 63 +#define HTTP_QUERY_UPGRADE 64 +#define HTTP_QUERY_VARY 65 +#define HTTP_QUERY_VIA 66 +#define HTTP_QUERY_WARNING 67 +#define HTTP_QUERY_EXPECT 68 +#define HTTP_QUERY_PROXY_CONNECTION 69 +#define HTTP_QUERY_UNLESS_MODIFIED_SINCE 70 + + + +#define HTTP_QUERY_ECHO_REQUEST 71 +#define HTTP_QUERY_ECHO_REPLY 72 + +// These are the set of headers that should be added back to a request when +// re-doing a request after a RETRY_WITH response. +#define HTTP_QUERY_ECHO_HEADERS 73 +#define HTTP_QUERY_ECHO_HEADERS_CRLF 74 + +#define HTTP_QUERY_MAX 74 + +// +// HTTP_QUERY_CUSTOM - if this special value is supplied as the dwInfoLevel +// parameter of HttpQueryInfo() then the lpBuffer parameter contains the name +// of the header we are to query +// + +#define HTTP_QUERY_CUSTOM 65535 + +// +// HTTP_QUERY_FLAG_REQUEST_HEADERS - if this bit is set in the dwInfoLevel +// parameter of HttpQueryInfo() then the request headers will be queried for the +// request information +// + +#define HTTP_QUERY_FLAG_REQUEST_HEADERS 0x80000000 + +// +// HTTP_QUERY_FLAG_SYSTEMTIME - if this bit is set in the dwInfoLevel parameter +// of HttpQueryInfo() AND the header being queried contains date information, +// e.g. the "Expires:" header then lpBuffer will contain a SYSTEMTIME structure +// containing the date and time information converted from the header string +// + +#define HTTP_QUERY_FLAG_SYSTEMTIME 0x40000000 + +// +// HTTP_QUERY_FLAG_NUMBER - if this bit is set in the dwInfoLevel parameter of +// HttpQueryInfo(), then the value of the header will be converted to a number +// before being returned to the caller, if applicable +// + +#define HTTP_QUERY_FLAG_NUMBER 0x20000000 + +// +// HTTP_QUERY_FLAG_COALESCE - combine the values from several headers of the +// same name into the output buffer +// + +#define HTTP_QUERY_FLAG_COALESCE 0x10000000 + + +#define HTTP_QUERY_HEADER_MASK (~HTTP_QUERY_MODIFIER_FLAGS_MASK) + +// +// HTTP Response Status Codes: +// + +#define HTTP_STATUS_CONTINUE 100 // OK to continue with request +#define HTTP_STATUS_SWITCH_PROTOCOLS 101 // server has switched protocols in upgrade header + +#define HTTP_STATUS_OK 200 // request completed +#define HTTP_STATUS_CREATED 201 // object created, reason = new URI +#define HTTP_STATUS_ACCEPTED 202 // async completion (TBS) +#define HTTP_STATUS_PARTIAL 203 // partial completion +#define HTTP_STATUS_NO_CONTENT 204 // no info to return +#define HTTP_STATUS_RESET_CONTENT 205 // request completed, but clear form +#define HTTP_STATUS_PARTIAL_CONTENT 206 // partial GET furfilled + +#define HTTP_STATUS_AMBIGUOUS 300 // server couldn't decide what to return +#define HTTP_STATUS_MOVED 301 // object permanently moved +#define HTTP_STATUS_REDIRECT 302 // object temporarily moved +#define HTTP_STATUS_REDIRECT_METHOD 303 // redirection w/ new access method +#define HTTP_STATUS_NOT_MODIFIED 304 // if-modified-since was not modified +#define HTTP_STATUS_USE_PROXY 305 // redirection to proxy, location header specifies proxy to use +#define HTTP_STATUS_REDIRECT_KEEP_VERB 307 // HTTP/1.1: keep same verb + +#define HTTP_STATUS_BAD_REQUEST 400 // invalid syntax +#define HTTP_STATUS_DENIED 401 // access denied +#define HTTP_STATUS_PAYMENT_REQ 402 // payment required +#define HTTP_STATUS_FORBIDDEN 403 // request forbidden +#define HTTP_STATUS_NOT_FOUND 404 // object not found +#define HTTP_STATUS_BAD_METHOD 405 // method is not allowed +#define HTTP_STATUS_NONE_ACCEPTABLE 406 // no response acceptable to client found +#define HTTP_STATUS_PROXY_AUTH_REQ 407 // proxy authentication required +#define HTTP_STATUS_REQUEST_TIMEOUT 408 // server timed out waiting for request +#define HTTP_STATUS_CONFLICT 409 // user should resubmit with more info +#define HTTP_STATUS_GONE 410 // the resource is no longer available +#define HTTP_STATUS_LENGTH_REQUIRED 411 // the server refused to accept request w/o a length +#define HTTP_STATUS_PRECOND_FAILED 412 // precondition given in request failed +#define HTTP_STATUS_REQUEST_TOO_LARGE 413 // request entity was too large +#define HTTP_STATUS_URI_TOO_LONG 414 // request URI too long +#define HTTP_STATUS_UNSUPPORTED_MEDIA 415 // unsupported media type +#define HTTP_STATUS_RETRY_WITH 449 // retry after doing the appropriate action. + +#define HTTP_STATUS_SERVER_ERROR 500 // internal server error +#define HTTP_STATUS_NOT_SUPPORTED 501 // required not supported +#define HTTP_STATUS_BAD_GATEWAY 502 // error response received from gateway +#define HTTP_STATUS_SERVICE_UNAVAIL 503 // temporarily overloaded +#define HTTP_STATUS_GATEWAY_TIMEOUT 504 // timed out waiting for gateway +#define HTTP_STATUS_VERSION_NOT_SUP 505 // HTTP version not supported + +#define HTTP_STATUS_FIRST HTTP_STATUS_CONTINUE +#define HTTP_STATUS_LAST HTTP_STATUS_VERSION_NOT_SUP + + +// +// values for dwModifiers parameter of HttpAddRequestHeaders() +// + +#define HTTP_ADDREQ_INDEX_MASK 0x0000FFFF +#define HTTP_ADDREQ_FLAGS_MASK 0xFFFF0000 + +// +// HTTP_ADDREQ_FLAG_ADD_IF_NEW - the header will only be added if it doesn't +// already exist +// + +#define HTTP_ADDREQ_FLAG_ADD_IF_NEW 0x10000000 + +// +// HTTP_ADDREQ_FLAG_ADD - if HTTP_ADDREQ_FLAG_REPLACE is set but the header is +// not found then if this flag is set, the header is added anyway, so long as +// there is a valid header-value +// + +#define HTTP_ADDREQ_FLAG_ADD 0x20000000 + +// +// HTTP_ADDREQ_FLAG_COALESCE - coalesce headers with same name. e.g. +// "Accept: text/*" and "Accept: audio/*" with this flag results in a single +// header: "Accept: text/*, audio/*" +// + +#define HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA 0x40000000 +#define HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON 0x01000000 +#define HTTP_ADDREQ_FLAG_COALESCE HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA + +// +// HTTP_ADDREQ_FLAG_REPLACE - replaces the specified header. Only one header can +// be supplied in the buffer. If the header to be replaced is not the first +// in a list of headers with the same name, then the relative index should be +// supplied in the low 8 bits of the dwModifiers parameter. If the header-value +// part is missing, then the header is removed +// + +#define HTTP_ADDREQ_FLAG_REPLACE 0x80000000 + +// +// flags for HttpSendRequestEx(), HttpEndRequest() +// + +#define HSR_ASYNC WININET_API_FLAG_ASYNC // force async +#define HSR_SYNC WININET_API_FLAG_SYNC // force sync +#define HSR_USE_CONTEXT WININET_API_FLAG_USE_CONTEXT // use dwContext value +#define HSR_INITIATE 0x00000008 // iterative operation (completed by HttpEndRequest) +#define HSR_DOWNLOAD 0x00000010 // download to file +#define HSR_CHUNKED 0x00000020 // operation is send of chunked data + + +#define FLAG_ICC_FORCE_CONNECTION 0x00000001 + +// +// Internet UI +// + +// +// InternetErrorDlg - Provides UI for certain Errors. +// + +#define FLAGS_ERROR_UI_FILTER_FOR_ERRORS 0x01 +#define FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS 0x02 +#define FLAGS_ERROR_UI_FLAGS_GENERATE_DATA 0x04 +#define FLAGS_ERROR_UI_FLAGS_NO_UI 0x08 +#define FLAGS_ERROR_UI_SERIALIZE_DIALOGS 0x10 + +// +// If SERIALIZE_DIALOGS flag set, client should implement thread-safe non-blocking callback... +// + +// +// Internet API error returns +// + +#define INTERNET_ERROR_BASE 12000 + +#define ERROR_INTERNET_OUT_OF_HANDLES (INTERNET_ERROR_BASE + 1) +#define ERROR_INTERNET_TIMEOUT (INTERNET_ERROR_BASE + 2) +#define ERROR_INTERNET_EXTENDED_ERROR (INTERNET_ERROR_BASE + 3) +#define ERROR_INTERNET_INTERNAL_ERROR (INTERNET_ERROR_BASE + 4) +#define ERROR_INTERNET_INVALID_URL (INTERNET_ERROR_BASE + 5) +#define ERROR_INTERNET_UNRECOGNIZED_SCHEME (INTERNET_ERROR_BASE + 6) +#define ERROR_INTERNET_NAME_NOT_RESOLVED (INTERNET_ERROR_BASE + 7) +#define ERROR_INTERNET_PROTOCOL_NOT_FOUND (INTERNET_ERROR_BASE + 8) +#define ERROR_INTERNET_INVALID_OPTION (INTERNET_ERROR_BASE + 9) +#define ERROR_INTERNET_BAD_OPTION_LENGTH (INTERNET_ERROR_BASE + 10) +#define ERROR_INTERNET_OPTION_NOT_SETTABLE (INTERNET_ERROR_BASE + 11) +#define ERROR_INTERNET_SHUTDOWN (INTERNET_ERROR_BASE + 12) +#define ERROR_INTERNET_INCORRECT_USER_NAME (INTERNET_ERROR_BASE + 13) +#define ERROR_INTERNET_INCORRECT_PASSWORD (INTERNET_ERROR_BASE + 14) +#define ERROR_INTERNET_LOGIN_FAILURE (INTERNET_ERROR_BASE + 15) +#define ERROR_INTERNET_INVALID_OPERATION (INTERNET_ERROR_BASE + 16) +#define ERROR_INTERNET_OPERATION_CANCELLED (INTERNET_ERROR_BASE + 17) +#define ERROR_INTERNET_INCORRECT_HANDLE_TYPE (INTERNET_ERROR_BASE + 18) +#define ERROR_INTERNET_INCORRECT_HANDLE_STATE (INTERNET_ERROR_BASE + 19) +#define ERROR_INTERNET_NOT_PROXY_REQUEST (INTERNET_ERROR_BASE + 20) +#define ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND (INTERNET_ERROR_BASE + 21) +#define ERROR_INTERNET_BAD_REGISTRY_PARAMETER (INTERNET_ERROR_BASE + 22) +#define ERROR_INTERNET_NO_DIRECT_ACCESS (INTERNET_ERROR_BASE + 23) +#define ERROR_INTERNET_NO_CONTEXT (INTERNET_ERROR_BASE + 24) +#define ERROR_INTERNET_NO_CALLBACK (INTERNET_ERROR_BASE + 25) +#define ERROR_INTERNET_REQUEST_PENDING (INTERNET_ERROR_BASE + 26) +#define ERROR_INTERNET_INCORRECT_FORMAT (INTERNET_ERROR_BASE + 27) +#define ERROR_INTERNET_ITEM_NOT_FOUND (INTERNET_ERROR_BASE + 28) +#define ERROR_INTERNET_CANNOT_CONNECT (INTERNET_ERROR_BASE + 29) +#define ERROR_INTERNET_CONNECTION_ABORTED (INTERNET_ERROR_BASE + 30) +#define ERROR_INTERNET_CONNECTION_RESET (INTERNET_ERROR_BASE + 31) +#define ERROR_INTERNET_FORCE_RETRY (INTERNET_ERROR_BASE + 32) +#define ERROR_INTERNET_INVALID_PROXY_REQUEST (INTERNET_ERROR_BASE + 33) +#define ERROR_INTERNET_NEED_UI (INTERNET_ERROR_BASE + 34) + +#define ERROR_INTERNET_HANDLE_EXISTS (INTERNET_ERROR_BASE + 36) +#define ERROR_INTERNET_SEC_CERT_DATE_INVALID (INTERNET_ERROR_BASE + 37) +#define ERROR_INTERNET_SEC_CERT_CN_INVALID (INTERNET_ERROR_BASE + 38) +#define ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR (INTERNET_ERROR_BASE + 39) +#define ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR (INTERNET_ERROR_BASE + 40) +#define ERROR_INTERNET_MIXED_SECURITY (INTERNET_ERROR_BASE + 41) +#define ERROR_INTERNET_CHG_POST_IS_NON_SECURE (INTERNET_ERROR_BASE + 42) +#define ERROR_INTERNET_POST_IS_NON_SECURE (INTERNET_ERROR_BASE + 43) +#define ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED (INTERNET_ERROR_BASE + 44) +#define ERROR_INTERNET_INVALID_CA (INTERNET_ERROR_BASE + 45) +#define ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP (INTERNET_ERROR_BASE + 46) +#define ERROR_INTERNET_ASYNC_THREAD_FAILED (INTERNET_ERROR_BASE + 47) +#define ERROR_INTERNET_REDIRECT_SCHEME_CHANGE (INTERNET_ERROR_BASE + 48) +#define ERROR_INTERNET_DIALOG_PENDING (INTERNET_ERROR_BASE + 49) +#define ERROR_INTERNET_RETRY_DIALOG (INTERNET_ERROR_BASE + 50) +#define ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR (INTERNET_ERROR_BASE + 52) +#define ERROR_INTERNET_INSERT_CDROM (INTERNET_ERROR_BASE + 53) +#define ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED (INTERNET_ERROR_BASE + 54) +#define ERROR_INTERNET_SEC_CERT_ERRORS (INTERNET_ERROR_BASE + 55) +#define ERROR_INTERNET_SEC_CERT_NO_REV (INTERNET_ERROR_BASE + 56) +#define ERROR_INTERNET_SEC_CERT_REV_FAILED (INTERNET_ERROR_BASE + 57) + +// +// FTP API errors +// + +#define ERROR_FTP_TRANSFER_IN_PROGRESS (INTERNET_ERROR_BASE + 110) +#define ERROR_FTP_DROPPED (INTERNET_ERROR_BASE + 111) +#define ERROR_FTP_NO_PASSIVE_MODE (INTERNET_ERROR_BASE + 112) + +// +// gopher API errors +// + +#define ERROR_GOPHER_PROTOCOL_ERROR (INTERNET_ERROR_BASE + 130) +#define ERROR_GOPHER_NOT_FILE (INTERNET_ERROR_BASE + 131) +#define ERROR_GOPHER_DATA_ERROR (INTERNET_ERROR_BASE + 132) +#define ERROR_GOPHER_END_OF_DATA (INTERNET_ERROR_BASE + 133) +#define ERROR_GOPHER_INVALID_LOCATOR (INTERNET_ERROR_BASE + 134) +#define ERROR_GOPHER_INCORRECT_LOCATOR_TYPE (INTERNET_ERROR_BASE + 135) +#define ERROR_GOPHER_NOT_GOPHER_PLUS (INTERNET_ERROR_BASE + 136) +#define ERROR_GOPHER_ATTRIBUTE_NOT_FOUND (INTERNET_ERROR_BASE + 137) +#define ERROR_GOPHER_UNKNOWN_LOCATOR (INTERNET_ERROR_BASE + 138) + +// +// HTTP API errors +// + +#define ERROR_HTTP_HEADER_NOT_FOUND (INTERNET_ERROR_BASE + 150) +#define ERROR_HTTP_DOWNLEVEL_SERVER (INTERNET_ERROR_BASE + 151) +#define ERROR_HTTP_INVALID_SERVER_RESPONSE (INTERNET_ERROR_BASE + 152) +#define ERROR_HTTP_INVALID_HEADER (INTERNET_ERROR_BASE + 153) +#define ERROR_HTTP_INVALID_QUERY_REQUEST (INTERNET_ERROR_BASE + 154) +#define ERROR_HTTP_HEADER_ALREADY_EXISTS (INTERNET_ERROR_BASE + 155) +#define ERROR_HTTP_REDIRECT_FAILED (INTERNET_ERROR_BASE + 156) +#define ERROR_HTTP_NOT_REDIRECTED (INTERNET_ERROR_BASE + 160) +#define ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION (INTERNET_ERROR_BASE + 161) +#define ERROR_HTTP_COOKIE_DECLINED (INTERNET_ERROR_BASE + 162) +#define ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION (INTERNET_ERROR_BASE + 168) + +// +// additional Internet API error codes +// + +#define ERROR_INTERNET_SECURITY_CHANNEL_ERROR (INTERNET_ERROR_BASE + 157) +#define ERROR_INTERNET_UNABLE_TO_CACHE_FILE (INTERNET_ERROR_BASE + 158) +#define ERROR_INTERNET_TCPIP_NOT_INSTALLED (INTERNET_ERROR_BASE + 159) +#define ERROR_INTERNET_DISCONNECTED (INTERNET_ERROR_BASE + 163) +#define ERROR_INTERNET_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 164) +#define ERROR_INTERNET_PROXY_SERVER_UNREACHABLE (INTERNET_ERROR_BASE + 165) + +#define ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT (INTERNET_ERROR_BASE + 166) +#define ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT (INTERNET_ERROR_BASE + 167) +#define ERROR_INTERNET_SEC_INVALID_CERT (INTERNET_ERROR_BASE + 169) +#define ERROR_INTERNET_SEC_CERT_REVOKED (INTERNET_ERROR_BASE + 170) + +// InternetAutodial specific errors + +#define ERROR_INTERNET_FAILED_DUETOSECURITYCHECK (INTERNET_ERROR_BASE + 171) +#define ERROR_INTERNET_NOT_INITIALIZED (INTERNET_ERROR_BASE + 172) +#define ERROR_INTERNET_NEED_MSN_SSPI_PKG (INTERNET_ERROR_BASE + 173) +#define ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY (INTERNET_ERROR_BASE + 174) + + +#define INTERNET_ERROR_LAST ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY + + +// +// URLCACHE APIs +// + +// +// datatype definitions. +// + +// +// cache entry type flags. +// + +#define NORMAL_CACHE_ENTRY 0x00000001 +#define STICKY_CACHE_ENTRY 0x00000004 +#define EDITED_CACHE_ENTRY 0x00000008 +#define TRACK_OFFLINE_CACHE_ENTRY 0x00000010 +#define TRACK_ONLINE_CACHE_ENTRY 0x00000020 +#define SPARSE_CACHE_ENTRY 0x00010000 +#define COOKIE_CACHE_ENTRY 0x00100000 +#define URLHISTORY_CACHE_ENTRY 0x00200000 + + +// +// INTERNET_CACHE_ENTRY_INFO - +// + + +// +// Cache Group Flags +// +#define CACHEGROUP_ATTRIBUTE_GET_ALL 0xffffffff +#define CACHEGROUP_ATTRIBUTE_BASIC 0x00000001 +#define CACHEGROUP_ATTRIBUTE_FLAG 0x00000002 +#define CACHEGROUP_ATTRIBUTE_TYPE 0x00000004 +#define CACHEGROUP_ATTRIBUTE_QUOTA 0x00000008 +#define CACHEGROUP_ATTRIBUTE_GROUPNAME 0x00000010 +#define CACHEGROUP_ATTRIBUTE_STORAGE 0x00000020 + +#define CACHEGROUP_FLAG_NONPURGEABLE 0x00000001 +#define CACHEGROUP_FLAG_GIDONLY 0x00000004 + +#define CACHEGROUP_FLAG_FLUSHURL_ONDELETE 0x00000002 + +#define CACHEGROUP_SEARCH_ALL 0x00000000 +#define CACHEGROUP_SEARCH_BYURL 0x00000001 + +#define CACHEGROUP_TYPE_INVALID 0x00000001 + +// +// INTERNET_CACHE_GROUP_INFO +// + +#define GROUPNAME_MAX_LENGTH 120 +#define GROUP_OWNER_STORAGE_SIZE 4 + + +#define CACHE_ENTRY_ATTRIBUTE_FC 0x00000004 +#define CACHE_ENTRY_HITRATE_FC 0x00000010 +#define CACHE_ENTRY_MODTIME_FC 0x00000040 +#define CACHE_ENTRY_EXPTIME_FC 0x00000080 +#define CACHE_ENTRY_ACCTIME_FC 0x00000100 +#define CACHE_ENTRY_SYNCTIME_FC 0x00000200 +#define CACHE_ENTRY_HEADERINFO_FC 0x00000400 +#define CACHE_ENTRY_EXEMPT_DELTA_FC 0x00000800 + + +// Flags for InternetAutodial +#define INTERNET_AUTODIAL_FORCE_ONLINE 1 +#define INTERNET_AUTODIAL_FORCE_UNATTENDED 2 +#define INTERNET_AUTODIAL_FAILIFSECURITYCHECK 4 + + +// Flags for InternetGetConnectedState and Ex +#define INTERNET_CONNECTION_MODEM 0x01 +#define INTERNET_CONNECTION_LAN 0x02 +#define INTERNET_CONNECTION_PROXY 0x04 +#define INTERNET_CONNECTION_MODEM_BUSY 0x08 /* no longer used */ +#define INTERNET_RAS_INSTALLED 0x10 +#define INTERNET_CONNECTION_OFFLINE 0x20 +#define INTERNET_CONNECTION_CONFIGURED 0x40 + +// Flags for custom dial handler +#define INTERNET_CUSTOMDIAL_CONNECT 0 +#define INTERNET_CUSTOMDIAL_UNATTENDED 1 +#define INTERNET_CUSTOMDIAL_DISCONNECT 2 +#define INTERNET_CUSTOMDIAL_SHOWOFFLINE 4 + +// Custom dial handler supported functionality flags +#define INTERNET_CUSTOMDIAL_SAFE_FOR_UNATTENDED 1 +#define INTERNET_CUSTOMDIAL_WILL_SUPPLY_STATE 2 +#define INTERNET_CUSTOMDIAL_CAN_HANGUP 4 + diff --git a/harbour/contrib/what32/wintabs.prg b/harbour/contrib/what32/wintabs.prg index b2b0460fdf..d73dea7b86 100644 --- a/harbour/contrib/what32/wintabs.prg +++ b/harbour/contrib/what32/wintabs.prg @@ -1,535 +1,535 @@ -/* - * $Id: wintabs.Prg 8045 2007-11-25 18:36:59Z vouchcac $ - */ - -#Define WIN_WANT_VER4 -#define WIN_WANT_ALL -#Include "winuser.ch" -#include "hbclass.ch" -//#Include 'debug.ch' -#Include "commctrl.ch" -#Include "wintypes.ch" -#Include "cstruct.ch" -#include "wingdi.ch" - - -// move that structure to WinStruc.ch - -typedef struct {; - HWND hwndFrom; - UINT idFrom; - UINT code; -} NMHDR - -*-----------------------------------------------------------------------------* - -CLASS TabControl - - DATA hParent - DATA hTab AS NUMERIC - DATA Tabs AS ARRAY HIDDEN - DATA Dlgs AS ARRAY HIDDEN - DATA Procs AS ARRAY HIDDEN - DATA nCurSel - DATA nProc - DATA nId - DATA Cargo - - METHOD New() CONSTRUCTOR - METHOD TabProc() - METHOD Add() - METHOD Insert() - METHOD Delete() - METHOD Configure() - METHOD AdjustRect() - METHOD DeleteAll() - METHOD DeselectAll() - METHOD GetCurFocus() - METHOD GetCurSel() - METHOD GetExtendedStyle() - METHOD GetImageList() - METHOD GetItem() - METHOD GetItemCount() - METHOD GetItemRect() - METHOD GetRowCount() - METHOD GetToolTips() - METHOD GetUnicodeFormat() - METHOD HighlightItem() - METHOD HitTest() - METHOD RemoveImage() - METHOD SetCurFocus() - METHOD SetCurSel() - METHOD SetExtendedStyle() - METHOD SetImageList() - METHOD SetItem() - METHOD SetItemExtra() - METHOD SetItemSize() - METHOD SetMinTabWidth() - METHOD SetPadding() - METHOD SetToolTips() - METHOD SetUnicodeFormat() - -ENDCLASS - -*-----------------------------------------------------------------------------* - -METHOD New( hDlg, nL, nT, nW, nH, nStyle, nSel,nId ) - ::hParent:=hDlg - ::Tabs:={} - ::Dlgs:={} - ::Procs:={} - ::nId:=nId - ::nCurSel:=IF(nSel==NIL,1,nSel) - ::hTab:=TabCtrl_Create( hDlg, nL, nT, nW, nH, nStyle,nId) - ::nProc:=SetProcedure( hDlg, {|hDlg,nMsg,nwParam,nlParam|; - ::TabProc(hDlg,nMsg,nwParam,nlParam)} , {WM_NOTIFY} ) -RETURN Self - -*-----------------------------------------------------------------------------* - -static FUNCTION _TempPageProc(nMsg) - IF nMsg==WM_CTLCOLORDLG - return(GetStockObject(NULL_BRUSH)) - END - - RETURN(0) - -*-----------------------------------------------------------------------------* - -#undef TCN_SELCHANGE -#define TCN_SELCHANGE 0 - -METHOD TabProc(hDlg, nMsg, nwParam, nlParam) - - LOCAL tnhdr - - LOCAL n,nSel - LOCAL lVisible - LOCAL lEnabled - LOCAL nLen - - IF nMsg==WM_NOTIFY - - tnhdr IS NMHDR - tnhdr:Buffer( peek(nlParam,tnhdr:sizeof() ) ) - - IF tnhdr:code==0//TCN_SELCHANGE - - nSel:=TabCtrl_GetCurSel( ::hTab )+1 - IF ::nCursel <> nSel - ShowWindow(::Tabs[::nCurSel], SW_HIDE) - ::nCurSel:=nSel - ShowWindow(::Tabs[::nCurSel], SW_SHOW) - /* - IF ::nCurSel > 0 - - //nLen:=len(::Tabs[::nCurSel]) - nLen:=if(EMPTY(::Tabs[::nCurSel]),0,len(::Tabs[::nCurSel])) - FOR n:=1 TO nLen - ::Tabs[::nCurSel,n,2]:=isWindowEnabled(::Tabs[::nCurSel,n,1]) - ::Tabs[::nCurSel,n,3]:=isWindowVisible(::Tabs[::nCurSel,n,1]) - ShowWindow(::Tabs[::nCurSel,n,1],SW_HIDE) - EnableWindow(::Tabs[::nCurSel,n,1],.F.) - NEXT - ENDIF - - ::nCurSel:=nSel - nLen:=if(EMPTY(::Tabs[::nCurSel]),0,len(::Tabs[::nCurSel])) - - FOR n:=1 TO nLen - IF ::Tabs[::nCurSel,n,2] - EnableWindow(::Tabs[::nCurSel,n,1],.T.) - ENDIF - IF ::Tabs[::nCurSel,n,3] - ShowWindow(::Tabs[::nCurSel,n,1],SW_SHOW) - ENDIF - NEXT - */ - - ENDIF - - ENDIF - - ENDIF - - Return( CallWindowProc(::nProc, hDlg, nMsg, nwParam, nlParam) ) - -*-----------------------------------------------------------------------------* - -METHOD Add(cText,cRes,bProc,nImgPos) -LOCAL hTab - - IF (hTab:=TabCtrl_AddItem(::hTab,cText,nImgPos)) > -1 - AADD(::Dlgs,cRes) - AADD(::Tabs,NIL ) - AADD(::Procs,bProc) - ENDIF - - RETURN(hTab) - -*-----------------------------------------------------------------------------* - -METHOD Insert(nPos,cText,cRes,bProc,nImgPos) - - if TabCtrl_InsertItem(::hTab,cText,nPos,nImgpos) > -1 - AINS(::Dlgs,nPos,cRes,.T.) - aIns(::Tabs,nPos,NIL,.T.) - AINS(::Procs,nPos,bProc,.T.) - RETURN(.T.) - ENDIF - - return(.F.) - -*-----------------------------------------------------------------------------* - -METHOD Delete(nPos) - - Local nCount:=LEN(::Tabs) - if nPos > 0 .and. nPos <= nCount - IF nPos <= ::nCurSel // verify !!!!! - ::nCurSel-- - ENDIF - TabCtrl_DeleteItem(nPos-1) - ADel(::Dlgs,nPos,.t.) - if isWindow(::Tabs[nPos]) - DestroyWindow(::Tabs[nPos]) - endif - ADel(::Tabs,nPos,.t.) - ADEL(::Procs,nPos,.T.) - return(.T.) - Endif - - RETURN(.F.) - -*-----------------------------------------------------------------------------* - -METHOD Configure() - - LOCAL aTab :=GetClientRect(::hTab) - local acRect:={0,0,0,0} - LOCAL aTemp - LOCAL aWnd:={} - LOCAL hCtrl - LOCAL i - LOCAL aPt - LOCAL bBlock - - aPt:={aTab[1],aTab[2]} - ClientToScreen(::hTab ,aPt) - ScreenToClient(::hParent,aPt) - aTab[1]:=aPt[1] - aTab[2]:=aPt[2] - - aPt:={aTab[3],aTab[4]} - ClientToScreen(::hTab ,aPt) - ScreenToClient(::hParent,aPt) - aTab[3]:=aPt[1] - aTab[4]:=aPt[2] - - - IF LEN(::Tabs) > 0 - acRect:=TabCtrl_GetItemRect(::hTab,0) - FOR i:=1 TO LEN(::Tabs)-1 - aTemp:=TabCtrl_GetItemRect(::hTab,i) - acRect[1]:=MIN(acRect[1],aTemp[1]) - acRect[2]:=MIN(acRect[2],aTemp[2]) - acRect[3]:=MAX(acRect[3],aTemp[3]) - acRect[4]:=MAX(acRect[4],aTemp[4]) - NEXT - ENDIF - - aPt:={acRect[1],acRect[2]} - ClientToScreen(::hTab ,aPt) - ScreenToClient(::hParent,aPt) - acRect[1]:=aPt[1] - acRect[2]:=aPt[2] - /* - aPt:={acRect[3],acRect[4]} - ClientToScreen(::hTab ,aPt) - ScreenToClient(::hParent,aPt) - acRect[3]:=aPt[1] - acRect[4]:=aPt[2] - */ - FOR i:=1 TO LEN(::Dlgs) - IF ::Dlgs[i] != NIL .AND. EMPTY(::Tabs[i]) - - hCtrl:=CreatePage(::Dlgs[i],::hParent,::Procs, i ) - ::Tabs[i]:=hCtrl - MoveWindow( hCtrl, acRect[1]+4, acRect[2]+acRect[4]+4, aTab[3]-aTab[1]-8, aTab[4]-(acRect[4]+acRect[2])- 8, .F. ) - IF i<>::nCurSel - ShowWindow(hCtrl,SW_HIDE) - ENDIF - ENDIF - NEXT - - RETURN(self) - -*-----------------------------------------------------------------------------* -Static Function CreatePage(acRes,hParent,aProcs, i) - Local bBlock:=IF(valtype( aProcs[i])== "B", aProcs[i], {|nMsg| _TempPageProc(nMsg)} ) - RETURN CreateDialog( , acRes, hParent, bBlock ) - -*-----------------------------------------------------------------------------* -METHOD AdjustRect(lDisplay,aRect) - - TabCtrl_AdjustRect(::hTab,lDisplay,@aRect) - - RETURN(aRect) - -*-----------------------------------------------------------------------------* -METHOD DeleteAll() - - Local lRet:=TabCtrl_DeleteAllItems(::hTab) - - AEVAL(::Tabs,{|hWnd| IF(isWindow(hWnd),DestroyWindow(hWnd),)}) - ::Tabs:={} - ::aDlg:={} - ::Procs:={} - ::nCurSel:=0 - - RETURN(lRet) - -*-----------------------------------------------------------------------------* -METHOD DeselectAll(lExcludeFocus) - - TabCtrl_DeselectAll(::hTab,lExcludeFocus) - - RETURN(NIL) - -*-----------------------------------------------------------------------------* -METHOD GetCurFocus() - - RETURN TabCtrl_GetCurFocus(::hTab )+1 - -*-----------------------------------------------------------------------------* -METHOD GetCurSel() - - RETURN TabCtrl_GetCurSel(::hTab)+1 - -*-----------------------------------------------------------------------------* -METHOD GetExtendedStyle() - - RETURN TabCtrl_GetExtendedStyle(::hTab) - -*-----------------------------------------------------------------------------* -METHOD GetImageList() - - RETURN NIL //TabCtrl_GetImageList(::hTab) - -*-----------------------------------------------------------------------------* -METHOD GetItem(nItem,ptrItem) - - RETURN TabCtrl_GetItem(::hTab,nItem-1,@ptrItem) - -*-----------------------------------------------------------------------------* -METHOD GetItemCount() - - RETURN TabCtrl_GetItemCount(::hTab) - -*-----------------------------------------------------------------------------* -METHOD GetItemRect(nItem) - - RETURN TabCtrl_GetItemRect(::hTab,nItem-1) - -*-----------------------------------------------------------------------------* -METHOD GetRowCount() - - RETURN TabCtrl_GetRowCount(::hTab) - -*-----------------------------------------------------------------------------* -METHOD GetToolTips() - - RETURN TabCtrl_GetToolTips(::hTab) - -*-----------------------------------------------------------------------------* -METHOD GetUnicodeFormat() - - RETURN TabCtrl_GetUnicodeFormat(::hTab) - -*-----------------------------------------------------------------------------* -METHOD HighlightItem(nItem,nHighlight) - - RETURN TabCtrl_HighlightItem(::hTab,nItem-1,nHighlight) - -*-----------------------------------------------------------------------------* -METHOD HitTest(nPtrHitTestInfo) - - RETURN TabCtrl_HitTest(::hTab,nPtrHitTestInfo) + 1 - -*-----------------------------------------------------------------------------* -METHOD RemoveImage(nImageIndex) - - RETURN TabCtrl_RemoveImage(::hTab, nImageIndex-1) - -*-----------------------------------------------------------------------------* -METHOD SetCurFocus(nItem) - - TabCtrl_SetCurFocus(::hTab, nItem-1) - - RETURN(NIL) - -*-----------------------------------------------------------------------------* -METHOD SetCurSel(nItem) - - RETURN TabCtrl_SetCurSel(::hTab, nItem-1) + 1 - -*-----------------------------------------------------------------------------* -METHOD SetExtendedStyle(nExStyle) - - RETURN TabCtrl_SetExtendedStyle(::hTab,nExStyle) - -*-----------------------------------------------------------------------------* -METHOD SetImageList(hImageList) - - RETURN TabCtrl_SetImageList(::hTab, hImageList) - -*-----------------------------------------------------------------------------* -METHOD SetItem(nItem, cText) - - RETURN TabCtrl_SetItem(::hTab, nItem-1, cText ) - -*-----------------------------------------------------------------------------* -METHOD SetItemExtra(nBytes) - - RETURN TabCtrl_SetItemExtra(::hTab, nBytes) - -*-----------------------------------------------------------------------------* -METHOD SetItemSize(x,y) - - RETURN TabCtrl_SetItemSize(::hTab, x, y ) - -*-----------------------------------------------------------------------------* -METHOD SetMinTabWidth(dx) - - RETURN TabCtrl_SetMinTabWidth( ::hTab, dx ) - -*-----------------------------------------------------------------------------* -METHOD SetPadding( cx, cy ) - - TabCtrl_SetPadding( ::hTab, cx, cy ) - - RETURN(NIL) - -*-----------------------------------------------------------------------------* -METHOD SetToolTips( hToolTips ) - - TabCtrl_SetToolTips( ::hTab, hToolTips ) - - RETURN(NIL) - -*-----------------------------------------------------------------------------* -METHOD SetUnicodeFormat( lUnicode ) - - RETURN TabCtrl_SetUnicodeFormat( ::hTab, lUnicode ) - -*-----------------------------------------------------------------------------* - - - - -/* -*-----------------------------------------------------------------------------* - -METHOD Configure() - - - LOCAL aTab :=GetClientRect(::hTab) - local acRect:={0,0,0,0} - LOCAL aTemp - LOCAL aWnd:={} - LOCAL hCtrl - LOCAL cRes - LOCAL i - - IF LEN(::Tabs) > 0 - acRect:=TabCtrl_GetItemRect(::hTab,1) - FOR i:=2 TO LEN(::Tabs) - aTemp:=TabCtrl_GetItemRect(::hTab,i) - acRect[1]:=MIN(acRect[1],aTemp[1]) - acRect[2]:=MIN(acRect[2],aTemp[2]) - acRect[3]:=MAX(acRect[3],aTemp[3]) - acRect[4]:=MAX(acRect[4],aTemp[4]) - NEXT - ENDIF - - FOR i:=1 TO LEN(::Dlgs) - aWnd:={} - IF (cRes:=::Dlgs[i]) != NIL .AND. EMPTY(::Tabs[i]) - hCtrl :=CreateDialog(,cRes, ::hTab,{|| _TempPageProc()}) - MoveWindow(hCtrl,4,acRect[2]+acRect[4]+4,aTab[3]-8,aTab[4]-acRect[2]-acRect[4]-6,.F.) - aWnd:=TransferChildren(::hParent,hCtrl,i==::nCurSel) - DestroyWindow(hCtrl) - ::Tabs[i]:=ACLONE(aWnd) - ENDIF - NEXT - - RETURN(self) - -*-----------------------------------------------------------------------------* - -Function TransferChildren(hDlg,hPage,lShow) - - LOCAL aChildren:={} - LOCAL aRect - LOCAL aPt - LOCAL lVisible - LOCAL lEnabled - LOCAL cClass - LOCAL cText - LOCAL nStyle - LOCAL nExStyle - LOCAL nId - LOCAL hNewWnd - LOCAL hWnd:=GetWindow(hPage,GW_CHILD) - - DO WHILE !EMPTY(hWnd) - aRect:=GetWindowRect(hWnd) - aPt:={aRect[1],aRect[2]} - ScreenToClient(hDlg,aPt) - aRect[3]-=aRect[1] - aRect[4]-=aRect[2] - aRect[1]:=aPt[1] - aRect[2]:=aPt[2] - cClass:=GetClassName(hWnd) - cText:=GetWindowText(hWnd) - nStyle:=GetWindowLong(hWnd,GWL_STYLE) - nExStyle:=GetWindowLong(hWnd,GWL_EXSTYLE) - nId:=GetWindowLong(hWnd,GWL_ID) - hNewWnd:=CreateWindowEx(nExStyle,cClass,cText,nStyle,; - aRect[1],aRect[2],aRect[3],aRect[4],hDlg,nId) - SendMEssage(hNewWnd,WM_SETFONT,SendMessage(hWnd,WM_GETFONT,0,0), 0 ) - lVisible:=AND(nStyle,WS_VISIBLE)==WS_VISIBLE - lEnabled:=isWindowEnabled(hWnd) - AADD(aChildren,{hNewWnd,lEnabled,lVisible}) - IF !lShow - ShowWindow(hNewWnd,SW_HIDE) - EnableWindow(hNewWnd,.F.) - Endif - hWnd:=GetWindow(hWnd,GW_HWNDNEXT) - ENDDO - - RETURN(aChildren) - -*-----------------------------------------------------------------------------* - -*/ - - - - - - - - - - - - - - - - - - - - +/* + * $Id$ + */ + +#Define WIN_WANT_VER4 +#define WIN_WANT_ALL +#Include "winuser.ch" +#include "hbclass.ch" +//#Include 'debug.ch' +#Include "commctrl.ch" +#Include "wintypes.ch" +#Include "cstruct.ch" +#include "wingdi.ch" + + +// move that structure to WinStruc.ch + +typedef struct {; + HWND hwndFrom; + UINT idFrom; + UINT code; +} NMHDR + +*-----------------------------------------------------------------------------* + +CLASS TabControl + + DATA hParent + DATA hTab AS NUMERIC + DATA Tabs AS ARRAY HIDDEN + DATA Dlgs AS ARRAY HIDDEN + DATA Procs AS ARRAY HIDDEN + DATA nCurSel + DATA nProc + DATA nId + DATA Cargo + + METHOD New() CONSTRUCTOR + METHOD TabProc() + METHOD Add() + METHOD Insert() + METHOD Delete() + METHOD Configure() + METHOD AdjustRect() + METHOD DeleteAll() + METHOD DeselectAll() + METHOD GetCurFocus() + METHOD GetCurSel() + METHOD GetExtendedStyle() + METHOD GetImageList() + METHOD GetItem() + METHOD GetItemCount() + METHOD GetItemRect() + METHOD GetRowCount() + METHOD GetToolTips() + METHOD GetUnicodeFormat() + METHOD HighlightItem() + METHOD HitTest() + METHOD RemoveImage() + METHOD SetCurFocus() + METHOD SetCurSel() + METHOD SetExtendedStyle() + METHOD SetImageList() + METHOD SetItem() + METHOD SetItemExtra() + METHOD SetItemSize() + METHOD SetMinTabWidth() + METHOD SetPadding() + METHOD SetToolTips() + METHOD SetUnicodeFormat() + +ENDCLASS + +*-----------------------------------------------------------------------------* + +METHOD New( hDlg, nL, nT, nW, nH, nStyle, nSel,nId ) + ::hParent:=hDlg + ::Tabs:={} + ::Dlgs:={} + ::Procs:={} + ::nId:=nId + ::nCurSel:=IF(nSel==NIL,1,nSel) + ::hTab:=TabCtrl_Create( hDlg, nL, nT, nW, nH, nStyle,nId) + ::nProc:=SetProcedure( hDlg, {|hDlg,nMsg,nwParam,nlParam|; + ::TabProc(hDlg,nMsg,nwParam,nlParam)} , {WM_NOTIFY} ) +RETURN Self + +*-----------------------------------------------------------------------------* + +static FUNCTION _TempPageProc(nMsg) + IF nMsg==WM_CTLCOLORDLG + return(GetStockObject(NULL_BRUSH)) + END + + RETURN(0) + +*-----------------------------------------------------------------------------* + +#undef TCN_SELCHANGE +#define TCN_SELCHANGE 0 + +METHOD TabProc(hDlg, nMsg, nwParam, nlParam) + + LOCAL tnhdr + + LOCAL n,nSel + LOCAL lVisible + LOCAL lEnabled + LOCAL nLen + + IF nMsg==WM_NOTIFY + + tnhdr IS NMHDR + tnhdr:Buffer( peek(nlParam,tnhdr:sizeof() ) ) + + IF tnhdr:code==0//TCN_SELCHANGE + + nSel:=TabCtrl_GetCurSel( ::hTab )+1 + IF ::nCursel <> nSel + ShowWindow(::Tabs[::nCurSel], SW_HIDE) + ::nCurSel:=nSel + ShowWindow(::Tabs[::nCurSel], SW_SHOW) + /* + IF ::nCurSel > 0 + + //nLen:=len(::Tabs[::nCurSel]) + nLen:=if(EMPTY(::Tabs[::nCurSel]),0,len(::Tabs[::nCurSel])) + FOR n:=1 TO nLen + ::Tabs[::nCurSel,n,2]:=isWindowEnabled(::Tabs[::nCurSel,n,1]) + ::Tabs[::nCurSel,n,3]:=isWindowVisible(::Tabs[::nCurSel,n,1]) + ShowWindow(::Tabs[::nCurSel,n,1],SW_HIDE) + EnableWindow(::Tabs[::nCurSel,n,1],.F.) + NEXT + ENDIF + + ::nCurSel:=nSel + nLen:=if(EMPTY(::Tabs[::nCurSel]),0,len(::Tabs[::nCurSel])) + + FOR n:=1 TO nLen + IF ::Tabs[::nCurSel,n,2] + EnableWindow(::Tabs[::nCurSel,n,1],.T.) + ENDIF + IF ::Tabs[::nCurSel,n,3] + ShowWindow(::Tabs[::nCurSel,n,1],SW_SHOW) + ENDIF + NEXT + */ + + ENDIF + + ENDIF + + ENDIF + + Return( CallWindowProc(::nProc, hDlg, nMsg, nwParam, nlParam) ) + +*-----------------------------------------------------------------------------* + +METHOD Add(cText,cRes,bProc,nImgPos) +LOCAL hTab + + IF (hTab:=TabCtrl_AddItem(::hTab,cText,nImgPos)) > -1 + AADD(::Dlgs,cRes) + AADD(::Tabs,NIL ) + AADD(::Procs,bProc) + ENDIF + + RETURN(hTab) + +*-----------------------------------------------------------------------------* + +METHOD Insert(nPos,cText,cRes,bProc,nImgPos) + + if TabCtrl_InsertItem(::hTab,cText,nPos,nImgpos) > -1 + AINS(::Dlgs,nPos,cRes,.T.) + aIns(::Tabs,nPos,NIL,.T.) + AINS(::Procs,nPos,bProc,.T.) + RETURN(.T.) + ENDIF + + return(.F.) + +*-----------------------------------------------------------------------------* + +METHOD Delete(nPos) + + Local nCount:=LEN(::Tabs) + if nPos > 0 .and. nPos <= nCount + IF nPos <= ::nCurSel // verify !!!!! + ::nCurSel-- + ENDIF + TabCtrl_DeleteItem(nPos-1) + ADel(::Dlgs,nPos,.t.) + if isWindow(::Tabs[nPos]) + DestroyWindow(::Tabs[nPos]) + endif + ADel(::Tabs,nPos,.t.) + ADEL(::Procs,nPos,.T.) + return(.T.) + Endif + + RETURN(.F.) + +*-----------------------------------------------------------------------------* + +METHOD Configure() + + LOCAL aTab :=GetClientRect(::hTab) + local acRect:={0,0,0,0} + LOCAL aTemp + LOCAL aWnd:={} + LOCAL hCtrl + LOCAL i + LOCAL aPt + LOCAL bBlock + + aPt:={aTab[1],aTab[2]} + ClientToScreen(::hTab ,aPt) + ScreenToClient(::hParent,aPt) + aTab[1]:=aPt[1] + aTab[2]:=aPt[2] + + aPt:={aTab[3],aTab[4]} + ClientToScreen(::hTab ,aPt) + ScreenToClient(::hParent,aPt) + aTab[3]:=aPt[1] + aTab[4]:=aPt[2] + + + IF LEN(::Tabs) > 0 + acRect:=TabCtrl_GetItemRect(::hTab,0) + FOR i:=1 TO LEN(::Tabs)-1 + aTemp:=TabCtrl_GetItemRect(::hTab,i) + acRect[1]:=MIN(acRect[1],aTemp[1]) + acRect[2]:=MIN(acRect[2],aTemp[2]) + acRect[3]:=MAX(acRect[3],aTemp[3]) + acRect[4]:=MAX(acRect[4],aTemp[4]) + NEXT + ENDIF + + aPt:={acRect[1],acRect[2]} + ClientToScreen(::hTab ,aPt) + ScreenToClient(::hParent,aPt) + acRect[1]:=aPt[1] + acRect[2]:=aPt[2] + /* + aPt:={acRect[3],acRect[4]} + ClientToScreen(::hTab ,aPt) + ScreenToClient(::hParent,aPt) + acRect[3]:=aPt[1] + acRect[4]:=aPt[2] + */ + FOR i:=1 TO LEN(::Dlgs) + IF ::Dlgs[i] != NIL .AND. EMPTY(::Tabs[i]) + + hCtrl:=CreatePage(::Dlgs[i],::hParent,::Procs, i ) + ::Tabs[i]:=hCtrl + MoveWindow( hCtrl, acRect[1]+4, acRect[2]+acRect[4]+4, aTab[3]-aTab[1]-8, aTab[4]-(acRect[4]+acRect[2])- 8, .F. ) + IF i<>::nCurSel + ShowWindow(hCtrl,SW_HIDE) + ENDIF + ENDIF + NEXT + + RETURN(self) + +*-----------------------------------------------------------------------------* +Static Function CreatePage(acRes,hParent,aProcs, i) + Local bBlock:=IF(valtype( aProcs[i])== "B", aProcs[i], {|nMsg| _TempPageProc(nMsg)} ) + RETURN CreateDialog( , acRes, hParent, bBlock ) + +*-----------------------------------------------------------------------------* +METHOD AdjustRect(lDisplay,aRect) + + TabCtrl_AdjustRect(::hTab,lDisplay,@aRect) + + RETURN(aRect) + +*-----------------------------------------------------------------------------* +METHOD DeleteAll() + + Local lRet:=TabCtrl_DeleteAllItems(::hTab) + + AEVAL(::Tabs,{|hWnd| IF(isWindow(hWnd),DestroyWindow(hWnd),)}) + ::Tabs:={} + ::aDlg:={} + ::Procs:={} + ::nCurSel:=0 + + RETURN(lRet) + +*-----------------------------------------------------------------------------* +METHOD DeselectAll(lExcludeFocus) + + TabCtrl_DeselectAll(::hTab,lExcludeFocus) + + RETURN(NIL) + +*-----------------------------------------------------------------------------* +METHOD GetCurFocus() + + RETURN TabCtrl_GetCurFocus(::hTab )+1 + +*-----------------------------------------------------------------------------* +METHOD GetCurSel() + + RETURN TabCtrl_GetCurSel(::hTab)+1 + +*-----------------------------------------------------------------------------* +METHOD GetExtendedStyle() + + RETURN TabCtrl_GetExtendedStyle(::hTab) + +*-----------------------------------------------------------------------------* +METHOD GetImageList() + + RETURN NIL //TabCtrl_GetImageList(::hTab) + +*-----------------------------------------------------------------------------* +METHOD GetItem(nItem,ptrItem) + + RETURN TabCtrl_GetItem(::hTab,nItem-1,@ptrItem) + +*-----------------------------------------------------------------------------* +METHOD GetItemCount() + + RETURN TabCtrl_GetItemCount(::hTab) + +*-----------------------------------------------------------------------------* +METHOD GetItemRect(nItem) + + RETURN TabCtrl_GetItemRect(::hTab,nItem-1) + +*-----------------------------------------------------------------------------* +METHOD GetRowCount() + + RETURN TabCtrl_GetRowCount(::hTab) + +*-----------------------------------------------------------------------------* +METHOD GetToolTips() + + RETURN TabCtrl_GetToolTips(::hTab) + +*-----------------------------------------------------------------------------* +METHOD GetUnicodeFormat() + + RETURN TabCtrl_GetUnicodeFormat(::hTab) + +*-----------------------------------------------------------------------------* +METHOD HighlightItem(nItem,nHighlight) + + RETURN TabCtrl_HighlightItem(::hTab,nItem-1,nHighlight) + +*-----------------------------------------------------------------------------* +METHOD HitTest(nPtrHitTestInfo) + + RETURN TabCtrl_HitTest(::hTab,nPtrHitTestInfo) + 1 + +*-----------------------------------------------------------------------------* +METHOD RemoveImage(nImageIndex) + + RETURN TabCtrl_RemoveImage(::hTab, nImageIndex-1) + +*-----------------------------------------------------------------------------* +METHOD SetCurFocus(nItem) + + TabCtrl_SetCurFocus(::hTab, nItem-1) + + RETURN(NIL) + +*-----------------------------------------------------------------------------* +METHOD SetCurSel(nItem) + + RETURN TabCtrl_SetCurSel(::hTab, nItem-1) + 1 + +*-----------------------------------------------------------------------------* +METHOD SetExtendedStyle(nExStyle) + + RETURN TabCtrl_SetExtendedStyle(::hTab,nExStyle) + +*-----------------------------------------------------------------------------* +METHOD SetImageList(hImageList) + + RETURN TabCtrl_SetImageList(::hTab, hImageList) + +*-----------------------------------------------------------------------------* +METHOD SetItem(nItem, cText) + + RETURN TabCtrl_SetItem(::hTab, nItem-1, cText ) + +*-----------------------------------------------------------------------------* +METHOD SetItemExtra(nBytes) + + RETURN TabCtrl_SetItemExtra(::hTab, nBytes) + +*-----------------------------------------------------------------------------* +METHOD SetItemSize(x,y) + + RETURN TabCtrl_SetItemSize(::hTab, x, y ) + +*-----------------------------------------------------------------------------* +METHOD SetMinTabWidth(dx) + + RETURN TabCtrl_SetMinTabWidth( ::hTab, dx ) + +*-----------------------------------------------------------------------------* +METHOD SetPadding( cx, cy ) + + TabCtrl_SetPadding( ::hTab, cx, cy ) + + RETURN(NIL) + +*-----------------------------------------------------------------------------* +METHOD SetToolTips( hToolTips ) + + TabCtrl_SetToolTips( ::hTab, hToolTips ) + + RETURN(NIL) + +*-----------------------------------------------------------------------------* +METHOD SetUnicodeFormat( lUnicode ) + + RETURN TabCtrl_SetUnicodeFormat( ::hTab, lUnicode ) + +*-----------------------------------------------------------------------------* + + + + +/* +*-----------------------------------------------------------------------------* + +METHOD Configure() + + + LOCAL aTab :=GetClientRect(::hTab) + local acRect:={0,0,0,0} + LOCAL aTemp + LOCAL aWnd:={} + LOCAL hCtrl + LOCAL cRes + LOCAL i + + IF LEN(::Tabs) > 0 + acRect:=TabCtrl_GetItemRect(::hTab,1) + FOR i:=2 TO LEN(::Tabs) + aTemp:=TabCtrl_GetItemRect(::hTab,i) + acRect[1]:=MIN(acRect[1],aTemp[1]) + acRect[2]:=MIN(acRect[2],aTemp[2]) + acRect[3]:=MAX(acRect[3],aTemp[3]) + acRect[4]:=MAX(acRect[4],aTemp[4]) + NEXT + ENDIF + + FOR i:=1 TO LEN(::Dlgs) + aWnd:={} + IF (cRes:=::Dlgs[i]) != NIL .AND. EMPTY(::Tabs[i]) + hCtrl :=CreateDialog(,cRes, ::hTab,{|| _TempPageProc()}) + MoveWindow(hCtrl,4,acRect[2]+acRect[4]+4,aTab[3]-8,aTab[4]-acRect[2]-acRect[4]-6,.F.) + aWnd:=TransferChildren(::hParent,hCtrl,i==::nCurSel) + DestroyWindow(hCtrl) + ::Tabs[i]:=ACLONE(aWnd) + ENDIF + NEXT + + RETURN(self) + +*-----------------------------------------------------------------------------* + +Function TransferChildren(hDlg,hPage,lShow) + + LOCAL aChildren:={} + LOCAL aRect + LOCAL aPt + LOCAL lVisible + LOCAL lEnabled + LOCAL cClass + LOCAL cText + LOCAL nStyle + LOCAL nExStyle + LOCAL nId + LOCAL hNewWnd + LOCAL hWnd:=GetWindow(hPage,GW_CHILD) + + DO WHILE !EMPTY(hWnd) + aRect:=GetWindowRect(hWnd) + aPt:={aRect[1],aRect[2]} + ScreenToClient(hDlg,aPt) + aRect[3]-=aRect[1] + aRect[4]-=aRect[2] + aRect[1]:=aPt[1] + aRect[2]:=aPt[2] + cClass:=GetClassName(hWnd) + cText:=GetWindowText(hWnd) + nStyle:=GetWindowLong(hWnd,GWL_STYLE) + nExStyle:=GetWindowLong(hWnd,GWL_EXSTYLE) + nId:=GetWindowLong(hWnd,GWL_ID) + hNewWnd:=CreateWindowEx(nExStyle,cClass,cText,nStyle,; + aRect[1],aRect[2],aRect[3],aRect[4],hDlg,nId) + SendMEssage(hNewWnd,WM_SETFONT,SendMessage(hWnd,WM_GETFONT,0,0), 0 ) + lVisible:=AND(nStyle,WS_VISIBLE)==WS_VISIBLE + lEnabled:=isWindowEnabled(hWnd) + AADD(aChildren,{hNewWnd,lEnabled,lVisible}) + IF !lShow + ShowWindow(hNewWnd,SW_HIDE) + EnableWindow(hNewWnd,.F.) + Endif + hWnd:=GetWindow(hWnd,GW_HWNDNEXT) + ENDDO + + RETURN(aChildren) + +*-----------------------------------------------------------------------------* + +*/ + + + + + + + + + + + + + + + + + + + + diff --git a/harbour/contrib/what32/wintbar.prg b/harbour/contrib/what32/wintbar.prg index 6b54df8c7d..7ccc95bb88 100644 --- a/harbour/contrib/what32/wintbar.prg +++ b/harbour/contrib/what32/wintbar.prg @@ -1,452 +1,452 @@ -/* - * $Id: wintbar.Prg 8045 2007-11-25 18:36:59Z vouchcac $ - */ - - -// What32.Lib -// Tollbar class - - -#Include "winuser.ch" -#include "hbclass.ch" -#Include "commctrl.ch" -#Include 'debug.ch' -#Include "wintypes.ch" -#Include "cstruct.ch" -#Include 'what32.ch' - -pragma pack(4) - -typedef struct _RECT { ; - LONG left; - LONG top; - LONG right; - LONG bottom; -} RECT - -typedef struct tagNMHDR {; - HWND hwndFrom; - UINT idFrom; - UINT code; -} NMHDR - -typedef struct _TBBUTTON {; - int iBitmap; - int idCommand; - BYTE fsState; - BYTE fsStyle; - DWORD dwData; - int iString; -} TBBUTTON, NEAR* PTBBUTTON, FAR* LPTBBUTTON - -typedef struct tagNMTOOLBAR {; - NMHDR hdr; - int iItem; - TBBUTTON tbButton; - int cchText; - LPSTR pszText; - RECT rcButton; -} NMTOOLBAR, FAR* LPNMTOOLBAR - - - -typedef struct tagTBADDBITMAP {; - HINSTANCE hInst; - UINT nID; -} TBADDBITMAP, *LPTBADDBITMAP - -typedef struct {; - NMHDR hdr; // required for all WM_NOTIFY messages - LPTSTR lpszText; // see below - char szText[80]; // buffer for tool tip text - HINSTANCE hinst; // see below - UINT uflags; // flag indicating how to interpret the idFrom member of the NMHDR structure that is included in the structure -} TOOLTIPTEXT, FAR *LPTOOLTIPTEXT - -/* -typedef struct tagNMTBHOTITEM {; - NMHDR hdr; - int idOld; - int idNew; - DWORD dwFlags; -} NMTBHOTITEM, FAR *LPNMTBHOTITEM -*/ - -// based on cToolBar class -*-----------------------------------------------------------------------------* - -CLASS TOOLBAR - - DATA abuttons - DATA aBitmaps - DATA hParent - DATA hWnd - DATA nId - DATA nStyle - DATA Created - DATA aText - DATA hBmp - DATA nProc - DATA aTips - DATA nBtn HIDDEN - DATA aMenus -METHOD Init() CONSTRUCTOR - -METHOD AddButton -METHOD AddBitmap -METHOD AddString -METHOD Create -METHOD createbuttons -METHOD tbProc - -METHOD setsizes(xBtn,yBtn,xImg,yImg ) -METHOD setheight(nHeight ) -METHOD loadbitmap -METHOD setbitmap -METHOD setbuttons -METHOD commandtoindex -METHOD GetItemId -METHOD getitemrect -METHOD getbuttonstyle -METHOD getbuttoninfo -METHOD setbuttoninfo -METHOD getbuttontext -METHOD setbuttontext -METHOD gettollbarctrl -METHOD disable -METHOD enable -METHOD disableall -METHOD enableall -METHOD CheckButton -METHOD IsButtonChecked -METHOD AddMenu -ENDCLASS - - -*-----------------------------------------------------------------------------* - -METHOD Init() - - InitCommonControlsEx(ICC_BAR_CLASSES) - ::aButtons:={} - ::aTips :={} - ::nStyle :=0 - ::nId :=0 - ::Created := .F. - ::aText :={} - ::aBitmaps:={} - ::aMenus :={} -RETURN(self) - - -*-----------------------------------------------------------------------------* - -METHOD AddBitmap(hInst, nhIdBmp, nButtons) - - LOCAL tbab IS TBADDBITMAP - - DEFAULT nButtons TO 1 - - tbab:hInst := hInst - tbab:nId := nhIdBmp - - AADD(::aBitmaps,{tbab,nButtons}) - IF ::created - SendMessage(::hWnd,TB_ADDBITMAP,nButtons,tbab:value) - ENDIF - - - RETURN(1) - -*-----------------------------------------------------------------------------* - -METHOD AddButton(nIndex, nId, nState, nStyle, ncargo, nString, cText, cToolTip ) - - LOCAL tbb IS TBBUTTON - - tbb:ibitmap :=IFNIL(nIndex,-1,nIndex) - tbb:idCommand :=nId // must be supplied - tbb:fsState :=IFNIL(nState,TBSTATE_ENABLED,nState) - tbb:fsStyle :=IFNIL(nStyle,TBSTYLE_BUTTON,nStyle) - tbb:dwData :=IFNIL(ncargo,0,nCargo) - tbb:iString :=IFNIL(nString,0,nString) - - AADD(::aButtons,tbb) - AADD(::aTips,cToolTip) - IF ::Created - SendMessage(::hWnd,TB_ADDBUTTONS,1,tbb:value) - Endif - - -RETURN(self) - -METHOD AddMenu(nButton, nMenuId, cMenuText ) -AADD(::aMenus,{nButton, nMenuId, cMenuText }) -return(self) - -*-----------------------------------------------------------------------------* -METHOD addstring(cText) - - IF ::created - SendMessage(::hWnd,TB_ADDSTRING,0,cText) - Else - AADD(::aText,cText) - Endif - - RETURN(self) - -*-----------------------------------------------------------------------------* -// HWND CreateToolbarEx( HWND hwnd, DWORD ws, UINT wID,int nBitmaps,HINSTANCE hBMInst, -// UINT wBMID,LPCTBBUTTON lpButtons,int iNumButtons,int dxButton, -// int dyButton, int dxBitmap, int dyBitmap,UINT uStructSize ); - -METHOD Create(hParent,nStyle,nId,nImg,hBMInst,nBMId,xBtn,yBtn,xBmp,yBmp) - - LOCAL cButtons:="" - LOCAL cStrings:="" - LOCAL tbb IS TBBUTTON - LOCAL i - - - ::hParent:=hParent - ::nStyle :=IFNIL(nStyle,TBSTYLE_FLAT+WS_CHILD+WS_VISIBLE,nStyle) - ::nId :=IFNIL(nId,0,nId) - - if ISNIL(hBMInst) .AND. ISNIL(nBMId) - hBMInst:=HINST_COMMCTRL - nBMId :=IDB_STD_LARGE_COLOR - endif - - FOR i:=1 TO LEN(::aButtons) - cButtons+=::aButtons[i]:Value - NEXT - -// ::hWnd:=CreateWindowEx(0,TOOLBARCLASSNAME,"",::nStyle,0,0,300,30,::hParent,::nId) - - - ::hWnd:=CreateToolBarEx(::hParent,::nStyle,::nId,nImg,hBMInst,nBMId,cButtons,LEN(::aButtons),; - xbtn,yBtn,xBmp,yBmp, tbb:sizeof()) - - ::nProc:=SetProcedure(::hParent,{|hWnd, nMsg,nwParam,nlParam| ::tbProc(nMsg,nwParam,nlParam)},{WM_NOTIFY}) - - -// SendMessage(::hWnd,TB_BUTTONSTRUCTSIZE,::aButtons[1]:sizeof,0) - - // FOR i:=1 TO LEN(::aBitmaps) - // SendMessage(::hWnd,TB_ADDBITMAP,::aBitmaps[i,2],::aBitmaps[i,1]:value) - // NEXT - - sendmessage(::hwnd,TB_SETEXTENDEDSTYLE,0,TBSTYLE_EX_DRAWDDARROWS ) - - //SendMessage(::hWnd,TB_ADDBUTTONS,LEN(::aButtons),cButtons) - - FOR i:=1 to LEN(::aText) - SendMessage(::hWnd,TB_ADDSTRING,0,::aText[i]) - NEXT - - ::Created:=.T. - -RETURN(::hWnd) - - -*-----------------------------------------------------------------------------* - -#undef TBN_DROPDOWN -#undef TTN_NEEDTEXT -#undef TBN_QUERYINSERT -#undef TBN_QUERYDELETE -#undef TBN_GETBUTTONINFO - -#DEFINE TBN_DROPDOWN 0 -#DEFINE TTN_NEEDTEXT 1 -#DEFINE TBN_QUERYINSERT 2 -#DEFINE TBN_QUERYDELETE 3 -#DEFINE TBN_GETBUTTONINFO 4 - -METHOD tbProc(nMsg,nwParam,nlParam) - - LOCAL Hdr - LOCAL Ttt - LOCAL nmt - LOCAL nID - LOCAL hMenu,rc,aRect, aPoint - LOCAL n,x - LOCAL hic - DO CASE - CASE nMsg==WM_NOTIFY - Hdr IS NMHDR - Hdr:Buffer(peek(nlParam,Hdr:sizeof)) - - DO CASE - CASE Hdr:code==TBN_DROPDOWN - Nmt IS NMTOOLBAR - nmt:buffer(peek(nlParam,nmt:sizeof)) - IF (n:=ASCAN(::aMenus,{|a| a[1]==nmt:iItem})) > 0 - ::nBtn:=nmt:iItem - hMenu = CreatePopupMenu( ) - FOR x:=1 TO LEN(::aMenus) - IF ::aMenus[x][1] == nmt:iItem - IF ::aMenus[x][3] == "-".and. ::aMenus[x][2] == 0 - AppendMenu( hMenu, MF_SEPARATOR ) - ELSE - AppendMenu( hMenu, MF_ENABLED + MF_STRING,::aMenus[x][2],::aMenus[x][3]) - ENDIF - ENDIF - NEXT - - x:= ASCAN(::aButtons,{|btn| btn:idCommand==nmt:iItem}) - aRect:=GetToolBarItemRect(::hWnd,x-1) - aPoint := {aRect[1],aRect[4]} - ClientToScreen( ::hParent, @aPoint ) - TrackPopupMenu( hMenu, TPM_LEFTALIGN+TPM_TOPALIGN, aPoint[1]+9, aPoint[2], 0, ::hWnd ) - DestroyMenu(hMenu) - RETURN 0 - end - CASE Hdr:code==TTN_NEEDTEXT - IF (n:=ASCAN(::aButtons,{|btn| btn:idCommand==Hdr:idFrom})) > 0 - Ttt IS TOOLTIPTEXT - Ttt:Buffer(peek(nlParam,Ttt:sizeof)) - Ttt:lpszText:=::aTips[n] //"ID:"+STR(Hdr:IdFrom) - poke(nlParam,Ttt:value,Ttt:sizeof) - ENDIF - - CASE Hdr:code==TBN_QUERYINSERT - RETURN(1) - CASE Hdr:code==TBN_QUERYDELETE - RETURN(1) - CASE Hdr:code==TBN_GETBUTTONINFO - Nmt IS NMTOOLBAR - nmt:buffer(peek(nlParam,nmt:sizeof)) - /* - int iItem; // cmd - TBBUTTON tbButton; - int cchText; // str len - LPSTR pszText; // btn text - RECT rcButton; // new (!) - */ - RETURN(1) - - ENDCASE - - ENDCASE - -RETURN( CallWindowProc(::nProc,::hParent,nMsg,nwParam,nlParam)) - -*-----------------------------------------------------------------------------* - -METHOD CreateButtons() - - LOCAL aSize - LOCAL i - - - - - FOR i:=1 TO LEN(::aBitmaps) - - - - - NEXT - - -RETURN(NIL) - - - - - - - - -*-----------------------------------------------------------------------------* - - -METHOD setsizes(xBtn,yBtn,xImg,yImg ) -RETURN(self) -*-----------------------------------------------------------------------------* - -METHOD setheight(nHeight ) -RETURN(self) -*-----------------------------------------------------------------------------* - -METHOD loadbitmap -RETURN(self) -*-----------------------------------------------------------------------------* - -METHOD setbitmap -RETURN(self) -*-----------------------------------------------------------------------------* - -METHOD setbuttons -RETURN(self) -*-----------------------------------------------------------------------------* - -METHOD commandtoindex -RETURN(self) -*-----------------------------------------------------------------------------* - -METHOD GetItemId -RETURN(self) -*-----------------------------------------------------------------------------* - -METHOD getitemrect(nIndex) -RETURN(GetToolbarItemRect(::hWnd,nIndex)) - -*-----------------------------------------------------------------------------* - -METHOD getbuttonstyle -RETURN(self) -*-----------------------------------------------------------------------------* - -METHOD getbuttoninfo -RETURN(self) -*-----------------------------------------------------------------------------* - -METHOD setbuttoninfo -RETURN(self) -*-----------------------------------------------------------------------------* - -METHOD getbuttontext -RETURN(self) -*-----------------------------------------------------------------------------* - -METHOD setbuttontext -RETURN(self) -*-----------------------------------------------------------------------------* - -METHOD gettollbarctrl - -RETURN(self) -*-----------------------------------------------------------------------------* - -METHOD disable(nBtn) -SendMessage(::hWnd,TB_ENABLEBUTTON,nBtn,0) -RETURN(SELF) - -*-----------------------------------------------------------------------------* - -METHOD enable(nBtn,lFlag) -DEFAULT lFlag TO .T. -SendMessage(::hWnd,TB_ENABLEBUTTON,nBtn,If(lFlag,1,0)) -RETURN(SELF) - -*-----------------------------------------------------------------------------* - -METHOD disableall() -AEVAL(::aButtons,{|btn| ::disable(btn:idCommand)}) -return(self) - -*-----------------------------------------------------------------------------* - -METHOD enableall() -AEVAL(::aButtons,{|btn| ::enable(btn:idCommand)}) -return(self) - -METHOD CheckButton(nBtn,lFlag) -DEFAULT lFlag TO !::IsButtonChecked(nBtn) -SendMessage(::hWnd,TB_CHECKBUTTON,nBtn,If(lFlag,1,0)) -RETURN(SELF) - -METHOD IsButtonChecked(nBtn) -RETURN(IIF(SendMessage(::hWnd,TB_ISBUTTONCHECKED,nBtn,0)==0,.F.,.T.)) +/* + * $Id$ + */ + + +// What32.Lib +// Tollbar class + + +#Include "winuser.ch" +#include "hbclass.ch" +#Include "commctrl.ch" +#Include 'debug.ch' +#Include "wintypes.ch" +#Include "cstruct.ch" +#Include 'what32.ch' + +pragma pack(4) + +typedef struct _RECT { ; + LONG left; + LONG top; + LONG right; + LONG bottom; +} RECT + +typedef struct tagNMHDR {; + HWND hwndFrom; + UINT idFrom; + UINT code; +} NMHDR + +typedef struct _TBBUTTON {; + int iBitmap; + int idCommand; + BYTE fsState; + BYTE fsStyle; + DWORD dwData; + int iString; +} TBBUTTON, NEAR* PTBBUTTON, FAR* LPTBBUTTON + +typedef struct tagNMTOOLBAR {; + NMHDR hdr; + int iItem; + TBBUTTON tbButton; + int cchText; + LPSTR pszText; + RECT rcButton; +} NMTOOLBAR, FAR* LPNMTOOLBAR + + + +typedef struct tagTBADDBITMAP {; + HINSTANCE hInst; + UINT nID; +} TBADDBITMAP, *LPTBADDBITMAP + +typedef struct {; + NMHDR hdr; // required for all WM_NOTIFY messages + LPTSTR lpszText; // see below + char szText[80]; // buffer for tool tip text + HINSTANCE hinst; // see below + UINT uflags; // flag indicating how to interpret the idFrom member of the NMHDR structure that is included in the structure +} TOOLTIPTEXT, FAR *LPTOOLTIPTEXT + +/* +typedef struct tagNMTBHOTITEM {; + NMHDR hdr; + int idOld; + int idNew; + DWORD dwFlags; +} NMTBHOTITEM, FAR *LPNMTBHOTITEM +*/ + +// based on cToolBar class +*-----------------------------------------------------------------------------* + +CLASS TOOLBAR + + DATA abuttons + DATA aBitmaps + DATA hParent + DATA hWnd + DATA nId + DATA nStyle + DATA Created + DATA aText + DATA hBmp + DATA nProc + DATA aTips + DATA nBtn HIDDEN + DATA aMenus +METHOD Init() CONSTRUCTOR + +METHOD AddButton +METHOD AddBitmap +METHOD AddString +METHOD Create +METHOD createbuttons +METHOD tbProc + +METHOD setsizes(xBtn,yBtn,xImg,yImg ) +METHOD setheight(nHeight ) +METHOD loadbitmap +METHOD setbitmap +METHOD setbuttons +METHOD commandtoindex +METHOD GetItemId +METHOD getitemrect +METHOD getbuttonstyle +METHOD getbuttoninfo +METHOD setbuttoninfo +METHOD getbuttontext +METHOD setbuttontext +METHOD gettollbarctrl +METHOD disable +METHOD enable +METHOD disableall +METHOD enableall +METHOD CheckButton +METHOD IsButtonChecked +METHOD AddMenu +ENDCLASS + + +*-----------------------------------------------------------------------------* + +METHOD Init() + + InitCommonControlsEx(ICC_BAR_CLASSES) + ::aButtons:={} + ::aTips :={} + ::nStyle :=0 + ::nId :=0 + ::Created := .F. + ::aText :={} + ::aBitmaps:={} + ::aMenus :={} +RETURN(self) + + +*-----------------------------------------------------------------------------* + +METHOD AddBitmap(hInst, nhIdBmp, nButtons) + + LOCAL tbab IS TBADDBITMAP + + DEFAULT nButtons TO 1 + + tbab:hInst := hInst + tbab:nId := nhIdBmp + + AADD(::aBitmaps,{tbab,nButtons}) + IF ::created + SendMessage(::hWnd,TB_ADDBITMAP,nButtons,tbab:value) + ENDIF + + + RETURN(1) + +*-----------------------------------------------------------------------------* + +METHOD AddButton(nIndex, nId, nState, nStyle, ncargo, nString, cText, cToolTip ) + + LOCAL tbb IS TBBUTTON + + tbb:ibitmap :=IFNIL(nIndex,-1,nIndex) + tbb:idCommand :=nId // must be supplied + tbb:fsState :=IFNIL(nState,TBSTATE_ENABLED,nState) + tbb:fsStyle :=IFNIL(nStyle,TBSTYLE_BUTTON,nStyle) + tbb:dwData :=IFNIL(ncargo,0,nCargo) + tbb:iString :=IFNIL(nString,0,nString) + + AADD(::aButtons,tbb) + AADD(::aTips,cToolTip) + IF ::Created + SendMessage(::hWnd,TB_ADDBUTTONS,1,tbb:value) + Endif + + +RETURN(self) + +METHOD AddMenu(nButton, nMenuId, cMenuText ) +AADD(::aMenus,{nButton, nMenuId, cMenuText }) +return(self) + +*-----------------------------------------------------------------------------* +METHOD addstring(cText) + + IF ::created + SendMessage(::hWnd,TB_ADDSTRING,0,cText) + Else + AADD(::aText,cText) + Endif + + RETURN(self) + +*-----------------------------------------------------------------------------* +// HWND CreateToolbarEx( HWND hwnd, DWORD ws, UINT wID,int nBitmaps,HINSTANCE hBMInst, +// UINT wBMID,LPCTBBUTTON lpButtons,int iNumButtons,int dxButton, +// int dyButton, int dxBitmap, int dyBitmap,UINT uStructSize ); + +METHOD Create(hParent,nStyle,nId,nImg,hBMInst,nBMId,xBtn,yBtn,xBmp,yBmp) + + LOCAL cButtons:="" + LOCAL cStrings:="" + LOCAL tbb IS TBBUTTON + LOCAL i + + + ::hParent:=hParent + ::nStyle :=IFNIL(nStyle,TBSTYLE_FLAT+WS_CHILD+WS_VISIBLE,nStyle) + ::nId :=IFNIL(nId,0,nId) + + if ISNIL(hBMInst) .AND. ISNIL(nBMId) + hBMInst:=HINST_COMMCTRL + nBMId :=IDB_STD_LARGE_COLOR + endif + + FOR i:=1 TO LEN(::aButtons) + cButtons+=::aButtons[i]:Value + NEXT + +// ::hWnd:=CreateWindowEx(0,TOOLBARCLASSNAME,"",::nStyle,0,0,300,30,::hParent,::nId) + + + ::hWnd:=CreateToolBarEx(::hParent,::nStyle,::nId,nImg,hBMInst,nBMId,cButtons,LEN(::aButtons),; + xbtn,yBtn,xBmp,yBmp, tbb:sizeof()) + + ::nProc:=SetProcedure(::hParent,{|hWnd, nMsg,nwParam,nlParam| ::tbProc(nMsg,nwParam,nlParam)},{WM_NOTIFY}) + + +// SendMessage(::hWnd,TB_BUTTONSTRUCTSIZE,::aButtons[1]:sizeof,0) + + // FOR i:=1 TO LEN(::aBitmaps) + // SendMessage(::hWnd,TB_ADDBITMAP,::aBitmaps[i,2],::aBitmaps[i,1]:value) + // NEXT + + sendmessage(::hwnd,TB_SETEXTENDEDSTYLE,0,TBSTYLE_EX_DRAWDDARROWS ) + + //SendMessage(::hWnd,TB_ADDBUTTONS,LEN(::aButtons),cButtons) + + FOR i:=1 to LEN(::aText) + SendMessage(::hWnd,TB_ADDSTRING,0,::aText[i]) + NEXT + + ::Created:=.T. + +RETURN(::hWnd) + + +*-----------------------------------------------------------------------------* + +#undef TBN_DROPDOWN +#undef TTN_NEEDTEXT +#undef TBN_QUERYINSERT +#undef TBN_QUERYDELETE +#undef TBN_GETBUTTONINFO + +#DEFINE TBN_DROPDOWN 0 +#DEFINE TTN_NEEDTEXT 1 +#DEFINE TBN_QUERYINSERT 2 +#DEFINE TBN_QUERYDELETE 3 +#DEFINE TBN_GETBUTTONINFO 4 + +METHOD tbProc(nMsg,nwParam,nlParam) + + LOCAL Hdr + LOCAL Ttt + LOCAL nmt + LOCAL nID + LOCAL hMenu,rc,aRect, aPoint + LOCAL n,x + LOCAL hic + DO CASE + CASE nMsg==WM_NOTIFY + Hdr IS NMHDR + Hdr:Buffer(peek(nlParam,Hdr:sizeof)) + + DO CASE + CASE Hdr:code==TBN_DROPDOWN + Nmt IS NMTOOLBAR + nmt:buffer(peek(nlParam,nmt:sizeof)) + IF (n:=ASCAN(::aMenus,{|a| a[1]==nmt:iItem})) > 0 + ::nBtn:=nmt:iItem + hMenu = CreatePopupMenu( ) + FOR x:=1 TO LEN(::aMenus) + IF ::aMenus[x][1] == nmt:iItem + IF ::aMenus[x][3] == "-".and. ::aMenus[x][2] == 0 + AppendMenu( hMenu, MF_SEPARATOR ) + ELSE + AppendMenu( hMenu, MF_ENABLED + MF_STRING,::aMenus[x][2],::aMenus[x][3]) + ENDIF + ENDIF + NEXT + + x:= ASCAN(::aButtons,{|btn| btn:idCommand==nmt:iItem}) + aRect:=GetToolBarItemRect(::hWnd,x-1) + aPoint := {aRect[1],aRect[4]} + ClientToScreen( ::hParent, @aPoint ) + TrackPopupMenu( hMenu, TPM_LEFTALIGN+TPM_TOPALIGN, aPoint[1]+9, aPoint[2], 0, ::hWnd ) + DestroyMenu(hMenu) + RETURN 0 + end + CASE Hdr:code==TTN_NEEDTEXT + IF (n:=ASCAN(::aButtons,{|btn| btn:idCommand==Hdr:idFrom})) > 0 + Ttt IS TOOLTIPTEXT + Ttt:Buffer(peek(nlParam,Ttt:sizeof)) + Ttt:lpszText:=::aTips[n] //"ID:"+STR(Hdr:IdFrom) + poke(nlParam,Ttt:value,Ttt:sizeof) + ENDIF + + CASE Hdr:code==TBN_QUERYINSERT + RETURN(1) + CASE Hdr:code==TBN_QUERYDELETE + RETURN(1) + CASE Hdr:code==TBN_GETBUTTONINFO + Nmt IS NMTOOLBAR + nmt:buffer(peek(nlParam,nmt:sizeof)) + /* + int iItem; // cmd + TBBUTTON tbButton; + int cchText; // str len + LPSTR pszText; // btn text + RECT rcButton; // new (!) + */ + RETURN(1) + + ENDCASE + + ENDCASE + +RETURN( CallWindowProc(::nProc,::hParent,nMsg,nwParam,nlParam)) + +*-----------------------------------------------------------------------------* + +METHOD CreateButtons() + + LOCAL aSize + LOCAL i + + + + + FOR i:=1 TO LEN(::aBitmaps) + + + + + NEXT + + +RETURN(NIL) + + + + + + + + +*-----------------------------------------------------------------------------* + + +METHOD setsizes(xBtn,yBtn,xImg,yImg ) +RETURN(self) +*-----------------------------------------------------------------------------* + +METHOD setheight(nHeight ) +RETURN(self) +*-----------------------------------------------------------------------------* + +METHOD loadbitmap +RETURN(self) +*-----------------------------------------------------------------------------* + +METHOD setbitmap +RETURN(self) +*-----------------------------------------------------------------------------* + +METHOD setbuttons +RETURN(self) +*-----------------------------------------------------------------------------* + +METHOD commandtoindex +RETURN(self) +*-----------------------------------------------------------------------------* + +METHOD GetItemId +RETURN(self) +*-----------------------------------------------------------------------------* + +METHOD getitemrect(nIndex) +RETURN(GetToolbarItemRect(::hWnd,nIndex)) + +*-----------------------------------------------------------------------------* + +METHOD getbuttonstyle +RETURN(self) +*-----------------------------------------------------------------------------* + +METHOD getbuttoninfo +RETURN(self) +*-----------------------------------------------------------------------------* + +METHOD setbuttoninfo +RETURN(self) +*-----------------------------------------------------------------------------* + +METHOD getbuttontext +RETURN(self) +*-----------------------------------------------------------------------------* + +METHOD setbuttontext +RETURN(self) +*-----------------------------------------------------------------------------* + +METHOD gettollbarctrl + +RETURN(self) +*-----------------------------------------------------------------------------* + +METHOD disable(nBtn) +SendMessage(::hWnd,TB_ENABLEBUTTON,nBtn,0) +RETURN(SELF) + +*-----------------------------------------------------------------------------* + +METHOD enable(nBtn,lFlag) +DEFAULT lFlag TO .T. +SendMessage(::hWnd,TB_ENABLEBUTTON,nBtn,If(lFlag,1,0)) +RETURN(SELF) + +*-----------------------------------------------------------------------------* + +METHOD disableall() +AEVAL(::aButtons,{|btn| ::disable(btn:idCommand)}) +return(self) + +*-----------------------------------------------------------------------------* + +METHOD enableall() +AEVAL(::aButtons,{|btn| ::enable(btn:idCommand)}) +return(self) + +METHOD CheckButton(nBtn,lFlag) +DEFAULT lFlag TO !::IsButtonChecked(nBtn) +SendMessage(::hWnd,TB_CHECKBUTTON,nBtn,If(lFlag,1,0)) +RETURN(SELF) + +METHOD IsButtonChecked(nBtn) +RETURN(IIF(SendMessage(::hWnd,TB_ISBUTTONCHECKED,nBtn,0)==0,.F.,.T.))