hi to all
I'm tring to add / remove dynamicly buttons from a toolbar.
to add a button no problem, but when i remove a button ( cForm.cBtn.release ), the button is still present but with no action !
Is it a way to completly remove it ?
Ps: i'm surprise that the "Parent" of the button is not the toolbar but the form
( cForm.cToolbar.cButton.release ) -> Error
thx
ToolBar button add / Remove
Moderator: Rathinagiri
- danielmaximiliano
- Posts: 2612
- Joined: Fri Apr 09, 2010 4:53 pm
- Location: Argentina
- Contact:
Re: ToolBar button add / Remove
Hola JPP : HMG Reference
You can post an example as real tiepo add an item to see if I use the method
AddItem Method
- Since ToolBar is a container, you can specify when refer to properties or events of its child buttons, ie:file:///C:/hmg.3.2/doc/data/index.htm
Code: Select all
Win1.ToolBar1.Button1.Enabled := .F.
AddItem Method
Code: Select all
<ParentWindowName>.<ControlName>.AddItem (<cItem> | <acItem> )
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Re: ToolBar button add / Remove
thx daniel for ure answer
but my purpose is not to enable or disable a button in the toolbar,
but to destroy it as u can do it for a control in a form (cForm.cControl.release ).
I the hmg ref ( my bed book ! ) i've not seen the method release for a toolbutton...
but my purpose is not to enable or disable a button in the toolbar,
but to destroy it as u can do it for a control in a form (cForm.cControl.release ).
I the hmg ref ( my bed book ! ) i've not seen the method release for a toolbutton...
- danielmaximiliano
- Posts: 2612
- Joined: Fri Apr 09, 2010 4:53 pm
- Location: Argentina
- Contact:
Re: ToolBar button add / Remove
I would eliminate the Toolbar completely and recreate the necessary buttons.
this is an example to create and delete controls inside a form I made a while
this is an example to create and delete controls inside a form I made a while
Code: Select all
Public nPage := 0
Public cPage := "Page" + ltrim(str(nPage))
Public cText := "Text" + ltrim(str(nPage))
Public cImage := "Image" + ltrim(str(nPage))
Public cLabel := "Label" + ltrim(str(nPage))
Public cCombo := "Combo" + ltrim(str(nPage))
Procedure DeletePage()
Local nDelete
nDelete:= Principal.Container_Tab.Value
cImage := "Image" + ltrim(str(nDelete))
cLabel := "Label" + ltrim(str(nDelete))
cText := "Text" + ltrim(str(nDelete))
cCombo := "Combo" + ltrim(str(nDelete))
if iscontroldefined(&cImage,Principal)
Principal.&(cLabel).RELEASE
Principal.&(cImage).RELEASE
Principal.&(cText).RELEASE
Principal.&(cCombo).RELEASE
Principal.Container_Tab.DELETEPAGE(nDelete)
nPage--
IF nPage == 1
AddNewPage()
ENDIF
ELSE
MSGINFO("Cannot delete PAGE Add+"," Info " )
ENDIF
Function AddNewPage()
IF nPage == 1
cPage := 'Page'+ltrim(str(nPage))
Principal.Container_Tab.AddPage ( nPage, cPage )
AddControls()
nPage++
Principal.Container_Tab.Value := nPage - 1
RETURN
ENDIF
IF Principal.Container_Tab.Value == nPage
IF nPage >= 2
cPage := 'Page'+ltrim(str(nPage))
Principal.Container_Tab.DeletePage(nPage)
Principal.Container_Tab.AddPage ( nPage, cPage )
AddControls()
nPage++
Principal.Container_Tab.AddPage ( nPage, 'Add+','New.jpg' )
Principal.Container_Tab.Value := nPage - 1
ELSE
nPage++
cPage := 'Page'+ltrim(str(nPage))
Principal.Container_Tab.AddPage ( nPage, cPage )
AddControls()
nPage++
Principal.Container_Tab.AddPage ( nPage, 'Add+' )
Principal.Container_Tab.Value := 1
ENDIF
ENDIF
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Re: ToolBar button add / Remove
thx
i have made a small sample to understand my problem ( Hmg 3.2 )
if u have some time to test it it will be nice !
i have made a small sample to understand my problem ( Hmg 3.2 )
if u have some time to test it it will be nice !
Code: Select all
/*
Test toolbar
*/
#include "hmg.ch"
proc main
DEFINE WINDOW W_TEST ;
AT 0,0 ;
WIDTH 500 ;
HEIGHT 300 ;
TITLE "TEST" ;
Main
DEFINE MAIN MENU
DEFINE POPUP 'Test'
MENUITEM 'Create toolbar' ACTION createtool()
MENUITEM 'destruct toolbar with error create again' ACTION deltoolbar_with_error_create_again()
MENUITEM 'destruct toolbar OK create again' ACTION deltoolbar_OK()
MENUITEM "delete btn1" ACTION delbtn1()
MENUITEM "Create btn3" ACTION createbtn3()
END POPUP
END MENU
ON KEY ESCAPE ACTION THISWINDOW.RELEASE
END WINDOW
CENTER WINDOW W_TEST
ACTIVATE WINDOW W_TEST
Return
function createtool()
/*
*/
_DefineToolBar ( "ToolBar1" ,"w_test" , 100 , 30 , .T. , .T. , .T. , .F. , , , .F. , .F. , .F. , .F. , , , .F. , 20 , 20 , .F. )
_DefineToolButton( "Btn1", ,"Btn1", { || MsgInfo('Btn1') })
_DefineToolButton( "Btn2", ,"Btn2", { || MsgInfo('Btn2') })
return nil
function deltoolbar_with_error_create_again()
/*
First : the toolbar seems to be destroy, but if you want to create it one's again
u will have an error "Btn1 of w_test always defined"
THAT WHY i ask me about the "real" parent of btn1 and btn2 ....
*/
w_test.toolbar1.release
return nil
function deltoolbar_ok()
/*
*/
w_test.btn1.release // w_test parent for toolbar's BTN ?????
w_test.btn2.release
w_test.toolbar1.release
return nil
function delbtn1()
/*
As u can see btn1 is still present but non action available
HOW TO REMOVE IT FOM THE TOOLBAR ??????
*/
w_test.btn1.release
return nil
Function createbtn3()
/*
How know _defineToolButton the ref of the toolbar ???
*/
_DefineToolButton( "Btn3", ,"Btn3", { || MsgInfo('Btn3') })
return nil