Menü bsp

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
Konne
Beiträge: 764
Registriert: 30.03.2005 02:20
Kontaktdaten:

Beitrag von Konne »

Meinte er sowas?

Code: Alles auswählen


Structure Items
  Name.s 
  Color.b
  Id.l
EndStructure

NewList Menu.Items()

Procedure CreateDOSMenu(Ueberschrift.s)
ClearConsole()
ConsoleCursor(0)

Breaken.s=Chr(13)+Chr(28)

PrintN(Ueberschrift.s)
PrintN("")

ForEach Menu()
  Elemente+1
  If Elemente=1
    ConsoleColor(Menu()\Color, 0)
    PrintN(Menu()\Name)
    ConsoleColor(7, 0)
  Else  
    PrintN(Menu()\Name)
  EndIf
Next

Repeat

OldWo=Wo
  Select Inkey()
    Case "ÿP"
      Wo+1      
            
    Case "ÿH"
      Wo-1
    
    Case Breaken.s
      ForEach Menu()
        If Wo = t
          ConsoleCursor(1)     
          ProcedureReturn Menu()\ID
        EndIf
        t+1
      Next

  EndSelect

  If OldWo<>Wo
    If Wo < 0
      Wo=Elemente-1
    ElseIf Wo > Elemente-1
      Wo=0
    EndIf
    
    ForEach Menu()  
      If t=Wo      
        ConsoleLocate(0, t+2)      
        ConsoleColor(Menu()\Color, 0)
        Print(Menu()\Name)
      ElseIf t = OldWo
        ConsoleLocate(0, t+2)      
        ConsoleColor(7, 0)
        Print(Menu()\Name)
      EndIf
      t+1
    Next
    t=0
  
    
  EndIf
Delay(1)  
ForEver

ProcedureReturn 1
EndProcedure

OpenConsole()

AddElement(Menu())
Menu()\Name="1 Zeile"
Menu()\Color=10
Menu()\ID=1

AddElement(Menu())
Menu()\Name="2 Zeile"
Menu()\Color=13
Menu()\ID=2

AddElement(Menu())
Menu()\Name="3 Zeile"
Menu()\Color=14
Menu()\ID=3

Debug CreateDOSMenu("Ueberschrift")
Benutzeravatar
FGK
Beiträge: 249
Registriert: 09.01.2005 14:02
Computerausstattung: i5-4430 CPU / 8GB RAM
GeForce GT630
Windows 10 Home / 64-bit
Wohnort: Augsburg

Beitrag von FGK »

@Konne

Ja genau so was in der Art meinte er wohl.

Gruß

FGK
Antworten