2008-11-25 02:14 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)

* harbour/contrib/gtwvg/hbgtwvg.ch
  * harbour/contrib/gtwvg/wvtwin.ch
  * harbour/contrib/gtwvg/wvggui.c
  * harbour/contrib/gtwvg/wvgwin.c
  * harbour/contrib/gtwvg/wvgax.prg
  * harbour/contrib/gtwvg/wvgphdlr.prg
  * harbour/contrib/gtwvg/wvgtoolb.prg
  * harbour/contrib/gtwvg/wvgwnd.prg
    + Added WvgToolBar() class demonstrating limited features.

  * harbour/contrib/gtwvg/tests/demowvg.prg
    ! Added WvgToolBar() functionality. Click on ActiveX dialogs and
      see the difference between two two types of buttons. It is just
      limited featured toolbar. Extended version will follow. 

    ;THANKS - Bitmap management code is lifted from GTWVW. 
              Thanks Budyanto for this well written code.
              I examined many implementations but found this piece
              of code satisfying.
                Just tweaked to make UNICODE compliant.
This commit is contained in:
Pritpal Bedi
2008-11-25 10:35:07 +00:00
parent f3a3469af0
commit 23f63ba827
10 changed files with 1114 additions and 102 deletions

View File

@@ -8,6 +8,28 @@
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2008-11-25 02:14 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* harbour/contrib/gtwvg/hbgtwvg.ch
* harbour/contrib/gtwvg/wvtwin.ch
* harbour/contrib/gtwvg/wvggui.c
* harbour/contrib/gtwvg/wvgwin.c
* harbour/contrib/gtwvg/wvgax.prg
* harbour/contrib/gtwvg/wvgphdlr.prg
* harbour/contrib/gtwvg/wvgtoolb.prg
* harbour/contrib/gtwvg/wvgwnd.prg
+ Added WvgToolBar() class demonstrating limited features.
* harbour/contrib/gtwvg/tests/demowvg.prg
! Added WvgToolBar() functionality. Click on ActiveX dialogs and
see the difference between two two types of buttons. It is just
limited featured toolbar. Extended version will follow.
;THANKS - Bitmap management code is lifted from GTWVW.
Thanks Budyanto for this well written code.
I examined many implementations but found this piece
of code satisfying.
Just tweaked to make UNICODE compliant.
2008-11-24 16:41 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/pp/ppcore.c
* harbour/source/rtl/run.c

View File

@@ -67,6 +67,7 @@
#define HB_GTE_KEYBOARD 7
#define HB_GTE_TIMER 8
#define HB_GTE_MENU 9
#define HB_GTE_NOTIFY 10
#define HB_GTI_SETFONT 71
#define HB_GTI_PRESPARAMS 72
@@ -142,6 +143,8 @@
#define objTypeToolBarButton 6
#define objTypeMenu 7
//----------------------------------------------------------------------//
#define WVGALIGN_TOP 0
#define WVGALIGN_LEFT 0
#define WVGALIGN_HCENTER 1

View File

@@ -129,9 +129,9 @@ EXIT PROCEDURE KillGTs()
RETURN
//----------------------------------------------------------------------//
PROCEDURE Main( cDSN )
PROCEDURE Main()
LOCAL aLastPaint, clr, scr, bWhen, bValid, a_:={}
LOCAL aLastPaint, clr, scr, a_:={}
LOCAL dDate := ctod( "" )
LOCAL cName := Pad( "Pritpal Bedi", 35 )
LOCAL cAdd1 := Pad( "60, New Professor Colony", 35 )
@@ -152,8 +152,7 @@ PROCEDURE Main( cDSN )
LOCAL aObj := {}
LOCAL hPopup
LOCAL oMenu
LOCAL nConxn
LOCAL pGT
SET DATE BRITISH
SET( _SET_EVENTMASK, INKEY_ALL )
@@ -303,12 +302,14 @@ Function HB_GTSYS()
REQUEST HB_GT_WGU
Return NIL
//------------------------------------------------------------------//
PROCEDURE WvtConsoleGets()
PROCEDURE WvtConsoleGets( nMode )
DEFAULT nMode TO 0
IF hb_mtvm()
Hb_ThreadStart( {|oCrt| hb_gtReload( 'WVT' ) , ;
oCrt := hb_gtSelect(), ;
WvtNextGetsConsole() , ;
IF( nMode == 0, WvtNextGetsConsole(), GoogleMap() ) , ;
oCrt := NIL ;
} )
ENDIF
@@ -490,7 +491,7 @@ FUNCTION Wvt_Paint()
// needs to process messages sent through WM_SETFOCUS message
// received by the window.
//-------------------------------------------------------------------//
FUNCTION Wvt_SetFocus( hWnd )
FUNCTION Wvt_SetFocus()
LOCAL nRow := row()
LOCAL nCol := col()
@@ -505,7 +506,7 @@ FUNCTION Wvt_SetFocus( hWnd )
// needs to process messages sent through WM_KILLFOCUS message
// received by the window.
//-------------------------------------------------------------------//
FUNCTION Wvt_KillFocus( hWnd )
FUNCTION Wvt_KillFocus()
LOCAL nRow := row()
LOCAL nCol := col()
@@ -522,7 +523,7 @@ FUNCTION Wvt_KillFocus( hWnd )
//
//-------------------------------------------------------------------//
FUNCTION Wvt_Mouse( nKey, nRow, nCol )
LOCAL i, nLen, aObjects := WvtSetObjects()
LOCAL nLen, aObjects := WvtSetObjects()
LOCAL nObj
STATIC nLastObj := 0
@@ -759,9 +760,7 @@ FUNCTION WvtMyBrowse_X( oCrt )
LOCAL cScr := SaveScreen( 0,0,maxrow(),maxcol() )
LOCAL aObjects:= WvtSetObjects( {} )
LOCAL hPopup := Wvt_SetPopupMenu()
LOCAL stru_:={}, cDbfFile, cSqlFile, cFileIndex, cFileDbf, cRDD, nIndex
Local pGT, pGT1, nStStyle, nExStyle
Local oMenu
LOCAL stru_:={}, cFileIndex, cFileDbf, cRDD, nIndex
STATIC nStyle := 0
THREAD STATIC nFactor := 200
@@ -890,7 +889,7 @@ FUNCTION WvtMyBrowse_X( oCrt )
RETURN nil
//-------------------------------------------------------------------//
STATIC FUNCTION DbSkipBlock( n, oTbr )
STATIC FUNCTION DbSkipBlock( n )
LOCAL nSkipped := 0
@@ -898,18 +897,18 @@ STATIC FUNCTION DbSkipBlock( n, oTbr )
DBSkip( 0 )
elseif n > 0
do while nSkipped != n .and. TBNext( oTbr )
do while nSkipped != n .and. TBNext()
nSkipped++
enddo
else
do while nSkipped != n .and. TBPrev( oTbr )
do while nSkipped != n .and. TBPrev()
nSkipped--
enddo
endif
RETURN nSkipped
//-------------------------------------------------------------------//
STATIC FUNCTION TBNext( oTbr )
STATIC FUNCTION TBNext()
LOCAL nSaveRecNum := recno()
LOCAL lMoved := .T.
@@ -926,7 +925,7 @@ STATIC FUNCTION TBNext( oTbr )
RETURN lMoved
//-------------------------------------------------------------------//
STATIC FUNCTION TBPrev( oTbr )
STATIC FUNCTION TBPrev()
LOCAL nSaveRecNum := Recno()
LOCAL lMoved := .T.
@@ -1011,6 +1010,8 @@ STATIC FUNCTION BrwHandleKey( oBrowse, nKey, lEnd )
STATIC FUNCTION BrwOnEvent( oWvtBrw, cPaintID, oBrowse, nKey )
LOCAL lRet := .t., lRefAll := .f.
HB_SYMBOL_UNUSED( cPaintID )
do case
case nKey == K_DOWN
oBrowse:Down()
@@ -1381,15 +1382,17 @@ FUNCTION CreateMainMenu()
oMenu := wvtMenu():new():create()
oMenu:Caption := "Traditional"
oMenu:AddItem( "Gets . GTWVG . Threaded" , {|| WvtNextGets() } )
oMenu:AddItem( "Gets . GTWVG . Threaded" , {|| WvtNextGets() } )
oMenu:AddItem( "-")
oMenu:AddItem( "Gets . GTWVT . Threaded" , {|| WvtConsoleGets() } )
oMenu:AddItem( "Gets . GTWVT . Threaded" , {|| WvtConsoleGets( 0 ) } )
oMenu:AddItem( "-")
oMenu:AddItem( "Browser . GTWVG . Threaded " , {|| WvtMyBrowse() } )
oMenu:AddItem( "Browser . GTWVG . Threaded " , {|| WvtMyBrowse() } )
oMenu:AddItem( "-")
oMenu:AddItem( "Partial Screen . Main Window", {|| WvtPartialScreen() } )
oMenu:AddItem( "Partial Screen . Main Window", {|| WvtPartialScreen() } )
oMenu:AddItem( "-")
oMenu:AddItem( "Wvt Lines . Main Window" , {|| WvtLines() } )
oMenu:AddItem( "Wvt Lines . Main Window" , {|| WvtLines() } )
oMenu:AddItem( "-")
oMenu:AddItem( "Google Maps" , {|| WvtConsoleGets( 1 ) } )
g_oMenuBar:addItem( "",oMenu )
oMenu := wvtMenu():new():create()
@@ -1473,14 +1476,16 @@ STATIC FUNCTION MyDialogOne( nMode )
//----------------------------------------------------------------------//
STATIC FUNCTION MyDialogOne_X( oCrt )
LOCAL aObjects:= WvtSetBlocks( {} )
Local nWinRows, nWinCols, cWinTitle, cFont, nHeight, nWidth
Local oDlg, obj_, oBar, d_, nN, cUseAlias
Local nWinRows, nWinCols, cWinTitle, cFont, nHeight
Local oDlg, oBar, cUseAlias
Local oText, oTBar, aImg_, oImg, oLine, oBox, oBtn, oBtn2
Local oBBox, oCon, oGet, oGet2, nRowG, oBBox2, oBnr, oTBx
Local oBBox, oCon, oGet, oBBox2, oBnr, oTBx
Local oBRsd, cTxt, oRct, nGetCol, nSayCol, bBlock, bBlock1
Local oMnu, oWvtBrw, oWvtBrw1, lOpen, lOpen1, cUseAlias1, oGetArea, oGet1
Local oWvtBrw, oWvtBrw1, lOpen, lOpen1, cUseAlias1, oGetArea, oGet1
LOCAL hPopup, nGetRow, aGets_, lChkMouse
LOCAL g_oMenuBar, oMenu, oPBar2,oPBar3
LOCAL g_oMenuBar, oPBar2,oPBar3, oMenu
HB_SYMBOL_UNUSED( oCrt )
WvtSetKeys( .f. )
lChkMouse := SetMouseCheck( .f. )
@@ -1541,7 +1546,7 @@ STATIC FUNCTION MyDialogOne_X( oCrt )
oText:nBackColorHoverOn := RGB( 255, 100, 12 )
oText:lItalic := .t.
oText:ToolTip := "Software that GROWS with you"
oText:bOnSelect := {|o,v| .t. }
oText:bOnSelect := {|| .t. }
oDlg:AddObject( oText )
oImg := WvtImage():New( oDlg,102,20,oDlg:MaxCol()-40,37,oDlg:MaxCol()-2 )
@@ -1878,7 +1883,7 @@ STATIC FUNCTION ExeProgressBar( oPBar, oPBar3 )
//-------------------------------------------------------------------//
Function DynDialog_2( nInfo )
Local hDlg, aDlg, nStyle, nTimerTicks, cDlgIcon, cDlgProc, lOnTop, hMenu, nProc, bDlgProc
Local hDlg, aDlg, nStyle, nTimerTicks, cDlgIcon, cDlgProc, lOnTop, hMenu, bDlgProc
nStyle := DS_SETFONT + WS_VISIBLE + WS_POPUP + WS_CAPTION + WS_SYSMENU + WS_THICKFRAME + WS_MINIMIZEBOX
@@ -2174,9 +2179,12 @@ FUNCTION DlgSlideShow()
//-------------------------------------------------------------------//
FUNCTION DlgSlideShowProc( hDlg, nMsg, wParam, lParam )
LOCAL aRect, hDC
THREAD STATIC nSlide := 1
HB_SYMBOL_UNUSED( wParam )
HB_SYMBOL_UNUSED( lParam )
Switch nMsg
case WM_INITDIALOG
@@ -2227,8 +2235,8 @@ Static Function MyFunction( nMode )
tone( MUSIC_WAITON[2], 1 )
tone( MUSIC_WAITON[1], 1 )
case nMode == 3 // THUD
tone( 60,0.5 )
case nMode == 3
Win_MessageBox( , "Button clicked!" )
case nMode == 101 // Charge
Eval( {|| tone(523,2),tone(698,2),tone(880,2),tone(1046,4),tone(880,2),tone(1046,8) } )
@@ -2268,15 +2276,50 @@ Static Function ActiveXBuildMenu( oCrt )
oSubMenu:title := "~Functional"
oSubMenu:addItem( { "Play Opening ~1", {|| MyFunction( 1 ) } } )
oSubMenu:addItem( { "Play Closing ~2", {|| MyFunction( 2 ) } } )
oSubMenu:addItem( { "~Play Badkey" , {|| MyFunction( 3 ) } } )
oSubMenu:addItem( { "~MessageBox" , {|| MyFunction( 3 ) } } )
oMenuBar:addItem( { oSubMenu, NIL } )
Return nil
//----------------------------------------------------------------------//
STATIC FUNCTION ActiveXBuildToolBar( oCrt, nActiveX )
LOCAL oTBar
oTBar := WvgToolBar():new( oCrt , , { 0,0 }, { oCrt:currentSize()[ 1 ], 30 }, , .T. )
oTBar:borderStyle := WVGFRAME_RECT
oTBar:buttonWidth := 26
oTBar:buttonHeight := 26
oTBar:imageWidth := 24
oTBar:imageHeight := 24
IF ( nActiveX % 2 ) == 1
oTBar:showToolTips := .f.
ENDIF
// After setting properties, create toolbar.
oTBar:create()
oTBar:addItem( "New" , 'c:\harbour\contrib\gtwvg\tests\v_new.bmp' )
oTBar:addItem( "Select" , 'c:\harbour\contrib\gtwvg\tests\v_selct1.bmp' )
oTBar:addItem( "Calendar" , 'c:\harbour\contrib\gtwvg\tests\v_calend.bmp' )
oTBar:addItem( "Lock" , 'c:\harbour\contrib\gtwvg\tests\v_lock.bmp' )
oTBar:addItem( "Index" , 'c:\harbour\contrib\gtwvg\tests\v_index.bmp' )
oTBar:addItem( "Calculator", 'c:\harbour\contrib\gtwvg\tests\v_clclt.bmp' )
oTBar:addItem( "Notes" , 'c:\harbour\contrib\gtwvg\tests\v_notes1.bmp' )
//oTBar:addItem("Button #2", 101)
//oTBar:transparentColor := WVG_CLR_INVALID
oTBar:buttonClick := {|oButton| Win_MessageBox( , "Button [" + oButton:caption + "] clicked!" ) }
RETURN oTBar
//----------------------------------------------------------------------//
// The function has to be called via hb_threadStart( {|| ExecuteActiveX( nActiveX ) } )
//
Function ExecuteActiveX( nActiveX )
Local oCrt
Function ExecuteActiveX( nActiveX, xParam )
Local oCrt, oTBar
#if 0
oCrt := WvgCrt():New( , , { 5,5 }, { 29,59 }, , .f. )
@@ -2291,28 +2334,33 @@ Function ExecuteActiveX( nActiveX )
oCrt := WvgDialog():new( , , { 30,30 }, { 500,550 }, , .f. )
oCrt:closable := .f.
oCrt:create()
ActiveXBuildMenu( oCrt )
#endif
ActiveXBuildMenu( oCrt )
oTBar := ActiveXBuildToolBar( oCrt, nActiveX )
oCrt:show()
ExeActiveX( oCrt, nActiveX )
ExeActiveX( nActiveX, oCrt, oTBar, xParam )
oCrt:Destroy()
Return nil
//----------------------------------------------------------------------//
Static Function ResizeMe( oCom )
Local nW, nH
Static Function ResizeMe( oCom, oTBar )
Local nW, nH, aSize
nW := hb_gtInfo( HB_GTI_SCREENWIDTH )
nH := hb_gtInfo( HB_GTI_SCREENHEIGHT )
oCom:SetSize( { nW, nH }, .t. )
aSize := oTBar:currentSize()
oTBar:SetSize( { nW, 30 }, .t. )
oCom:SetPosAndSize( { 0, aSize[ 2 ] }, { nW, nH - aSize[ 2 ] }, .t. )
Return nil
//----------------------------------------------------------------------//
Static Function ExeActiveX( oCrt, nActiveX )
Local oCom, nKey, cDhtml, cServer, cNavigate, sData, cTitle
Static Function ExeActiveX( nActiveX, oCrt, oTBar, xParam )
Local oCom, nKey, sData
Local lEnd := .f.
static nTurn := 0
@@ -2321,7 +2369,7 @@ Static Function ExeActiveX( oCrt, nActiveX )
DEFAULT nActiveX TO 2
oCom := WvgActiveXControl():New( oCrt, , { 0,0 }, { 200,200 }, , .t. )
oCom := WvgActiveXControl():New( oCrt, , { 0,27 }, { 200,200 }, , .t. )
do case
case nActiveX == 1
@@ -2345,7 +2393,7 @@ Static Function ExeActiveX( oCrt, nActiveX )
oCom:CLSID := 'AnalogClockControl.AnalogClock'
oCom:Id := 5
oCom:mapEvent( evDblClk, {|| oCom:Value := .75632 ,;
oCom:mapEvent( evDblClk, {|| oCom:Value := seconds()/86400 ,;
oCom:BackColor := RGB( 0,140,210 ),;
oCom:Refresh() ,;
oCom:ShowSecondsHand := .t. ,;
@@ -2354,7 +2402,7 @@ Static Function ExeActiveX( oCrt, nActiveX )
oCom:showAboutBox() ;
} )
oCom:mapEvent( evBtnUp, {|nBtn,nShift,nX,nY| if( nBtn == 2, lEnd := .t., NIL ) } )
oCom:mapEvent( evBtnUp, {|nBtn| if( nBtn == 2, lEnd := .t., NIL ) } )
case nActiveX == 3
hb_gtInfo( HB_GTI_WINTITLE, 'file://C:\harbour\contrib\gtwvg\tests\myharu.pdf' )
@@ -2377,7 +2425,8 @@ Static Function ExeActiveX( oCrt, nActiveX )
//
if nActiveX == 1
oCom:AddressBar := .t.
oCom:Navigate( 'http://www.harbour.vouch.info' )
hb_gtInfo( HB_GTI_WINTITLE, IF( empty( xParam ), 'http://www.harbour.vouch.info', xParam ) )
oCom:Navigate( IF( empty( xParam ), 'http://www.harbour.vouch.info', xParam ) )
elseif nActiveX == 4
ConfigureRMChart( oCom )
@@ -2390,8 +2439,12 @@ Static Function ExeActiveX( oCrt, nActiveX )
do while !( lEnd )
nKey := inkey( 0.1 )
IF nActiveX == 2
oCom:Value := seconds()/86400
ENDIF
if nKey == HB_K_RESIZE
ResizeMe( oCom )
ResizeMe( oCom, oTBar )
elseif nKey == K_F12
if nActiveX == 1
@@ -2633,8 +2686,8 @@ Static Function DoModalWindow()
oCrt:closable := .f.
oCrt:title := 'Information! [R:4 C:8]'
oCrt:rbUp := {|aPos,uNIL,obj| DispOutAt( maxrow(), 0, padc( 'rbUp', maxcol()+1 ),'W+/R*' ) }
oCrt:lbUp := {|aPos,uNIL,obj| DispOutAt( maxrow(), 0, padc( 'lbUp', maxcol()+1 ),'W+/B*' ) }
oCrt:rbUp := {|| DispOutAt( maxrow(), 0, padc( 'rbUp', maxcol()+1 ),'W+/R*' ) }
oCrt:lbUp := {|| DispOutAt( maxrow(), 0, padc( 'lbUp', maxcol()+1 ),'W+/B*' ) }
oCrt:leave := {|| DispOutAt( maxrow(), 0, padc( 'Leaving', maxcol()+1 ), 'W+/RB' ) }
oCrt:enter := {|| DispOutAt( maxrow(), 0, padc( 'Entering', maxcol()+1 ), 'W+/B' ) }
@@ -2663,3 +2716,43 @@ Static Function DoModalWindow()
Return nil
//----------------------------------------------------------------------//
FUNCTION GoogleMap()
Local mfrom1, mto1, mfrom2, mto2, mfrom3, mto3, mweb
Local nCursor := setcursor()
LOCAL getlist := {}
SetMode( 22,65 )
setcolor( 'N/W,N/GR*,,,N/W*' )
cls
hb_gtInfo( HB_GTI_WINTITLE, 'Google Maps' )
mfrom1 := mto1 := space(20)
mfrom2 := mto2 := space(40)
mfrom3 := mto3 := space(50)
while .T.
@ 05, 01 say "FROM :"
@ 07, 01 say "State ...:" get mfrom1 picture "@!"
@ 08, 01 say "City ....:" get mfrom2 picture "@!"
@ 09, 01 say "Street ..:" get mfrom3 picture "@!"
@ 11, 01 say "TO :"
@ 13, 01 say "State ...:" get mto1 picture "@!"
@ 14, 01 say "City ....:" get mto2 picture "@!"
@ 15, 01 say "Street ..:" get mto3 picture "@!"
setcursor(1); read; setcursor(nCursor)
if lastkey() == K_ESC
exit
endif
mweb := "http://maps.google.com/maps?q=from " +;
alltrim( mfrom3 ) +" "+ alltrim( mfrom2 ) +" "+ alltrim( mfrom1 ) + " to " +;
alltrim( mto3 ) +" "+ alltrim( mto2 ) +" "+ alltrim( mto1 )
Hb_ThreadStart( {|| ExecuteActiveX( 1, mweb ) } )
ENDDO
RETURN nil
//----------------------------------------------------------------------//

View File

@@ -111,9 +111,6 @@ CLASS WvgActiveXControl FROM TOleAuto, WvgWindow
DATA hContainer
DATA hSink
DATA style INIT WS_CHILD + WS_VISIBLE + WS_CLIPCHILDREN + WS_CLIPSIBLINGS
DATA hWnd
METHOD New()
METHOD Create()
METHOD Destroy()
@@ -146,6 +143,8 @@ METHOD New( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgActiv
::wvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::style := WS_CHILD + WS_VISIBLE + WS_CLIPCHILDREN + WS_CLIPSIBLINGS
RETURN Self
//----------------------------------------------------------------------//
METHOD Create( oParent, oOwner, aPos, aSize, aPresParams, lVisible, cCLSID, cLicense ) CLASS WvgActiveXControl

View File

@@ -1006,6 +1006,7 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara
hb_itemRelease( pEvParams );
return 0;
}
case WM_SIZING:
case WM_SIZE:
{
return( hb_gt_wvt_SizeChanged( pWVT ) );
@@ -1091,6 +1092,24 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara
pWVT->bTracking = FALSE;
return DefWindowProc( pWVT->hWnd, message, wParam, lParam );;
}
case WM_NOTIFY:
{
PHB_ITEM pEvParams = hb_itemNew( NULL );
LPNMMOUSE nmm = ( LPNMMOUSE ) lParam;
NMHDR nmh = nmm->hdr;
hb_arrayNew( pEvParams, 5 );
hb_arraySetNI( pEvParams, 1, ( int ) wParam );
hb_arraySetNInt( pEvParams, 2, ( HB_PTRDIFF ) nmh.hwndFrom );
hb_arraySetNI( pEvParams, 3, nmh.idFrom );
hb_arraySetNI( pEvParams, 4, nmh.code );
hb_arraySetNL( pEvParams, 5, nmm->dwItemSpec );
hb_gt_wvt_FireEvent( pWVT, HB_GTE_NOTIFY, pEvParams );
hb_itemRelease( pEvParams );
return TRUE;
}
case WM_CREATE:
{
return 0;

View File

@@ -95,7 +95,7 @@ CLASS WvgPartHandler
METHOD notifier( nEvent, xParams )
DATA hChildren INIT hb_hash()
DATA aChildren INIT {}
DATA nNameId
DATA oParent
DATA oOwner
@@ -167,7 +167,7 @@ METHOD status() CLASS WvgPartHandler
METHOD addChild( oWvg ) CLASS WvgPartHandler
HB_SYMBOL_UNUSED( oWvg )
aadd( ::aChildren, oWvg )
RETURN Self
@@ -235,7 +235,7 @@ METHOD setParent( oWvg ) CLASS WvgPartHandler
METHOD notifier( nEvent, xParams ) CLASS WvgPartHandler
Local aPos
LOCAL nReturn := 0
LOCAL aMenuItem
LOCAL aMenuItem, nIndex, nCtrlID, nObj
DO CASE
@@ -373,6 +373,25 @@ METHOD notifier( nEvent, xParams ) CLASS WvgPartHandler
ENDIF
ENDCASE
CASE nEvent == HB_GTE_NOTIFY
nCtrlID := xParams[ 1 ]
nIndex := ascan( ::aChildren, {|o| o:nID == nCtrlID } )
IF nIndex > 0
DO CASE
CASE xParams[ 4 ] == NM_CLICK
IF hb_isBlock( ::aChildren[ nIndex ]:sl_buttonClick )
nObj := ascan( ::aChildren[ nIndex ]:aItems, {|e_| e_[ 1 ] == xParams[ 5 ] } )
Eval( ::aChildren[ nIndex ]:sl_buttonClick, ::aChildren[ nIndex ]:aItems[ nObj,2 ] )
ENDIF
ENDCASE
ENDIF
ENDCASE
RETURN nReturn

View File

@@ -123,7 +123,7 @@ CLASS WvgToolBar INHERIT WvgActiveXControl
ENDCLASS
//----------------------------------------------------------------------//
METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgToolBar
DEFAULT oParent TO ::oParent
DEFAULT oOwner TO ::oOwner
@@ -141,11 +141,69 @@ METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::WvgActiveXControl:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::style := WS_CHILD + TBSTYLE_FLAT + CCS_ADJUSTABLE //+ CCS_NODIVIDER //+CCS_VERT
::exStyle := TBSTYLE_EX_DOUBLEBUFFER
::className := TOOLBARCLASSNAME
::objType := objTypeToolBar
RETURN Self
//----------------------------------------------------------------------//
METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgToolBar
DEFAULT oParent TO ::oParent
DEFAULT oOwner TO ::oOwner
DEFAULT aPos TO ::aPos
DEFAULT aSize TO ::aSize
DEFAULT aPresParams TO ::aPresParams
DEFAULT lVisible TO ::visible
::oParent := oParent
::oOwner := oOwner
::aPos := aPos
::aSize := aSize
::aPresParams := aPresParams
::visible := lVisible
IF ::visible
::style += WS_VISIBLE
ENDIF
IF ::wrappable
::style += TBSTYLE_WRAPABLE
ENDIF
IF ::showToolTips
::style += TBSTYLE_TOOLTIPS
ENDIF
IF ::borderStyle == WVGFRAME_RECT
::style += WS_BORDER
ENDIF
#if 0
IF ::appearance == WVG_APPEARANCE_3D
ENDIF
#endif
::oParent:AddChild( SELF )
::createControl()
IF ::showToolTips
::sendMessage( TB_SETMAXTEXTROWS, 0, 0 )
ENDIF
//::sendMessage( TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DOUBLEBUFFER )
//::sendMessage( TB_SETPADDING , 0, Win_MakeLParam( 3,3 ) )
//::sendMessage( TB_SETLISTGAP, 4, 0 ) // vista
IF ::visible
::show()
ENDIF
RETURN Self
//----------------------------------------------------------------------//
METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgToolBar
DEFAULT oParent TO ::oParent
DEFAULT oOwner TO ::oOwner
@@ -165,93 +223,112 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
//----------------------------------------------------------------------//
METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
METHOD destroy() CLASS WvgToolBar
LOCAL i, nItems
DEFAULT oParent TO ::oParent
DEFAULT oOwner TO ::oOwner
DEFAULT aPos TO ::aPos
DEFAULT aSize TO ::aSize
DEFAULT aPresParams TO ::aPresParams
DEFAULT lVisible TO ::visible
::oParent := oParent
::oOwner := oOwner
::aPos := aPos
::aSize := aSize
::aPresParams := aPresParams
::visible := lVisible
RETURN Self
//----------------------------------------------------------------------//
METHOD destroy()
IF ( nItems := ::numItems() ) > 0
FOR i := 1 TO nItems
IF ::aItems[ i ]:image <> NIL
Win_DeleteObject( ::aItems[ i ]:image )
ENDIF
NEXT
ENDIF
RETURN NIL
//----------------------------------------------------------------------//
METHOD addItem()
METHOD addItem( cCaption, xImage, xDisabledImage, xHotImage, cDLL, nStyle, cKey ) CLASS WvgToolBar
LOCAL oBtn, hBitmap, cType
HB_SYMBOL_UNUSED( xDisabledImage )
HB_SYMBOL_UNUSED( xHotImage )
HB_SYMBOL_UNUSED( cDLL )
oBtn := WvgToolbarButton():new( cCaption, nStyle, cKey )
oBtn:index := ::numItems + 1
oBtn:command := 100 + oBtn:index
cType := valtype( xImage )
DO CASE
CASE cType == 'C'
hBitmap = Wvg_PrepareBitmapFromFile( xImage, ::imageWidth, ::imageHeight, .t., ::hWnd )
IF hBitmap <> 0
oBtn:image := hBitmap
Wvg_AddToolbarButton( ::hWnd, oBtn:image, oBtn:caption, oBtn:command, 1 )
endif
ENDCASE
aadd( ::aItems, { oBtn:command, oBtn } )
RETURN Self
//----------------------------------------------------------------------//
METHOD delItem()
METHOD delItem() CLASS WvgToolBar
RETURN Self
//----------------------------------------------------------------------//
METHOD getItem()
METHOD getItem() CLASS WvgToolBar
RETURN Self
//----------------------------------------------------------------------//
METHOD clear()
METHOD clear() CLASS WvgToolBar
RETURN Self
//----------------------------------------------------------------------//
METHOD customize()
METHOD customize() CLASS WvgToolBar
RETURN Self
//----------------------------------------------------------------------//
METHOD loadImageSet()
METHOD loadImageSet() CLASS WvgToolBar
RETURN Self
//----------------------------------------------------------------------//
METHOD saveToolbar()
METHOD saveToolbar() CLASS WvgToolBar
RETURN Self
//----------------------------------------------------------------------//
METHOD restToolbar()
METHOD restToolbar() CLASS WvgToolBar
RETURN Self
//----------------------------------------------------------------------//
METHOD setPosAndSize()
METHOD setPosAndSize() CLASS WvgToolBar
RETURN Self
//----------------------------------------------------------------------//
METHOD setSize()
METHOD setSize() CLASS WvgToolBar
::sendMessage( TB_AUTOSIZE, 0, 0 )
RETURN Self
//----------------------------------------------------------------------//
METHOD buttonClick( xParam )
METHOD buttonClick( xParam ) CLASS WvgToolBar
IF hb_isBlock( xParam ) .or. hb_isNil( xParam )
::sl_buttonClick := xParam
@@ -261,7 +338,7 @@ METHOD buttonClick( xParam )
//----------------------------------------------------------------------//
METHOD change( xParam )
METHOD change( xParam ) CLASS WvgToolBar
IF hb_isBlock( xParam ) .or. hb_isNil( xParam )
::sl_change := xParam
@@ -271,7 +348,7 @@ METHOD change( xParam )
//----------------------------------------------------------------------//
METHOD buttonMenuClick( xParam )
METHOD buttonMenuClick( xParam ) CLASS WvgToolBar
IF hb_isBlock( xParam ) .or. hb_isNil( xParam )
::sl_buttonMenuClick := xParam
@@ -281,7 +358,7 @@ METHOD buttonMenuClick( xParam )
//----------------------------------------------------------------------//
METHOD buttonDropDown( xParam )
METHOD buttonDropDown( xParam ) CLASS WvgToolBar
IF hb_isBlock( xParam ) .or. hb_isNil( xParam )
::sl_buttonDropDown := xParam
@@ -290,4 +367,50 @@ METHOD buttonDropDown( xParam )
RETURN Self
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//
// WvgToolbarButton() Class compatible with XbpToolbarButton()
//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
CLASS WvgToolbarButton
DATA enabled INIT .T.
DATA index INIT 0
DATA key INIT ''
DATA style INIT WVGTOOLBAR_BUTTON_DEFAULT
DATA caption INIT ''
DATA image INIT NIL
DATA disabledImage INIT NIL
DATA hotImage INIT NIL
DATA mixedState INIT .F.
DATA pressed INIT .F.
DATA visible INIT .T.
DATA left INIT 0
DATA bottom INIT 0
DATA top INIT 0
DATA width INIT 0
DATA height INIT 0
DATA description INIT ''
DATA tooltipText INIT ''
DATA command INIT 0
METHOD new()
ENDCLASS
//----------------------------------------------------------------------//
METHOD new( cCaption, nStyle, cKey ) CLASS WvgToolbarButton
DEFAULT cCaption TO ::caption
DEFAULT nStyle TO ::style
DEFAULT cKey TO ::key
::caption := cCaption
::style := nStyle
::key := cKey
RETURN Self
//----------------------------------------------------------------------//

View File

@@ -303,13 +303,14 @@ HB_FUNC( WIN_GETDLGITEM )
HB_FUNC( WIN_MESSAGEBOX )
{
LPTSTR lpBuffer = HB_TCHAR_CONVTO( hb_parc( 2 ) );
LPTSTR lpBuffer2 = HB_TCHAR_CONVTO( hb_parc( 3 ) );
HWND hWnd = ISNIL( 1 ) ? GetActiveWindow() : ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ) ;
LPTSTR lpMsg = HB_TCHAR_CONVTO( ISNIL( 2 ) ? "" : hb_parc( 2 ) );
LPTSTR lpTitle = HB_TCHAR_CONVTO( ISNIL( 3 ) ? "Info" : hb_parc( 3 ) );
hb_retni( MessageBox( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ), lpBuffer, lpBuffer2, ISNIL( 4 ) ? MB_OK : hb_parni( 4 ) ) ) ;
hb_retni( MessageBox( hWnd, lpMsg, lpTitle, ISNIL( 4 ) ? MB_OK : hb_parni( 4 ) ) ) ;
HB_TCHAR_FREE( lpBuffer );
HB_TCHAR_FREE( lpBuffer2 );
HB_TCHAR_FREE( lpTitle );
HB_TCHAR_FREE( lpMsg );
}
//-------------------------------------------------------------------//
@@ -782,3 +783,429 @@ HB_FUNC( WIN_SHOWWINDOW )
}
//----------------------------------------------------------------------//
HB_FUNC( WIN_MAKELPARAM )
{
hb_retnint( MAKELPARAM( hb_parnint( 1 ), hb_parnint( 2 ) ) );
}
//----------------------------------------------------------------------//
HB_FUNC( WIN_CREATEWINDOWEX )
{
HWND hWnd;
LPTSTR szWinName;
LPTSTR szClassName;
szClassName = HB_TCHAR_CONVTO( hb_parc( 2 ) );
szWinName = HB_TCHAR_CONVTO( ISNIL( 3 ) ? "" : hb_parc( 3 ) );
hWnd = CreateWindowEx( hb_parnint( 1 ),
szClassName,
szWinName,
hb_parnint( 4 ),
hb_parni( 5 ), hb_parni( 6 ),
hb_parni( 7 ), hb_parni( 8 ),
( HWND ) ( HB_PTRDIFF ) hb_parnint( 9 ),
ISNIL( 10 ) ? NULL : ( HMENU ) ( HB_PTRDIFF ) hb_parnint( 10 ),
ISNIL( 11 ) ? wvg_hInstance() : ( HINSTANCE ) ( HB_PTRDIFF ) hb_parnint( 11 ),
NULL );
HB_TCHAR_FREE( szClassName );
HB_TCHAR_FREE( szWinName );
hb_retnint( ( HB_PTRDIFF ) hWnd );
}
//----------------------------------------------------------------------//
HB_FUNC( WIN_CREATETOOLBAREX )
{
HWND hWnd;
hWnd = CreateToolbarEx( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ),
hb_parnint( 2 ),
hb_parni( 3 ),
hb_parni( 4 ),
ISNIL( 5 ) ? NULL : ( HINSTANCE ) ( HB_PTRDIFF ) hb_parnint( 5 ),
ISNIL( 6 ) ? NULL : hb_parnint( 6 ),
ISNIL( 7 ) ? NULL : ( HANDLE ) ( HB_PTRDIFF ) hb_parnint( 7 ),
hb_parni( 8 ),
hb_parni( 9 ),
hb_parni( 10 ),
hb_parni( 11 ),
hb_parni( 12 ),
sizeof( TBBUTTON ) );
hb_retnint( ( HB_PTRDIFF ) hWnd );
}
//----------------------------------------------------------------------//
//
// Bitmap Management Function . Coutesy GTWVW
//
//----------------------------------------------------------------------//
static BITMAPINFO * PackedDibLoad( PTSTR szFileName )
{
BITMAPFILEHEADER bmfh ;
BITMAPINFO * pbmi ;
BOOL bSuccess ;
DWORD dwPackedDibSize, dwBytesRead ;
HANDLE hFile ;
hFile = CreateFile( szFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL ) ;
if( hFile == INVALID_HANDLE_VALUE )
return NULL ;
bSuccess = ReadFile( hFile, &bmfh, sizeof (BITMAPFILEHEADER), &dwBytesRead, NULL ) ;
if( !bSuccess || ( dwBytesRead != sizeof( BITMAPFILEHEADER ) )
|| ( bmfh.bfType != * ( WORD * ) "BM" ) )
{
CloseHandle( hFile ) ;
return NULL ;
}
dwPackedDibSize = bmfh.bfSize - sizeof( BITMAPFILEHEADER ) ;
pbmi = ( BITMAPINFO * ) hb_xgrab( dwPackedDibSize ) ;
bSuccess = ReadFile( hFile, pbmi, dwPackedDibSize, &dwBytesRead, NULL ) ;
CloseHandle( hFile ) ;
if ( !bSuccess || ( dwBytesRead != dwPackedDibSize ) )
{
hb_xfree( pbmi ) ;
return NULL ;
}
return pbmi ;
}
static int PackedDibGetWidth( BITMAPINFO * pPackedDib )
{
if( pPackedDib->bmiHeader.biSize == sizeof( BITMAPCOREHEADER ) )
return ( ( PBITMAPCOREINFO ) pPackedDib )->bmciHeader.bcWidth ;
else
return pPackedDib->bmiHeader.biWidth ;
}
static int PackedDibGetHeight( BITMAPINFO * pPackedDib )
{
if( pPackedDib->bmiHeader.biSize == sizeof( BITMAPCOREHEADER ) )
return ( ( PBITMAPCOREINFO ) pPackedDib )->bmciHeader.bcHeight ;
else
return abs( pPackedDib->bmiHeader.biHeight ) ;
}
static int PackedDibGetBitCount( BITMAPINFO * pPackedDib )
{
if( pPackedDib->bmiHeader.biSize == sizeof( BITMAPCOREHEADER ) )
return ( ( PBITMAPCOREINFO ) pPackedDib )->bmciHeader.bcBitCount ;
else
return pPackedDib->bmiHeader.biBitCount ;
}
static int PackedDibGetInfoHeaderSize( BITMAPINFO * pPackedDib )
{
if( pPackedDib->bmiHeader.biSize == sizeof( BITMAPCOREHEADER ) )
return ( ( PBITMAPCOREINFO ) pPackedDib )->bmciHeader.bcSize ;
else if( pPackedDib->bmiHeader.biSize == sizeof( BITMAPINFOHEADER ) )
return pPackedDib->bmiHeader.biSize +
( pPackedDib->bmiHeader.biCompression == BI_BITFIELDS ? 12 : 0 ) ;
else return pPackedDib->bmiHeader.biSize ;
}
static int PackedDibGetColorsUsed( BITMAPINFO * pPackedDib )
{
if( pPackedDib->bmiHeader.biSize == sizeof( BITMAPCOREHEADER ) )
return 0 ;
else
return pPackedDib->bmiHeader.biClrUsed ;
}
static int PackedDibGetNumColors( BITMAPINFO * pPackedDib )
{
int iNumColors ;
iNumColors = PackedDibGetColorsUsed( pPackedDib ) ;
if( iNumColors == 0 && PackedDibGetBitCount( pPackedDib ) < 16 )
iNumColors = 1 << PackedDibGetBitCount( pPackedDib ) ;
return iNumColors ;
}
static int PackedDibGetColorTableSize( BITMAPINFO * pPackedDib )
{
if( pPackedDib->bmiHeader.biSize == sizeof( BITMAPCOREHEADER ) )
return PackedDibGetNumColors( pPackedDib ) * sizeof( RGBTRIPLE ) ;
else
return PackedDibGetNumColors( pPackedDib ) * sizeof( RGBQUAD ) ;
}
#if 0
static RGBQUAD * PackedDibGetColorTablePtr( BITMAPINFO * pPackedDib )
{
if( PackedDibGetNumColors( pPackedDib ) == 0 )
return 0 ;
return ( RGBQUAD * ) ( ( ( BYTE * ) pPackedDib ) + PackedDibGetInfoHeaderSize( pPackedDib ) ) ;
}
static RGBQUAD * PackedDibGetColorTableEntry( BITMAPINFO * pPackedDib, int i )
{
if( PackedDibGetNumColors( pPackedDib ) == 0 )
return 0 ;
if( pPackedDib->bmiHeader.biSize == sizeof( BITMAPCOREHEADER ) )
return ( RGBQUAD * ) ( ( ( RGBTRIPLE * ) PackedDibGetColorTablePtr( pPackedDib ) ) + i ) ;
else
return PackedDibGetColorTablePtr( pPackedDib ) + i ;
}
#endif
static BYTE * PackedDibGetBitsPtr( BITMAPINFO * pPackedDib )
{
return ( ( BYTE * ) pPackedDib ) + PackedDibGetInfoHeaderSize( pPackedDib ) +
PackedDibGetColorTableSize( pPackedDib ) ;
}
static HBITMAP hPrepareBitmap( char * szBitmapX, UINT uiBitmap,
int iExpWidth, int iExpHeight,
BOOL bMap3Dcolors,
HWND hCtrl )
{
HBITMAP hBitmap;
if( szBitmapX )
{
int iWidth, iHeight;
{
BITMAPINFO * pPackedDib = NULL;
HDC hdc;
TCHAR * szBitmap;
szBitmap = HB_TCHAR_CONVTO( szBitmapX );
if( !bMap3Dcolors )
{
pPackedDib = PackedDibLoad( szBitmap );
}
if( pPackedDib || bMap3Dcolors )
{
hdc = GetDC( hCtrl );
if( !bMap3Dcolors )
{
hBitmap = CreateDIBitmap( hdc,
( PBITMAPINFOHEADER ) pPackedDib,
CBM_INIT,
PackedDibGetBitsPtr( pPackedDib ),
pPackedDib,
DIB_RGB_COLORS ) ;
if( hBitmap == NULL )
{
return NULL;
}
iWidth = PackedDibGetWidth( pPackedDib );
iHeight = PackedDibGetHeight( pPackedDib );
}
else
{
hBitmap = ( HBITMAP ) LoadImage( ( HINSTANCE ) NULL,
szBitmap,
IMAGE_BITMAP,
iExpWidth,
iExpHeight,
LR_LOADFROMFILE | LR_LOADMAP3DCOLORS );
if( hBitmap == NULL )
{
return NULL;
}
iWidth = iExpWidth;
iHeight = iExpHeight;
}
if( iExpWidth == 0 && iExpHeight == 0 )
{
iWidth = iExpWidth;
iHeight = iExpHeight;
}
if( iExpWidth != iWidth || iExpHeight != iHeight )
{
HDC hdcSource, hdcTarget;
HBITMAP hBitmap2;
BOOL bResult;
hdcSource = CreateCompatibleDC( hdc );
SelectObject( hdcSource, hBitmap );
hdcTarget = CreateCompatibleDC( hdc );
hBitmap2 = CreateCompatibleBitmap( hdcSource, iExpWidth, iExpHeight );
SelectObject( hdcTarget, hBitmap2 );
bResult = StretchBlt(
hdcTarget, /* handle to destination DC */
0, /* x-coord of destination upper-left corner */
0, /* y-coord of destination upper-left corner */
iExpWidth, /* width of destination rectangle */
iExpHeight, /* height of destination rectangle */
hdcSource, /* handle to source DC */
0, /* x-coord of source upper-left corner */
0, /* y-coord of source upper-left corner */
iWidth, /* width of source rectangle */
iHeight, /* height of source rectangle */
SRCCOPY /* raster operation code */
);
if( !bResult )
{
DeleteObject( hBitmap2 );
}
else
{
DeleteObject( hBitmap );
hBitmap = hBitmap2;
}
DeleteDC( hdcSource );
DeleteDC( hdcTarget );
}
HB_TCHAR_FREE( szBitmap );
ReleaseDC( hCtrl, hdc ) ;
if( pPackedDib )
{
hb_xfree( pPackedDib ) ;
}
}
}
}
else /* loading from resources */
{
UINT uiOptions = bMap3Dcolors ? LR_LOADMAP3DCOLORS : LR_DEFAULTCOLOR;
char szResname[ _MAX_PATH+1 ];
sprintf( szResname, "?%u", uiBitmap );
hBitmap = ( HBITMAP ) LoadImage(
wvg_hInstance(),
( LPCTSTR ) MAKEINTRESOURCE( ( WORD ) uiBitmap ),
IMAGE_BITMAP,
iExpWidth,
iExpHeight,
uiOptions );
if( hBitmap == NULL )
{
return NULL;
}
} /* loading from resources */
return hBitmap;
}
//----------------------------------------------------------------------//
HB_FUNC( WVG_PREPAREBITMAPFROMFILE )
{
HBITMAP hBitmap;
hBitmap = hPrepareBitmap( hb_parc( 1 ), 0, hb_parni( 2 ), hb_parni( 3 ), hb_parl( 4 ),
( HWND ) ( HB_PTRDIFF ) hb_parnint( 5 ) );
hb_retnint( ( HB_PTRDIFF ) hBitmap );
}
//----------------------------------------------------------------------//
HB_FUNC( WVG_PREPAREBITMAPFROMRESOURCEID )
{
HBITMAP hBitmap;
hBitmap = hPrepareBitmap( ( char * ) NULL, hb_parni( 1 ), hb_parni( 2 ), hb_parni( 3 ), hb_parl( 4 ),
( HWND ) ( HB_PTRDIFF ) hb_parnint( 5 ) );
hb_retnint( ( HB_PTRDIFF ) hBitmap );
}
//----------------------------------------------------------------------//
HB_FUNC( WVG_PREPAREBITMAPFROMRESOURCENAME )
{
HBITMAP hBitmap;
hBitmap = hPrepareBitmap( hb_parc( 1 ), 0, hb_parni( 2 ), hb_parni( 3 ), hb_parl( 4 ),
( HWND ) ( HB_PTRDIFF ) hb_parnint( 5 ) );
hb_retnint( ( HB_PTRDIFF ) hBitmap );
}
//----------------------------------------------------------------------//
//
// Wvg_AddToolbarButton( hWndTB, hBitmap, cCaption, nButtonID, nMode )
//
HB_FUNC( WVG_ADDTOOLBARBUTTON )
{
TBBUTTON tbb;
TBADDBITMAP tbab;
BOOL bSuccess;
HWND hWndTB = ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 );
int iCommand = hb_parni( 4 );
TCHAR * szCaption;
switch( hb_parni( 5 ) )
{
case 1: // button from image
{
HBITMAP hBitmap = ( HBITMAP ) ( HB_PTRDIFF ) hb_parnint( 2 );
int iNewBitmap, iNewString;
// set bitmap
tbab.hInst = NULL;
tbab.nID = ( UINT ) hBitmap;
iNewBitmap = SendMessage( hWndTB, TB_ADDBITMAP, ( WPARAM ) 1, ( LPARAM ) &tbab );
// set string
//
szCaption = HB_TCHAR_CONVTO( hb_parc( 3 ) );
iNewString = SendMessage( hWndTB, TB_ADDSTRING, ( WPARAM ) 0, ( LPARAM ) szCaption );
HB_TCHAR_FREE( szCaption );
// add button
tbb.iBitmap = iNewBitmap;
tbb.idCommand = iCommand;
tbb.fsState = TBSTATE_ENABLED;
tbb.fsStyle = TBSTYLE_BUTTON;
tbb.dwData = 0;
tbb.iString = iNewString;
bSuccess = SendMessage( hWndTB, TB_ADDBUTTONS, ( WPARAM ) 1, ( LPARAM ) ( LPTBBUTTON ) &tbb );
hb_retl( bSuccess );
return;
}
case 2: // system bitmap
case 3: // separator
{
tbb.iBitmap = 0;
tbb.idCommand = 0;
tbb.fsState = TBSTATE_ENABLED;
tbb.fsStyle = TBSTYLE_SEP;
tbb.dwData = 0;
tbb.iString = 0;
bSuccess = SendMessage( hWndTB, TB_ADDBUTTONS, ( WPARAM ) 1, ( LPARAM ) ( LPTBBUTTON ) &tbb );
hb_retl( bSuccess );
return;
}
}
}
//----------------------------------------------------------------------//

View File

@@ -226,7 +226,6 @@ EXPORTED:
METHOD setFocus()
METHOD sendMessage()
PROTECTED:
DATA hWnd
DATA aPos INIT { 0,0 }
DATA aSize INIT { 0,0 }
@@ -238,6 +237,11 @@ PROTECTED:
DATA maxRow INIT 24
DATA mouseMode INIT 1
DATA nID INIT 0
DATA nControlID INIT 100
METHOD createControl()
METHOD getControlID() INLINE ++::nControlID
ENDCLASS
//----------------------------------------------------------------------//
@@ -386,7 +390,24 @@ METHOD setPos() CLASS WvgWindow
//----------------------------------------------------------------------//
METHOD setPosAndSize() CLASS WvgWindow
METHOD setPosAndSize( aPos, aSize, lPaint ) CLASS WvgWindow
if hb_isArray( aPos ) .and. hb_isArray( aSize )
DEFAULT lPaint TO .T.
switch ::objType
case objTypeDialog
case objTypeActiveX
Win_MoveWindow( ::hWnd, aPos[ 1 ], aPos[ 2 ], aSize[ 1 ], aSize[ 2 ], lPaint )
exit
case objTypeCrt
hb_gtInfo( HB_GTI_SCREENWIDTH , aSize[ 1 ] )
hb_gtInfo( HB_GTI_SCREENHEIGHT, aSize[ 2 ] )
exit
end
endif
RETURN Self
@@ -1036,3 +1057,57 @@ METHOD sendMessage( nMessage, nlParam, nwParam ) CLASS WvgWindow
RETURN Self
//----------------------------------------------------------------------//
METHOD createControl() CLASS WvgWindow
LOCAL hWnd
DO CASE
CASE ::objType == objTypeToolBar
::nID := ::oParent:GetControlId()
#if 1
hWnd := Win_CreateToolBarEx( ::oParent:hWnd,; // hWnd - window handle hosting the toolbar
::style,; // ws - style of the toolbar
::nID,; // wID - control identifier supplied with WM_COMMAND
0,; // nBitmaps - number of button images
NIL,; // hBMInst - mudule instance which hosts the bitmap resource
NIL,; // wBPID - resource identifier of the bitmap
NIL,; // lpButton - TBUTTON structure
0,; // number of buttons
::buttonWidth,; //
::buttonHeight,;
::imageWidth,;
::imageHeight )
//Win_SendMessage( hWnd, TB_AUTOSIZE, 0, 0 )
#else
hWnd := Win_CreateWindowEx( ::exStyle, ;
TOOLBARCLASSNAME, ;
NIL, ; // window name
::style, ;
::aPos[ 1 ], ::aPos[ 2 ],;
::aSize[ 1 ], ::aSize[ 2 ],;
::oParent:hWnd,;
NIL,; // hMenu
NIL,; // hInstance
NIL ) // lParam
#endif
OTHERWISE
hWnd := Win_CreateWindowEx( ::exStyle, ;
::className, ;
"", ; // window name
::style, ;
::aPos[ 1 ], ::aPos[ 2 ],;
::aSize[ 1 ], ::aSize[ 2 ],;
::oParent:hWnd,;
NIL,; // hMenu
NIL,; // hInstance
NIL ) // lParam
ENDCASE
IF ( hWnd <> 0 )
::hWnd := hWnd
ENDIF
RETURN Self
//----------------------------------------------------------------------//

View File

@@ -49,10 +49,9 @@
* If you do not wish that, delete this exception notice.
*
*/
//----------------------------------------------------------------------//
#ifndef _WVGWIN_CH
#define _WVGWIN_CH
//-------------------------------------------------------------------//
//
// GTWVT Specific
@@ -1235,6 +1234,239 @@
#define OFN_DONTADDTORECENT 33554432
#define OFN_FORCESHOWHIDDEN 268435456 // Show All files including System and hidden files
//----------------------------------------------------------------------//
/* Common Control Constants */
#define CCS_TOP 1
#define CCS_NOMOVEY 2
#define CCS_BOTTOM 3
#define CCS_NORESIZE 4
#define CCS_NOPARENTALIGN 8
#define CCS_ADJUSTABLE 32
#define CCS_NODIVIDER 64
#define CCS_VERT 128
#define CCS_LEFT (CCS_VERT + CCS_TOP)
#define CCS_RIGHT (CCS_VERT + CCS_BOTTOM)
#define CCS_NOMOVEX (CCS_VERT + CCS_NOMOVEY)
//----------------------------------------------------------------------//
#define TOOLBARCLASSNAME "ToolbarWindow32"
/* Toolbar messages */
#define TB_SAVERESTOREA (WM_USER + 26)
#define TB_SAVERESTOREW (WM_USER + 76)
#define TB_CUSTOMIZE (WM_USER + 27)
#define TB_ADDSTRINGA (WM_USER + 28)
#define TB_ADDSTRINGW (WM_USER + 77)
#define TB_GETITEMRECT (WM_USER + 29)
#define TB_BUTTONSTRUCTSIZE (WM_USER + 30)
#define TB_SETBUTTONSIZE (WM_USER + 31)
#define TB_SETBITMAPSIZE (WM_USER + 32)
#define TB_AUTOSIZE (WM_USER + 33)
#define TB_GETTOOLTIPS (WM_USER + 35)
#define TB_SETTOOLTIPS (WM_USER + 36)
#define TB_SETPARENT (WM_USER + 37)
#define TB_SETROWS (WM_USER + 39)
#define TB_GETROWS (WM_USER + 40)
#define TB_GETBITMAPFLAGS (WM_USER + 41)
#define TB_SETCMDID (WM_USER + 42)
#define TB_CHANGEBITMAP (WM_USER + 43)
#define TB_GETBITMAP (WM_USER + 44)
#define TB_GETBUTTONTEXTA (WM_USER + 45)
#define TB_GETBUTTONTEXTW (WM_USER + 75)
#define TB_REPLACEBITMAP (WM_USER + 46)
#define TB_SETINDENT (WM_USER + 47)
#define TB_SETIMAGELIST (WM_USER + 48)
#define TB_GETIMAGELIST (WM_USER + 49)
#define TB_LOADIMAGES (WM_USER + 50)
#define TB_GETRECT (WM_USER + 51) // wParam is the Cmd instead of index
#define TB_SETHOTIMAGELIST (WM_USER + 52)
#define TB_GETHOTIMAGELIST (WM_USER + 53)
#define TB_SETDISABLEDIMAGELIST (WM_USER + 54)
#define TB_GETDISABLEDIMAGELIST (WM_USER + 55)
#define TB_SETSTYLE (WM_USER + 56)
#define TB_GETSTYLE (WM_USER + 57)
#define TB_GETBUTTONSIZE (WM_USER + 58)
#define TB_SETBUTTONWIDTH (WM_USER + 59)
#define TB_SETMAXTEXTROWS (WM_USER + 60)
#define TB_GETTEXTROWS (WM_USER + 61)
#ifdef UNICODE
#define TB_GETBUTTONTEXT TB_GETBUTTONTEXTW
#define TB_SAVERESTORE TB_SAVERESTOREW
#define TB_ADDSTRING TB_ADDSTRINGW
#else
#define TB_GETBUTTONTEXT TB_GETBUTTONTEXTA
#define TB_SAVERESTORE TB_SAVERESTOREA
#define TB_ADDSTRING TB_ADDSTRINGA
#endif
#define TB_GETOBJECT (WM_USER + 62) // wParam == IID, lParam void **ppv
#define TB_GETHOTITEM (WM_USER + 71)
#define TB_SETHOTITEM (WM_USER + 72) // wParam == iHotItem
#define TB_SETANCHORHIGHLIGHT (WM_USER + 73) // wParam == TRUE/FALSE
#define TB_GETANCHORHIGHLIGHT (WM_USER + 74)
#define TB_MAPACCELERATORA (WM_USER + 78) // wParam == ch, lParam int * pidBtn
#define TB_GETINSERTMARK (WM_USER + 79) // lParam == LPTBINSERTMARK
#define TB_SETINSERTMARK (WM_USER + 80) // lParam == LPTBINSERTMARK
#define TB_INSERTMARKHITTEST (WM_USER + 81) // wParam == LPPOINT lParam == LPTBINSERTMARK
#define TB_MOVEBUTTON (WM_USER + 82)
#define TB_GETMAXSIZE (WM_USER + 83) // lParam == LPSIZE
#define TB_SETEXTENDEDSTYLE (WM_USER + 84) // For TBSTYLE_EX_*
#define TB_GETEXTENDEDSTYLE (WM_USER + 85) // For TBSTYLE_EX_*
#define TB_GETPADDING (WM_USER + 86)
#define TB_SETPADDING (WM_USER + 87)
#define TB_SETINSERTMARKCOLOR (WM_USER + 88)
#define TB_GETINSERTMARKCOLOR (WM_USER + 89)
#define TB_SETCOLORSCHEME CCM_SETCOLORSCHEME // lParam is color scheme
#define TB_GETCOLORSCHEME CCM_GETCOLORSCHEME // fills in COLORSCHEME pointed to by lParam
#define TB_SETUNICODEFORMAT CCM_SETUNICODEFORMAT
#define TB_GETUNICODEFORMAT CCM_GETUNICODEFORMAT
#define TB_MAPACCELERATORW (WM_USER + 90) // wParam == ch, lParam int * pidBtn
#ifdef UNICODE
#define TB_MAPACCELERATOR TB_MAPACCELERATORW
#else
#define TB_MAPACCELERATOR TB_MAPACCELERATORA
#endif
#define TBIMHT_AFTER 1 // TRUE = insert After iButton, otherwise before
#define TBIMHT_BACKGROUND 2 // TRUE iff missed buttons completely
#define TBBF_LARGE 1
#define TBIF_IMAGE 1
#define TBIF_TEXT 2
#define TBIF_STATE 4
#define TBIF_STYLE 8
#define TBIF_LPARAM 16
#define TBIF_COMMAND 32
#define TBIF_SIZE 64
#define TBIF_BYINDEX 2147483648 // this specifies that the wparam in Get/SetButtonInfo is an index, not id
#ifdef UNICODE
#define TBBUTTONINFO TBBUTTONINFOW
#define LPTBBUTTONINFO LPTBBUTTONINFOW
#else
#define TBBUTTONINFO TBBUTTONINFOA
#define LPTBBUTTONINFO LPTBBUTTONINFOA
#endif
#define TB_GETBUTTONINFOW (WM_USER + 63)
#define TB_SETBUTTONINFOW (WM_USER + 64)
#define TB_GETBUTTONINFOA (WM_USER + 65)
#define TB_SETBUTTONINFOA (WM_USER + 66)
#ifdef UNICODE
#define TB_GETBUTTONINFO TB_GETBUTTONINFOW
#define TB_SETBUTTONINFO TB_SETBUTTONINFOW
#else
#define TB_GETBUTTONINFO TB_GETBUTTONINFOA
#define TB_SETBUTTONINFO TB_SETBUTTONINFOA
#endif
#define TB_INSERTBUTTONW (WM_USER + 67)
#define TB_ADDBUTTONSW (WM_USER + 68)
#define TB_HITTEST (WM_USER + 69)
#ifdef UNICODE
#define TB_INSERTBUTTON TB_INSERTBUTTONW
#define TB_ADDBUTTONS TB_ADDBUTTONSW
#else
#define TB_INSERTBUTTON TB_INSERTBUTTONA
#define TB_ADDBUTTONS TB_ADDBUTTONSA
#endif
#define TB_SETDRAWTEXTFLAGS (WM_USER + 70) // wParam == mask lParam == bit values
#define TB_GETSTRING (WM_USER + 92)
#define TBN_GETBUTTONINFOA (TBN_FIRST-0)
#define TBN_BEGINDRAG (TBN_FIRST-1)
#define TBN_ENDDRAG (TBN_FIRST-2)
#define TBN_BEGINADJUST (TBN_FIRST-3)
#define TBN_ENDADJUST (TBN_FIRST-4)
#define TBN_RESET (TBN_FIRST-5)
#define TBN_QUERYINSERT (TBN_FIRST-6)
#define TBN_QUERYDELETE (TBN_FIRST-7)
#define TBN_TOOLBARCHANGE (TBN_FIRST-8)
#define TBN_CUSTHELP (TBN_FIRST-9)
#define TBN_DROPDOWN (TBN_FIRST-10)
#define TBN_GETOBJECT (TBN_FIRST-12)
/* Toolbar Control Constants */
#define TBSTATE_CHECKED 1
#define TBSTATE_PRESSED 2
#define TBSTATE_ENABLED 4
#define TBSTATE_HIDDEN 8
#define TBSTATE_INDETERMINATE 16
#define TBSTATE_WRAP 32
#define TBSTATE_ELLIPSES 64
#define TBSTATE_MARKED 128
#define TBSTYLE_BUTTON 0 // obsolete; use BTNS_BUTTON instead
#define TBSTYLE_SEP 1 // obsolete; use BTNS_SEP instead
#define TBSTYLE_CHECK 2 // obsolete; use BTNS_CHECK instead
#define TBSTYLE_GROUP 4 // obsolete; use BTNS_GROUP instead
#define TBSTYLE_CHECKGROUP (TBSTYLE_GROUP + TBSTYLE_CHECK) // obsolete; use BTNS_CHECKGROUP instead
#define TBSTYLE_DROPDOWN 8 // obsolete; use BTNS_DROPDOWN instead
#define TBSTYLE_AUTOSIZE 16 // obsolete; use BTNS_AUTOSIZE instead
#define TBSTYLE_NOPREFIX 32 // obsolete; use BTNS_NOPREFIX instead
#define TBSTYLE_TOOLTIPS 256
#define TBSTYLE_WRAPABLE 512
#define TBSTYLE_ALTDRAG 1024
#define TBSTYLE_FLAT 2048
#define TBSTYLE_LIST 4096
#define TBSTYLE_CUSTOMERASE 8192
#define TBSTYLE_REGISTERDROP 16384
#define TBSTYLE_TRANSPARENT 32768
#define BTNS_BUTTON TBSTYLE_BUTTON // 0x0000
#define BTNS_SEP TBSTYLE_SEP // 0x0001
#define BTNS_CHECK TBSTYLE_CHECK // 0x0002
#define BTNS_GROUP TBSTYLE_GROUP // 0x0004
#define BTNS_CHECKGROUP TBSTYLE_CHECKGROUP // (TBSTYLE_GROUP | TBSTYLE_CHECK)
#define BTNS_DROPDOWN TBSTYLE_DROPDOWN // 0x0008
#define BTNS_AUTOSIZE TBSTYLE_AUTOSIZE // 0x0010; automatically calculate the cx of the button
#define BTNS_NOPREFIX TBSTYLE_NOPREFIX // 0x0020; this button should not have accel prefix
#define BTNS_SHOWTEXT 64 // ignored unless TBSTYLE_EX_MIXEDBUTTONS is set
#define BTNS_WHOLEDROPDOWN 128 // draw drop-down arrow, but without split arrow section
#define TBSTYLE_EX_DRAWDDARROWS 1
#define TBSTYLE_EX_MIXEDBUTTONS 8
#define TBSTYLE_EX_HIDECLIPPEDBUTTONS 16 // don't show partially obscured buttons
#define TBSTYLE_EX_DOUBLEBUFFER 0x00000080
//----------------------------------------------------------------------//
// WM_NOTIFY codes (NMHDR.code values)
#define NM_FIRST (0- 0) // generic to all controls
#define NM_LAST (0- 99)
#define NM_OUTOFMEMORY (NM_FIRST-1)
#define NM_CLICK (NM_FIRST-2) // uses NMCLICK struct
#define NM_DBLCLK (NM_FIRST-3)
#define NM_RETURN (NM_FIRST-4)
#define NM_RCLICK (NM_FIRST-5) // uses NMCLICK struct
#define NM_RDBLCLK (NM_FIRST-6)
#define NM_SETFOCUS (NM_FIRST-7)
#define NM_KILLFOCUS (NM_FIRST-8)
#define NM_CUSTOMDRAW (NM_FIRST-12)
#define NM_HOVER (NM_FIRST-13)
#define NM_NCHITTEST (NM_FIRST-14) // uses NMMOUSE struct
#define NM_KEYDOWN (NM_FIRST-15) // uses NMKEY struct
#define NM_RELEASEDCAPTURE (NM_FIRST-16)
#define NM_SETCURSOR (NM_FIRST-17) // uses NMMOUSE struct
#define NM_CHAR (NM_FIRST-18) // uses NMCHAR struct
#define NM_TOOLTIPSCREATED (NM_FIRST-19) // notify of when the tooltips window is create
#define NM_LDOWN (NM_FIRST-20)
#define NM_RDOWN (NM_FIRST-21)
//----------------------------------------------------------------------//
#endif
//----------------------------------------------------------------------//