Página 1 de 1

erro criar janela de 4 nivel

Enviado: 05 Out 2009 10:03
por tonyx

Código: Selecionar todos

*--------------------------------------*
* SISTEMA    : PROTOCOLO               *
* EMPRESA    : G.W.M                   *
* MANUTENCAO : ANTONIO SIXEL           *
* PROGRAMA   : ENTRADA                 *
*--------------------------------------*
#include "inkey.ch"
#include "gtinfo.ch"
#include "winuser.ch"
//==============================//
#define COR_NORMAL        setcolor("N/W*,GR+/B*,N/N,GR+/N*,W+/N*,R/W*,W/W*,B/W*") 

//=================//
FUNCTION MAIN()
   
 PUBLIC NOME_SIS,dir_c,DIR_JPG
 //======================
 dir_c:= "c:\teste"
 DIR_JPG:= DIR_C+"\JPG"
 NOME_SIS:= "GWM - TESTE"
 //============================
 REQUEST DBFCDX
 RDDSETDEFAULT("DBFCDX")
 DBSETDRIVER("DBFCDX")
 //======================= teste se esta ativo ======//
 #Define _BARRA_DOS_WINDOWS_ "\"
 If (empty(CreateMutex( , .T., strtran(GetModuleFileName(),_BARRA_DOS_WINDOWS_,'_') )) .or. (GetLastError() > 0 ) )
  wvw_showwindow(0,0) // Esconde janela principal
  wvw_messagebox(,"Sistema [ "+nome_sis+" ] Ja esta Ativo","Alerta",0) // msg_ok
  Quit
 endif
 //============
 iniciar()
 //==========//
 Cria_Menu()
 //========================
 wait "saida do menu"

RETURN

//=============================//
FUNCTION Iniciar()
******************
 local vret := .T.
 *====================
 SET ECHO OFF
 SET ALTERNATE OFF
 *SET BELL OFF
 *SET CARRY OFF
 SET CENTURY ON
 SET CONFIRM OFF
 SET CONSOLE ON
 SET DATE FRENCH
 SET DECIMALS TO 2
 SET DELETE ON
 SET DELIMITERS OFF
 SET DEVICE TO SCREE
 SET ESCAPE ON
 SET EXACT ON
 SET FIXED OFF
 SET HEADING ON
 SET INTENSITY ON
 SET MENU ON
 SET PRINT OFF
 SET SAFETY ON
 SET SCOREBOARD OFF
 SET STATUS OFF
 SET TALK OFF
 SET UNIQUE OFF
 SET CURSOR ON
 *========================
 RUN CD &DIR_C
 SET PATH TO &DIR_C
 SET DEFA TO &DIR_C
 SET EXCLUSIVE OFF
 SET AUTOPEN OFF
 *---------------------------- PARA O XHARBOUR --------------
 set dbflockscheme to 2  // PARA USO JUNTO COM O CLIPPER
 //REQUEST HB_NOMOUSE
 *========
 REQUEST HB_LANG_PT
 HB_LANGSELECT("PT")
 *-----
 REQUEST HB_CODEPAGE_PT850
 HB_SETCODEPAGE("PT850")
 *------
 REQUEST DBFCDX
 RDDSETDEFAULT("DBFCDX")
 DBSETDRIVER("DBFCDX")
 *------
 mfonte="Lucida Console"
 wvw_setcodepage(,255)
 wvw_settitle(0,nome_sis)
 SETMODE(24,80)
 //  DOS = 24,80 => mfonte="Terminal"
 //    gtinfo(GTI_FONTSIZE, 24) 
 //  NAO APARECE A BARRA DE TITULO 
 //  ------- COM BARRA DE TITULO ------ 
 do case  // Identifica a resolucao do video
   case gtinfo(GTI_DESKTOPWIDTH) > 1439
    gtinfo(GTI_FONTWIDTH, 12) // 12 anterior   //   13  //   12
    gtinfo(GTI_FONTSIZE, 27)  // 28 anterior   //   29  //   27
    // wvw_setfont(,mfonte,32,1440/maxcol()) //29,12
    // wvw_setfont(,mfonte,32,12) //29,12

   case gtinfo(GTI_DESKTOPWIDTH) > 1023
    gtinfo(GTI_FONTWIDTH, 12) // 12 anterior   //   13  //   12
    gtinfo(GTI_FONTSIZE, 27)  // 28 anterior   //   29  //   27
    // wvw_setfont(,mfonte,32,1024/maxcol()) //29,12
    // wvw_setfont(,mfonte,32,12) //29,12

   case gtinfo(GTI_DESKTOPWIDTH) > 799
    //gtinfo(GTI_FONTWIDTH, 10 ) // 10 anterior  //   10
    //gtinfo(GTI_FONTSIZE, 22 )  // 20 anterior  //   22

    SETMODE(24,80)
    wvw_setfont(,mfonte,23,10) //23,10
   
   otherwise
    gtinfo(GTI_FONTWIDTH, 8)
    gtinfo(GTI_FONTSIZE, 17)
    // wvw_setfont(,mfonte,18,round(640/maxcol(),0)) // 18,8
    //  wvw_setfont(,mfonte,18,8) // 18,8
 endcase
 //----------------------------------------
 //WVW_NOCLOSE() // desabilitando o X
 WVW_SetIcon(, DIR_JPG+'\GWM.ICO' )
 //wvw_setmousemove(.t.)
 //wvw_size_ready(.T.)
 // wvw_setmaincoord(.t.)
 //wvw_SBcreate()
 //wvw_SBaddPart(, "99:99:99")
 //wvw_SetTimer(, 1000)
 //set(20,100)  // nada serve
 //wvw_showwindow(0,0) // Esconde janela principal
 //   wvw_SetPaintRefresh(0)
 //   wvw_SetVertCaret(.F.)
 //   wvw_enableshortcuts(0,.T.)
 SETINKEYAFTERBLOCK({|nkey| AfterInkey(nkey)})
 COR_NORMAL
 CLEAR 
return(vret)
//==========================================//

Function cria_menu()
 private MenuMain
 op_101:= 1
 op_102:= 2
 //==============//
 MenuMain = WVW_CreateMenu( ) 
   //==============================//
   Menu_A = WVW_CreateMenu( )
     Menu_A_2 = WVW_CreateMenu( ) 
     WVW_AppendMenu( Menu_A_2 , MF_ENABLED + MF_STRING,op_101 ,"1- op_1- menu_A_1" ) 
     WVW_AppendMenu( Menu_A_2 , MF_ENABLED + MF_STRING,op_102 ,"2- op_2- menu_A_1" )
   WVW_AppendMenu( Menu_A , MF_ENABLED + MF_POPUP ,   , "1- Menu_A_1"  )
   WVW_AppendMenu( Menu_A , MF_ENABLED + MF_POPUP ,Menu_A_2 , "2- Menu_A_2"  )
   //=============================//
   Menu_B = WVW_CreateMenu( )
     Menu_B_2 = WVW_CreateMenu( )

//========================== erro esta aqui ======
       Menu_B_2_2 = WVW_CreateMenu( )  // JA DA ERRO AO CRIAR
//       WVW_AppendMenu( Menu_B_2_2 , MF_ENABLED + MF_STRING, op_203, "1- op1 - menu_B_2_2") 
//       WVW_AppendMenu( Menu_B_2_2 , MF_ENABLED + MF_STRING, op_204, "2- op2 - Menu_B_2_2") 
//       WVW_AppendMenu( Menu_B_2_2 , MF_ENABLED + MF_STRING, op_205, "3- op3 - Menu_B_2_2") 
          
//     WVW_AppendMenu( Menu_B_2 , MF_ENABLED + MF_STRING, op_202    , "1- op1 - menu_B_2") 
   WVW_AppendMenu( Menu_B_2 , MF_ENABLED + MF_STRING, Menu_B_2_2, "2- op2 - menu_B_2") 

   WVW_AppendMenu( Menu_B , MF_ENABLED + MF_POPUP ,   , "1- Menu_B_1",  )
   WVW_AppendMenu( Menu_B , MF_ENABLED + MF_POPUP , Menu_B_2, "2- Menu_B_2",  )
   ///
 WVW_AppendMenu( MenuMain , MF_ENABLED + MF_POPUP , Menu_A  , "A- menu_A",  )
 WVW_AppendMenu( MenuMain , MF_ENABLED + MF_POPUP , Menu_B , "B- menu_B",  )

  //================================//
  WVW_SetMenu(, MenuMain )
  //=========================== LOOP DO MENU =====//
  do while lastkey()<>27
    inkey(0)
  enddo
return

function AfterInkey(nkey)
local MenuId
 IF nKey=1024
  MenuId:=WVW_GETLASTMENUEVENT()
  DO CASE
   case MenuId = op_101
    fop_1()
   CASE MenuId = OP_102
    fop_2()
  ENDCASE
 ENDIF
return nkey

//==================
function fop_1
  setcolor('N/W')
  wvw_nopenwindow('',5,5,7,20)
  @ 1,1 say 'teste1'
  inkey(0)
  wvw_lclosewindow()
return nil

function fop_2
  setcolor('N/W')
  wvw_nopenwindow('',5,5,7,20)
  tt = '1'
  @ 1,1 say 'teste2' get tt pict '9'
  read
  inkey(0)
  wvw_lclosewindow()
return nil

Re: erro criar janela de 4 nivel

Enviado: 05 Out 2009 11:04
por gvc
Ok. Vc postou o código fonte mas não falou nada sobre o erro.
O titulo é auto explicativo?

Re: erro criar janela de 4 nivel

Enviado: 05 Out 2009 16:31
por tonyx
Quebrei a cabeca mas consegui :P

Finalmente consegui entender e fazer funcionar ate o 4 nivel de menu com WVW_APPENDMENU

Código: Selecionar todos

//============================//
Function cria_menu()
 private MenuMain
 private op_1,op_2,op_3
 op_1:= 1
 op_2:= 2
 op_3:= 3
 //==============//
 MenuMain= WVW_CreateMenu()
  Menu_A:= WVW_CreateMenu()
     Menu_A_3:= WVW_CreateMenu()
  Menu_B:= WVW_CreateMenu()
     Menu_B_3:= WVW_CreateMenu()
  Menu_C:= WVW_CreateMenu()
     Menu_C_1:= WVW_CreateMenu()
       Menu_C_11:= WVW_CreateMenu()
         Menu_C_111:= WVW_CreateMenu()
 //==========================
 WVW_AppendMenu( MenuMain, MF_ENABLED + MF_POPUP, Menu_A, "A- Menu_A" )
 //====== MENU_A
    WVW_AppendMenu( Menu_A, MF_ENABLED + MF_STRING, OP_1, "1- Op_1 Menu_A"  )
    WVW_AppendMenu( Menu_A, MF_ENABLED + MF_STRING, OP_2, "2- Op_2 Menu_A"  )
       WVW_AppendMenu( Menu_A, MF_ENABLED + MF_POPUP, Menu_A_3, "3- Menu_A_3" )
          WVW_AppendMenu( Menu_A_3, MF_ENABLED + MF_STRING, OP_1, "1- Op_1 Menu_A_3"  )
          WVW_AppendMenu( Menu_A_3, MF_ENABLED + MF_STRING, OP_2, "2- Op_1 Menu_A_3"  )
 //===== MENU B
    WVW_AppendMenu( MenuMain, MF_ENABLED + MF_POPUP, Menu_B, "A- Menu_A" )
       WVW_AppendMenu( Menu_B, MF_ENABLED + MF_STRING, OP_1, "1- Op_1 Menu_B"  )
       WVW_AppendMenu( Menu_B, MF_ENABLED + MF_STRING, OP_2, "2- Op_1 Menu_B"  )
       MENUTRACOS  MENU_B
       WVW_AppendMenu( Menu_B, MF_ENABLED + MF_POPUP, Menu_B_3, "3- Menu_A_3" )
          WVW_AppendMenu( Menu_B_3, MF_ENABLED + MF_STRING, OP_1, "1- Op_1 Menu_B_3"  )
          WVW_AppendMenu( Menu_B_3, MF_ENABLED + MF_STRING, OP_2, "2- Op_2 Menu_B_3"  )
          WVW_AppendMenu( Menu_B_3, MF_ENABLED + MF_STRING, OP_2, "3- Op_3 Menu_B_3"  )
  // MENU_C
    WVW_AppendMenu( MenuMain, MF_ENABLED + MF_POPUP, Menu_C, "C- Menu_C" )
       WVW_AppendMenu( Menu_C, MF_ENABLED + MF_POPUP, Menu_C_1, "1- Menu_C1" )
          WVW_AppendMenu( Menu_C_1, MF_ENABLED + MF_POPUP, Menu_C_11, "1- Menu_C11" )
             WVW_AppendMenu( Menu_C_11, MF_ENABLED + MF_POPUP, Menu_C_111, "1- Menu_C111" )
                WVW_AppendMenu( Menu_C_111, MF_ENABLED + MF_STRING, OP_2, "1- Op_1 Menu_C_111"  )
 //================================//
 WVW_SetMenu(, MenuMain )
 //=========================== LOOP DO MENU =====//
 do while lastkey()<>27
  inkey(0)
 enddo
return

function AfterInkey(nkey)
local MenuId
 IF nKey=1024
  MenuId:=WVW_GETLASTMENUEVENT()
  DO CASE
   case MenuId = op_1
    fop_1()
   CASE MenuId = OP_2
    fop_2()
  ENDCASE
 ENDIF
return nkey

//==================
function fop_1
  setcolor('N/W')
  wvw_nopenwindow('',5,5,7,20)
  @ 1,1 say 'teste1'
  inkey(0)
  wvw_lclosewindow()
return nil

function fop_2
  setcolor('N/W')
  wvw_nopenwindow('',5,5,7,20)
  tt = '1'
  @ 1,1 say 'teste2' get tt pict '9'
  read
  inkey(0)
  wvw_lclosewindow()
return nil

Re: erro criar janela de 4 nivel

Enviado: 06 Out 2009 13:09
por sygecom
Olá Antonio,
Menos mal que consegui resolver, quando tiver com dificuldades com a gtwvw pode dar uma consultada também na wvwtools que tem algumas rotinas que facilita o uso da gtwvw. Você pode achar a wvwtools no site do xharbour.com