Seite 1 von 1

Eventabfrage

Verfasst: 19.11.2004 13:28
von BetMaster
Hallo,

ich bin neu hier, und habe bereits ein erstes Problem, dass ich nicht gelöst bekomme.
und zwar:

Code: Alles auswählen

;***********************************************

If LoadFont(0,"Trebuchet MS Fett",8) 
   SetGadgetFont(#PB_Default,FontID())   ; geladenen Arial 16 Zeichensatz als neuen Standard festlegen 
EndIf 


;- Window Constants
;
Enumeration
  #Window_0=2
EndEnumeration

;- Gadget Constants
;

Enumeration
  #Combo_0
  #ImageButton_1
  #ImageButton_2
  #ImageButton_3
  #ImageButton_4
  #ImageButton_5
  #ImageButton_6
  #Button_7
  #Button_8
  #checkbox_0 
  #Frame3D_0
  #Frame3D_1
  #Frame3D_2
  #Frame3D_3
  #Frame3D_4

  #Frame3D_5
  #Frame3D_6
  #Frame3D_7
  #Frame3D_8
  #Gadget_1
  #string_1
  #string_2
  #string_3
  #string_4
  #string_5
  #string_6
  #string_7
  #string_8
  #string_9
  #string_10
  #string_11
  #string_12
  #string_13
  #string_14
  #string_15
  #string_16
  #string_17

  #String_18
  #String_19
  #String_20
  #String_21
  #String_22
  #String_23
  #String_24

  #text_1
  #text_2
  #text_3
  #text_4
  #text_5
  #text_6
  #text_7
  #text_8
  #text_9
  #text_10
  #text_11
  #text_12
  #text_13
  #text_14
  #text_15
  #text_16

  #Text_17
  #Text_18
  #Text_19
  #Text_20
  #Text_21
  #Text_22
  #Text_23

EndEnumeration

If LoadImage(1,"resource\document_plain.ico") ; NEU
EndIf

If LoadImage(2,"resource\delete2.ico") ; ABBRUCH
EndIf
         
If LoadImage(3,"resource\disk_blue.ico") ; SPEICHERN
EndIf

If LoadImage(4,"resource\document_gear.ico") ; BEARBEITEN
EndIf

If LoadImage(5,"resource\exit.ico") ; VERLASSEN
EndIf

If LoadImage(6,"resource\garbage_empty.ico") ; LÖSCHEN
EndIf





If OpenWindow(#Window_0, 184, 39, 450, 418,  #PB_Window_SystemMenu | #PB_Window_TitleBar , "Mitarbeiterverwaltung")
       
   If CreateGadgetList(WindowID())
     
      lfdnr.l=0      
      ComboBoxGadget(#combo_0,15,20,225,100) 
 
     If InitDatabase()
      If OpenDatabase(1,"PureBasicDNS","","")
         array=DatabaseQuery("Select * from Mitarbeiter")
         While NextDatabaseRow()<>0
           loginnr$=GetDatabaseString(1)
            loginname$=GetDatabaseString(2)
            loginvname$=GetDatabaseString(3)
            loginuser$=loginnr$+" - "+loginname$+", "+loginvname$
           AddGadgetItem(#combo_0,lfdnr.l,loginuser$)
            lfdnr.l=lfdnr.l+1
         Wend
         CloseDatabase(1)
      EndIf
   EndIf
   SetGadgetState(#combo_0,0)    

            
 

; MENÜLEISTE 
      ;ButtonImageGadget(#ImageButton_1, 255, 20, 20, 23, UseImage(1)) ; NEU
      ;ButtonImageGadget(#ImageButton_4, 275, 20, 20, 23, UseImage(4)) ; BEARBEITEN
      ;ButtonImageGadget(#ImageButton_6, 295, 20, 20, 23, UseImage(6)) ; LÖSCHEN

      ;ButtonImageGadget(#ImageButton_5, 395, 20, 20, 23, UseImage(5)) ; VERLASSEN

      
      ;- Panel2004
      PanelGadget(#Gadget_1, 15, 55, 400, 345)
      ;CloseGadgetList()
      AddGadgetItem(#Gadget_1, -1, "Allgemein")      
       ;  ButtonImageGadget(#ImageButton_2, 370, 10, 20, 23, UseImage(2)) ; ABBRUCH
       ;  ButtonImageGadget(#ImageButton_3, 345, 10, 20, 23, UseImage(3)) ; SPEICHERN
       ;  DisableGadget(#ImageButton_2,1)
       ;  DisableGadget(#ImageButton_3,1)
         
         Frame3DGadget(#Frame3D_1, 10, 0, 300, 145, "")
         TextGadget(#Text_1, 15, 15, 60, 15, "Nummer:")
         TextGadget(#Text_4, 15, 35, 60, 15, "Name:")
         TextGadget(#Text_5, 15, 55, 60, 15, "Vorname:")
         TextGadget(#Text_6, 15, 75, 60, 15, "Straße:")
         TextGadget(#Text_7, 15, 95, 60, 15, "PLZ:")
         TextGadget(#Text_8, 15, 115, 60, 15, "Ort:")
         StringGadget(#String_1, 80, 15, 40, 20, "")  ; MI-NR
         StringGadget(#String_4, 80, 35, 220, 20, "") ; NAME
         StringGadget(#String_5, 80, 55, 220, 20, "") ; VNAME
         StringGadget(#String_6, 80, 75, 220, 20, "") ; STRAßE
         StringGadget(#String_7, 80, 95, 55, 20, "") ; PLZ
         StringGadget(#String_8, 80, 115, 220, 20, "") ; ORT

         Frame3DGadget(#Frame3D_0, 10, 145, 300, 80, "")
         TextGadget(#Text_9, 15, 160, 65, 15, "Festnetz:")
         TextGadget(#Text_10, 15, 180, 65, 15, "Mobil:")
         TextGadget(#Text_11, 15, 200, 65, 15, "Firma:")
         StringGadget(#String_9, 80, 160, 105, 20, "") ; FESTNETZ
         StringGadget(#String_10, 80, 180, 105, 20, "") ; MOBIL
         StringGadget(#String_11, 80, 200, 105, 20, "") ; FIRMA
         
         Frame3DGadget(#Frame3D_2, 10, 225, 300, 65, "")
         TextGadget(#Text_2, 15, 240, 115, 20, "Erfassungsdatum:")
         TextGadget(#Text_3, 15, 260, 115, 20, "Letzte Änderung:")
         StringGadget(#String_2, 120, 240, 70, 20, "") : DisableGadget(#string_2,1); ERFASSUNGSDATUM
         StringGadget(#String_3, 120, 260, 70, 20, "") : DisableGadget(#string_3,1); LETZTE ÄNDERUNG

; Begrenzung für die Textfelder festlegen
         SendMessage_(GadgetID(#String_1), #EM_LIMITTEXT, 4, 0)
         SendMessage_(GadgetID(#String_4), #EM_LIMITTEXT, 30, 0) ; NAME
         SendMessage_(GadgetID(#String_5), #EM_LIMITTEXT, 30, 0) ; VNAME
         SendMessage_(GadgetID(#String_6), #EM_LIMITTEXT, 30, 0) ; STRAßE
         SendMessage_(GadgetID(#String_7), #EM_LIMITTEXT, 5, 0) ; PLZ
         SendMessage_(GadgetID(#String_8), #EM_LIMITTEXT, 30, 0) ; ORT
         SendMessage_(GadgetID(#String_2), #EM_LIMITTEXT, 10, 0) ; ERFASSUNGSDATUM
         SendMessage_(GadgetID(#String_3), #EM_LIMITTEXT, 10, 0)
         SendMessage_(GadgetID(#String_9), #EM_LIMITTEXT, 12, 0) ;FESTNETZ
         SendMessage_(GadgetID(#String_10), #EM_LIMITTEXT, 12, 0); MOBIL
         SendMessage_(GadgetID(#String_11), #EM_LIMITTEXT, 12, 0); FIRMA
         
      AddGadgetItem(#gadget_1, -1, "Intern")
         TextGadget(#Text_12, 18, 38, 40, 15, "Eintritt:")
         TextGadget(#Text_13, 193, 38, 45, 15, "Austritt:")
         TextGadget(#Text_14, 8, 93, 40, 15, "Kürzel:")
         TextGadget(#Text_15, 133, 103, 65, 15, "Ersteingabe:")
         TextGadget(#Text_16, 133, 128, 55, 15, "Kontrolle:")
    
         StringGadget(#String_13, 65, 33, 90, 20, "") ; EINTRITT
         StringGadget(#String_14, 245, 33, 90, 20, "") ; AUSTRITT
         StringGadget(#String_15, 53, 88, 40, 20, "") ; KÜRZEL
         StringGadget(#String_16, 208, 98, 90, 20, "",#PB_String_Password) ; ERSTEINGABE
         StringGadget(#String_17, 208, 123, 90, 20, "",#PB_String_Password) ; KONTROLLE
          
         CheckBoxGadget(#CheckBox_0, 8, 128, 100, 20, "Provisionsfähig") 
         Frame3DGadget(#Frame3D_3, 8, 13, 343, 50, "Beschäftigung")
         Frame3DGadget(#Frame3D_4, 123, 83, 228, 65, "Passwort")

; Begrenzung für die Textfelder festlegen
         SendMessage_(GadgetID(#String_13), #EM_LIMITTEXT, 10, 0)
         SendMessage_(GadgetID(#String_14), #EM_LIMITTEXT, 10, 0)
         SendMessage_(GadgetID(#String_15), #EM_LIMITTEXT, 4, 0)
         SendMessage_(GadgetID(#String_16), #EM_LIMITTEXT, 10, 0)
         SendMessage_(GadgetID(#String_17), #EM_LIMITTEXT, 10, 0)
  
      
      AddGadgetItem(#Gadget_1, -1, "Organisation")
         TextGadget(#Text_17, 23, 33, 140, 20, "zuletzt teilgenommen am:")
         TextGadget(#Text_18, 23, 93, 140, 20, "zuletzt kontrolliert:")
         TextGadget(#Text_19, 23, 153, 140, 20, "zuletzt angewiesen:")
         TextGadget(#Text_20, 23, 253, 55, 20, "zuletzt am:")
         TextGadget(#Text_21, 23, 173, 45, 20, "Revision:")
         TextGadget(#Text_22, 23, 193, 45, 20, "vom:")
         TextGadget(#Text_23, 23, 273, 55, 20, "Befund:")
         
         StringGadget(#String_18, 168, 33, 90, 20, "  .  .    " , #PB_String_Multiline)
         
         StringGadget(#String_19, 168, 93, 90, 20, "2")
         StringGadget(#String_20, 168, 153, 90, 20, "3")  
         StringGadget(#String_21, 168, 253, 90, 20, "4")
         StringGadget(#String_22, 168, 193, 90, 20, "5")
         StringGadget(#String_23, 168, 173, 50, 20, "6")
         StringGadget(#String_24, 168, 273, 90, 20, "7")
      
; Begrenzung für die Textfelder festlegen
         SendMessage_(GadgetID(#String_18), #EM_LIMITTEXT, 10, 0)
         SendMessage_(GadgetID(#String_19), #EM_LIMITTEXT, 10, 0)
         SendMessage_(GadgetID(#String_20), #EM_LIMITTEXT, 10, 0)
         SendMessage_(GadgetID(#String_21), #EM_LIMITTEXT, 10, 0)
         SendMessage_(GadgetID(#String_22), #EM_LIMITTEXT, 10, 0)
         SendMessage_(GadgetID(#String_23), #EM_LIMITTEXT, 5, 0)
         SendMessage_(GadgetID(#String_24), #EM_LIMITTEXT, 100, 0)

         Frame3DGadget(#Frame3D_5, 13, 13, 350, 50, "Erste-Hilfe Lehrgang")
         Frame3DGadget(#Frame3D_6, 13, 73, 350, 50, "Führerschein")
         Frame3DGadget(#Frame3D_7, 13, 133, 350, 90, "Betriebsanweisung")
         Frame3DGadget(#Frame3D_8, 13, 233, 350, 65, "Untersuchung")
      
    EndIf
  EndIf
          

Repeat
     EventID.l = WaitWindowEvent()

     If EventID = #PB_Eventgadget
        Select EventGadgetID()
                    
          Case #String_18
             Debug "HIER"
             
        EndSelect
     EndIf
   

   If EventGadgetID()=#ImageButton_5
      End
   EndIf
       

Until WaitWindowEvent()=#PB_EventCloseWindow
bei diesem Code geht es mir darum, daß ich den Moment abfangen kann, indem der Benutzer auf des Stringgadget #String_18 klickt. Dann soll nämlich der gesamte Inhalt markiert werden.
Problem ist, die Schleife fängt nicht jeden Klick auf String_18 ab.

Weiß jemand woran das liegt?

Gruß
Dirk

EDIT by freedimension: hab mal Codetags hinzugefügt

Verfasst: 19.11.2004 13:47
von Lebostein
Hm, kann sein dass du Probleme bekommst, weil du in deiner Hauptschleife 2 mal WaitWindowEvent() drin hast und dein Programm 2 mal pro 'Runde' auf ein Ereignis wartet.

Verfasst: 19.11.2004 14:00
von MLK
tausch mal deine hauptschleife gegen diese aus:

Code: Alles auswählen

Repeat 
    Select WaitWindowEvent() 
        Case #PB_Event_Gadget
            Select EventGadgetID() 
                Case #String_18 
                    Debug "HIER"
                Case #ImageButton_5
                    ;...
            EndSelect
        Case #PB_Event_Menu
            Select EventMenuID()
                ;case ...
            EndSelect
        Case #PB_Event_CloseWindow
            Break 
    EndSelect    
ForEver

Re: Eventabfrage

Verfasst: 19.11.2004 14:00
von BetMaster
Tausend Dank,

Code: Alles auswählen

[quote="BetMaster"]

.....
Repeat
     EventID.l = WaitWindowEvent()

     If EventID = #PB_Eventgadget
        Select EventGadgetID()
                    
          Case #String_18
             Debug "HIER"
             
        EndSelect
     EndIf
   

   If EventGadgetID()=#ImageButton_5
      End
   EndIf
       

Until WaitWindowEvent()=#PB_EventCloseWindow
bei Until WaitWindowEvent()=#PB_EventCloseWindow liegt der Fehler. Ersetzt man hier das 2. WaitwindowEvent() mit EventID funktioniert es wunderbar.

*megafreu*