Problem mit SetGadgetText

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
GreyEnt
Beiträge: 376
Registriert: 20.07.2006 19:41

Problem mit SetGadgetText

Beitrag von GreyEnt »

Hallo NG,
ich habe ein Problem mit SetGadgetText.
Und zwar werden folgende Werte in den Stringgadgets garnicht angezeigt.
bzw. bleibt der Vorgabetext in meinem Fall "#"
SetGadgetText(103,Str(koordx))
SetGadgetText(105,Str(koordy))

Komischerweise funktionieren die anweisungen in einer anderen schleife tadellos.
Gibt es evtl. etwas zu beachten? Bin ganz ratlos weil es eigentlich nicht zum falschmachen gibt. :)

MfG
Dieter
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Beitrag von ts-soft »

Ein bissel mehr Code ist wohl erforderlich. Nach Möglichkeit soviel, das der Fehler reproduzierbar ist.
Wie sieht Deine Eventschleife aus?
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Benutzeravatar
GreyEnt
Beiträge: 376
Registriert: 20.07.2006 19:41

Hi TS SOFT

Beitrag von GreyEnt »

Ich stell mal den gesammten Code rein.
Wie kann ich den den Code als Code markieren?
Oder einfach so ins Fenster reinkopieren?

Danke schonmal?
[/code]
Benutzeravatar
edel
Beiträge: 3667
Registriert: 28.07.2005 12:39
Computerausstattung: GameBoy
Kontaktdaten:

Beitrag von edel »

Code: Alles auswählen

[code]
quellcode
[/code]
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Beitrag von ts-soft »

code in brackets zu anfang und /code in brackets am ende :wink:
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Benutzeravatar
GreyEnt
Beiträge: 376
Registriert: 20.07.2006 19:41

Hier der Code

Beitrag von GreyEnt »

Das fragwürdige liegt in Zeile 655.
Das Programm ist noch nicht fertig. Wird es wohl auch nie. :)
Wenn auf Linie geklickt wird sollte man im Zeichenbereich eine Linie durch Startpunkt und Endpunkt definieren.
Die Koordinaten hätte ich gerne rechts in den StringGadGet angezeigt.
Und dort liegt das Problem.

Wenn man sich über einer vorhanden linie bewegt werden ebenfalls die Eigenschaften der Linien angezeigt. Dies klappt schon ganz gut.

Danke euch.

Code: Alles auswählen

;
; ------------------------------------------------------------
;
;   VARICAD
;   xy-CAD
;   Geometrie Editor
;   The Incredible CAD
;   PureXY CAD
;
;   geschrieben in PureBasic 3.92
;   Juni 2006
;   von Dieter Platzke
;   platzke@muenster.de
;
; ------------------------------------------------------------
;
Global pi.f
Global winkelgrad.f
Global quit.b
Global anzeigex1.l
Global anzeigey1.l
Global anzeigex2.l
Global anzeigey2.l
Global ladedatei$
Global aktivelement.l
Global mission.s


mission=""
pi=3.14159265
winkelgrad=pi/180
quit=0
anzeigex1.l=400
anzeigey1=300
anzeigex2.l=800
anzeigey2=600
gz.l=160    ;Zeile für freie gadgets
aobjekt.l=0 ;Aktuelles Objekt für Eigenschaftsfenster
farbe.l=0
cursorblau.l=0
cursorgruen.l=0
cursorrot.l=0
mcount=0
findencount.l=0

Structure bogen
  zentrumx.f
  zentrumy.f
  radius.f
  startwinkel.f
  endwinkel.f
EndStructure
Structure kreis
  zentrumx.f
  zentrumy.f
  radius.f
EndStructure
Structure linie
  startx.f
  starty.f
  endx.f
  endy.f
EndStructure
Structure punkt
  x.f
  y.f  
EndStructure
Structure dreieck
  startx.f
  starty.f
  liniec.f
  liniea.f
  linieb.f
EndStructure
Structure vieleck
  zentrumx.f
  zentrumy.f
  kantenzahl.w
  kantenlaenge.f
EndStructure
Structure elipse
  zentrumx.f
  zentrumy.f
  radius1.f
  radius2.f
EndStructure
Structure limiten ;ohne Funktion
limxmin.f
limxmax.f
limymin.f
limymax.f
EndStructure
Structure gummiband ;ohne Funktion
  x.f
  y.f  
EndStructure

Global NewList bo.bogen()
Global NewList kr.kreis()
Global NewList li.linie()
Global NewList pu.punkt()
Global NewList dr.dreieck()
Global NewList vi.vieleck()
Global NewList el.elipse()
Global NewList lim.limiten()
Global NewList gummiband.linie()
AddElement(li())
li()\startx=0
li()\starty=0
li()\endx=50
li()\endy=0


Procedure fegen()
StartDrawing(WindowOutput(0))
FrontColor(RGB(255,255,255))
Box(108,28,WindowWidth(0)-300,WindowHeight(0)-68)
FrontColor(RGB(212,208,200))
Box(109,29,WindowWidth(0)-302,WindowHeight(0)-70)
StopDrawing()
EndProcedure
Procedure limiten()
;FirstElement(lim())
FirstElement(kr())
If CountList(kr())>0
xmin.f=kr()\zentrumx-kr()\radius
xmax.f=kr()\zentrumx+kr()\radius
ymin.f=kr()\zentrumy-kr()\radius
ymax.f=kr()\zentrumy+kr()\radius
ForEach kr()
If kr()\zentrumx-kr()\radius<xmin
xmin=kr()\zentrumx-kr()\radius
EndIf
If kr()\zentrumx+kr()\radius>xmax
xmax=kr()\zentrumx+kr()\radius
EndIf
If kr()\zentrumy-kr()\radius<ymin
ymin=kr()\zentrumy-kr()\radius
EndIf
If kr()\zentrumy+kr()\radius>ymax
ymax=kr()\zentrumx+kr()\radius
EndIf
Next
EndIf

If CountList(bo())>0
ForEach bo()
If bo()\zentrumx-bo()\radius<xmin
xmin=bo()\zentrumx-bo()\radius
EndIf
If bo()\zentrumx+bo()\radius>xmax
xmax=bo()\zentrumx+bo()\radius
EndIf
If bo()\zentrumy-bo()\radius<ymin
ymin=bo()\zentrumy-bo()\radius
EndIf
If bo()\zentrumy+bo()\radius>ymax
ymax=bo()\zentrumx+bo()\radius
EndIf
Next
EndIf

If CountList(li())>0
ForEach li()
If li()\startx<xmin
xmin=li()\startx
EndIf
If li()\endx>xmax
xmax=li()\endx
EndIf
If li()\starty<ymin
ymin=li()\starty
EndIf
If li()\endy>ymax
ymax=li()\endy
EndIf
Next
EndIf

Debug("xmin"+StrF(xmin))
Debug("xmax"+StrF(xmax))
Debug("ymin"+StrF(ymin))
Debug("ymax"+StrF(ymax))
Debug("Linien "+Str(CountList(li())))
Debug("Bogen "+Str(CountList(bo())))
Debug("Kreise "+Str(CountList(kr())))

EndProcedure
Procedure bogenzeichnen()
winkel1.f=bo()\endwinkel-bo()\startwinkel
If bo()\startwinkel<bo()\endwinkel
bogenwinkel.f=winkel1       ; Der Bogenwinkel ist der Winkel zwischen Startwinkel und Endwinkel
Else
bogenwinkel.f=360+winkel1
EndIf
koordx1.f = bo()\zentrumx + anzeigex1 +Cos(winkelgrad*bo()\startwinkel)*bo()\radius
koordx2.f = koordx1
koordy1.f = -bo()\zentrumy + anzeigey1 -Sin(winkelgrad*bo()\startwinkel)*bo()\radius
koordy2.f = koordy1
a.f=bo()\startwinkel
While a<bo()\startwinkel+bogenwinkel
koordx1 = bo()\zentrumx + anzeigex1 +Cos(winkelgrad*a)*bo()\radius
koordy1 = -bo()\zentrumy + anzeigey1 -Sin(winkelgrad*a)*bo()\radius
LineXY(koordx1,koordy1,koordx2,koordy2)
koordx2 = koordx1
koordy2 = koordy1
a=a+1
Wend
EndProcedure
Procedure kreiszeichnen()
a.f = 0
  koordx1.l = kr()\zentrumx + anzeigex1 + Cos(winkelgrad*a)*kr()\radius
  koordx2.l = koordx1.l
  koordy1.l = -kr()\zentrumy + anzeigey1 + Sin(winkelgrad*a)*kr()\radius
  koordy2.l = koordy1.l
  Repeat
  koordx1 = kr()\zentrumx + anzeigex1 + Cos(winkelgrad*a)*kr()\radius
  koordy1 = -kr()\zentrumy + anzeigey1 + Sin(winkelgrad*a)*kr()\radius
  LineXY(koordx1,koordy1,koordx2,koordy2)
  koordx2.l = koordx1.l
  koordy2.l = koordy1.l
  a=a+1
  Until a>360
EndProcedure
Procedure liniezeichnen()
startx.f=li()\startx + anzeigex1
starty.f=anzeigey1 - li()\starty
endx.f=li()\endx + anzeigex1
endy.f=anzeigey1 - li()\endy
LineXY(startx,starty,endx,endy)
EndProcedure
Procedure dxflesen()
ReadFile(1,ladedatei$)
Repeat
  a$=ReadString(1)
  Select a$
      Case "ARC"
      bozaehler=bozaehler+1
      AddElement(bo())
       box:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto box
       EndIf
       bo()\zentrumx = ValF(b$)
       boy:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto boy
       EndIf
       bo()\zentrumy = ValF(b$)
       boz:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto boz
       EndIf
       bor:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto bor
       EndIf
       bo()\radius = ValF(b$)
       bosw:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto bosw
       EndIf
       bo()\startwinkel = ValF(b$)
       boew:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto boew
       EndIf
       bo()\endwinkel = ValF(b$)
       
      Case "LINE"
      lizaehler=lizaehler+1
       AddElement(li())
       lisx:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto lisx
       EndIf
       li()\startx = ValF(b$)
       lisy:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto lisy
       EndIf
       li()\starty = ValF(b$)
       liz:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto liz
       EndIf
       liex:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto liex
       EndIf
       li()\endx = ValF(b$)
       liey:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto liey
       EndIf
       li()\endy = ValF(b$)
       
      Case "CIRCLE"
      krzaehler=krzaehler+1
       AddElement(kr())
       krxlesen:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto krxlesen
       EndIf
       kr()\zentrumx = ValF(b$)
       krylesen:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto krylesen
       EndIf
       kr()\zentrumy = ValF(b$)
       krzlesen:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto krzlesen
       EndIf
       krradiuslesen:
       b$ = ReadString(1)
       If FindString(b$,".",1)=0
        Goto krradiuslesen
       EndIf
       kr()\radius = ValF(b$)
  EndSelect
 Until a$="EOF"
CloseFile(1)
limiten()
EndProcedure

OpenWindow(0, 20, 20, 800, 600,"Pure XY Editor", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget)


  ;
  ; This is the 'event loop'. All the user actions are processed here.
  ; It's very easy to understand: when an action occurs, the EventID
  ; isn't 0 and we just have to see what have happened...
  ;
  ;AddKeyboardShortcut(0,#PB_ShortCut_B, 1)
  CreateStatusBar(0, WindowID(0))
    AddStatusBarField(200)
    AddStatusBarField(200)
    AddStatusBarField(50)
    AddStatusBarField(50)
  
  StatusBarText(0, 0, "Area 1")
  StatusBarText(0, 1, "Area 2", #PB_StatusBar_BorderLess)
  StatusBarText(0, 2, "Area 3", #PB_StatusBar_Right | #PB_StatusBar_Raised)
  StatusBarText(0, 3, "Area 3", #PB_StatusBar_Right | #PB_StatusBar_Raised) 

  CreateToolBar(0, WindowID(0)) 
    ToolBarStandardButton(0,#PB_ToolBarIcon_New) 
    ToolBarStandardButton(1,#PB_ToolBarIcon_Open) 
    ToolBarStandardButton(2,#PB_ToolBarIcon_Save)
    ToolBarStandardButton(3,#PB_ToolBarIcon_Print)
    ToolBarStandardButton(4,#PB_ToolBarIcon_Find)
    ToolBarStandardButton(5,#PB_ToolBarIcon_Replace)
    ToolBarStandardButton(6,#PB_ToolBarIcon_Cut)
    ToolBarStandardButton(7,#PB_ToolBarIcon_Copy) 
    ToolBarStandardButton(8,#PB_ToolBarIcon_Paste) 
    ToolBarStandardButton(9,#PB_ToolBarIcon_Undo)
    ToolBarStandardButton(10,#PB_ToolBarIcon_Redo) 
    ToolBarStandardButton(11,#PB_ToolBarIcon_Delete)
    ToolBarStandardButton(12,#PB_ToolBarIcon_Properties)
    ToolBarStandardButton(13,#PB_ToolBarIcon_Help)
    
  CreateMenu(0, WindowID(0))
    MenuTitle("Datei")
    MenuItem(0,"Neu")
    MenuItem(1,"Öffnen")
    MenuItem(2,"Sichern")
    MenuBar()
    MenuItem(14,"Schließen")
    MenuTitle("Skizzieren")
    MenuItem(15,"Linie")
    MenuItem(16,"Kreis")  
    MenuTitle("?")
    MenuItem(17,"Info")
  
  CreateGadgetList(WindowID(0))
    ButtonGadget(1, 1, 25,106,25, "Neuzeichnen")
    ButtonGadget(2, 1, 50,106,25, "Programm beenden")
    ButtonGadget(3, 1, 75,106,25, "Neuer Bogen")
    ButtonGadget(16,1,100,106,25, "Neuer Kreis")
    ButtonGadget(17,1,125,106,25, "Neue Linie")
    TextGadget(100,WindowWidth(0)-140,10, 50, 19, "#")
      StringGadget(101,WindowWidth(0)-90 ,10, 80, 19,"#")
    TextGadget(102,WindowWidth(0)-140,30, 50, 19, "#")
      StringGadget(103,WindowWidth(0)-90 ,30, 80, 19,"#")
    TextGadget(104,WindowWidth(0)-140,50, 50, 19, "#")
      StringGadget(105,WindowWidth(0)-90 ,50, 80, 19,"#")
    TextGadget(106,WindowWidth(0)-140,70, 50, 19, "#")
      StringGadget(107,WindowWidth(0)-90 ,70, 80, 19,"#")
    TextGadget(108,WindowWidth(0)-140,90, 50, 19, "#")
      StringGadget(109,WindowWidth(0)-90 ,90, 80, 19,"#")
    TextGadget(110,WindowWidth(0)-140,110, 50, 19, "#")
      StringGadget(111,WindowWidth(0)-90 ,110, 80, 19,"#")
    TextGadget(112,WindowWidth(0)-140,130, 50, 19, "#")
      StringGadget(113,WindowWidth(0)-90 ,130, 80, 19,"#")
    TextGadget(114,WindowWidth(0)-140,150, 50, 19, "#")
      StringGadget(115,WindowWidth(0)-90 ,150, 80, 19,"#")
    TextGadget(116,WindowWidth(0)-140,170, 50, 19, "#")
      StringGadget(117,WindowWidth(0)-90 ,170, 80, 19,"#")
    TextGadget(118,WindowWidth(0)-140,190, 50, 19, "#")
      StringGadget(119,WindowWidth(0)-90 ,190, 80, 19,"#")
    
  
  AddKeyboardShortcut(0,#PB_Shortcut_Up, 20)    ;Tasten für PAN
  AddKeyboardShortcut(0,#PB_Shortcut_Down, 21)  ;     -||-
  AddKeyboardShortcut(0,#PB_Shortcut_Left, 22)  ;     -||-
  AddKeyboardShortcut(0,#PB_Shortcut_Right, 23) ;     -||-
  
  fegen()
  zbx1.l=109                ;Zeichenbereich festlegen
  zby1.l=29
  zbx2.l=WindowWidth(0)-195
  zby2.l=WindowHeight(0)-40
  Gosub SomeGraphics
  
Repeat
Ereignis = WaitWindowEvent()
  
Select Ereignis

Case #PB_Event_CloseWindow
quit = 1

Case #PB_Event_Gadget
 Select EventGadget()
  Case 1
  Gosub SomeGraphics
  Case 2
  quit = 1
  Case 3 ;Eingabe neuer Bogen
      CreateGadgetList(WindowID(0))
      StringGadget(5, 1, gz, 50, 19, "200")
      StringGadget(6, 1, gz+20, 50, 19, "200")
      StringGadget(7, 1, gz+40, 50, 19, "150")
      StringGadget(8, 1, gz+60, 50, 19, "0")
      StringGadget(9, 1, gz+80, 50, 19, "60")
      TextGadget(10, 55, gz, 50 , 19,"Zentr.X")
      TextGadget(11, 55, gz+20, 50 , 19,"Zentr.Y")
      TextGadget(12, 55, gz+40, 50 , 19,"Radius")
      TextGadget(13, 55, gz+60, 50 , 19,"S.Winkel")
      TextGadget(14, 55, gz+80, 50 , 19,"E.Winkel")
      ButtonGadget(15, 1, gz+100, 106, 25, " OK ")
  Case 15 ;ok neuer Bogen
      AddElement(bo())
      bo()\zentrumx = ValF(GetGadgetText(5))
      bo()\zentrumy = ValF(GetGadgetText(6))
      bo()\radius = ValF(GetGadgetText(7))
      bo()\startwinkel = ValF(GetGadgetText(8))
      bo()\endwinkel = ValF(GetGadgetText(9))
      For a.b=5 To 15
      FreeGadget(a)
      Next a
      Gosub SomeGraphics
  Case 16 ;Eingabe neuer Kreis
      CreateGadgetList(WindowID(0))
      StringGadget(5, 1, gz, 50, 19, "200")
      StringGadget(6, 1, gz+20, 50, 19, "200")
      StringGadget(7, 1, gz+40, 50, 19, "150")
      TextGadget(8, 55, gz, 50 , 19,"Zentr.X")
      TextGadget(9, 55, gz+20, 50 , 19,"Zentr.Y")
      TextGadget(10, 55, gz+40, 50 , 19,"Radius")
      ButtonGadget(11, 1, gz+60, 106, 25, " OK ")
  Case 11 ;ok neuer Kreis
      AddElement(kr())
      kr()\zentrumx = ValF(GetGadgetText(5))
      kr()\zentrumy = ValF(GetGadgetText(6))
      kr()\radius = ValF(GetGadgetText(7))
      For a.b=5 To 11
      FreeGadget(a)
      Next a
      Gosub SomeGraphics
  Case 17 ;Eingabe neue Linie
    mission="linie s"
    SetGadgetText(100,"Linie")
    SetGadgetText(101,Str(CountList(li())))
    SetGadgetText(102,"SX")
    SetGadgetText(104,"SY")
    
  Case 103
  ;SelectElement(li(), findencount)
  ;li()\startx=ValF(GetGadgetText(103))
  ;mission=""
    
  EndSelect ;Ende Case #pb_event_gadget
  
 Case #PB_Event_Menu
 Select EventMenu()
    Case 0                  ; Elemente Löschen
    ClearList(bo())
    ClearList(kr())
    ClearList(li())
    fegen()
    SetWindowTitle(0,"VARICAD-"+"Neu")
    
    Case 1                  ; Fenster für Laden
    LastElement(bo())
    LastElement(kr())
    LastElement(li())
    ladedatei$ = OpenFileRequester("Laden","c:\test.cad","CAD-Dateien|*.cad;*.dxf",0)
    If Right(ladedatei$,3)="dxf"
    dxflesen()
    EndIf
    If Right(ladedatei$,3)="cad"
     ReadFile(1,ladedatei$)
     Repeat
     a$=ReadString(1)
     Select a$
      Case "Bogen"
      AddElement(bo())
      bo()\zentrumx = ValF(ReadString(1))
      bo()\zentrumy = ValF(ReadString(1))
      bo()\radius = ValF(ReadString(1))
      bo()\startwinkel = ValF(ReadString(1))
      bo()\endwinkel = ValF(ReadString(1))
      Case "Kreis"
      AddElement(kr())
      kr()\zentrumx = ValF(ReadString(1))
      kr()\zentrumy = ValF(ReadString(1))
      kr()\radius = ValF(ReadString(1))
      Case "Linie"
      AddElement(li())
      li()\startx = ValF(ReadString(1))
      li()\starty = ValF(ReadString(1))
      li()\endx = ValF(ReadString(1))
      li()\endy = ValF(ReadString(1))
     EndSelect
     Until a$=""
     CloseFile(1)
    EndIf
    Gosub SomeGraphics:
    SetWindowTitle(0,"VARICAD-"+ ladedatei$)
    limiten()
 
    Case 2; Fenster für Sichern
     savedatei$ = SaveFileRequester("Sichern","c:\test.cad","CAD-Dateien|*.cad",0)
     namedatei$=GetFilePart(savedatei$)
     OpenFile(1,savedatei$)
      ForEach bo()
      WriteStringN(1,"Bogen");hier bogen in Datei schreiben
      WriteStringN(1,StrF(bo()\zentrumx))
      WriteStringN(1,StrF(bo()\zentrumy))
      WriteStringN(1,StrF(bo()\radius))
      WriteStringN(1,StrF(bo()\startwinkel))
      WriteStringN(1,StrF(bo()\endwinkel))
      Next
      ForEach kr()
      WriteStringN(1,"Kreis");hier kreis in Datei schreiben
      WriteStringN(1,StrF(kr()\zentrumx))
      WriteStringN(1,StrF(kr()\zentrumy))
      WriteStringN(1,StrF(kr()\radius))
      Next
      ForEach li()
      WriteStringN(1,"Linie");hier linie in Datei schreiben
      WriteStringN(1,StrF(li()\startx))
      WriteStringN(1,StrF(li()\starty))
      WriteStringN(1,StrF(li()\endx))
      WriteStringN(1,StrF(li()\endy))
      Next
      CloseFile(1)
      SetWindowTitle(0,"VARICAD-"+ savedatei$)
      
    Case 20
    anzeigey1=anzeigey1-10
    fegen()
    Gosub somegraphics
    Case 21
    anzeigey1=anzeigey1+10
    fegen()
    Gosub somegraphics
    Case 22
    anzeigex1=anzeigex1-10
    fegen()
    Gosub somegraphics
    Case 23
    anzeigex1=anzeigex1+10
    fegen()
    Gosub somegraphics
       
    EndSelect ;Ende Event_Menu
    EndSelect ;Ende Ereignis
    
    StartDrawing(WindowOutput(0))
    cursorblau= Blue(Point(WindowMouseX(0),WindowMouseY(0)))
    cursorgruen=Green(Point(WindowMouseX(0),WindowMouseY(0)))
    cursorrot=Red(Point(WindowMouseX(0),WindowMouseY(0)))
    StopDrawing()
    koordx.l=WindowMouseX(0)-anzeigex1 : koordy.l=anzeigey1-WindowMouseY(0)
    StatusBarText(0,0,"X: "+Str(koordx)+"/ Y: "+Str(koordy))
    StatusBarText(0,1,Str(cursorrot)+" "+Str(cursorgruen)+" "+Str(cursorblau))
    StatusBarText(0,3,mission)
    
    If WindowMouseX(0)>zbx1 And WindowMouseX(0)<zbx2 And WindowMouseY(0)>zby1 And WindowMouseY(0)<zby2
    zb.s="ja"
    Else
    zb.s="nein"
    EndIf
    StatusBarText(0,2,"ZB="+zb)
    
    lk=GetAsyncKeyState_(#VK_LBUTTON) ;Linke Mausklickabfrage
    
    Select mission
    Case "linie e"
    ;SetGadgetText(106,"EX")
    ;SetGadgetText(107,Str(koordx))
    ;SetGadgetText(108,"EY")
    ;SetGadgetText(109,Str(koordy))
     ;Gummiband zeichnen
    gaendx.f = gnendx.f
    gaendy.f = gnendy.f
    gnstartx.f = lnstartx.f + anzeigex1
    gnstarty.f = anzeigey1 - lnstarty.f
    gnendx.f = koordx + anzeigex1
    gnendy.f = anzeigey1 - koordy
      If gaendx <> gnendx Or gaendy <> gnendy
      fegen()
      Gosub SomeGraphics
      StartDrawing(WindowOutput(0))
      FrontColor(RGB(0,255,0))
      LineXY(gnstartx,gnstarty,gnendx,gnendy)
      FrontColor(RGB(0,0,0))
      StopDrawing()
      EndIf
    
    If lk And mcount=0
    LastElement(li())
    AddElement(li())
    li()\startx=lnstartx
    li()\starty=lnstarty
    li()\endx=koordx
    li()\endy=koordy
    StartDrawing(WindowOutput(0))
    FrontColor(RGB(0,0,255))
    liniezeichnen()
    StopDrawing()
    mission=""
    lk=0
    mcount=100
    EndIf
    
    Case "linie s"
    SetGadgetText(103,Str(koordx))
    SetGadgetText(105,Str(koordy))
    If lk And mcount=0
    lnstartx.f=koordx
    lnstarty.f=koordy
    mission="linie e"
    lk=0
    mcount=100
    EndIf
        
    EndSelect ;select mission
    
    
    If cursorrot <> 212 And mission="" And zb="ja" ;Block zum finden des ausgewählten Objektes
    SelectElement(li(), findencount)
    StartDrawing(WindowOutput(0))
    FrontColor(RGB(253,0,0))
    liniezeichnen()
    cursorrot=Red(Point(WindowMouseX(0),WindowMouseY(0)))
    If cursorrot = 253
    StopDrawing()
    Goto endblock
    Else
    FrontColor(RGB(0,0,0))
    liniezeichnen()
    EndIf
    StopDrawing()
    findencount=findencount+1
    If findencount> CountList(li())
    findencount=0
    EndIf
    EndIf
    endblock:
    
    If cursorrot <> 212 And mission="" And zb="ja"
    SetGadgetText(100,"Linie")
    SetGadgetText(101,Str(findencount))
    SetGadgetText(102,"SX")
    SetGadgetText(103,StrF(li()\startx))
    SetGadgetText(104,"SY")
    SetGadgetText(105,StrF(li()\starty))
    SetGadgetText(106,"EX")
    SetGadgetText(107,StrF(li()\endx))
    SetGadgetText(108,"EY")
    SetGadgetText(109,StrF(li()\endy))
    SetGadgetText(110,"Länge")
    SetGadgetText(111, StrF(Sqr( Pow(li()\startx-li()\endx,2)+Pow(li()\starty-li()\endy,2) )))
    deltax.f=li()\startx-li()\endx
    SetGadgetText(112,"deltaX")
    SetGadgetText(113,StrF(deltax))
    deltay.f=li()\starty-li()\endy
    SetGadgetText(114,"deltaY")
    SetGadgetText(115,StrF(deltay))
    steigung.f=deltay/deltax
    SetGadgetText(116,"Steigung")
    SetGadgetText(117,StrF(steigung))
    winkel.f=ATan(steigung)/winkelgrad
    SetGadgetText(118,"Winkel")
    SetGadgetText(119,StrF(winkel))
    EndIf

If mcount>0
mcount=mcount-1
EndIf
Until Ereignis = #PB_Event_CloseWindow Or quit=1  ; If the user has pressed on the close button

  
End   ; All the opened windows are closed automatically by PureBasic
;
; Some 2D graphics functions...
;

SomeGraphics:
  StartDrawing(WindowOutput(0))
  ForEach bo()
  bogenzeichnen()
  Next
  ForEach kr()
  kreiszeichnen()
  Next
  ForEach li()
  liniezeichnen()
  Next
  StopDrawing() ; This is absolutely needed when the drawing operations are finished !!! Never forget it !
Return ;Somegraphics
_________
BBCode aktiviert -- bobobo
Benutzeravatar
GreyEnt
Beiträge: 376
Registriert: 20.07.2006 19:41

Sorry Code ist in PB4.00 geschrieben.

Beitrag von GreyEnt »

Hab den Text noch nicht aktualisiert.
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Beitrag von ts-soft »

Einmal [ /code ] sollte genügen, alleine schon wegen der Smilies
Entferne doch bitte alles überflüssige, die Speicherroutinen usw. haben
sicherlich nichts mit dem Problem zu tun.
So ein Spaghetti-Code ist von Hause aus schwer zu lesen. Deine
Zeichenroutinen scheinen auch unbegrenzt überall hinzukritzeln.
So ist mir das zu unübersichtlich, kriegste bestimmt noch kleiner und besser
lesbar hin :wink:
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Benutzeravatar
GreyEnt
Beiträge: 376
Registriert: 20.07.2006 19:41

Beitrag von GreyEnt »

>Einmal [ /code ] sollte genügen, alleine schon wegen der Smilies
Wird gemacht. Hab mich irgendwie vertan.
>Entferne doch bitte alles überflüssige, die Speicherroutinen usw. haben
>sicherlich nichts mit dem Problem zu tun.
Sehr unwarscheinlich.
>So ein Spaghetti-Code ist von Hause aus schwer zu lesen. Deine
>Zeichenroutinen scheinen auch unbegrenzt überall hinzukritzeln.
Das Proggi ist noch lange nicht fertig.
>So ist mir das zu unübersichtlich, kriegste bestimmt noch kleiner und >besser lesbar hin.
Wird ein weilchen daueren. Aber danke schonmal das ihr euch so viel zeit nimmt.

tschüßi
Dieter
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Beitrag von ts-soft »

Der fehler wird mit Sicherheit entstehen, wo Du Deine Gadget im EventLoop
erstellst. ist keine gute Lösung. Lieber gleich alle erstellen und mit
HideGadget anzeigen oder nicht!
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Antworten