1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Criar Árvore no Menu

Discussão em 'Progress 4GL' iniciado por DFResmer, Março 22, 2011.

  1. DFResmer

    DFResmer Membro Participativo

    isto, exatamente!
    Exemplo, este menu seria para um programa que tenho em uma clínica, estou modificando todo ele:

    Pacientes
    |---------Cadastro
    |---------Consultas
    |---------Atestados
    |---------Exames
    Agendamentos
    |---------Pacientes
    |---------Centro Cirúrgico

    quando o usuário clicar em Paciente, ele abre as outras opções Cadastro, consulta, atestados, exames, depois quando clicar em cadastro por exemplo abrir o programa de cadastro.


    Att,

    Diogo
  2. jalegria

    jalegria Membro Participativo

    faça um teste aí...

    crie uma janela nova no appbuilder, tipo "Window"
    na toolbox (pallete) escolha o botão "OCX"
    vai abrir uma lista com os activeX presentes na sua maquina
    escolha "Microsoft Treeview Control, version 6.0"
    posicione ele na janela, e troque o nome dele, por exemplo xTree

    depois coloque este código, em alguma procedure ou no main-block mesmo p/ testar:

    Código:
    chxTree:TreeView:Nodes:ADD(,,'root','Pacientes',).
    
    chxTree:TreeView:Nodes:ADD('root',4,'cad','Cadastro',).
    chxTree:TreeView:Nodes:ADD('root',4,'cons','Consultas',).
    chxTree:TreeView:Nodes:ADD('root',4,'att','Atestados',).
    chxTree:TreeView:Nodes:ADD('root',4,'exm','Exames',).
    
    estou supondo q o seu windows é pelo menos o XP com SP1
    e o progress 8 pra frente

    veja se dá certo, qqer coisa estamos por aqui... boa sorte
  3. DFResmer

    DFResmer Membro Participativo

    Não deu Certo,
    Estou usando winxp, progress 8.2

    Coloquei a sua rotina na maimblock, e na OCX que coloquei na frame mudei o nome para xTree e testei tbem como chxTree e dá o seguinte erro:

    "** Unknown Field or Variable name - chxTree"

    Ele não está encontrando a variável chxTree, devo criá-la? Para testar criei uma variável chxTree como char mas aí dá outro erro

    Multi-level attribute reference alloowed only for com-handles. (5713)
    ** Could not undestend line. (196)

    Este erro ocorre em todas as linhas.

    Att,
    Diogo
  4. jalegria

    jalegria Membro Participativo

    bem, não me lembro se tem alguma diferença na vs8 qto a utilização de ocx...
    não precisa criar uma var chxtree, o pgs cria uma automaticamente, ele cria uma com o mesmo nome do objeto com um "ch" na frente
    entao se vc colocar xtree o pgs ira criar uma variavel do tipo com-handle com o nome chxtree

    faz o seguinte:
    cria uma janela no appbuilder vazia do tipo window
    coloca o ocx q eu te falei na janela, renomeia ele para xtree e posta o fonte .w aki pra eu lembrar como o pgs monta na vs8

    se só colocar o treeview e rodar direto funciona? tipo aparece a janela com o treeview vazio?
  5. DFResmer

    DFResmer Membro Participativo

    Se eu rodar apenas a OCX aparece uma tela em branco.

    Vou postar o arquivo
    [prog=]&ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
    &ANALYZE-RESUME
    &Scoped-define WINDOW-NAME W-Win
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS W-Win
    /*------------------------------------------------------------------------

    File:

    Description: from cntnrwin.w - ADM SmartWindow Template

    Input Parameters:
    <none>

    Output Parameters:
    <none>

    History:

    ------------------------------------------------------------------------*/
    /* This .W file was created with the Progress UIB. */
    /*----------------------------------------------------------------------*/

    /* Create an unnamed pool to store all the widgets created
    by this procedure. This is a good default which assures
    that this procedure's triggers and internal procedures
    will execute in this procedure's storage, and that proper
    cleanup will occur on deletion of the procedure. */

    CREATE WIDGET-POOL.

    /* *************************** Definitions ************************** */

    /* Parameters Definitions --- */


    /* Local Variable Definitions --- */

    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME


    &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK

    /* ******************** Preprocessor Definitions ******************** */

    &Scoped-define PROCEDURE-TYPE SmartWindow

    &Scoped-define ADM-CONTAINER WINDOW

    /* Name of first Frame and/or Browse and/or first Query */
    &Scoped-define FRAME-NAME fr-001

    /* Custom List Definitions */
    /* List-1,List-2,List-3,List-4,List-5,List-6 */

    /* _UIB-PREPROCESSOR-BLOCK-END */
    &ANALYZE-RESUME



    /* *********************** Control Definitions ********************** */

    /* Define the widget handle for the window */
    DEFINE VAR W-Win AS WIDGET-HANDLE NO-UNDO.

    /* Definitions of handles for OCX Containers */
    DEFINE VARIABLE CtrlFrame AS WIDGET-HANDLE NO-UNDO.
    DEFINE VARIABLE chCtrlFrame AS COMPONENT-HANDLE NO-UNDO.

    /* ************************ Frame Definitions *********************** */

    DEFINE FRAME fr-001
    WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
    SIDE-LABELS NO-UNDERLINE THREE-D
    AT COL 1 ROW 1
    SIZE 85 BY 21.05.


    /* *********************** Procedure Settings ************************ */

    &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
    /* Settings for THIS-PROCEDURE
    Type: SmartWindow
    Allow: Basic,Browse,DB-Fields,Query,Smart,Window
    */
    &ANALYZE-RESUME _END-PROCEDURE-SETTINGS

    /* ************************* Create Window ************************** */

    &ANALYZE-SUSPEND _CREATE-WINDOW
    IF SESSION:DISPLAY-TYPE = "GUI":U THEN
    CREATE WINDOW W-Win ASSIGN
    HIDDEN = YES
    TITLE = "<insert SmartWindow title>"
    HEIGHT = 20.91
    WIDTH = 83.4
    MAX-HEIGHT = 27.67
    MAX-WIDTH = 120.2
    VIRTUAL-HEIGHT = 27.67
    VIRTUAL-WIDTH = 120.2
    RESIZE = no
    SCROLL-BARS = no
    STATUS-AREA = no
    BGCOLOR = ?
    FGCOLOR = ?
    THREE-D = yes
    MESSAGE-AREA = no
    SENSITIVE = yes.
    ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
    /* END WINDOW DEFINITION */
    &ANALYZE-RESUME


    /* *************** Runtime Attributes and UIB Settings ************** */

    &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
    /* SETTINGS FOR WINDOW W-Win
    VISIBLE,,RUN-PERSISTENT */
    /* SETTINGS FOR FRAME fr-001
    */
    IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(W-Win)
    THEN W-Win:HIDDEN = yes.

    /* _RUN-TIME-ATTRIBUTES-END */
    &ANALYZE-RESUME




    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB W-Win
    /* ************************* Included-Libraries *********************** */

    {src/adm/method/containr.i}

    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME



    /* ********************** Create OCX Containers ********************** */

    &ANALYZE-SUSPEND _CREATE-DYNAMIC

    &IF "{&OPSYS}" = "WIN32":U AND "{&WINDOW-SYSTEM}" NE "TTY":U &THEN

    CREATE CONTROL-FRAME CtrlFrame ASSIGN
    FRAME = FRAME fr-001:HANDLE
    ROW = 2.91
    COLUMN = 15
    HEIGHT = 15.71
    WIDTH = 54
    HIDDEN = no
    SENSITIVE = yes.

    PROCEDURE adm-create-controls:
    CtrlFrame:NAME = "CtrlFrame":U .
    /* CtrlFrame OCXINFO:CREATE-CONTROL from: {C74190B6-8589-11D1-B16A-00C0F0283628} type: xTree */

    END PROCEDURE.

    &ENDIF

    &ANALYZE-RESUME /* End of _CREATE-DYNAMIC */


    /* ************************ Control Triggers ************************ */

    &Scoped-define SELF-NAME W-Win
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL W-Win W-Win
    ON END-ERROR OF W-Win /* <insert SmartWindow title> */
    OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
    /* This case occurs when the user presses the "Esc" key.
    In a persistently run window, just ignore this. If we did not, the
    application would exit. */
    IF THIS-PROCEDURE:pERSISTENT THEN RETURN NO-APPLY.
    END.

    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME


    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL W-Win W-Win
    ON WINDOW-CLOSE OF W-Win /* <insert SmartWindow title> */
    DO:
    /* This ADM code must be left here in order for the SmartWindow
    and its descendents to terminate properly on exit. */
    APPLY "CLOSE":U TO THIS-PROCEDURE.
    RETURN NO-APPLY.
    END.

    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME


    &UNDEFINE SELF-NAME

    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK W-Win


    /* *************************** Main Block *************************** */



    /* Include custom Main Block code for SmartWindows. */
    {src/adm/template/windowmn.i}

    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME


    /* ********************** Internal Procedures *********************** */

    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-create-objects W-Win _ADM-CREATE-OBJECTS
    PROCEDURE adm-create-objects :
    /*------------------------------------------------------------------------------
    Purpose: Create handles for all SmartObjects used in this procedure.
    After SmartObjects are initialized, then SmartLinks are added.
    Parameters: <none>
    ------------------------------------------------------------------------------*/

    END PROCEDURE.

    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME


    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available W-Win _ADM-ROW-AVAILABLE
    PROCEDURE adm-row-available :
    /*------------------------------------------------------------------------------
    Purpose: Dispatched to this procedure when the Record-
    Source has a new row available. This procedure
    tries to get the new row (or foriegn keys) from
    the Record-Source and process it.
    Parameters: <none>
    ------------------------------------------------------------------------------*/

    /* Define variables needed by this internal procedure. */
    {src/adm/template/row-head.i}

    /* Process the newly available records (i.e. display fields,
    open queries, and/or pass records on to any RECORD-TARGETS). */
    {src/adm/template/row-end.i}

    END PROCEDURE.

    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME


    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE control_load W-Win _CONTROL-LOAD
    PROCEDURE control_load :
    /*------------------------------------------------------------------------------
    Purpose: Load the OCXs
    Parameters: <none>
    Notes: Here we load, initialize and make visible the
    OCXs in the interface.
    ------------------------------------------------------------------------------*/

    &IF "{&OPSYS}" = "WIN32":U AND "{&WINDOW-SYSTEM}" NE "TTY":U &THEN
    DEFINE VARIABLE UIB_S AS LOGICAL NO-UNDO.
    DEFINE VARIABLE OCXFile AS CHARACTER NO-UNDO.

    OCXFile = SEARCH( "menu_tree.wrx":U ).

    IF OCXFile <> ? THEN DO:
    ASSIGN
    chCtrlFrame = CtrlFrame:COM-HANDLE
    UIB_S = chCtrlFrame:LoadControls( OCXFile, "CtrlFrame":U)
    .
    RUN DISPATCH IN THIS-PROCEDURE("initialize-controls":U) NO-ERROR.
    END.
    ELSE MESSAGE "The file, menu_tree.wrx, could not be found." skip
    "The controls cannot be loaded."
    VIEW-AS ALERT-BOX TITLE "Controls Not Loaded".

    &ENDIF

    END PROCEDURE.

    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME


    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI W-Win _DEFAULT-DISABLE
    PROCEDURE disable_UI :
    /*------------------------------------------------------------------------------
    Purpose: DISABLE the User Interface
    Parameters: <none>
    Notes: Here we clean-up the user-interface by deleting
    dynamic widgets we have created and/or hide
    frames. This procedure is usually called when
    we are ready to "clean-up" after running.
    ------------------------------------------------------------------------------*/
    /* Delete the WINDOW we created */
    IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(W-Win)
    THEN DELETE WIDGET W-Win.
    IF THIS-PROCEDURE:pERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
    END PROCEDURE.

    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME


    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI W-Win _DEFAULT-ENABLE
    PROCEDURE enable_UI :
    /*------------------------------------------------------------------------------
    Purpose: ENABLE the User Interface
    Parameters: <none>
    Notes: Here we display/view/enable the widgets in the
    user-interface. In addition, OPEN all queries
    associated with each FRAME and BROWSE.
    These statements here are based on the "Other
    Settings" section of the widget Property Sheets.
    ------------------------------------------------------------------------------*/
    VIEW FRAME fr-001 IN WINDOW W-Win.
    {&OPEN-BROWSERS-IN-QUERY-fr-001}
    VIEW W-Win.
    END PROCEDURE.

    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME


    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-exit W-Win
    PROCEDURE local-exit :
    /* -----------------------------------------------------------
    Purpose: Starts an "exit" by APPLYing CLOSE event, which starts "destroy".
    Parameters: <none>
    Notes: If activated, should APPLY CLOSE, *not* dispatch adm-exit.
    -------------------------------------------------------------*/
    APPLY "CLOSE":U TO THIS-PROCEDURE.

    RETURN.

    END PROCEDURE.

    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME


    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records W-Win _ADM-SEND-RECORDS
    PROCEDURE send-records :
    /*------------------------------------------------------------------------------
    Purpose: Send record ROWID's for all tables used by
    this file.
    Parameters: see template/snd-head.i
    ------------------------------------------------------------------------------*/

    /* SEND-RECORDS does nothing because there are no External
    Tables specified for this SmartWindow, and there are no
    tables specified in any contained Browse, Query, or Frame. */

    END PROCEDURE.

    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME


    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed W-Win
    PROCEDURE state-changed :
    /* -----------------------------------------------------------
    Purpose:
    Parameters: <none>
    Notes:
    -------------------------------------------------------------*/
    DEFINE INPUT PARAMETER p-issuer-hdl AS HANDLE NO-UNDO.
    DEFINE INPUT PARAMETER p-state AS CHARACTER NO-UNDO.
    END PROCEDURE.

    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME[/prog]
  6. jalegria

    jalegria Membro Participativo

    vendo o código, o nome está o padrão qdo vc coloca o treeview na janela "CtrlFrame".

    coloca o seguinte no main-block e ve se roda:

    Código:
    chCtrlFrame:TreeView:Nodes:ADD(,,'root','Pacientes',).
    
    chCtrlFrame:TreeView:Nodes:ADD('root',4,'cad','Cadastro',).
    chCtrlFrame:TreeView:Nodes:ADD('root',4,'cons','Consultas',).
    chCtrlFrame:TreeView:Nodes:ADD('root',4,'att','Atestados',).
    chCtrlFrame:TreeView:Nodes:ADD('root',4,'exm','Exames',).
    

Compartilhe esta Página