| |
Visual-Basic EinsteigerKreis öffnen | | | Autor: Manfred44 | Datum: 15.12.16 13:24 |
| Ich bekomme leider keinen öffnenden Kreis hin.
Woran könnte es liegen?
Danke im Voraus für eure Bemühungen...
Option Explicit
Dim z% ' Zustandsvariable
Dim x1!, y1!, x2!, y2! ' Eck-Koordinaten
Dim x0!, y0! ' Speichervariable
Dim X, Y
Private Sub Form_Load()
z = 1 ' Zustand 1 = Startzustand
Picture1.AutoRedraw = True
Picture1.DrawMode = 10
End Sub
Private Sub Picture1_MouseDown(Button%, Shift%, X!, Y!)
If z = 1 Then
x1 = X: y1 = Y ' initialisieren
x2 = X: y2 = Y
Picture1.Circle (x1, y1)-(x2, y2)
x0 = x1: y0 = y1 ' Merken l.o. Ecke
End If
z = 2 ' weiter mit Zustand 2
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As
Integer, X As Single, Y As Single)
If z = 2 Then
x1 = X: y1 = Y
x2 = x0: y2 = y0
Picture1.Circle (x1, y1)-(x2, y2)
x1 = X: y1 = Y
x2 = X: y2 = Y
Picture1.Circle (x1, y1)-(x2, y2)
x0 = x2: y0 = y2
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, As Single, Y As Single)
z = 1 ' zurück zum Zustand 1
End Sub | |
Re: Kreis öffnen | | | Autor: Zardoz | Datum: 15.12.16 15:57 |
| Hallo Manfred44,
da stimmt so einiges nicht. Die Parameterübergabe für
VB-Circle ist falsch. Du mußt die x- und die y-Postion
des Kreismittelpunktes, dann den Radius und optional die
Farbe angeben. Wenn du den Kreis in die Koordinaten
eines Rechtecks zeichnen willst, mußt du die Werte
entsprechend umrechnen. Alternativ bietet sich die
Api-Funktion Ellipse an. Probier' mal dies:
Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal x1 As _
Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As Long
Private XD!, YD!
Private Sub Form_Load()
Picture1.ScaleMode = vbPixels
Picture1.ForeColor = vbRed
Picture1.DrawWidth = 3
Picture1.AutoRedraw = True
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As _
Single, Y As Single)
XD = X
YD = Y
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As _
Single, Y As Single)
Dim x1!, y1!, x2!, y2!
If Button = vbLeftButton Then
x1 = IIf(X < XD, X, XD)
y1 = IIf(Y < YD, Y, YD)
x2 = IIf(X < XD, XD, X)
y2 = IIf(Y < YD, YD, Y)
Picture1.Cls
Call Ellipse(Picture1.hdc, x1, y1, x2, y2)
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, _
Y As Single)
Set Picture1.Picture = Picture1.Image
End Sub Gruss,
Zardoz | |
Re: Kreis öffnen | | | Autor: Manfred44 | Datum: 16.12.16 18:03 |
| Dank an Zardoz | |
Re: Kreis öffnen | | | Autor: VB3-Guru | Datum: 25.12.16 14:04 |
| Also ich zeichne Kreise oder Teilkreise vorzugsweise mittels Polyline, bzw. Polygon-Befehl. D.h. Berechnung eines Pologons für den Kreisausschnitts mit Sinus und Kosinus etc.
Es geht aber auch mit der VB-eigenen Circle Funktion:
http://www.activevb.de/tipps/vb6tipps/tipp0745.html
Das schießt zwar für deine Anwendung vielleicht etwas übers Ziel hinaus, aber es zeigt, wie man Anfangs- und Endwinkel angeben muss.
lg, vg3-guru | |
| Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
|
|
TOP! Unser Nr. 1
Neu! sevDataGrid 3.0
Mehrspaltige Listen, mit oder ohne DB-Anbindung. Autom. Sortierung, Editieren von Spalteninhalten oder das interaktive Hinzufügen von Datenzeilen sind ebenso möglich wie das Erstellen eines Web-Reports. Weitere InfosTipp des Monats TOP Entwickler-Paket
TOP-Preis!!
Mit der Developer CD erhalten Sie insgesamt 24 Entwickler- komponenten und Windows-DLLs. Die Einzelkomponenten haben einen Gesamtwert von 1605.50 EUR...
Jetzt nur 599,00 EURWeitere Infos
|