Hmg.4 permit Two toolbars with same buttons

Moderator: Rathinagiri

Post Reply
Rossine
Posts: 87
Joined: Thu Jun 30, 2011 10:04 pm

Hmg.4 permit Two toolbars with same buttons

Post by Rossine »

Hello,

Only reporting a possible problem ;)

In hmg.3 not allowed two buttons with the same name in a window even when they are different toolbar, because the buttons are anchored in the window and not in the toolbar. Here's an example:

Code: Select all


      DEFINE TOOLBAR oToolBar1

         TOOLBUTTON oButton1 ;
            Caption 'new' ;
            picture 'new.png' ;
            ACTION MsgInfo( 'New!' ) ;
            tooltip 'tooltip'

      END TOOLBAR


      DEFINE TOOLBAR oToolBar2

         TOOLBUTTON oButton1 ;
            Caption 'new' ;
            picture 'new.png' ;
            ACTION MsgInfo( 'New!' ) ;
            tooltip 'tooltip'

      END TOOLBAR

You see that there are two oButton1.

In HMG.4 this is correct ?

Best Regards,

Rossine.
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Hmg.4 permit Two toolbars with same buttons

Post by l3whmg »

Hi Rossine. Yes, it's possible with HMG4 not HMG3 compliant.
To give you an answer, you must think about parent. With HMG4 (HMG3 it's +- the same, but...) every object is built with a related parent (there are some internally excpetions, anyway...) This can be a scheme:

Code: Select all

Form
  +--ToolBar1
  |        +---ToolButton1
  |        +---ToolButton2
  +--ToolBar2
  |        +---ToolButton1
  |        +---ToolButton2
ToolButton1 is repeated two times, because one has parent with ToolBar1 and te second one with ToolBar2
But you can not have, at the same level, the same name

Code: Select all

Form
  +--ToolBar1
  |        +---ToolButton1
  |        +---ToolButton1 NO, wrong
  +--ToolBar1 NO wrong
  |        +---ToolButton1
  |        +---ToolButton2
And remember:
  • - A)using streactly OOP you can omit the name of the object (this means you never will have the same name)
    - B) using a mixed OOP you can omit the name of the object, but you can't retrieve it
    - C) using XBase command style you can have problem with duplicate (error) names in some conditions.
Examples:
A)

Code: Select all

CLASS myclass....
DATA oButton
.....
METHOD New() CLASS myClass
WITH OBJECT oButton := BUTTON():New()
......
B)
Not defined class, but using.... Here you can't re-use "ButtonName"

Code: Select all

STATIC FUNCTION ....
......
WITH OBJECT BUTTON():New( "ButtonName",....)
................
MainForm:ButtonName
C)

Code: Select all

DEFINE BUTTON ButtonName
........    
It's mandatory ButtonName and you can't re-use it within its parent (ie FormName).

I hope my explanation it's clear and helpfull.

p.s. To show trees, you can call somewhere HMGAPP():ShowObjectsTree(). It creates HTML file within executable folder with all defined objects .

Cheers
Luigi from Italy
www.L3W.it
Rossine
Posts: 87
Joined: Thu Jun 30, 2011 10:04 pm

Re: Hmg.4 permit Two toolbars with same buttons

Post by Rossine »

Hi Luigi,
l3whmg wrote:Hi Rossine. Yes, it's possible with HMG4 not HMG3 compliant.
To give you an answer, you must think about parent. With HMG4 (HMG3 it's +- the same, but...) every object is built with a related parent (there are some internally excpetions, anyway...) This can be a scheme:

Code: Select all

Form
  +--ToolBar1
  |        +---ToolButton1
  |        +---ToolButton2
  +--ToolBar2
  |        +---ToolButton1
  |        +---ToolButton2
ToolButton1 is repeated two times, because one has parent with ToolBar1 and te second one with ToolBar2
But you can not have, at the same level, the same name

Code: Select all

Form
  +--ToolBar1
  |        +---ToolButton1
  |        +---ToolButton1 NO, wrong
  +--ToolBar1 NO wrong
  |        +---ToolButton1
  |        +---ToolButton2
And remember:
  • - A)using streactly OOP you can omit the name of the object (this means you never will have the same name)
    - B) using a mixed OOP you can omit the name of the object, but you can't retrieve it
    - C) using XBase command style you can have problem with duplicate (error) names in some conditions.
Examples:
A)

Code: Select all

CLASS myclass....
DATA oButton
.....
METHOD New() CLASS myClass
WITH OBJECT oButton := BUTTON():New()
......
B)
Not defined class, but using.... Here you can't re-use "ButtonName"

Code: Select all

STATIC FUNCTION ....
......
WITH OBJECT BUTTON():New( "ButtonName",....)
................
MainForm:ButtonName
C)

Code: Select all

DEFINE BUTTON ButtonName
........    
It's mandatory ButtonName and you can't re-use it within its parent (ie FormName).

I hope my explanation it's clear and helpfull.
Cheers
Yes many clear. Many thank´s for this explanation ;)
l3whmg wrote:
p.s. To show trees, you can call somewhere HMGAPP():ShowObjectsTree(). It creates HTML file within executable folder with all defined objects .

Cheers
Sorry, this feature is not generating the file "html".

I tested "\hmg.4\svn\samples\window.main\demo_3.prg" and pressed F10 and also did not generate the HTML file. I may be forgetting something ?

Many thank´s,

Rossine.
Rossine
Posts: 87
Joined: Thu Jun 30, 2011 10:04 pm

Re: Hmg.4 permit Two toolbars with same buttons

Post by Rossine »

Hi Luigi,
Rossine wrote:Sorry, this feature is not generating the file "html".

I tested "\hmg.4\svn\samples\window.main\demo_3.prg" and pressed F10 and also did not generate the HTML file. I may be forgetting something ?

Many thank´s,

Rossine.
Strange. On another computer generated HTML ;)

Very useful this function: "HMGAPP():ShowObjectsTree()"

Thank you very much,

Rossine.
Post Reply