Forum Liberty Basic France

Le 05/03/2021 à 13h21

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2489
Reprise du message précédent

Voilà qui est bien; on sait au moins de quoi on parle.
Pourquoi ne fais-tu pas avec les menus, qui cascadent très bien ?
____________________
Roro

   
Le 06/03/2021 à 18h01

Modérateur

Groupe: Modérateur

Inscrit le: 09/02/2015
Messages: 741
Bonjour tous !

Je n'ai pas pu tester en JustBasic, car celui-ci ne reconnait pas l'instruction HWND, permettant de récupérer l'identifiant de la fenêtre tel que le voit Windows.

J'ai fait quelques essais pour créer un menu déroulant avec sous-menu qui fonctionne en JustBasic, mais j'aboutis vite à des trucs tarabiscotés et peu satisfaisants : chaque solution trouvée a sa pierre d'achoppement. Je pense malgré tout qu'un connaisseur confirmé devrait pouvoir y arriver, mais je n'ai rien d'autre à proposer que mon premier essai, publié au début de cette discussion.

En JustBasic, j'ai pu faire fonctionner l'exemple de Castel, en supprimant les "stylebits" qui ne fonctionnent qu'avec Liberty Basic.

La question du menu contextuel est intéressante ;)
____________________
Just BASIC v2.0 :
  • utilisation courante avec GNU/Linux Mageia7+ Wine (Pas trouvé d'incohérences ou de bug de compilation à ce jour)
  • utilisation occasionnelle ou vérification/débugage difficile avec Windows XP sur un petit eeepc

   
Le 07/03/2021 à 04h15

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2489
Pour pas cher:
Code VB :
 
      NOMAINWIN
     mapw=500: maph= 400
    WindowWidth=mapw+15: WindowHeight=maph+40
    UpperLeftX = 10: UpperLeftY = 20
   GRAPHICBOX #w.g, 5, 5, mapw, maph
    OPEN "Help" FOR window_nf AS #w
    #w, "TRAPCLOSE [closeHelp]"
    #w.g, "when leftButtonDown [scanne]"
   #w.g, "when rightButtonDown [scanner]"
    #w.g, "down;fill white;color black;backcolor white"
    #w.g, "place 50 50": #w.g, "\Clic here   or right clic"
    #w.g, "place 50 100": #w.g, "\And clic any where"
    #w.g, "flush"
    wait
 [scanne]
   ax=MouseX: ay=MouseY
   if ax > 50 and ax < 100 and ay > 30 and ay < 70 then
      goto [a]
   end if
   if opa=1 then opa=0: close #a
 wait
 [scanner]
   if opa=1 then opa=0:  close #a
   ax=MouseX: ay=MouseY
   goto [a]
 wait
 [a]
     WindowWidth=100: WindowHeight=200
    UpperLeftX = ax: UpperLeftY = ay
   GRAPHICBOX #a.g, 0, 0, 150, 200
    OPEN "Popup menu" FOR window_nf AS #a
    opa=1
    #a.g, "when leftButtonDown [scannea]"
    #a.g, "down;fill white;color black;backcolor white"
    #a.g, "place 10 30": #a.g, "\Premier"
    #a.g, "place 10 60": #a.g, "\Second"
    #a.g, "place 10 90": #a.g, "\Troisième"
    wait
    [scannea]
   bx=MouseX: by=MouseY
   if bx > 10 and bx < 100 and by > 20 and by < 40 then
      notice, "clic sur premier"
   end if
   if bx > 10 and bx < 100 and  by > 40 and by < 60 then
      notice, "clic sur second"
   end if
   if bx > 10 and bx < 100 and by > 80 and by < 100 then
      notice, "clic sur troisième"
   end if
  wait
  [closeHelp]
    if opa=1 then opa=0: close #a
    CLOSE  #w
    END
 
 
____________________
Roro

   
Le 07/03/2021 à 20h09

Modérateur

Groupe: Modérateur

Inscrit le: 09/02/2015
Messages: 741
J'aurais dû persévérer ;)
____________________
Just BASIC v2.0 :
  • utilisation courante avec GNU/Linux Mageia7+ Wine (Pas trouvé d'incohérences ou de bug de compilation à ce jour)
  • utilisation occasionnelle ou vérification/débugage difficile avec Windows XP sur un petit eeepc

   
Le 10/03/2021 à 20h43

Modérateur

Groupe: Modérateur

Inscrit le: 30/03/2011
Messages: 437
oui c bien mieux avec un code ! tu m'as même appris des trucs c sympa !! je vais me pencher dessus ;).

Roland, pk tu met pas window_popup au lieu de _nf ? XD (ca fait plus .... popup ;P)
____________________
Yo !

MSN Web    
Le 10/03/2021 à 22h41

Modérateur

Groupe: Modérateur

Inscrit le: 30/03/2011
Messages: 437
Hum je pense que avec un système comme ca c'est fesable non ? :D (bidouillage !)

Code VB :
 
    NOMAINWIN
    mapw=500: maph= 400
    WindowWidth=mapw+15: WindowHeight=maph+40
    UpperLeftX = 10: UpperLeftY = 20
    GRAPHICBOX #w.g, 5, 5, mapw, maph
    OPEN "Help" FOR window_nf AS #w
    #w, "TRAPCLOSE [closeHelp]"
    #w.g, "when leftButtonDown [scanne]"
    #w.g, "when rightButtonDown [scanner]"
    #w.g, "down;fill white;color black;backcolor white"
    #w.g, "place 50 50": #w.g, "\Clic here   or right clic"
    #w.g, "place 50 100": #w.g, "\And clic any where"
    #w.g, "flush"
    wait
 
    [scanne]
    ax=MouseX: ay=MouseY
    if ax > 50 and ax < 100 and ay > 30 and ay < 70 then goto [a]
    if opa=1 then opa=0 : sousMENU1 = 0 : sousMENU2 = 0 : sousMENU3 = 0 : close #a
    wait
 
    [scanner]
    if opa=1 then opa=0:  close #a
    ax=MouseX: ay=MouseY
    goto [a]
    wait
 
    [a]
    WindowWidth=200: WindowHeight=130
    UpperLeftX = ax : UpperLeftY = ay
    BackgroundColor$ = "white" : ForegroundColor$ = "white"
    GRAPHICBOX #a.g, 0, 0, 110, 75
    if sousMENU1 = 1 then GRAPHICBOX #a.h, 110, 0, 70, 90
    if sousMENU2 = 1 then GRAPHICBOX #a.h, 110, 20, 70, 90
    if sousMENU3 = 1 then GRAPHICBOX #a.h, 110, 40, 70, 90
    OPEN "Popup menu" FOR window_popup AS #a
    opa=1
    #a.g, "when leftButtonDown [scannea]"
    #a.g, "down;fill blue;color white;backcolor blue"
    #a.g, "place 10 20 ;\"; "Premier"    : #a.g, "place 85 20 ;\"; ">"
    #a.g, "place 10 40 ;\"; "Second"     : #a.g, "place 85 40 ;\"; ">"
    #a.g, "place 10 60 ;\"; "Troisième"  : #a.g, "place 85 60 ;\"; ">"
    if sousMENU1 = 1 then
        #a.h, "down;fill blue;color yellow;backcolor blue"
        #a.h, "place 10 20 ;\"; "Bis 1"
        #a.h, "place 10 40 ;\"; "Bis 2"
        #a.h, "place 10 60 ;\"; "Bis 3"
        #a.h, "place 10 80 ;\"; "Bis 4"
    end if
    if sousMENU2 = 1 then
        #a.h, "down;fill blue;color yellow;backcolor blue"
        #a.h, "place 10 20 ;\"; "Bis 1"
        #a.h, "place 10 40 ;\"; "Bis 2"
        #a.h, "place 10 60 ;\"; "Bis 3"
        #a.h, "place 10 80 ;\"; "Bis 4"
    end if
    if sousMENU3 = 1 then
        #a.h, "down;fill blue;color yellow;backcolor blue"
        #a.h, "place 10 20 ;\"; "Bis 1"
        #a.h, "place 10 40 ;\"; "Bis 2"
        #a.h, "place 10 60 ;\"; "Bis 3"
        #a.h, "place 10 80 ;\"; "Bis 4"
    end if
    wait
 
 
   [scannea]
   bx=MouseX: by=MouseY
   sousMENU1 = 0 : sousMENU2 = 0 : sousMENU3 = 0
   if bx > 10 and bx < 95 and by > 7 and by < 22 then
        if opa=1 then opa=0: close #a
        sousMENU1= 1 : goto [a]
   end if
   if bx > 10 and bx < 95 and by > 27 and by < 42 then
        if opa=1 then opa=0: close #a
        sousMENU2= 1 : goto [a]
   end if
   if bx > 10 and bx < 95 and by > 47 and by < 62 then
        if opa=1 then opa=0: close #a
        sousMENU3= 1 : goto [a]
   end if
   wait
 
   [closeHelp]
   if opa=1 then opa=0: close #a
   CLOSE  #w
   END
 
 
____________________
Yo !

MSN Web    
Le 12/03/2021 à 19h55

Modérateur

Groupe: Modérateur

Inscrit le: 09/02/2015
Messages: 741
Pas si bricolage, et ça fait le job si on accepte de faire un clic gauche pour entrer dans le sous-menu, mais un vrai menu contextuel réagit automatiquement.

il faudrait voir si on peut faire avec des instructions graphiques : faire une sauvegarde de la portion de fenêtre masquée par le futur popupmenu, l'afficher, détecter l'entrée survolée par la souris, afficher le sous-menu correspondant, détecter l'entrée du sous-menu survolée par la souris lorsqu'on a cliqué gauche, remettre la capture d'écran initiale et lancer le sous-programme correspondant à l'entrée. il faudrait aussi être dans une fenêtre graphique, ce qui fait que la méthode ne sera pas universelle.

Ceci dit, ça semble simple, dit comme ça, mais rien que d'y penser j'ai un peu mal à la tête ;)
____________________
Just BASIC v2.0 :
  • utilisation courante avec GNU/Linux Mageia7+ Wine (Pas trouvé d'incohérences ou de bug de compilation à ce jour)
  • utilisation occasionnelle ou vérification/débugage difficile avec Windows XP sur un petit eeepc

   
Le 13/03/2021 à 02h08

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2489
Pour moi c'est encore plus simple; je ne vois aucun intérêt aux pop-menus, puisqu'on peut mettre cent et six sous menus aux menus courants.
D'ailleurs si quelqu'un pouvait me citer les avantages des pop-menus, je mourrais moins bête
____________________
Roro

   
Le 13/03/2021 à 19h24

Modérateur

Groupe: Modérateur

Inscrit le: 30/03/2011
Messages: 437
c'est joli :D
____________________
Yo !

MSN Web    
Le 16/03/2021 à 11h03

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2489
____________________
Roro

   

 |  |

1 Utilisateur en ligne : 0 Administrateur, 0 Modérateur, 0 Membre et 1 Visiteur
Utilisateur en ligne : Aucun membre connecté
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie