Menu

#63 Sample of toobar with menu dropdown active.

v1.0_(example)
open
nobody
None
1
2023-09-20
2023-09-19
No

Hi!
I need an example that demonstrates its use.
I did it this way, but it didn't work.

#include "hwgui.ch"
Function main
Local oDlg, oBrw, oToolbar1

   INIT DIALOG oDlg TITLE "TOOLBAR WITH DROPDOWN MENU" style DS_CENTER;
         AT 0, 0 SIZE 800, 500  ;
         FONT HFont():Add( "MS Sans Serif",0,-13 )


  @ 0,0 TOOLBAR oToolbar1 ;
                   SIZE oDlg:nWidth,32 ;                       
                   STYLE WS_DLGFRAME + TBSTYLE_TRANSPARENT

     TOOLBUTTON  oToolbar1 ;
                 ID       701 ;
                 BITMAP   "..\imagens\folder-red.bmp" ;
                 STATE    4 ;
                 TEXT     ""  ;
                 MENU {{"MENU DROPDOWN", 1,{| This, nId | HWG_MSGINFO('OK'), onDlgInit( ) }}} ;
                 TOOLTIP  "Abrir o documento." ;
                 ON CLICK {||  hwg_msginfo('ok') }

    oToolbar1:AddButton(0, , 4,  1, "" ,,,'', "oToolbuttonsep1")

    TOOLBUTTON  oToolbar1 ;
                ID       701 ;
                BITMAP   "..\imagens\folder_yellow.BMP" ;
                STATE    4;
                TEXT     ""  ;
                TOOLTIP  "" ;
                ON CLICK {||  oDlg:Close() }

    oToolbar1:AddButton(0, , 4,  1, "" ,,,'', "oToolbuttonsep2")

   ACTIVATE DIALOG oDlg
Return Nil

Best regards,
Itamar M. Lins Jr.

Related

Support Requests: #63

Discussion

  • Alexander S.Kresin

    I never used this control and don't know how it works and what the MENU clause is. In my applications I use the PANEL and ownerbuttons instead.

    If you need a menu, which appears after pressing a button, you may use the context menu, full example is in samples/testtree.prg.

    You need to define a context menu:

    CONTEXT MENU oMyMenu
    MENUITEM "Item1" ACTION { || SomeFunc_1( ) }
    MENUITEM "Item2" ACTION { || SomeFunc_2( ) }
    ENDMENU

    and then you can call it with a:
    oMyMenu:Show( oWindow ),
    where oWindow is any suitable window object.

    Place this oMyMenu:Show( ) call into any ON CLICK, or to any other handler.

    Regards, Alexander.

     
    • Luis Fernando Basso

      Hi

      ID 701
      TOOLBUTTON oToolbar1 ; ID 701 ;

      and
      TOOLBUTTON oToolbar1 ; ID 702 ;

      Att
      Luis Fernando

      From: Alexander S.Kresin
      Sent: Wednesday, September 20, 2023 5:23 AM
      To: [hwgui:support-requests]
      Subject: [hwgui:support-requests] #63 Sample of toobar with menu dropdown active.

      I never used this control and don't know how it works and what the MENU clause is. In my applications I use the PANEL and ownerbuttons instead.

      If you need a menu, which appears after pressing a button, you may use the context menu, full example is in samples/testtree.prg.

      You need to define a context menu:

      CONTEXT MENU oMyMenu
      MENUITEM "Item1" ACTION { || SomeFunc_1( ) }
      MENUITEM "Item2" ACTION { || SomeFunc_2( ) }
      ENDMENU

      and then you can call it with a:
      oMyMenu:Show( oWindow ),
      where oWindow is any suitable window object.

      Place this oMyMenu:Show( ) call into any ON CLICK, or to any other handler.

      Regards, Alexander.


      [support-requests:#63] Sample of toobar with menu dropdown active.

      Status: open
      Group: v1.0_(example)
      Created: Tue Sep 19, 2023 12:15 PM UTC by Itamar M. Lins Jr.
      Last Updated: Tue Sep 19, 2023 12:15 PM UTC
      Owner: nobody

      Hi!
      I need an example that demonstrates its use.
      I did it this way, but it didn't work.

      include "hwgui.ch"

      Function main
      Local oDlg, oBrw, oToolbar1

      INIT DIALOG oDlg TITLE "TOOLBAR WITH DROPDOWN MENU" style DS_CENTER;
      AT 0, 0 SIZE 800, 500 ;
      FONT HFont():Add( "MS Sans Serif",0,-13 )

      @ 0,0 TOOLBAR oToolbar1 ;
      SIZE oDlg:nWidth,32 ;
      STYLE WS_DLGFRAME + TBSTYLE_TRANSPARENT

       TOOLBUTTON  oToolbar1 ;
                   ID       701 ;
                   BITMAP   "..\imagens\folder-red.bmp" ;
                   STATE    4 ;
                   TEXT     ""  ;
                   MENU {{"MENU DROPDOWN", 1,{| This, nId | HWG_MSGINFO('OK'), onDlgInit( ) }}} ;
                   TOOLTIP  "Abrir o documento." ;
                   ON CLICK {||  hwg_msginfo('ok') }
      
      oToolbar1:AddButton(0, , 4,  1, "" ,,,'', "oToolbuttonsep1")
      
      TOOLBUTTON  oToolbar1 ;
                  ID       701 ;
                  BITMAP   "..\imagens\folder_yellow.BMP" ;
                  STATE    4;
                  TEXT     ""  ;
                  TOOLTIP  "" ;
                  ON CLICK {||  oDlg:Close() }
      
      oToolbar1:AddButton(0, , 4,  1, "" ,,,'', "oToolbuttonsep2")
      

      ACTIVATE DIALOG oDlg
      Return Nil
      Best regards,
      Itamar M. Lins Jr.


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/hwgui/support-requests/63/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Support Requests: #63


Log in to post a comment.