Error menu name variable type accepts only charracter

HMG en Español

Moderator: Rathinagiri

Post Reply
User avatar
jairpinho
Posts: 420
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Contact:

Error menu name variable type accepts only charracter

Post by jairpinho »

hello people can not assign a variable to a menu other than character
following example and the image


#include <hmg.ch>

Function Main
LOCAL aMenu := array(10)
Load Window Main

aMenu[1] := "MNU1" -- > does not work
cMenu := "MNU1"


Main.Center
Main.Activate

Return
Attachments
MENU PRINCIPAL.png
MENU PRINCIPAL.png (15.41 KiB) Viewed 4867 times
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Error menu name variable type accepts only charracter

Post by danielmaximiliano »

try this:
a modification of the example menu in hmg.3.0.40
Attachments
Crimson Editor - [Chmg.3.0.40SAMPLESMENU.1demo.jpg
Crimson Editor - [Chmg.3.0.40SAMPLESMENU.1demo.jpg (120.63 KiB) Viewed 4862 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Error menu name variable type accepts only charracter

Post by danielmaximiliano »

other ideas
array.jpg
array.jpg (99.68 KiB) Viewed 4855 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Error menu name variable type accepts only charracter

Post by danielmaximiliano »

Ola Jair:
Try This
macro work.jpg
macro work.jpg (191.04 KiB) Viewed 4849 times
Main.fmg

Code: Select all

* HMG-IDE Form Designer Generated Code
* (c) Roberto Lopez - http://sites.google.com/site/hmgweb

DEFINE WINDOW TEMPLATE AT 342 , 504 WIDTH 550 HEIGHT 350 VIRTUAL WIDTH Nil VIRTUAL HEIGHT Nil TITLE "Macro Work" ICON NIL MAIN CURSOR NIL ON INIT Nil ON RELEASE Nil ON INTERACTIVECLOSE Nil ON MOUSECLICK Nil ON MOUSEDRAG Nil ON MOUSEMOVE Nil ON SIZE Nil ON MAXIMIZE Nil ON MINIMIZE Nil ON PAINT Nil BACKCOLOR Nil NOTIFYICON NIL NOTIFYTOOLTIP NIL ON NOTIFYCLICK Nil ON GOTFOCUS Nil ON LOSTFOCUS Nil ON SCROLLUP Nil ON SCROLLDOWN Nil ON SCROLLLEFT Nil ON SCROLLRIGHT Nil ON HSCROLLBOX Nil ON VSCROLLBOX Nil

    DEFINE MAIN MENU
        DEFINE POPUP "Principal" NAME &(aMENU[1])
        END POPUP
    END MENU
    DEFINE MAIN MENU
        DEFINE POPUP "Secundario" NAME &(aMENU[2])
        END POPUP
    END MENU

    DEFINE BUTTON Button_1
        ROW    150
        COL    280
        WIDTH  100
        HEIGHT 28
        ACTION Nil
        CAPTION "Button_1"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON

END WINDOW

*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
jairpinho
Posts: 420
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Contact:

Re: Error menu name variable type accepts only charracter

Post by jairpinho »

ola daniel funcionou como vc sugeriu porem nao aceita modificar o objeto pelo nome olha o exemplo
o que vou fazer seria um controle de modulo de usuarios onde posso adicionar os modulos para cada usuario sendo assim preciso habilitar ou desabilitar menus e toolbar esse é o proposito.


#include <hmg.ch>

Function Main
declare window main
LOCAL aMenu := array(10)

Load Window Main

aMenu[1] := "MNU1" && -- > does not work
cMenu := "MNU1"

MODIFY CONTROL MNU1 OF Main ENABLED .F. // NÃO FUNCIONA

Main.Center
Main.Activate

Return
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
User avatar
jairpinho
Posts: 420
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Contact:

Re: Error menu name variable type accepts only charracter

Post by jairpinho »

Muito obrigado Daniel Funcionou tive que modificar um pouco a declaração da variavel antes do Load Window


#include <hmg.ch>

Function Main
declare window main
LOCAL aMenu := array(10)
aMenu[1] := "MNU1"

Load Window Main
MODIFY CONTROL MNU1 OF Main ENABLED .F. // NÃO FUNCIONA
Main.Center
Main.Activate

Return
Attachments
MENU PRINCIPAL2.png
MENU PRINCIPAL2.png (10.44 KiB) Viewed 4800 times
Last edited by jairpinho on Sun Apr 22, 2012 7:34 pm, edited 1 time in total.
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Error menu name variable type accepts only charracter

Post by danielmaximiliano »

jairpinho wrote:ola daniel funcionou como vc sugeriu porem nao aceita modificar o objeto pelo nome olha o exemplo
o que vou fazer seria um controle de modulo de usuarios onde posso adicionar os modulos para cada usuario sendo assim preciso habilitar ou desabilitar menus e toolbar esse é o proposito.


#include <hmg.ch>

Function Main
declare window main
LOCAL aMenu := array(10)

Load Window Main

aMenu[1] := "MNU1" && -- > does not work
cMenu := "MNU1"

MODIFY CONTROL MNU1 OF Main ENABLED .F. // NÃO FUNCIONA

Main.Center
Main.Activate

Return
según la referencia de HMG para el Control Main Menu.
não pode mudar os valores no menu principal

Code: Select all

DEFINE MAINMENU [ PARENT <ParentWindowName> ]
   DEFINE POPUP <cPopupCaption> [ NAME <PopupName> ]
     MENUITEM <cItemCaption>
         ONCLICK <ActionProvedureName> | <bBlock>
             [ NAME <MenuItemName>]
                 [ IMAGE <cImageName> ]
                    [ CHECKED <lValue> ]
                   ..
                   ..
                [ SEPARATOR ]
                  ...
                  ...
    END POPUP
                  ...
                  ... 
 END MENU

MainMenu Properties:

 - Parent (R)
   R: Read-Only

MenuItem Properties:

  - Name (R)
  - Checked
  - Enabled
  - Image
  R: Read-Only

MenuItem Events:

 - OnClick (R)
  R: Read-Onl
HMG.4 possivelmente pode fazê-lo.
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Error menu name variable type accepts only charracter

Post by danielmaximiliano »

Hola Jair:
aqui tiene un ejemplo de utilizar una Macro "&" para crear menu personalizado.
Main.prg

Code: Select all

#include <hmg.ch>

Function Main
Public aMenu := {'JairMenu'  , 'RobertoMenu'  , 'DanielmaximilianoMenu', 'OtherMenu'  }
Public aPopup:= {'Popup' , 'Popup' , 'Popup' }
Public aItems:= {'Items1' , 'Items1' , 'Items1' }
Public aUsers:= {'Jair'   , 'Roberto', 'DanielMaximiliano' , 'Other'  }
Public cUsers := getenv("UserName")
Public cPopup := 'Principal'
Public xMenu  := 0
        Load Window Main
        Main.Center
        Main.Activate
Return

Function Mainname(cUser)
Local cMainname :=  ''
 Do case
    Case cUsers = 'Jair'
    cMainname := aMenu[1]
    xMenu     := 1
    Case cUsers = 'Roberto'
    cMainname := aMenu[2]
    xMenu     := 2
    Case cUsers = 'Other'
    cMainname := aMenu[3]
    xMenu     := 3
    Case cUsers = 'DanielMaximiliano'
    cMainname := aMenu[3]
    xMenu     := 4
 Endcase
 cPopup := cPopup + cMainname
Return (cMainname)
Main.fmg
* HMG-IDE Form Designer Generated Code
* (c) Roberto Lopez - http://sites.google.com/site/hmgweb

DEFINE WINDOW TEMPLATE AT 183 , 360 WIDTH 550 HEIGHT 350 VIRTUAL WIDTH Nil VIRTUAL HEIGHT Nil TITLE "Macro Work" ICON NIL MAIN CURSOR NIL ON INIT Nil ON RELEASE Nil ON INTERACTIVECLOSE Nil ON MOUSECLICK Nil ON MOUSEDRAG Nil ON MOUSEMOVE Nil ON SIZE Nil ON MAXIMIZE Nil ON MINIMIZE Nil ON PAINT Nil BACKCOLOR Nil NOTIFYICON NIL NOTIFYTOOLTIP NIL ON NOTIFYCLICK Nil ON GOTFOCUS Nil ON LOSTFOCUS Nil ON SCROLLUP Nil ON SCROLLDOWN Nil ON SCROLLLEFT Nil ON SCROLLRIGHT Nil ON HSCROLLBOX Nil ON VSCROLLBOX Nil

DEFINE MAIN MENU
DEFINE POPUP &("Mainname()") NAME &(aMenu[xMenu])
END POPUP
END MENU

DEFINE STATUSBAR FONT "Arial" SIZE 9
STATUSITEM "User : "+cUsers WIDTH 300 ACTION Nil ICON "Users" TOOLTIP "Usuario Logueado"
END STATUSBAR

DEFINE BUTTON Button_1
ROW 90
COL 200
WIDTH 100
HEIGHT 28
ACTION Nil
CAPTION "Button_1"
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
HELPID Nil
FLAT .F.
TABSTOP .T.
VISIBLE .T.
TRANSPARENT .F.
MULTILINE .F.
PICTURE Nil
PICTALIGNMENT TOP
END BUTTON

END WINDOW
Macro Work_2012-04-22_17-25-03.jpg
Macro Work_2012-04-22_17-25-03.jpg (16.21 KiB) Viewed 4796 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Post Reply