Hello,
I have a problem with the menus of my main window.
The code is :
----------------------------
BuildMenu()
oWnd:SetMenu(oMenu)
----------------------------
I made a procedure BuildMenu() which reads the menus out of a file into oMenu.
The menus are set by : oWnd:SetMenu(oMenu).
I need to do this because, depending on some settings set by the user, the menus need to be changed.
That works fine until I passed these code lines between 10 or 15 times.
Then I can click on one of my menuitems, but nothing happens anymore.
The only thing I can do is quitting my application and restarting it. Then the menu is working fine again until I passed between 10 or 15 times the code I mentioned.
What is the reason for this problem and how can I solve it ?
Thanks.
Michel
Problem with menus
Problem with menus
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Michel,
Do you use:
to build your menu from inside BuildMenu() ? Please show us a portion of your code, thanks
Do you use:
Code: Select all
MENU oMenu
MENUITEM ...
...
ENDMENU
James,
The reason for the menu to be changed while running my application, has to do with priorities, but also with adding documents in menus that have been added, etc.
Antonio,
Here is the code I use :
I hope you can understand what I mean.
Thank you.
Michel
The reason for the menu to be changed while running my application, has to do with priorities, but also with adding documents in menus that have been added, etc.
Antonio,
Here is the code I use :
Code: Select all
FUNCTION BuildMenu1
LOCAL OldPar := {ALIAS(),INDEXORD(),RECNO()}
DeleteObject(oMenu)
MEMORY(-1)
SYSREFRESH()
SELECT US
SET ORDER TO 3
SEEK(UPPER(nUser))
oMenu := NIL
MENU oMenu
FOR i=1 TO 8
IF i<> 4
SELECT MEN
SET ORDER TO i
ELSE
SELECT MENT
SET ORDER TO 3
ENDIF
GO TOP
IF !EOF() .AND. &("MEN"+IF(i=4,"T","")+"->MNNR") = i .AND. &("MEN"+IF(i=4,"T","")+"->MNSOORT") = 0
IF xPriority >= &("MEN"+IF(i=4,"T","")+"->MNPRIOR") .AND. (US->RSCHERM .OR. (!US->RSCHERM .AND. i <> 6))
MENUITEM &("oMenu"+STR(i,1,0)) PROMPT ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MN"+IF(i<>4 .OR. EMPTY(MENT->MNPOPTXT),"TEKST","POPTXT")))
MENU
SKIP
IF i = 4 .AND. MENT->MNSOORT = 3 ; SKIP ; ENDIF
DO WHILE !EOF() .AND. &("MEN"+IF(i=4,"T","")+"->MNNR") = i
IF ((xPriority >= &("MEN"+IF(i=4,"T","")+"->MNPRIOR")) .OR. (IF(i=4,.T.,MEN->MNPRIVE .AND. xBoekExt<>"PAR"))) .AND. ((i = 4 .OR. (i <> 4 .AND. ((PAR->BKWISSEL .AND. MEN->MNBOEKH .AND. (!EMPTY(US->UBOEPATH) .AND. ALLTRIM(US->UBOEPATH) <> "\") .OR. (PAR->DOSBOEKH .AND. DOSS->DOSBOEKH)) .OR. !MEN->MNBOEKH)))) .AND. (&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 0 .OR. (&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") <> 0)) .AND. (i = 4 .OR. (i <> 4 .AND. ((!US->RSCHERM .AND. i <> 6) .OR. (US->RSCHERM .AND. (i = 6 .OR. !MEN->MNSCHERM)))))
IF i<>4 .OR. !MENT->MNPOPACT
IF (&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 0) .OR. ;
(&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 1 .AND. PAR->OZDOSSIER) .OR. ;
(&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 2 .AND. PAR->OZONDERW ) .OR. ;
(&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 3 .AND. PAR->OZONDERV ) .OR. ;
(&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 4 .AND. PAR->OZDATUM ) .OR. ;
(&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 5 .AND. PAR->OZNUMMER ) .OR. ;
(&("MEN"+IF(i=4,"T","")+"->MNSRTOPSL") = 6 .AND. (PAR->OZDOSSIER .OR. PAR->OZONDERW .OR. PAR->OZONDERV .OR. PAR->OZDATUM .OR. PAR->OZNUMMER))
IF i=4 .OR. (i<>4 .AND. (MEN->MNSRTBH = 0 .OR. ((((&(xBoekExt+"->SRTBOEKH") <> 2 .AND. MEN->MNSRTBH = 1) .OR. (&(xBoekExt+"->SRTBOEKH") = 2 .AND. MEN->MNSRTBH = 2))))))
DO CASE
CASE &("MEN"+IF(i=4,"T","")+"->MNSOORT") = 1 ; VulMenu1(i) ; MENU
CASE &("MEN"+IF(i=4,"T","")+"->MNSOORT") = 2 ; VulMenu1(i)
CASE &("MEN"+IF(i=4,"T","")+"->MNSOORT") = 3 ; SEPARATOR
CASE &("MEN"+IF(i=4,"T","")+"->MNSOORT") = 4 ; ENDMENU
ENDCASE
ENDIF
ENDIF
ENDIF
ENDIF
SKIP
ENDDO
ENDMENU
ENDIF
ENDIF
NEXT
ENDMENU
SELECT(OldPar[1])
SET ORDER TO OldPar[2]
GOTO OldPar[3]
RETURN(.T.)
******************************************************************************
PROCEDURE VulMenu1(i)
LOCAL cActie
IF !EMPTY(cActie := &("MEN"+IF(i=4,"T","")+"->MNACTIE")) .AND. UPPER(LEFT(&("MEN"+IF(i=4,"T","")+"->MNACTIE"),1)) <> "*" .AND. UPPER(LEFT(&("MEN"+IF(i=4,"T","")+"->MNACTIE"),4)) <> "REM "
IF i <> 4
cActie := "{||StartSub(MEN->MNDISABLE)," + ALLTRIM(cActie) + ",EndSub(MEN->MNDISABLE)}"
ELSE
cActie := LEFT(ALLTRIM(cActie),LEN(ALLTRIM(cActie))-1) + ",OpenBase(.T.)}"
ENDIF
IF !EMPTY(&("MEN"+IF(i=4,"T","")+"->MNVIRTKEY"))
IF i = 2 .AND. AT("TAALACT(1)",UPPER(MEN->MNACTIE)) <> 0
MENUITEM ("Agendacontrole "+IF(US->UAGCONTR,"uitschakelen","inschakelen") + IF(!EMPTY(MEN->MNFKEY),CHR(9)+ALLTRIM(MEN->MNFKEY),"")) BLOCK &(cActie) ACCELERATOR MEN->MNSTATE,MEN->MNVIRTKEY
ELSEIF i = 4 .AND. MENT->MNVOLGNR >= 9999978 .AND. MENT->MNVOLGNR <= 9999980
MENUITEM (IF(MENT->MNVOLGNR=9999978,"Taalkeuze",IF(MENT->MNVOLGNR=9999979,"Taal spellingcontrole","Controle lettertekens"))+" "+IF((MENT->MNVOLGNR=9999978 .AND. US->UTXTTAAL) .OR. (MENT->MNVOLGNR=9999979 .AND. US->UTXTSPEL) .OR. (MENT->MNVOLGNR=9999980 .AND. US->UTXTFLET),"uitschakelen","activeren") + IF(!EMPTY(MENT->MNFKEY),CHR(9)+ALLTRIM(MENT->MNFKEY),"")) BLOCK &(cActie) ACCELERATOR MENT->MNSTATE,MENT->MNVIRTKEY
ELSE
MENUITEM (ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MN"+IF(i<>4 .OR. EMPTY(MENT->MNPOPTXT),"TEKST","POPTXT"))) + IF(!EMPTY(&("MEN"+IF(i=4,"T","")+"->MNFKEY")),CHR(9)+ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MNFKEY")),"")) BLOCK &(cActie) ACCELERATOR &("MEN"+IF(i=4,"T","")+"->MNSTATE"),&("MEN"+IF(i=4,"T","")+"->MNVIRTKEY")
ENDIF
ELSE
IF i = 2 .AND. AT("TAALACT(1)",UPPER(MEN->MNACTIE)) <> 0
MENUITEM ("Agendacontrole "+IF(US->UAGCONTR,"uitschakelen","inschakelen") + IF(!EMPTY(MEN->MNFKEY),CHR(9)+ALLTRIM(MEN->MNFKEY),"")) BLOCK &(cActie)
ELSEIF i = 4 .AND. MENT->MNVOLGNR >= 9999978 .AND. MENT->MNVOLGNR <= 9999980
MENUITEM (IF(MENT->MNVOLGNR=9999978,"Taalkeuze",IF(MENT->MNVOLGNR=9999979,"Taal spellingcontrole","Controle lettertekens"))+" "+IF((MENT->MNVOLGNR=9999978 .AND. US->UTXTTAAL) .OR. (MENT->MNVOLGNR=9999979 .AND. US->UTXTSPEL) .OR. (MENT->MNVOLGNR=9999980 .AND. US->UTXTFLET),"uitschakelen","activeren") + IF(!EMPTY(MENT->MNFKEY),CHR(9)+ALLTRIM(MENT->MNFKEY),"")) BLOCK &(cActie)
ELSE
MENUITEM (ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MN"+IF(i<>4 .OR. EMPTY(MENT->MNPOPTXT),"TEKST","POPTXT"))) + IF(!EMPTY(&("MEN"+IF(i=4,"T","")+"->MNFKEY")),CHR(9)+ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MNFKEY")),"")) BLOCK &(cActie)
ENDIF
ENDIF
ELSE
IF &("MEN"+IF(i=4,"T","")+"->MNSOORT") = 2
IF i = 2 .AND. AT("TAALACT(1)",UPPER(MEN->MNACTIE)) <> 0
MENUITEM ("Agendacontrole "+IF(US->UAGCONTR,"uitschakelen","inschakelen") + IF(!EMPTY(MEN->MNFKEY),CHR(9)+ALLTRIM(MEN->MNFKEY),"")) DISABLED
ELSEIF i = 4 .AND. MENT->MNVOLGNR >= 9999978 .AND. MENT->MNVOLGNR <= 9999980
MENUITEM (IF(MENT->MNVOLGNR=9999978,"Taalkeuze",IF(MENT->MNVOLGNR=9999979,"Taal spellingcontrole","Controle lettertekens"))+" "+IF((MENT->MNVOLGNR=9999978 .AND. US->UTXTTAAL) .OR. (MENT->MNVOLGNR=9999979 .AND. US->UTXTSPEL) .OR. (MENT->MNVOLGNR=9999980 .AND. US->UTXTFLET),"uitschakelen","activeren") + IF(!EMPTY(MENT->MNFKEY),CHR(9)+ALLTRIM(MENT->MNFKEY),"")) DISABLED
ELSE
MENUITEM (ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MN"+IF(i<>4 .OR. EMPTY(MENT->MNPOPTXT),"TEKST","POPTXT"))) + IF(i<>4 .AND. !EMPTY(MEN->MNFKEY),CHR(9)+ALLTRIM(MEN->MNFKEY),"")) DISABLED
ENDIF
ELSE
IF i = 2 .AND. AT("TAALACT(1)",UPPER(MEN->MNACTIE)) <> 0
MENUITEM ("Agendacontrole "+IF(US->UAGCONTR,"uitschakelen","inschakelen") + IF(!EMPTY(MEN->MNFKEY),CHR(9)+ALLTRIM(MEN->MNFKEY),""))
ELSEIF i = 4 .AND. MENT->MNVOLGNR >= 9999978 .AND. MENT->MNVOLGNR <= 9999980
MENUITEM (IF(MENT->MNVOLGNR=9999978,"Taalkeuze",IF(MENT->MNVOLGNR=9999979,"Taal spellingcontrole","Controle lettertekens"))+" "+IF((MENT->MNVOLGNR=9999978 .AND. US->UTXTTAAL) .OR. (MENT->MNVOLGNR=9999979 .AND. US->UTXTSPEL) .OR. (MENT->MNVOLGNR=9999980 .AND. US->UTXTFLET),"uitschakelen","activeren") + IF(!EMPTY(MENT->MNFKEY),CHR(9)+ALLTRIM(MENT->MNFKEY),""))
ELSE
MENUITEM (ALLTRIM(&("MEN"+IF(i=4,"T","")+"->MN"+IF(i<>4 .OR. EMPTY(MENT->MNPOPTXT),"TEKST","POPTXT"))) + IF(i<>4 .AND. !EMPTY(MEN->MNFKEY),CHR(9)+ALLTRIM(MEN->MNFKEY),""))
ENDIF
ENDIF
ENDIF
RETURN
******************************************************************************
Thank you.
Michel
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Antonio,
Thanks for your answer.
I changed the code as you told me to but if the "osetmenu" sentence is executed between 10 and 15 times, the menuitems don't work anymore.
Have a nice weekend.
Michel
Thanks for your answer.
I changed the code as you told me to but if the "osetmenu" sentence is executed between 10 and 15 times, the menuitems don't work anymore.
Have a nice weekend.
Michel
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Michel,
Please test this sample, it seems to work fine:
Please test this sample, it seems to work fine:
Code: Select all
#include "FiveWin.ch"
function Main()
local oWnd, oBar
DEFINE WINDOW oWnd TITLE "Menus Test" ;
MENU BuildMenu()
DEFINE BUTTONBAR oBar OF oWnd 3D
DEFINE BUTTON OF oBar ACTION oWnd:SetMenu( BuildMenu() )
ACTIVATE WINDOW oWnd
return nil
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "Test"
MENU
MENUITEM "One" ACTION MsgInfo( "One" )
MENUITEM "Two" ACTION MsgInfo( "Two" )
MENUITEM "Three" ACTION MsgInfo( "Three" )
ENDMENU
ENDMENU
return oMenu