2007-11-25 13:07 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com)

* harbour/contrib/what32
    - wininet.CH
    - errorsys.prg
    - debug.prg
    - wintabs.Prg
    - wintbar.Prg
      Removed to have all lower case and avoid name conflicts.
This commit is contained in:
Pritpal Bedi
2007-11-25 21:10:03 +00:00
parent 4c9a582dbe
commit 512bb7f1f9
5 changed files with 0 additions and 2848 deletions

View File

@@ -1,165 +0,0 @@
/*
* $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 "<Array>"
CASE v == "O"
RETURN "<Object " + x:classname( ) + ">"
CASE v == "B"
RETURN "<Block>"
OTHERWISE
RETURN ""
END CASE
RETURN( x )

View File

@@ -1,622 +0,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 := "<none>"
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 )
*------------------------------------------------------------------------------*

File diff suppressed because it is too large Load Diff

View File

@@ -1,533 +0,0 @@
/*
* $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)
*-----------------------------------------------------------------------------*
#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==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)
*-----------------------------------------------------------------------------*
*/

View File

@@ -1,446 +0,0 @@
/*
* $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)
*-----------------------------------------------------------------------------*
#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.))