¿Es posible modificar el menú de un diálogo?

¿Es posible modificar el menú de un diálogo?

Postby AngelSalom » Mon Dec 07, 2020 11:51 am

Hola amigos, desde testdlg.prg en samples intenté modificar el menú del icono del diálogo pero no lo consigo :

Se trata de :
Image

Sobre el ejemplo :
Code: Select all  Expand view
// Our first DialogBox sample

#include "FiveWin.ch"

function Main()

   local oDlg, oIco, cTest := "Hello world!   "

   DEFINE ICON oIco FILE "..\icons\fivewin.ico"

   DEFINE DIALOG oDlg TITLE "I am a DialogBox" COLOR "W+/B" ;
      ICON oIco

   @ 1, 3 GET cTest

   @ 3, 5 BUTTON "&Ok" SIZE 40, 12 ;
      ACTION oDlg:Move (200,200) DEFAULT

   @ 3, 16 BUTTON "&Cancel" SIZE 40, 12 ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED ;
      VALID MsgYesNo( "Do you want to end ?" )

return nil


Traté con :

Code: Select all  Expand view
oDlg:SetMenu ( oMenu )


Sin éxito.

¿Alguna idea?
Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
User avatar
AngelSalom
 
Posts: 708
Joined: Fri Oct 07, 2005 7:38 am
Location: Benicarló (Castellón ) - España

Re: ¿Es posible modificar el menú de un diálogo?

Postby cnavarro » Mon Dec 07, 2020 5:06 pm

Inclui esa posibilidad e incluso eliminar items
Code: Select all  Expand view

// ---------------------------------------------------------------------//
// MNUNEW05.PRG
// Prueba de nuevas caracteristicas en menus
//
//
// ---------------------------------------------------------------------//

#include "Fivewin.ch"

Static oWnd
Static oFontMenu
Static oBr

Function Main()
   Local cFont   := "Segoe UI Symbol"  //"Arial" //"Calibri"
   Local cFontH  := -14  //-10 //-12 //-16 //-18  //-20
   Local oBar
   Local cTitle
   Local oIcon
   local cBrush   := "..\bitmaps\backgrnd\confetti.bmp"
   local cVar1    := "中国版"
   local nHt      := 0
   //local cVar      :=  "தமிழ் (India)"
   //local oGet
   Fw_SetUnicode( .T. )  
   SetResDebug( .T. )
   //? Len( cVar1 ), HB_UTF8LEN( cVar1 ), Len( cFont ), HB_UTF8LEN( cFont )
   if !IsWin8() .and. !IsWindows10()
      cFont   := "Calibri"
   endif
   DEFINE BRUSH oBr FILE cBrush //RESIZE
   DEFINE FONT oFontMenu NAME cFont SIZE 0, cFontH
   DEFINE ICON oIcon FILE "..\icons\menu.ico"
   cTitle := " Pruebas de Menus:  Font - " + if( !Empty( oFontMenu ), oFontMenu:cFaceName, "" ) +;
      if( !Empty( oFontMenu ), Str( oFontMenu:nHeight ), "" ) + "   -  Redefine SYSMENU  -  5"

   //? GetTextWidth( 0, cVar1, oFontMenu:hFont, @nHt ), GetTextWidthW( 0, cVar1, oFontMenu:hFont )
   //? nHt, GetTextHeight( 0, cVar1, oFontMenu:hFont )

   //DEFINE WINDOW oWnd FROM 3, 6 TO 30, 100 ; //MDI ;
   DEFINE DIALOG oWnd FROM 3,6 TO 30, 100 ;
       TITLE cTitle COLOR CLR_WHITE, METRO_OLIVE //VSCROLL
   //oWnd:SetFont( oFontMenu )
   oWnd:SetIcon( oIcon )

   // @ 1, 2 GET oGet VAR cVar OF oWnd NOBORDER //PICTURE "@X"
   
  // SET MESSAGE OF oWnd TO "Prueba de Controles" FONT oFontMenu ;
   //    COLORS CLR_WHITE, RGB( 116, 149, 193 ) ; //RGB( 31, 117, 70 ) ;
   //    NOINSET CLOCK DATE KEYBOARD NOBORDER

   ACTIVATE DIALOG oWnd CENTERED ON INIT BuildMnu0()
   //ACTIVATE WINDOW oWnd MAXIMIZED ON INIT BuildMnu0()

    if !Empty( oFontMenu )
       While oFontMenu:nCount > 0
          oFontMenu:End()
       Enddo
    endif
    RELEASE BRUSH oBr
    oIcon:End()
   
   if File( "checkres.txt" )
      FErase( "checkres.txt" )
   endif
   CheckRes()

Return nil

// ---------------------------------------------------------------------//

Function BuildMnu0()
   
   local oMnu

   REDEFINE SYSMENU oMnu OF oWnd FONT oFontMenu //2007 //COLORS 2013
      //IMGMENU "..\bitmaps\AlphaBmp\lock.bmp"
      //BRUSH "..\bitmaps\backgrnd\confetti.bmp"
    SEPARATOR
    MENUITEM "SubMenu"        CHARICON 57605
    MENU 2007 //FONT oFontMenu COLORS //2013
      MENUITEM "Segundo Item" CHARICON 57696
      SEPARATOR
      MENUITEM "Tercer Item"  CHARICON 57736
    ENDMENU
    SEPARATOR
    MENUITEM "தமிழ் (India)"
         MENU // COLORS  BRUSH "..\bitmaps\backgrnd\confetti.bmp"
            //LOGOMENU "..\bitmaps\menu4v.bmp"

          MENUITEM "FIVEDIT" SEPARATOR BOLD //RESOURCE "new16" BOLD
          MENUITEM "Methods" HSYSBITMAP 32761
          MENUITEM "Datas" HSYSBITMAP 32760
          MENUITEM "Messages" HSYSBITMAP 32744
          MENUITEM "Messages" HSYSBITMAP 32743
          MENUITEM "ClassData" CHARICON "M"
            //SEPARATOR
          MENUITEM "SCINTILLA" SEPARATOR BREAK BOLD //RESOURCE "dupline16" BOLD
          MENUITEM "Methods de Object" CHECKED //HSYSBITMAP 32738
          MENUITEM "Datas Values" HSYSBITMAP 32739
          MENUITEM "Messages Data" CHARICON 57731 //HSYSBITMAP 32740
          MENUITEM "Messages Method" HSYSBITMAP 32741
          MENUITEM "ClassData Object" HSYSBITMAP 32742
         ENDMENU
    SEPARATOR
    MENUITEM "中国版 (China)" CHECKED
    SEPARATOR
    MENUITEM "&Reset Menu"  ACTION oMnu:Reset()
   ENDSYSMENU

Return oMnu

// ---------------------------------------------------------------------//

 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: ¿Es posible modificar el menú de un diálogo?

Postby AngelSalom » Mon Dec 07, 2020 5:44 pm

Excelente ejemplo Cristóbal como siempre.
Aunque observo que se añade el menú al ya existente del sistema , ¿es posible dejar únicamente el menú que definimos nosotros desde código?

Image

Gracias!
Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
User avatar
AngelSalom
 
Posts: 708
Joined: Fri Oct 07, 2005 7:38 am
Location: Benicarló (Castellón ) - España

Re: ¿Es posible modificar el menú de un diálogo?

Postby cnavarro » Mon Dec 07, 2020 5:51 pm

Si claro, juega un poco con esta function que te permite disable ( la X de cierre ) y eliminar items. Llamala antes de añadir tu systemmenu ( has de hacer una mezcla entre este ejemplo y el anterior ) o después, ves las posibilidades que tiene, y, por favor, pon después aquí tus conclusiones.
Ojo, el comportamiento de los sysmenus es distinto si se trata de dialogs o de windows creo recordar ( me refiero al orden en el que son guardados los items que ya trae por defecto )

Code: Select all  Expand view


#include "FiveWin.ch"

#define MF_BYPOSITION 1024 // 0x0400
#define MF_DISABLED     2

Function Main()

   Local oDlg, ;
         lExit := .F.,;
         oIcon

   Define ICON oIcon FILE "..\ICONS\FiveWin.Ico"

   Define Dialog oDlg Title "Test" ICON oIcon

   @ 30, 10 Button "Exit" Of oDlg Size 30, 15 Pixel Action ( lExit := .T., oDlg:End() )

   ACTIVATE Dialog oDlg Centered ON Init DisableX( oDlg, .T.) ;
            Valid lExit

Return Nil

//----------------------------------------------------------------------------//

FUNCTION DisableX(oWin, lDisable)

LOCAL hMenu  := 0
LOCAL nCount := 0

DEFAULT lDisable := .T.

IF lDisable
   hMenu  = GetSystemMenu(oWin:hWnd, .F.)
   nCount = GetMItemCount(hMenu)
   ? nCount

   IF oWin:ClassName() = "TDIALOG"
      //RemoveMenu(hMenu, 1, nOR( MF_BYPOSITION, MF_DISABLED) )
      //RemoveMenu(hMenu, 1, nOR( MF_BYPOSITION, 0 ) )
      RemoveMenu(hMenu, 0, nOR( MF_BYPOSITION, 0 ) )
      RemoveMenu(hMenu, 0, nOR( MF_BYPOSITION, 0 ) )
      //RemoveMenu(hMenu, 2, nOR( MF_BYPOSITION, MF_DISABLED) )
      //RemoveMenu(hMenu, 0, nOR( MF_BYPOSITION, MF_DISABLED) )
   ELSE
      RemoveMenu(hMenu, nCount - 1, nOR( MF_BYPOSITION, MF_DISABLED) )
      RemoveMenu(hMenu, nCount - 2, nOR( MF_BYPOSITION, MF_DISABLED) )
   ENDIF

ELSE
   GetSystemMenu( oWin:hWnd, .T. )
ENDIF

RETURN nil
 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: ¿Es posible modificar el menú de un diálogo?

Postby AngelSalom » Mon Dec 07, 2020 6:33 pm

Perfecto, hago algunas pruebas y comento.
Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
User avatar
AngelSalom
 
Posts: 708
Joined: Fri Oct 07, 2005 7:38 am
Location: Benicarló (Castellón ) - España

Re: ¿Es posible modificar el menú de un diálogo?

Postby AngelSalom » Fri Dec 11, 2020 9:06 am

Pues funcionó perfecto, aquí el ejemplo que me facilitaste del menú y utilizando el DisableX

Code: Select all  Expand view

// ---------------------------------------------------------------------//
// MNUNEW05.PRG
// Prueba de nuevas caracteristicas en menus
//
//
// ---------------------------------------------------------------------//

#include "Fivewin.ch"

#define MF_BYPOSITION 1024 // 0x0400
#define MF_DISABLED     2

Static oWnd
Static oFontMenu
Static oBr

Function Main()
   Local cFont   := "Segoe UI Symbol"
   Local cFontH  := -14  
   Local oBar
   Local cTitle
   Local oIcon
   local cVar1    := "中国版"
   local nHt      := 0
   Fw_SetUnicode( .T. )  
   SetResDebug( .T. )
   if !IsWin8() .and. !IsWindows10()
      cFont   := "Calibri"
   endif
   DEFINE FONT oFontMenu NAME cFont SIZE 0, cFontH
   DEFINE ICON oIcon FILE "..\icons\menu.ico"
   cTitle := " Pruebas de Menus:  Font - " + if( !Empty( oFontMenu ), oFontMenu:cFaceName, "" ) +;
      if( !Empty( oFontMenu ), Str( oFontMenu:nHeight ), "" ) + "   -  Redefine SYSMENU  -  5"


   DEFINE DIALOG oWnd FROM 3,6 TO 30, 100 ;
       TITLE cTitle COLOR CLR_WHITE, METRO_OLIVE
   oWnd:SetIcon( oIcon )


   ACTIVATE DIALOG oWnd CENTERED ON INIT ( DisableX( oWnd, .T.) , BuildMnu0() )

    if !Empty( oFontMenu )
       While oFontMenu:nCount > 0
          oFontMenu:End()
       Enddo
    endif
    RELEASE BRUSH oBr
    oIcon:End()
   
   if File( "checkres.txt" )
      FErase( "checkres.txt" )
   endif
   CheckRes()

Return nil

// ---------------------------------------------------------------------//

Function BuildMnu0()
   
   local oMnu

   REDEFINE SYSMENU oMnu OF oWnd FONT oFontMenu
    SEPARATOR
    MENUITEM "SubMenu"        CHARICON 57605
    MENU 2007
      MENUITEM "Segundo Item" CHARICON 57696
      SEPARATOR
      MENUITEM "Tercer Item"  CHARICON 57736
    ENDMENU
    SEPARATOR
    MENUITEM "தமிழ் (India)"
         MENU
          MENUITEM "FIVEDIT" SEPARATOR BOLD
          MENUITEM "Methods" HSYSBITMAP 32761
          MENUITEM "Datas" HSYSBITMAP 32760
          MENUITEM "Messages" HSYSBITMAP 32744
          MENUITEM "Messages" HSYSBITMAP 32743
          MENUITEM "ClassData" CHARICON "M"

          MENUITEM "SCINTILLA" SEPARATOR BREAK BOLD
          MENUITEM "Methods de Object" CHECKED
          MENUITEM "Datas Values" HSYSBITMAP 32739
          MENUITEM "Messages Data" CHARICON 57731
          MENUITEM "Messages Method" HSYSBITMAP 32741
          MENUITEM "ClassData Object" HSYSBITMAP 32742
         ENDMENU
    SEPARATOR
    MENUITEM "中国版 (China)" CHECKED
    SEPARATOR
    MENUITEM "&Reset Menu"  ACTION oMnu:Reset()
   ENDSYSMENU

Return oMnu

// ---------------------------------------------------------------------//

FUNCTION DisableX(oWin, lDisable)

   LOCAL hMenu  := 0
   LOCAL nCount := 0
   
   DEFAULT lDisable := .T.
   
   IF lDisable
      hMenu  = GetSystemMenu(oWin:hWnd, .F.)
      nCount = GetMItemCount(hMenu)
      ? nCount
   
      IF oWin:ClassName() = "TDIALOG"
         RemoveMenu(hMenu, 0, nOR( MF_BYPOSITION, 0 ) )
         RemoveMenu(hMenu, 0, nOR( MF_BYPOSITION, 0 ) )
      ELSE
         RemoveMenu(hMenu, nCount - 1, nOR( MF_BYPOSITION, MF_DISABLED) )
         RemoveMenu(hMenu, nCount - 2, nOR( MF_BYPOSITION, MF_DISABLED) )
      ENDIF
   
   ELSE
      GetSystemMenu( oWin:hWnd, .T. )
   ENDIF
   
   RETURN nil


Se consigue un menú de sistema totalmente personalizado, fabuloso Cristóbal, gracias.
Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
User avatar
AngelSalom
 
Posts: 708
Joined: Fri Oct 07, 2005 7:38 am
Location: Benicarló (Castellón ) - España

Re: ¿Es posible modificar el menú de un diálogo?

Postby AngelSalom » Fri Dec 11, 2020 11:29 am

Con el sistema de menús del que disponemos se pueden hacer cosas interesantes !!! :D :D

Image
Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
User avatar
AngelSalom
 
Posts: 708
Joined: Fri Oct 07, 2005 7:38 am
Location: Benicarló (Castellón ) - España

Re: ¿Es posible modificar el menú de un diálogo?

Postby cnavarro » Fri Dec 11, 2020 4:33 pm

Aqui puedes ver la información necesaria ( hay en esta pagina un ejemplo especialmente significativo: no dejes de ver y probar el ejemplo MNUSELECT.PRG )

http://wiki.fivetechsoft.com/doku.php?i ... ldown_menu
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: ¿Es posible modificar el menú de un diálogo?

Postby cnavarro » Sat Dec 26, 2020 9:56 pm

En la próxima versión, la barra del menú Bar, admite brush también
Image
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 76 guests