2008-11-23 13:27 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)

* harbour/contrib/gtwvg/gtwvg.c
    + static void hb_gt_wvt_FireMenuEvent( PHB_GTWVT pWVT, int iMode, int menuIndex )
    + WM_ENTERMENULOOP
    + WM_EXITMENULOOP
    ! WM_COMMAND - Enhanced

  * harbour/contrib/gtwvg/wvggui.c
    + Same as with gtwvg.c

  * harbour/contrib/gtwvg/wvgsink.c
    + Experimental TypeLib info extraction function. Disabled for now.

  * harbour/contrib/gtwvg/wvgwin.c
    + Many new Win_* winapi functions.

  * harbour/contrib/gtwvg/hbgtwvg.ch
    + HB_GTI_MENU

  * harbour/contrib/gtwvg/wvgax.prg
  * harbour/contrib/gtwvg/wvgcrt.prg
  * harbour/contrib/gtwvg/wvgdlg.prg
  + harbour/contrib/gtwvg/wvgmenub.prg
  * harbour/contrib/gtwvg/wvgphdlr.prg
    + Implemented ( partially but functional ) Xbase++ compatible
      WvgMenuBar() and WvgMenu() classes.

  * harbour/contrib/gtwvg/tests/demowvg.prg
    + Demonstrated WvgMenuBar() and WvgMenu() implementation
      by picking up the real-time Xbase++ code.

  ; NEXT: WvtToolBar() class per XbpToolBar().
This commit is contained in:
Pritpal Bedi
2008-11-23 22:22:39 +00:00
parent 7ec06640e7
commit 882bd891a2
12 changed files with 1361 additions and 85 deletions

View File

@@ -8,6 +8,39 @@
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2008-11-23 13:27 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* harbour/contrib/gtwvg/gtwvg.c
+ static void hb_gt_wvt_FireMenuEvent( PHB_GTWVT pWVT, int iMode, int menuIndex )
+ WM_ENTERMENULOOP
+ WM_EXITMENULOOP
! WM_COMMAND - Enhanced
* harbour/contrib/gtwvg/wvggui.c
+ Same as with gtwvg.c
* harbour/contrib/gtwvg/wvgsink.c
+ Experimental TypeLib info extraction function. Disabled for now.
* harbour/contrib/gtwvg/wvgwin.c
+ Many new Win_* winapi functions.
* harbour/contrib/gtwvg/hbgtwvg.ch
+ HB_GTI_MENU
* harbour/contrib/gtwvg/wvgax.prg
* harbour/contrib/gtwvg/wvgcrt.prg
* harbour/contrib/gtwvg/wvgdlg.prg
+ harbour/contrib/gtwvg/wvgmenub.prg
* harbour/contrib/gtwvg/wvgphdlr.prg
+ Implemented ( partially but functional ) Xbase++ compatible
WvgMenuBar() and WvgMenu() classes.
* harbour/contrib/gtwvg/tests/demowvg.prg
+ Demonstrated WvgMenuBar() and WvgMenu() implementation
by picking up the real-time Xbase++ code.
; NEXT: WvtToolBar() class per XbpToolBar().
2008-11-22 15:57 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
+ harbour/contrib/gtwvg/tests/myharu.pdf

View File

@@ -385,6 +385,19 @@ static int hb_gt_wvt_FireEvent( PHB_GTWVT pWVT, int nEvent, PHB_ITEM pParams )
return nResult;
}
static void hb_gt_wvt_FireMenuEvent( PHB_GTWVT pWVT, int iMode, int menuIndex )
{
PHB_ITEM pEvParams = hb_itemNew( NULL );
hb_arrayNew( pEvParams, 2 );
hb_arraySetNI( pEvParams, 1, iMode );
hb_arraySetNI( pEvParams, 2, menuIndex );
hb_gt_wvt_FireEvent( pWVT, HB_GTE_MENU, pEvParams );
hb_itemRelease( pEvParams );
}
/*
* use the standard fixed oem font, unless the caller has requested set size fonts
*/
@@ -1925,9 +1938,24 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara
return 0;
case WM_COMMAND:
hb_wvt_gtHandleMenuSelection( pWVT, ( int ) LOWORD( wParam ) );
{
if( HIWORD( wParam ) == 0 )
{
hb_wvt_gtHandleMenuSelection( pWVT, ( int ) LOWORD( wParam ) );
hb_gt_wvt_FireMenuEvent( pWVT, 0, ( int ) LOWORD( wParam ) );
}
return 0;
}
case WM_ENTERMENULOOP:
{
hb_gt_wvt_FireMenuEvent( pWVT, 1, ( int ) wParam );
return 0;
}
case WM_EXITMENULOOP:
{
hb_gt_wvt_FireMenuEvent( pWVT, 2, ( int ) wParam );
return 0;
}
case WM_MOUSEHOVER:
{
PHB_ITEM pEvParams = hb_itemNew( NULL );

View File

@@ -66,6 +66,7 @@
#define HB_GTE_MOUSE 6
#define HB_GTE_KEYBOARD 7
#define HB_GTE_TIMER 8
#define HB_GTE_MENU 9
#define HB_GTI_SETFONT 71
#define HB_GTI_PRESPARAMS 72

View File

@@ -693,7 +693,7 @@ FUNCTION WvtMyBrowse()
oCrt:icon := "dia_excl.ico",;
oCrt:create(),;
Wvt_SetGui( .t. ),;
WvtMyBrowse_X(),;
WvtMyBrowse_X( oCrt ),;
oCrt:destroy();
} )
@@ -703,7 +703,47 @@ FUNCTION WvtMyBrowse()
Return NIL
//----------------------------------------------------------------------//
FUNCTION WvtMyBrowse_X()
STATIC FUNCTION BrwBuildMenu( oCrt )
Local oMenu, oSMenu
oMenu := WvgMenuBar():new( oCrt, , .t. ):create()
oSMenu := WvgMenu():new( oMenu ):create()
oSMenu:addItem( { '~First' , {|| alert( 'First' ) } } )
oSMenu:addItem( { '~Second', {|| alert( 'Second' ) } } )
oSMenu:addItem()
oSMenu:addItem( { '~Third' , {|| alert( 'Third' ) } } )
oMenu:addItem( { oSMenu, '~Hello' } )
oSMenu := WvgMenu():new( oMenu ):create()
oSMenu:addItem( { '~First' , {|| alert( 'First' ) } } )
oSMenu:addItem( '-' )
oSMenu:addItem( { '~Second', {|| alert( 'Second' ) } } )
oSMenu:addItem( { '~Third' , {|| alert( 'Third' ) } } )
oMenu:addItem( { oSMenu, '~MyFriends' } )
oSMenu := WvgMenu():new( oMenu ):create()
oSMenu:title := "~Procedural"
oSMenu:addItem( { "Procedure ~1", } )
oSMenu:addItem( { "Procedure ~2", } )
oSMenu:itemSelected := {|mp1| MyMenuProcedure( 100+mp1 ) }
oSMenu:checkItem( 2 )
oMenu:addItem( { oSMenu, NIL } )
Return oMenu
//----------------------------------------------------------------------//
Static Function MyMenuProcedure( nID )
do case
case nID == 101
alert( 'Procedure 101' )
case nID == 102
alert( 'Procedure 102' )
endcase
Return .t.
//----------------------------------------------------------------------//
FUNCTION WvtMyBrowse_X( oCrt )
LOCAL nKey, bBlock, oBrowse , aLastPaint, i, aLastPaint1
LOCAL lEnd := .f.
LOCAL aBlocks := {}
@@ -721,10 +761,13 @@ FUNCTION WvtMyBrowse_X()
LOCAL hPopup := Wvt_SetPopupMenu()
LOCAL stru_:={}, cDbfFile, cSqlFile, cFileIndex, cFileDbf, cRDD, nIndex
Local pGT, pGT1, nStStyle, nExStyle
Local oMenu
STATIC nStyle := 0
THREAD STATIC nFactor := 200
BrwBuildMenu( oCrt )
pGT_[ 2 ] := hb_gtSelect()
cRDD := "DBFCDX"
@@ -2171,6 +2214,65 @@ FUNCTION DrawSlide( hDlg, nSlide )
Return nil
//----------------------------------------------------------------------//
Static Function MyFunction( nMode )
#define MUSIC_WAITON {800, 1600}
do case
case nMode == 1
tone( MUSIC_WAITON[1], 1 )
tone( MUSIC_WAITON[2], 1 )
case nMode == 2
tone( MUSIC_WAITON[2], 1 )
tone( MUSIC_WAITON[1], 1 )
case nMode == 3 // THUD
tone( 60,0.5 )
case nMode == 101 // Charge
Eval( {|| tone(523,2),tone(698,2),tone(880,2),tone(1046,4),tone(880,2),tone(1046,8) } )
case nMode == 102 // NannyBoo
AEval( {{196,2},{196,2},{164,2},{220,2},{196,4},{164,4}}, {|a| tone(a[1],a[2]) } )
case nMode == 103 // BADKEY
tone( 480,0.25 )
tone( 240,0.25 )
endcase
Return nil
//----------------------------------------------------------------------//
Static Function ActiveXBuildMenu( oCrt )
Local oMenuBar, oSubMenu
oMenuBar := WvgMenuBar():new( oCrt ):create()
// Define submenu in procedural style.
// The numeric index of the selected menu item
// is passed to the Callback code block -> mp1
oSubMenu := WvgMenu():new( oMenuBar ):create()
oSubMenu:title := "~Procedural"
oSubMenu:addItem( { "Play Charge ~1", } )
oSubMenu:addItem( { "Play Nannyboo ~2", } )
oSubMenu:itemSelected := {|mp1| MyFunction( 100+mp1 ) }
oMenuBar:addItem( { oSubMenu, NIL } )
// Define submenu in the functional style:
// A menu item executes a code block that
// calls a function
oSubMenu := WvgMenu():new( oMenuBar ):create()
oSubMenu:title := "~Functional"
oSubMenu:addItem( { "Play Opening ~1", {|| MyFunction( 1 ) } } )
oSubMenu:addItem( { "Play Closing ~2", {|| MyFunction( 2 ) } } )
oSubMenu:addItem( { "~Play Badkey" , {|| MyFunction( 3 ) } } )
oMenuBar:addItem( { oSubMenu, NIL } )
Return nil
//----------------------------------------------------------------------//
// The function has to be called via hb_threadStart( {|| ExecuteActiveX( nActiveX ) } )
//
Function ExecuteActiveX( nActiveX )
@@ -2189,6 +2291,7 @@ Function ExecuteActiveX( nActiveX )
oCrt := WvgDialog():new( , , { 30,30 }, { 500,550 }, , .f. )
oCrt:closable := .f.
oCrt:create()
ActiveXBuildMenu( oCrt )
#endif
oCrt:show()
@@ -2247,7 +2350,9 @@ Static Function ExeActiveX( oCrt, nActiveX )
oCom:Refresh() ,;
oCom:ShowSecondsHand := .t. ,;
oCom:Hands3D := .t. ,;
oCom:Refresh() } )
oCom:Refresh() ,;
oCom:showAboutBox() ;
} )
oCom:mapEvent( evBtnUp, {|nBtn,nShift,nX,nY| if( nBtn == 2, lEnd := .t., NIL ) } )

View File

@@ -186,6 +186,10 @@ METHOD Create( oParent, oOwner, aPos, aSize, aPresParams, lVisible, cCLSID, cLic
::AdviseEvents()
ENDIF
#if 0
HB_AX_LoadTypeInfo( ::hObj )
#endif
RETURN Self
//----------------------------------------------------------------------//
METHOD Destroy() CLASS WvgActiveXControl

View File

@@ -76,6 +76,8 @@
CLASS WvgCrt INHERIT WvgPartHandler
DATA oMenu
// CONFIGURATION
//
DATA alwaysOnTop INIT .F. // Determines whether the dialog can be covered by other windows
@@ -372,6 +374,10 @@ METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS Wv
METHOD destroy() CLASS WvgCrt
IF hb_isObject( ::oMenu )
::oMenu:destroy()
ENDIF
if ::lModal
::pGT := NIL
hb_gtSelect( ::pGTp )
@@ -485,8 +491,15 @@ METHOD lockUpdate() CLASS WvgCrt
//----------------------------------------------------------------------//
METHOD menuBar() CLASS WvgCrt
LOCAL oMenuBar
RETURN Self
IF !hb_isObject( ::oMenu )
oMenuBar := WvgMenuBar():New( self ):create()
ELSE
oMenuBar := ::oMenu
ENDIF
RETURN oMenuBar
//----------------------------------------------------------------------//

View File

@@ -75,6 +75,8 @@
//----------------------------------------------------------------------//
CLASS WvgDialog FROM WvgWindow
DATA oMenu
METHOD init()
METHOD create()
METHOD configure()
@@ -152,6 +154,10 @@ METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS Wv
//----------------------------------------------------------------------//
METHOD destroy() CLASS WvgDialog
IF hb_isObject( ::oMenu )
::oMenu:destroy()
ENDIF
::pGT := NIL
::pGTp := NIL

View File

@@ -326,6 +326,20 @@ static int hb_gt_wvt_FireEvent( PHB_GTWVT pWVT, int nEvent, PHB_ITEM pParams )
return nResult;
}
static void hb_gt_wvt_FireMenuEvent( PHB_GTWVT pWVT, int iMode, int menuIndex )
{
PHB_ITEM pEvParams = hb_itemNew( NULL );
hb_arrayNew( pEvParams, 2 );
hb_arraySetNI( pEvParams, 1, iMode );
hb_arraySetNI( pEvParams, 2, menuIndex );
hb_gt_wvt_FireEvent( pWVT, HB_GTE_MENU, pEvParams );
hb_itemRelease( pEvParams );
}
/*
* functions for handling the input queues for the mouse and keyboard
*/
@@ -996,10 +1010,6 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara
{
return( hb_gt_wvt_SizeChanged( pWVT ) );
}
case WM_COMMAND:
{
return 0;
}
case WM_SYSCOMMAND:
{
switch( wParam )
@@ -1034,6 +1044,24 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara
}
return 0;
}
case WM_COMMAND:
{
if( HIWORD( wParam ) == 0 )
{
hb_gt_wvt_FireMenuEvent( pWVT, 0, ( int ) LOWORD( wParam ) );
}
return 0;
}
case WM_ENTERMENULOOP:
{
hb_gt_wvt_FireMenuEvent( pWVT, 1, ( int ) wParam );
return 0;
}
case WM_EXITMENULOOP:
{
hb_gt_wvt_FireMenuEvent( pWVT, 2, ( int ) wParam );
return 0;
}
case WM_MOUSEHOVER:
{
PHB_ITEM pEvParams = hb_itemNew( NULL );

View File

@@ -0,0 +1,584 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Source file for the Wvg*Classes
*
* Copyright 2008 Pritpal Bedi <pritpal@vouchcac.com>
* http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//
// EkOnkar
// ( The LORD is ONE )
//
// Xbase++ Compatible xbpMenuBar Class
//
// Pritpal Bedi <pritpal@vouchcac.com>
// 22Nov2008
//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
#include 'hbclass.ch'
#include 'common.ch'
#include 'hbgtinfo.ch'
#include 'hbgtwvg.ch'
#include 'wvtwin.ch'
#include 'inkey.ch'
//----------------------------------------------------------------------//
CLASS wvgMenuBar INHERIT wvgWindow
DATA hMenu
METHOD new()
METHOD create()
METHOD configure()
METHOD destroy()
//Manipulation
METHOD addItem()
METHOD checkItem()
METHOD delItem()
METHOD disableItem()
METHOD enableItem()
METHOD getItem()
METHOD insItem()
METHOD isItemChecked()
METHOD isItemEnabled()
METHOD numItems() INLINE len( ::aMenuItems )
METHOD selectItem()
METHOD setItem()
// Event CallBack Slots
DATA sl_beginMenu
DATA sl_endMenu
DATA sl_itemMarked
DATA sl_itemSelected
DATA sl_drawItem
DATA sl_measureItem
DATA sl_onMenuKey
// Event Callback Methods
METHOD beginMenu() SETGET
METHOD endMenu() SETGET
METHOD itemMarked() SETGET
METHOD itemSelected() SETGET
METHOD drawItem() SETGET
METHOD measureItem() SETGET
METHOD onMenuKey() SETGET
METHOD findMenuItemById()
METHOD findMenuPosById()
METHOD DelAllItems()
DATA aMenuItems INIT {}
CLASSVAR nMenuItemID INIT 0
DATA nPass INIT 0
DATA caption INIT ''
DATA nItemID INIT 0
DATA aIds INIT {}
DATA className INIT 'MENUBAR'
ENDCLASS
//----------------------------------------------------------------------//
METHOD new( oParent, aPresParams, lVisible ) CLASS wvgMenuBar
DEFAULT oParent TO ::oParent
DEFAULT aPresParams TO ::aPresParams
DEFAULT lVisible TO ::visible
::oParent := oParent
::aPresParams := aPresParams
::visible := lVisible
::wvgWindow:new( ::oParent, , , , ::aPresParams, ::visible )
RETURN Self
//----------------------------------------------------------------------//
METHOD create( oParent, aPresParams, lVisible ) CLASS wvgMenuBar
DEFAULT oParent TO ::oParent
DEFAULT aPresParams TO ::aPresParams
DEFAULT lVisible TO ::visible
::oParent := oParent
::aPresParams := aPresParams
::visible := lVisible
::wvgWindow:create( ::oParent, , , , ::aPresParams, ::visible )
::hMenu := Win_CreateMenu()
if ::hMenu <> 0
// check for if the parent already has a menu
// we need to destroy that first
// TO DO
// finally set the menu
//Win_SetMenu( ::oParent:getHWND(), ::hMenu )
// how to make menu invisible ?
//
if ( ::visible )
//Win_ShowWindow( ::oParent:getHWND(), SW_MINIMIZE )
//Win_ShowWindow( ::oParent:getHWND(), SW_NORMAL )
endif
::oParent:oMenu := Self
endif
RETURN Self
//----------------------------------------------------------------------//
METHOD configure( oParent, aPresParams, lVisible ) CLASS wvgMenuBar
DEFAULT oParent TO ::oParent
DEFAULT aPresParams TO ::aPresParams
DEFAULT lVisible TO ::visible
::oParent := oParent
::aPresParams := aPresParams
::visible := lVisible
RETURN Self
//----------------------------------------------------------------------//
METHOD destroy() CLASS wvgMenuBar
IF !empty( ::hMenu )
::DelAllItems()
IF !Win_DestroyMenu( ::hMenu )
//Throw( ErrorNew( "wvtMenu", 1000, "wvtMenu:Destroy()", "Destroy menu FAILED", {},"wvt.prg" ) )
ENDIF
::hMenu := 0
ENDIF
RETURN( .T. )
//----------------------------------------------------------------------//
METHOD delAllItems() CLASS wvgMenuBar
LOCAL lResult:= .T., nItems
nItems := ::numItems()
DO WHILE nItems > 0 .AND. lResult
lResult := ::DelItem( nItems )
nItems--
ENDDO
RETURN ( lResult )
//-------------------------------------------------------------------//
METHOD delItem( nItemNum ) CLASS wvgMenuBar
LOCAL lResult:= .F.
IF nItemNum > 0 .AND. nItemNum <= ::numItems()
IF ::aMenuItems[ nItemNum,WVT_MENU_TYPE ] == MF_POPUP
::aMenuItems[ nItemNum,WVT_MENU_MENUOBJ ]:Destroy()
ENDIF
IF ( lResult:= Win_DeleteMenu( ::hMenu, nItemNum-1, MF_BYPOSITION ) ) // Remember ZERO base
ADEL( ::aMenuItems, nItemNum )
ASIZE( ::aMenuItems, LEN( ::aMenuItems ) - 1 )
ELSE
//Throw( ErrorNew( "wvtMenu", 1000, "wvtMenu:DelItem()", "Delete menu item FAILED", { nItemNum },"wvt.prg" ) )
ENDIF
ENDIF
RETURN lResult
//----------------------------------------------------------------------//
// { xCaption, bAction, nStyle, nAttrb }
//
METHOD addItem( aItem, p2, p3, p4 ) CLASS wvgMenuBar
LOCAL nItemIndex, nMenuItemID, cCaption
LOCAL xCaption, bAction, nStyle, nAttrib
if PCount() == 1 .and. valtype( aItem ) == 'A'
ASize( aItem, 4 )
xCaption := aItem[ 1 ]
bAction := aItem[ 2 ]
nStyle := aItem[ 3 ]
nAttrib := aItem[ 4 ]
else
xCaption := aItem
bAction := p2
nStyle := p3
nAttrib := p4
endif
nItemIndex := ::numItems() + 1
// xCaption : NIL | cPrompt | ncResource | oMenu
switch valtype( xCaption )
case 'U'
// Separator
aItem := { MF_SEPARATOR, 0, 0, NIL }
exit
case 'C'
if left( xCaption,1 ) == '-'
aItem := { MF_SEPARATOR, 0, 0, NIL }
else
aItem := { MF_STRING, ++::nMenuItemID, xCaption, bAction }
endif
exit
case 'O'
cCaption := IF( bAction == NIL, xCaption:title, bAction )
aItem := { MF_POPUP , xCaption:hMenu , cCaption, xCaption }
exit
case 'N'
// Resource ID
exit
end
aadd( ::aMenuItems, aItem )
Win_AppendMenu( ::hMenu, aItem[ 1 ], aItem[ 2 ], aItem[ 3 ] )
IF ++::nPass == 1
IF ::oParent:className $ 'WVGCRT,WVGDIALOG'
Win_SetMenu( ::oParent:getHWND(), ::hMenu )
ENDIF
ELSE
IF ::oParent:className $ 'WVGCRT,WVGDIALOG'
Win_DrawMenubar( ::oParent:getHWND() )
ENDIF
ENDIF
RETURN nItemIndex
//----------------------------------------------------------------------//
METHOD findMenuItemById( nId ) CLASS wvgMenuBar
LOCAL x, aResult :={}, aRes :={}
IF !empty( nId )
x := ::numItems()
DO WHILE x > 0 .AND. empty( aResult )
IF ::aMenuItems[ x, WVT_MENU_TYPE ] == MF_POPUP
aResult:= ::aMenuItems[ x,WVT_MENU_MENUOBJ ]:findMenuItemById( nId )
ELSEIF ::aMenuItems[ x, WVT_MENU_IDENTIFIER ] == nId
aResult := { x, ::aMenuItems[ x, WVT_MENU_ACTION ], ::sl_itemSelected, Self }
ENDIF
x--
ENDDO
ENDIF
RETURN ( aResult )
//-------------------------------------------------------------------//
METHOD findMenuPosById( nId ) CLASS wvgMenuBar
LOCAL x, nPos
IF !empty( nId )
x := ::numItems()
DO WHILE x > 0 .AND. empty( nPos )
IF ::aMenuItems[ x,WVT_MENU_TYPE ] == MF_POPUP
nPos := ::aMenuItems[ x,WVT_MENU_MENUOBJ ]:findMenuPosById( nId )
ELSEIF ::aMenuItems[ x,WVT_MENU_IDENTIFIER ] == nId
nPos := x
ENDIF
x--
ENDDO
ENDIF
RETURN ( nPos )
//-------------------------------------------------------------------//
METHOD checkItem( nItemNum, lCheck ) CLASS wvgMenuBar
LOCAL nRet := -1
DEFAULT lCheck TO .T.
IF !empty( ::hMenu ) .AND. !empty( nItemNum )
nRet := Win_CheckMenuItem( ::hMenu, nItemNum, MF_BYPOSITION + IF( lCheck, MF_CHECKED, MF_UNCHECKED ) )
ENDIF
RETURN IF( nRet == -1, .F., .T. )
//----------------------------------------------------------------------//
METHOD enableItem( nItemNum ) CLASS wvgMenuBar
LOCAL lSuccess := .f.
IF !empty( ::hMenu ) .AND. !empty( nItemNum )
lSuccess := Win_EnableMenuItem( ::hMenu, nItemNum-1, MF_BYPOSITION + MF_ENABLED )
ENDIF
RETURN ( lSuccess )
//-------------------------------------------------------------------//
METHOD disableItem( nItemNum ) CLASS wvgMenuBar
LOCAL lSuccess := .f.
IF !empty( ::hMenu ) .AND. !empty( nItemNum )
lSuccess := Win_EnableMenuItem( ::hMenu, nItemNum-1, MF_BYPOSITION + MF_GRAYED )
ENDIF
RETURN ( lSuccess )
//-------------------------------------------------------------------//
METHOD getItem() CLASS wvgMenuBar
RETURN Self
//----------------------------------------------------------------------//
METHOD insItem() CLASS wvgMenuBar
RETURN Self
//----------------------------------------------------------------------//
METHOD isItemChecked() CLASS wvgMenuBar
RETURN Self
//----------------------------------------------------------------------//
METHOD isItemEnabled() CLASS wvgMenuBar
RETURN Self
//----------------------------------------------------------------------//
METHOD selectItem() CLASS wvgMenuBar
RETURN Self
//----------------------------------------------------------------------//
METHOD setItem() CLASS wvgMenuBar
RETURN Self
//----------------------------------------------------------------------//
// Callback Methods
//----------------------------------------------------------------------//
METHOD beginMenu( xParam ) CLASS wvgMenuBar
if hb_isBlock( xParam ) .or. hb_isNil( xParam )
::sl_beginMenu := xParam
RETURN NIL
endif
RETURN Self
//----------------------------------------------------------------------//
METHOD endMenu( xParam ) CLASS wvgMenuBar
if hb_isBlock( xParam ) .or. hb_isNil( xParam )
::sl_endMenu := xParam
RETURN NIL
endif
RETURN Self
//----------------------------------------------------------------------//
METHOD itemMarked( xParam ) CLASS wvgMenuBar
if hb_isBlock( xParam ) .or. hb_isNil( xParam )
::sl_itemMarked := xParam
RETURN NIL
endif
RETURN Self
//----------------------------------------------------------------------//
METHOD itemSelected( xParam ) CLASS wvgMenuBar
if hb_isBlock( xParam ) .or. hb_isNil( xParam )
::sl_itemSelected := xParam
RETURN NIL
endif
RETURN Self
//----------------------------------------------------------------------//
METHOD drawItem( xParam ) CLASS wvgMenuBar
if hb_isBlock( xParam ) .or. hb_isNil( xParam )
::sl_drawItem := xParam
RETURN NIL
endif
RETURN Self
//----------------------------------------------------------------------//
METHOD measureItem( xParam ) CLASS wvgMenuBar
if hb_isBlock( xParam ) .or. hb_isNil( xParam )
::sl_measureItem := xParam
RETURN NIL
endif
RETURN Self
//----------------------------------------------------------------------//
METHOD onMenuKey( xParam ) CLASS wvgMenuBar
if hb_isBlock( xParam ) .or. hb_isNil( xParam )
::sl_onMenuKey := xParam
RETURN NIL
endif
RETURN Self
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//
// Xbase++ compatible xbpMenu class
//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
CLASS wvgMenu INHERIT wvgMenuBar
DATA title INIT ''
METHOD new()
METHOD create()
METHOD getTitle()
METHOD setTitle()
METHOD popup()
ENDCLASS
//----------------------------------------------------------------------//
METHOD new( oParent, aPresParams, lVisible ) CLASS wvgMenu
DEFAULT oParent TO ::oParent
DEFAULT aPresParams TO ::aPresParams
DEFAULT lVisible TO ::visible
::oParent := oParent
::aPresParams := aPresParams
::visible := lVisible
RETURN Self
//----------------------------------------------------------------------//
METHOD create( oParent, aPresParams, lVisible ) CLASS wvgMenu
DEFAULT oParent TO ::oParent
DEFAULT aPresParams TO ::aPresParams
DEFAULT lVisible TO ::visible
::oParent := oParent
::aPresParams := aPresParams
::visible := lVisible
::className := 'POPUPMENU'
::hMenu := Win_CreatePopupMenu()
RETURN Self
//----------------------------------------------------------------------//
METHOD getTitle() CLASS wvgMenu
RETURN ::title
//----------------------------------------------------------------------//
METHOD setTitle( cTitle )
RETURN ::title := cTitle
//----------------------------------------------------------------------//
METHOD popUp() CLASS wvgMenu
RETURN Self
//----------------------------------------------------------------------//

View File

@@ -176,9 +176,9 @@ METHOD addChild( oWvg ) CLASS WvgPartHandler
METHOD childFromName( nNameId ) CLASS WvgPartHandler
LOCAL oWvg
if ::hChildren[ nNameId ] <> NIL
IF ::hChildren[ nNameId ] <> NIL
oWvg := ::hChildren[ nNameId ] // ???
endif
ENDIF
RETURN oWvg
@@ -202,9 +202,9 @@ METHOD delChild( oWvg ) CLASS WvgPartHandler
METHOD setName( nNameId ) CLASS WvgPartHandler
LOCAL nOldNameId := ::nNameId
if Valtype( nNameId ) == 'N'
IF Valtype( nNameId ) == 'N'
::nNameId := nNameId
endif
ENDIF
RETURN nOldNameId
@@ -213,9 +213,9 @@ METHOD setName( nNameId ) CLASS WvgPartHandler
METHOD setOwner( oWvg ) CLASS WvgPartHandler
LOCAL oOldXbp := ::oOwner
if valtype( oWvg ) == 'O'
IF valtype( oWvg ) == 'O'
::oOwner := oWvg
endif
ENDIF
RETURN oOldXbp
@@ -224,126 +224,155 @@ METHOD setOwner( oWvg ) CLASS WvgPartHandler
METHOD setParent( oWvg ) CLASS WvgPartHandler
LOCAL oOldXbp := ::oParent
if valtype( oWvg ) == 'O'
IF valtype( oWvg ) == 'O'
::oParent := oWvg
endif
ENDIF
RETURN oOldXbp
//----------------------------------------------------------------------//
METHOD notifier( nEvent, xParams ) CLASS WvgPartHandler
Local aPos, nReturn := 0
Local xResult, n, aPos
LOCAL nReturn := 0
LOCAL aMenuItem, bBlock, nPos
DO CASE
CASE nEvent == HB_GTE_MOUSE
if xParams[ 1 ] == WM_MOUSEHOVER
IF xParams[ 1 ] == WM_MOUSEHOVER
aPos := { xParams[ 3 ], xParams[ 4 ] }
elseif xParams[ 1 ] == WM_MOUSELEAVE
// Nothing
else
aPos := if( ::mouseMode == 2, { xParams[ 3 ], xParams[ 4 ] }, { xParams[ 5 ], xParams[ 6 ] } )
endif
ENDIF
SWITCH xParams[ 1 ]
case WM_MOUSEHOVER
if hb_isBlock( ::sl_enter )
CASE WM_MOUSEHOVER
IF hb_isBlock( ::sl_enter )
eval( ::sl_enter, aPos, NIL, self )
endif
ENDIF
EXIT
case WM_MOUSELEAVE
if hb_isBlock( ::sl_leave )
CASE WM_MOUSELEAVE
IF hb_isBlock( ::sl_leave )
eval( ::sl_leave, aPos, NIL, self )
endif
ENDIF
EXIT
case WM_RBUTTONDOWN
if hb_isBlock( ::sl_rbDown )
CASE WM_RBUTTONDOWN
IF hb_isBlock( ::sl_rbDown )
eval( ::sl_rbDown, aPos, NIL, self )
endif
ENDIF
EXIT
case WM_LBUTTONDOWN
if hb_isBlock( ::sl_lbDown )
CASE WM_LBUTTONDOWN
IF hb_isBlock( ::sl_lbDown )
eval( ::sl_lbDown, aPos, NIL, self )
endif
ENDIF
EXIT
case WM_RBUTTONUP ////
if hb_isBlock( ::sl_rbUp )
CASE WM_RBUTTONUP ////
IF hb_isBlock( ::sl_rbUp )
eval( ::sl_rbUp, aPos, NIL, self )
endif
ENDIF
EXIT
case WM_LBUTTONUP ////
if hb_isBlock( ::sl_lbUp )
CASE WM_LBUTTONUP ////
IF hb_isBlock( ::sl_lbUp )
eval( ::sl_lbUp, aPos, NIL, self )
endif
ENDIF
EXIT
case WM_RBUTTONDBLCLK
if hb_isBlock( ::sl_rbDblClick )
CASE WM_RBUTTONDBLCLK
IF hb_isBlock( ::sl_rbDblClick )
eval( ::sl_rbDblClick, aPos, NIL, self )
endif
ENDIF
EXIT
case WM_LBUTTONDBLCLK
if hb_isBlock( ::sl_lbDblClick )
CASE WM_LBUTTONDBLCLK
IF hb_isBlock( ::sl_lbDblClick )
eval( ::sl_lbDblClick, aPos, NIL, self )
endif
ENDIF
EXIT
case WM_MBUTTONDOWN
if hb_isBlock( ::sl_mbDown )
CASE WM_MBUTTONDOWN
IF hb_isBlock( ::sl_mbDown )
eval( ::sl_mbDown, aPos, NIL, self )
endif
ENDIF
EXIT
case WM_MBUTTONUP ////
if hb_isBlock( ::sl_mbClick )
CASE WM_MBUTTONUP ////
IF hb_isBlock( ::sl_mbClick )
eval( ::sl_mbClick, aPos, NIL, self )
endif
ENDIF
EXIT
case WM_MBUTTONDBLCLK
if hb_isBlock( ::sl_mbDblClick )
CASE WM_MBUTTONDBLCLK
IF hb_isBlock( ::sl_mbDblClick )
eval( ::sl_mbDblClick, aPos, NIL, self )
endif
ENDIF
EXIT
case WM_MOUSEMOVE
if hb_isBlock( ::sl_motion )
CASE WM_MOUSEMOVE
IF hb_isBlock( ::sl_motion )
eval( ::sl_motion, aPos, NIL, self )
endif
ENDIF
EXIT
case WM_MOUSEWHEEL
if hb_isBlock( ::sl_wheel )
CASE WM_MOUSEWHEEL
IF hb_isBlock( ::sl_wheel )
eval( ::sl_wheel, aPos, NIL, self )
endif
ENDIF
EXIT
case WM_NCMOUSEMOVE
CASE WM_NCMOUSEMOVE
EXIT
END
CASE nEvent == HB_GTE_KEYBOARD
if hb_isBlock( ::keyboard )
IF hb_isBlock( ::keyboard )
eval( ::keyboard, xParams, NIL, Self )
endif
ENDIF
CASE nEvent == HB_GTE_SETFOCUS
if hb_isBlock( ::setInputFocus )
IF hb_isBlock( ::setInputFocus )
eval( ::setInputFocus, NIL, NIL, Self )
endif
ENDIF
::lHasInputFocus := .t.
CASE nEvent == HB_GTE_KILLFOCUS
if hb_isBlock( ::killInputFocus )
IF hb_isBlock( ::killInputFocus )
eval( ::killInputFocus, NIL, NIL, Self )
endif
ENDIF
::lHasInputFocus := .f.
CASE nEvent == HB_GTE_RESIZED
if hb_isBlock( ::sl_resize )
IF hb_isBlock( ::sl_resize )
eval( ::sl_resize, { xParams[ 1 ], xParams[ 2 ] }, { xParams[ 3 ], xParams[ 4 ] }, Self )
endif
ENDIF
CASE nEvent == HB_GTE_CLOSE
if hb_isBlock( ::close )
IF hb_isBlock( ::close )
nReturn := eval( ::close, NIL, NIL, Self )
endif
ENDIF
CASE nEvent == HB_GTE_MENU
DO CASE
CASE xParams[ 1 ] == 0 // menu selected
IF hb_isObject( ::oMenu )
IF !empty( aMenuItem := ::oMenu:FindMenuItemById( xParams[ 2 ] ) )
IF hb_isBlock( aMenuItem[ 2 ] )
Eval( aMenuItem[ 2 ], aMenuItem[ 1 ], NIL, aMenuItem[ 4 ] )
ELSEIF hb_isBlock( aMenuItem[ 3 ] )
Eval( aMenuItem[ 3 ], aMenuItem[ 1 ], NIL, aMenuItem[ 4 ] )
ENDIF
ENDIF
ENDIF
CASE xParams[ 1 ] == 1 // enter menu loop
IF hb_isBlock( ::oMenu:sl_beginMenu )
Eval( ::oMenu:sl_beginMenu, NIL, NIL, Self )
ENDIF
CASE xParams[ 1 ] == 2 // exit menu loop
IF hb_isBlock( ::oMenu:sl_endMenu )
Eval( ::oMenu:sl_endMenu, NIL, NIL, Self )
ENDIF
ENDCASE
ENDCASE
RETURN nReturn

View File

@@ -823,4 +823,330 @@ HB_FUNC( HB_AX_ATLAXWINTERM )
hb_retl( bRet );
}
//----------------------------------------------------------------------//
// Load Type Info
//----------------------------------------------------------------------//
typedef struct {
DISPID m_dispID; // dispatch id
BSTR m_bstrName; // method or property name
WORD m_wFlag; // invoke flag
short m_oVft; // offset of virtual function
CALLCONV m_callconv; // calling convention
VARTYPE m_vtOutputType; // output type
VARIANT* m_pOutput; // output data
int m_nParamCount; // number of parameters
WORD* m_pParamTypes; // parameter type array
} DispInfo;
//----------------------------------------------------------------------//
#if 0
//=================================================
// BUGGY experimental, untested and unfinished code
//=================================================
int LoadTypeInformation( IDispatch* pDisp ) // pass dispatch interface
{
//UINT nTypeInfoCount;
//m_hRet = m_pDisp->GetTypeInfoCount(&nTypeInfoCount);
//if(m_hRet!=S_OK||nTypeInfoCount==0)
//{
// #ifdef XYDISPDRIVER_DEBUG
// _tprintf(_T("GetTypeInfoCount failed or no type info: %x\n"),m_hRet);
// #endif
//}
ITypeInfo* pTypeInfo;
TYPEATTR* pTypeAttr;
HRESULT hr;
int i=0,j;
unsigned int nCount;
int m_nMethodCount;
int m_nVarCount;
int m_nDispInfoCount;
DispInfo* m_pDispInfo;
char cBuffer[128];
//pDisp->lpVtbl->GetTypeInfoCount(pDisp, &i ); // i should be 1, otherwise no typeinfo present
//wsprintf( cBuffer, "typeinfocount: %i", i );
//OutputDebugString( cBuffer);
hb_ToOutDebug( "looking for type info" );
hr = pDisp->lpVtbl->GetTypeInfo( pDisp, 0, LOCALE_SYSTEM_DEFAULT, &pTypeInfo );
if(hr != S_OK || pTypeInfo == NULL )
{
return 0;
}
hr = pDisp->lpVtbl->GetTypeInfoCount( pDisp, &i );
wsprintf( cBuffer, "typeinfocount: %i, returned: %i", i, hr );
OutputDebugString( cBuffer);
OutputDebugString("got type info");
hr = pTypeInfo->lpVtbl->GetTypeAttr( pTypeInfo, &pTypeAttr );
if( hr != S_OK )
{
pTypeInfo->lpVtbl->Release(pTypeInfo);
return 0;
}
OutputDebugString("got type attributes");
if( pTypeAttr->typekind != TKIND_DISPATCH && pTypeAttr->typekind != TKIND_COCLASS && pTypeAttr->typekind != TKIND_INTERFACE )
{
wsprintf( cBuffer, "typekind: %i", pTypeAttr->typekind );
OutputDebugString( cBuffer);
pTypeInfo->lpVtbl->ReleaseTypeAttr( pTypeInfo, pTypeAttr );
pTypeInfo->lpVtbl->Release(pTypeInfo);
hr = S_FALSE;
//return pTypeAttr->typekind; //0;
}
OutputDebugString("got type kind");
if( pTypeAttr->typekind == TKIND_COCLASS )
{
int nFlags;
HREFTYPE hRefType;
ITypeInfo* pTempInfo;
TYPEATTR* pTempAttr = NULL;
for ( i=0 ; i < pTypeAttr->cImplTypes ; i++)
{
if( pTypeInfo->lpVtbl->GetImplTypeFlags( pTypeInfo, i, &nFlags ) == S_OK && ( nFlags & IMPLTYPEFLAG_FDEFAULT ))
{
hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType( pTypeInfo, i, &hRefType );
if( hr == S_OK )
{
hr = pTypeInfo->lpVtbl->GetRefTypeInfo( pTypeInfo, hRefType, &pTempInfo );
}
if( hr == S_OK )
{
hr = pTempInfo->lpVtbl->GetTypeAttr( pTempInfo, &pTempAttr );
if( hr != S_OK )
{
pTempInfo->lpVtbl->Release(pTempInfo);
pTempInfo = NULL;
break;
}
}
else break;
}
}
pTypeInfo->lpVtbl->ReleaseTypeAttr( pTypeInfo, pTypeAttr );
pTypeInfo->lpVtbl->Release(pTypeInfo);
if( pTempAttr == NULL )
{
if( hr == S_OK )
{
//hr = S_FALSE;
}
return 0;
}
else
{
pTypeInfo = pTempInfo;
pTypeAttr = pTempAttr;
}
}
OutputDebugString("allocating memory");
m_nMethodCount = pTypeAttr->cFuncs;
m_nVarCount = pTypeAttr->cVars;
m_nDispInfoCount = m_nMethodCount+2*m_nVarCount;
// allocate <m_nDispInfoCount> structures of DispInfo
m_pDispInfo = (DispInfo *) hb_xgrab( sizeof(DispInfo) * m_nDispInfoCount);
wsprintf( cBuffer, "methods: %i vars: %i DispInfo: %i", m_nMethodCount, m_nVarCount, m_nDispInfoCount );
hb_ToOutDebug( cBuffer);
hb_ToOutDebug( "looping through methods");
for( i=0; i < m_nMethodCount; i++ )
{
FUNCDESC* pFuncDesc;
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc );
if( hr != S_OK )
{
pTypeInfo->lpVtbl->ReleaseTypeAttr(pTypeInfo, pTypeAttr);
pTypeInfo->lpVtbl->Release(pTypeInfo);
//m_nMethodCount = m_nVarCount = m_nDispInfoCount = 0;
hb_xfree( m_pDispInfo);
return 0;
}
m_pDispInfo[i].m_dispID = pFuncDesc->memid;
wsprintf( cBuffer, " id: %i kind: %i", pFuncDesc->memid, pFuncDesc->invkind );
hb_ToOutDebug( cBuffer);
hr = pTypeInfo->lpVtbl->GetNames( pTypeInfo, m_pDispInfo[i].m_dispID ,&m_pDispInfo[i].m_bstrName, 1, &nCount );
if( hr != S_OK )
{
pTypeInfo->lpVtbl->ReleaseFuncDesc( pTypeInfo, pFuncDesc );
pTypeInfo->lpVtbl->ReleaseTypeAttr( pTypeInfo, pTypeAttr );
pTypeInfo->lpVtbl->Release(pTypeInfo);
//m_nMethodCount = m_nVarCount = m_nDispInfoCount = 0;
// free memory
hb_xfree( m_pDispInfo);
return 0;
}
// kind of entry
switch(pFuncDesc->invkind)
{
case INVOKE_PROPERTYGET:
m_pDispInfo[i].m_wFlag = DISPATCH_PROPERTYGET;
break;
case INVOKE_PROPERTYPUT:
m_pDispInfo[i].m_wFlag = DISPATCH_PROPERTYPUT;
break;
case INVOKE_PROPERTYPUTREF:
m_pDispInfo[i].m_wFlag = DISPATCH_PROPERTYPUTREF;
break;
case INVOKE_FUNC:
m_pDispInfo[i].m_wFlag = DISPATCH_METHOD;
break;
default:
break;
}
m_pDispInfo[i].m_oVft = pFuncDesc->oVft;
m_pDispInfo[i].m_callconv = pFuncDesc->callconv;
m_pDispInfo[i].m_pOutput = (VARIANT*) hb_xgrab( sizeof(VARIANT));
VariantInit( m_pDispInfo[i].m_pOutput );
m_pDispInfo[i].m_vtOutputType = pFuncDesc->elemdescFunc.tdesc.vt;
if(m_pDispInfo[i].m_vtOutputType==VT_VOID||m_pDispInfo[i].m_vtOutputType==VT_NULL)
{
m_pDispInfo[i].m_vtOutputType = VT_EMPTY;
}
wsprintf( cBuffer, " id: %i kind: %i", pFuncDesc->memid, pFuncDesc->invkind );
hb_ToOutDebug( cBuffer);
WideCharToMultiByte( CP_ACP, // code page
0, // performance and mapping flags
m_pDispInfo[i].m_bstrName, // wide-character string
-1, // number of chars in string.
cBuffer, // buffer for new string
128, // size of buffer
NULL, // default for unmappable chars
NULL // set when default char used
);
hb_ToOutDebug( cBuffer);
//OutputDebugString( m_pDispInfo[i].m_bstrName);
hb_ToOutDebug( "looping paremeters");
// parameters
m_pDispInfo[i].m_nParamCount = pFuncDesc->cParams;
m_pDispInfo[i].m_pParamTypes = (WORD*) hb_xgrab( sizeof(WORD) * (m_pDispInfo[i].m_nParamCount+1));
for( j=0; j<m_pDispInfo[i].m_nParamCount; j++ )
{
if(pFuncDesc->lprgelemdescParam[j].tdesc.vt==VT_SAFEARRAY)
{
m_pDispInfo[i].m_pParamTypes[j] = (pFuncDesc->lprgelemdescParam[j].tdesc.lptdesc->vt)|VT_ARRAY;
}
else if(pFuncDesc->lprgelemdescParam[j].tdesc.vt==VT_PTR)
{
m_pDispInfo[i].m_pParamTypes[j] = (pFuncDesc->lprgelemdescParam[j].tdesc.lptdesc->vt)|VT_BYREF;
}
else
{
m_pDispInfo[i].m_pParamTypes[j] = pFuncDesc->lprgelemdescParam[j].tdesc.vt;
}
}
m_pDispInfo[i].m_pParamTypes[m_pDispInfo[i].m_nParamCount] = 0;
pTypeInfo->lpVtbl->ReleaseFuncDesc( pTypeInfo, pFuncDesc );
}
hb_ToOutDebug( "looping through var count");
for( i=m_nMethodCount; i<m_nMethodCount+m_nVarCount; i++ )
{
VARDESC* pVarDesc;
hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, i-m_nMethodCount, &pVarDesc);
if( hr != S_OK )
{
pTypeInfo->lpVtbl->ReleaseTypeAttr( pTypeInfo, pTypeAttr );
pTypeInfo->lpVtbl->Release( pTypeInfo );
//m_nMethodCount = m_nVarCount = m_nDispInfoCount = 0;
// free memory
return 0;
}
m_pDispInfo[i].m_dispID = pVarDesc->memid;
m_pDispInfo[i+m_nVarCount].m_dispID = m_pDispInfo[i].m_dispID;
hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, m_pDispInfo[i].m_dispID ,&m_pDispInfo[i].m_bstrName,1,&nCount);
if( hr != S_OK )
{
pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
pTypeInfo->lpVtbl->ReleaseTypeAttr(pTypeInfo, pTypeAttr);
pTypeInfo->lpVtbl->Release(pTypeInfo);
//m_nMethodCount = m_nVarCount = m_nDispInfoCount = 0;
// free memory
return 0;
}
m_pDispInfo[i+m_nVarCount].m_bstrName = SysAllocString(m_pDispInfo[i].m_bstrName);
switch(pVarDesc->varkind)
{
case VAR_DISPATCH:
m_pDispInfo[i].m_wFlag = DISPATCH_PROPERTYGET;
m_pDispInfo[i+m_nVarCount].m_wFlag = DISPATCH_PROPERTYPUT;
m_pDispInfo[i].m_vtOutputType = pVarDesc->elemdescVar.tdesc.vt;
m_pDispInfo[i+m_nVarCount].m_vtOutputType = VT_EMPTY;
m_pDispInfo[i+m_nVarCount].m_nParamCount = 1;
m_pDispInfo[i+m_nVarCount].m_pParamTypes = (WORD*) hb_xgrab( 2* sizeof(WORD)); //new WORD[2];
m_pDispInfo[i+m_nVarCount].m_pParamTypes[0] = m_pDispInfo[i].m_vtOutputType;
m_pDispInfo[i+m_nVarCount].m_pParamTypes[1] = 0;
break;
default:
m_pDispInfo[i].m_wFlag = 0;
m_pDispInfo[i+m_nVarCount].m_wFlag = 0;
break;
}
m_pDispInfo[i].m_pOutput = (VARIANT*) hb_xgrab(sizeof(VARIANT));// new VARIANT;
::VariantInit(m_pDispInfo[i].m_pOutput);
m_pDispInfo[i+m_nVarCount].m_pOutput = (VARIANT*) hb_xgrab(sizeof(VARIANT)); // new VARIANT;
VariantInit(m_pDispInfo[i+m_nVarCount].m_pOutput);
pTypeInfo->lpVtbl->ReleaseVarDesc( pTypeInfo, pVarDesc );
}
hb_ToOutDebug( "end");
pTypeInfo->lpVtbl->ReleaseTypeAttr( pTypeInfo, pTypeAttr );
pTypeInfo->lpVtbl->Release( pTypeInfo );
return m_nDispInfoCount;
}
//----------------------------------------------------------------------//
HB_FUNC( HB_AX_LOADTYPEINFO )
{
hb_retni( LoadTypeInformation( ( IDispatch* ) hb_parnint( 1 ) ) );
}
#endif
//----------------------------------------------------------------------//

View File

@@ -237,13 +237,6 @@ HB_FUNC( WIN_GETDIALOGBASEUNITS )
//-------------------------------------------------------------------//
HB_FUNC( WIN_SETMENU )
{
SetMenu( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ), ( HMENU ) ( HB_PTRDIFF ) hb_parnint( 2 ) ) ;
}
//-------------------------------------------------------------------//
HB_FUNC( WIN_SETDLGITEMTEXT )
{
LPTSTR lpBuffer = HB_TCHAR_CONVTO( hb_parc( 3 ) );
@@ -514,13 +507,6 @@ HB_FUNC( WIN_DESTROYWINDOW )
//-------------------------------------------------------------------//
HB_FUNC( WIN_DESTROYMENU )
{
hb_retl( DestroyMenu( (HMENU) ( HB_PTRDIFF ) hb_parnint( 1 ) ) );
}
//-------------------------------------------------------------------//
HB_FUNC( WIN_CLIENTTOSCREEN )
{
POINT Point ;
@@ -663,3 +649,136 @@ HB_FUNC( WIN_SLEEP )
}
//----------------------------------------------------------------------//
// Menu Manipulations
//----------------------------------------------------------------------//
HB_FUNC( WIN_SETMENU )
{
HWND hWnd = ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 );
#if 1
BOOL bSet;
RECT wi = { 0, 0, 0, 0 };
RECT ci = { 0, 0, 0, 0 };
USHORT height, width;
bSet = SetMenu( hWnd, ( HMENU ) ( HB_PTRDIFF ) hb_parnint( 2 ) );
GetWindowRect( hWnd, &wi );
GetClientRect( hWnd, &ci );
height = ( USHORT ) ( ci.bottom - ci.top );
width = ( USHORT ) ( ci.right - ci.left );
width += ( USHORT ) ( wi.right - wi.left - ci.right );
height += ( USHORT ) ( wi.bottom - wi.top - ci.bottom );
SetWindowPos( hWnd, NULL, wi.left, wi.top, width, height, SWP_NOZORDER );
hb_retl( bSet );
#endif
#if 0
hb_retl( SetMenu( hWnd, ( HMENU ) ( HB_PTRDIFF ) hb_parnint( 2 ) ) );
#endif
}
//-------------------------------------------------------------------//
HB_FUNC( WIN_CREATEMENU )
{
hb_retnint( ( HB_PTRDIFF ) CreateMenu() );
}
//-------------------------------------------------------------------//
HB_FUNC( WIN_CREATEPOPUPMENU )
{
hb_retnint( ( HB_PTRDIFF ) CreatePopupMenu() );
}
//-------------------------------------------------------------------//
HB_FUNC( WIN_APPENDMENU )
{
char ucBuf[ 256 ];
int i,iLen ;
LPCTSTR lpszCaption;
if ( ISCHAR( 4 ) )
{
iLen = hb_parclen( 4 );
if ( iLen > 0 && iLen < 256 ) // Translate '~' to '&'
{
lpszCaption = HB_TCHAR_CONVTO( hb_parc( 4 ) );
for ( i = 0; i < iLen; i++ )
{
ucBuf[ i ] = ( *lpszCaption == '~' ) ? '&' : ( char ) *lpszCaption;
lpszCaption++;
}
ucBuf[ iLen ]= '\0';
lpszCaption = HB_TCHAR_CONVTO( ucBuf );
}
else
{
lpszCaption = HB_TCHAR_CONVTO( hb_parc( 4 ) );
}
}
else
{
lpszCaption = ( LPCTSTR ) ( HB_PTRDIFF ) hb_parnint( 4 ) ; // It is a SEPARATOR or Submenu
}
hb_retl( AppendMenu( ( HMENU ) ( HB_PTRDIFF ) hb_parnint( 1 ), ( UINT ) hb_parni( 2 ), ( HB_PTRDIFF ) hb_parnint( 3 ), ( LPCTSTR ) lpszCaption ) ) ;
}
//-------------------------------------------------------------------//
HB_FUNC( WIN_DELETEMENU )
{
hb_retl( DeleteMenu( ( HMENU ) ( HB_PTRDIFF ) hb_parnint( 1 ), ( UINT ) hb_parni( 2 ), ( UINT ) hb_parni( 3 ) ) );
}
//-------------------------------------------------------------------//
HB_FUNC( WIN_DESTROYMENU )
{
hb_retl( DestroyMenu( ( HMENU ) ( HB_PTRDIFF ) hb_parnint( 1 ) ) );
}
//-------------------------------------------------------------------//
HB_FUNC( WIN_ENABLEMENUITEM )
{
hb_retl( EnableMenuItem( ( HMENU ) ( HB_PTRDIFF ) hb_parnint( 1 ), ( UINT ) hb_parni( 2 ), ( UINT ) hb_parni( 3 ) ) );
}
//-------------------------------------------------------------------//
HB_FUNC( WIN_CHECKMENUITEM )
{
hb_retni( CheckMenuItem( ( HMENU ) ( HB_PTRDIFF ) hb_parnint( 1 ), ( UINT ) hb_parni( 2 ), ( UINT ) hb_parni( 3 ) ) );
}
//----------------------------------------------------------------------//
HB_FUNC( WIN_DRAWMENUBAR )
{
DrawMenuBar( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ) ) ;
}
//-------------------------------------------------------------------//
HB_FUNC( WIN_UPDATEWINDOW )
{
hb_retl( UpdateWindow( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ) ) );
}
//----------------------------------------------------------------------//
HB_FUNC( WIN_SHOWWINDOW )
{
hb_retl( ShowWindow( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ), hb_parni( 2 ) ) );
}
//----------------------------------------------------------------------//