Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht Das deutsche QBasic- und FreeBASIC-Forum
Für euch erreichbar unter qb-forum.de, fb-forum.de und freebasic-forum.de!
 
FAQFAQ   SuchenSuchen   MitgliederlisteMitgliederliste   BenutzergruppenBenutzergruppen  RegistrierenRegistrieren
ProfilProfil   Einloggen, um private Nachrichten zu lesenEinloggen, um private Nachrichten zu lesen   LoginLogin
Zur Begleitseite des Forums / Chat / Impressum
Aktueller Forenpartner:

objekt mit maus verschieben

 
Neues Thema eröffnen   Neue Antwort erstellen    Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht -> Allgemeine Fragen zu FreeBASIC.
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen  
Autor Nachricht
braesident



Anmeldungsdatum: 15.04.2008
Beiträge: 189
Wohnort: Berlin

BeitragVerfasst am: 06.02.2013, 13:01    Titel: objekt mit maus verschieben Antworten mit Zitat

Hi Leute,

ich moechte mir ne .bi zusammenstellen die Objekte wie normale Line()() Grafiken, .bmp, textfelder oder buttons verwalten soll.

Das was ich bis jetzt hab funktioniert zwar, allerdings wenn ich ein Objekt verschieben moechte ist das zu ruckelig und zu langsam - maus verliert dann meisten das objekt. Kann da jemand helfen ?

Falls nötig gebe ich auch noch die anderen beiden .bi nach

Das ist mein Testcode:
Code:

screenres 800, 600, 32
#include once "objekte.bi"

CreOb(1, 0, 0, 163, 133, &h23bbcc, "pm1", "1", &h000044, 0, 0, 1)
CreOb(0, 10, 10, 153, 123, 0, "", _
"Meine Mutter schneidet Speck, schneidet dir den Mittelfinger weg", &haa0000, 0, 0, 0)
CreOb(1, 0, 0, 163, 133, &haa2bcc, "", "2", &h000044, 0, 0, 1)
CreOb(1, 0, 0, 163, 133, &h333ccc, "", "3", &h000044, 0, 0, 1)
CreOb(1, 0, 0, 163, 133, &hbbcc33, "", "4", &h000044, 0, 0, 1)
CONST spielebutton = 1001
CreOb(spielebutton, 400, 300, 16, 16, 0, "games", "", 0, 0, 1, 0)

DO
  Sleep 25
  ScreenLock
  cls
  ShowOb(1, 5)
  ShowOb(1001, 0)
  ScreenUnlock
  IF in_Focus THEN
    ScreenLock
    Color &hffffff: Locate 15, 1: ? "P"
    ScreenUnLock
  END IF
  IF click_on_Obj THEN COLOR ,&h000066
  ObjMove
LOOP until Inkey = CHR(27)


und hier die .bi
Code:

' Funktion zur Objektverwaltung
' (anzeigen und zb Mausverhalten auf diese)
'
' BMPs - Buttons - Textfelder
' CreOb (,,,,,,,,,,)
' CreOb (ObjName(0/1/>999), pos_W, pos_H, groesse_W, groesse_H, BG_farbe,
'        BG_Grafik_bmp(mussgleiche groesse wie Txtfeld), Text, Textfarbe,
'        Textart(0/1), Serie(1-10), Move(0/1))
'
' ObjName ist ehr eine Nummer
' ObjName = 0 - Nummer wird beibehalten und mit selben verknuepft wobei SERIE
'     die Reihenfolge festlegt
' ObjName = 1 - Nummer wird neu erstellt - MUSS gewaehlt werden werden das erste mal
'                                          ein Objekt angelegt wird (mit automatischer
'                                          Nummerrierung)
' ObjName > 999 selbstfesgelegter Name
'
' Serie 1-10 ist nur bei selbst festgelegtem ObjNamen anzugeben, sonst 0 angeben
'
' Pos.. = 0 so wird diese per RANDOMIZE TIMER festgelegt
'
' BG_farbe > 0 dann wird Grafik ignoriert
'
' wird ein BG oder eine Graphik angegeben UND auch TEXT so wird dieser mittig
'     des BGs angezeigt
'
' Textart = 0 - normaler FB String
' Textart = 1 - kleiner String per autowrite
'
' Move = 1 - Objekt ist mit Maus verschiebbar
'
' weitere Idee:
'
' Aufruf zum loeschen des Objektes
' Rückgabefunktionen zB der Pos zum neu setzen der Pos durch verschieben mit
' der Maus
' ##############################################################################
#Include Once "autowrite.bi"
#Include Once "openBildPSET.bi"

TYPE Objektblock
  Nummer  AS Integer
  pwide   AS INTEGER
  phigh   AS INTEGER
  owide   AS INTEGER
  ohigh   AS INTEGER
  farbe   AS Double
  Grafik  AS String
  Text    AS String
  TextF   AS Double
  Textart AS Integer
  Serie   AS Integer
  Move    AS Integer
END TYPE
DIM SHARED Objekt() AS Objektblock
TYPE Objektblock2
  Nummer  AS Integer
  pwide   AS INTEGER
  phigh   AS INTEGER
  owide   AS INTEGER
  ohigh   AS INTEGER
  farbe   AS Double
  Grafik  AS String
  Text    AS String
  TextF   AS Double
  Textart AS Integer
  Serie   AS Integer
  Move    AS Integer
END TYPE
DIM SHARED Ob_tmp(10) AS Objektblock2

DIM SHARED AS Integer TALAS1 ' (This Arraynumber is the Last Arraynumber with Seriesnumber 1)
DIM SHARED AS Integer i_array, i_counter, i_objekt, info_W, info_H, text_spalte, text_zeile, _
                      Obj_maus_W, Obj_maus_H, Obj_maus_B, Obj_in_Move, Obj_TO_Move, markiert
DIM SHARED AS Integer i_serie = 1
DIM Shared AS Integer ObjektName = 0

Randomize Timer

DIM SHARED AS Integer i_test ' fuer testzwecke

' ################################## DECLAREs ##################################
Declare SUB CreOb(Obj_Name AS Integer, Obj_pos_W AS Integer, Obj_pos_H AS Integer, _
  Obj_gr_W AS Integer, Obj_gr_H AS Integer, Obj_BG_farbe AS Double, Obj_Grafik AS String, _
  Obj_Text AS String, Obj_Textfarbe AS Double, Obj_Textart AS Integer, Obj_Serie AS Integer, Obj_Move AS Integer)

Declare SUB ShowOb(von_num AS Integer, bis_num AS Integer)

Declare SUB ObjMove

Declare Function in_Focus AS Integer

Declare Function click_on_Obj AS Integer
' Declare Function click_on(Obj_number AS Integer) AS Integer


' ##################################### SUBs ###################################

SUB CreOb(Obj_Name AS Integer, Obj_pos_W AS Integer, Obj_pos_H AS Integer, _
  Obj_gr_W AS Integer, Obj_gr_H AS Integer, Obj_BG_farbe AS Double, Obj_Grafik AS String, _
  Obj_Text AS String, Obj_Textfarbe AS Double, Obj_Textart AS Integer, Obj_Serie AS Integer, Obj_Move AS Integer)
 
  REDIM PRESERVE Objekt(UBound(Objekt) + 1)
  ScreenInfo info_W, info_H
 
  IF Obj_Name = 0 THEN      ' Erkennungsnummer beibehalten
    Objekt(UBound(objekt)).Nummer = ObjektName
    i_serie += 1              ' -hierbei wird Serie autom. erhoeht
    Objekt(UBound(objekt)).Serie = i_serie
  ELSEIF Obj_Name = 1 THEN      ' NEUE Erkennungsnumer
    ObjektName += 1
    Objekt(UBound(objekt)).Nummer = ObjektName
    i_serie = 1                 ' -Serie ist hierbei 1
    Objekt(UBound(objekt)).Serie = i_serie
    TALAS1 = UBound(objekt)
  ELSEIF Obj_Name > 999 THEN      ' Erkennungsnummer wurde selbst definiert
    Objekt(UBound(objekt)).Nummer = Obj_Name
    Objekt(UBound(objekt)).Serie = Obj_Serie      ' -hier wird selbstdefinierte Seriennummer gebraucht
    IF Obj_Serie = 1 THEN TALAS1 = UBound(objekt)
  END IF
  IF objekt(UBound(objekt)).Serie > 1 THEN
    FOR i_array = 1 TO UBound(objekt)
      IF objekt(i_array).Nummer = objektName AND objekt(i_array).Serie = 1 THEN
        objekt(UBound(objekt)).pwide = objekt(i_array).pwide + Obj_pos_W
        objekt(UBound(objekt)).phigh = objekt(i_array).phigh + Obj_pos_H
        EXIT FOR
      END IF
    NEXT i_array
  ELSE
    IF Obj_pos_W = 0 THEN
      objekt(UBound(objekt)).pwide = int(rnd * (info_W - Obj_gr_W)) + 1
    ELSE
      objekt(UBound(objekt)).pwide = Obj_pos_W
    END IF
    IF Obj_pos_H = 0 THEN
      objekt(UBound(objekt)).phigh = int(rnd * (info_H - Obj_gr_H)) + 1
    ELSE
      objekt(UBound(objekt)).phigh = Obj_pos_H
    END IF
  END IF
 
  Objekt(UBound(objekt)).owide = Obj_gr_W
  Objekt(UBound(objekt)).ohigh = Obj_gr_H
  Objekt(UBound(objekt)).farbe = Obj_BG_farbe
  Objekt(UBound(objekt)).Grafik = Obj_Grafik
  Objekt(UBound(objekt)).Text = Obj_Text
  Objekt(UBound(objekt)).TextF = Obj_Textfarbe
  Objekt(UBound(objekt)).Textart = Obj_Textart
  Objekt(UBound(objekt)).Move = Obj_Move
End Sub

SUB ShowOb(von_num AS Integer, bis_num AS Integer)
  IF von_num < 1 THEN EXIT SUB
  IF bis_num < 1 THEN bis_num = von_num
 
  FOR i_array = 1 TO UBound(objekt)
 FOR i_objekt = von_num TO bis_num
   IF i_objekt = objekt(i_array).Nummer THEN
    IF objekt(i_array).farbe <> 0 THEN
      Line(objekt(i_array).pwide, objekt(i_array).phigh) - _
      STEP(objekt(i_array).owide, objekt(i_array).ohigh), objekt(i_array).farbe, BF
    ELSEIF objekt(i_array).farbe = 0 AND objekt(i_array).Grafik <> "" THEN
      openbildPSET(objekt(i_array).Grafik, objekt(i_array).owide, objekt(i_array).ohigh, objekt(i_array).pwide, objekt(i_array).phigh)
    END IF
   
    IF (objekt(i_array).farbe <> 0 OR objekt(i_array).Grafik <> "") AND _
      objekt(i_array).Text <> "" AND objekt(i_array).Textart = 0 THEN
      Color objekt(i_array).TextF
      Draw String ((objekt(i_array).pwide + (objekt(i_array).owide / 2)) - (LEN(objekt(i_array).Text) * 4), _
      (objekt(i_array).phigh + (objekt(i_array).ohigh / 2)) - 4), objekt(i_array).Text
   
    ELSEIF (objekt(i_array).farbe <> 0 OR objekt(i_array).Grafik <> "") AND _
      objekt(i_array).Text <> "" AND objekt(i_array).Textart = 1 THEN
      autowrite(objekt(i_array).TextF, (objekt(i_array).pwide + (objekt(i_array).owide / 2)) - (LEN(objekt(i_array).Text) * 4), _
      (objekt(i_array).phigh + (objekt(i_array).ohigh / 2)) - 4, objekt(i_array).Text, 0)
   
    ELSEIF objekt(i_array).farbe = 0 AND objekt(i_array).Grafik = "" AND _
      objekt(i_array).Text <> "" AND objekt(i_array).Textart = 0 THEN
      text_spalte = 0: text_zeile = 0: Color objekt(i_array).TextF
      FOR i_counter = 1 TO LEN(objekt(i_array).Text)
        Draw String (objekt(i_array).pwide + text_spalte, objekt(i_array).phigh + text_zeile), _
        MID(objekt(i_array).Text, i_counter, 1)
        text_spalte += 8
        IF text_spalte + 8 > objekt(i_array).owide THEN text_spalte = 0: text_zeile += 11
        IF text_zeile + 11 > objekt(i_array).ohigh THEN EXIT FOR
      NEXT i_counter
   
    ELSEIF objekt(i_array).farbe = 0 AND objekt(i_array).Grafik = "" AND _
      objekt(i_array).Text <> "" AND objekt(i_array).Textart = 1 THEN
      text_spalte = 0: text_zeile = 0
      FOR i_counter = 1 TO LEN(objekt(i_array).Text)
        autowrite(objekt(i_array).TextF, objekt(i_array).pwide + text_spalte, objekt(i_array).phigh + text_zeile, _
        MID(objekt(i_array).Text, i_counter, 1), 0)
        text_spalte += 6
        IF text_spalte + 6 > objekt(i_array).owide THEN text_spalte = 0: text_zeile += 9
        IF text_zeile + 9 > objekt(i_array).ohigh THEN EXIT FOR
      NEXT i_counter
    END IF
   END IF
 NEXT i_objekt
  NEXT i_array
END SUB

SUB ObjMove
  DIM AS Integer Obj_maus_Wa, Obj_maus_Ha,dif_W, dif_H
 
  GetMouse (Obj_maus_W, Obj_maus_H, , Obj_maus_B)
  Obj_maus_Wa = Obj_maus_W
  Obj_maus_Ha = Obj_maus_H
 
  IF Obj_maus_B = 0 THEN
    Obj_in_Move = 0: EXIT SUB
  ELSEIF (in_Focus) AND (Obj_maus_B = 1) AND (objekt(TALAS1).Move) THEN
    Sleep 300
    GetMouse (Obj_maus_W, Obj_maus_H, , Obj_maus_B)
    Obj_in_Move = 1
    dif_W = Obj_maus_W - Obj_maus_Wa
    dif_H = Obj_maus_H - Obj_maus_Ha

    IF objekt(TALAS1).pwide + dif_W < 1 THEN
      objekt(TALAS1).pwide = 1
    ELSEIF (objekt(TALAS1).pwide + dif_W) + objekt(TALAS1).owide > info_W THEN
      objekt(TALAS1).pwide = info_W - objekt(TALAS1).owide
    ELSE
      objekt(TALAS1).pwide += dif_W
    END IF
    IF objekt(TALAS1).phigh + dif_H < 1 THEN
      objekt(TALAS1).phigh = 1
    ELSEIF (objekt(TALAS1).phigh + dif_H) + objekt(TALAS1).ohigh > info_H THEN
      objekt(TALAS1).phigh = info_H - objekt(TALAS1).ohigh
    ELSE
      objekt(TALAS1).phigh += dif_H
    END IF
   
    IF TALAS1 < UBound(objekt) THEN
      FOR i_objekt = (TALAS1 + 1) TO UBound(objekt)
        IF objekt(TALAS1).pwide + dif_W < 1 THEN
          objekt(TALAS1).pwide = 1
        ELSEIF (objekt(TALAS1).pwide + dif_W) + objekt(TALAS1).owide > info_W THEN
          objekt(TALAS1).pwide = info_W - objekt(TALAS1).owide
        ELSE
          objekt(TALAS1).pwide += dif_W
        END IF
        IF objekt(TALAS1).phigh + dif_H < 1 THEN
          objekt(TALAS1).phigh = 1
        ELSEIF (objekt(TALAS1).phigh + dif_H) + objekt(TALAS1).ohigh > info_H THEN
          objekt(TALAS1).phigh = info_H - objekt(TALAS1).ohigh
        ELSE
          objekt(TALAS1).phigh += dif_H
        END IF
      NEXT i_objekt
    END IF
  END IF
END SUB

SUB testi
  Color &h00aa00
  locate 1
  FOR i_test = 1 TO UBound(objekt)
    ScreenLock
    ? "N " & objekt(i_test).Nummer & "  S " & objekt(i_test).Serie
    ScreenUnLock
  NEXT i_test
  Locate 1
  FOR i_test = 1 TO 10
    ScreenLock
    Locate , 15: ? "N " & ob_tmp(i_test).Nummer & "  S " & ob_tmp(i_test).Serie
    ScreenUnLock
  NEXT i_test
  GetKey
END SUB


' ################################## FUNCTIONs #################################

Function in_Focus AS Integer
  GetMouse (Obj_maus_W, Obj_maus_H, , Obj_maus_B)
  IF (Obj_maus_W >=  objekt(TALAS1).pwide) AND _
     (Obj_maus_W <= (Objekt(TALAS1).pwide + objekt(TALAS1).owide)) AND _
     (Obj_maus_H >=  objekt(TALAS1).phigh) AND _
     (Obj_maus_H <= (objekt(TALAS1).phigh + objekt(TALAS1).ohigh)) THEN
    in_Focus = 1
  ELSE
    in_Focus = 0
  END IF
END Function

Function click_on_Obj AS Integer
  IF Obj_in_Move THEN click_on_Obj = 0: EXIT Function

  GetMouse (Obj_maus_W, Obj_maus_H, , Obj_maus_B)
 
  IF (in_Focus) AND (Obj_maus_B = 1) THEN
    SLeep 350
    GetMouse (Obj_maus_W, Obj_maus_H, , Obj_maus_B)
    IF Obj_maus_B = 0 THEN
      click_on_Obj = 1: EXIT Function
    ELSE
      click_on_Obj = 0: EXIT Function
    END IF
  ELSEIF (Obj_maus_B = 1) AND (in_Focus = 0) THEN
    i_array = (TALAS1 - 1)
    DO
      Sleep 10
      ' geklicktes Objekt in tmp-array verschieben
      IF (Obj_maus_W >=  objekt(i_array).pwide) AND _
         (Obj_maus_W <= (Objekt(i_array).pwide + objekt(i_array).owide)) AND _
         (Obj_maus_H >=  objekt(i_array).phigh) AND _
         (Obj_maus_H <= (objekt(i_array).phigh + objekt(i_array).ohigh)) AND _
         objekt(i_array).Serie = 1 THEN
         markiert = objekt(i_array).Nummer
         Obj_TO_Move = 0
         FOR i_counter = 1 TO UBound(objekt)
           IF objekt(i_counter).Nummer = markiert THEN
             Obj_TO_Move += 1
             Ob_tmp(objekt(i_counter).Serie).Nummer = objekt(i_counter).Nummer
             objekt(i_counter).Nummer = 0
             Ob_tmp(objekt(i_counter).Serie).pwide = objekt(i_counter).pwide
             Ob_tmp(objekt(i_counter).Serie).phigh = objekt(i_counter).phigh
             Ob_tmp(objekt(i_counter).Serie).owide = objekt(i_counter).owide
             Ob_tmp(objekt(i_counter).Serie).ohigh = objekt(i_counter).ohigh
             Ob_tmp(objekt(i_counter).Serie).farbe = objekt(i_counter).farbe
             Ob_tmp(objekt(i_counter).Serie).Grafik = objekt(i_counter).Grafik
             Ob_tmp(objekt(i_counter).Serie).Text = objekt(i_counter).Text
             Ob_tmp(objekt(i_counter).Serie).Textf = objekt(i_counter).TextF
             Ob_tmp(objekt(i_counter).Serie).Textart = objekt(i_counter).Textart
             Ob_tmp(objekt(i_counter).Serie).Serie = objekt(i_counter).Serie
             Ob_tmp(objekt(i_counter).Serie).Move = objekt(i_counter).Move
           END IF
         NEXT i_counter
 
         ' Lueckenaufschluss
         FOR i_objekt = 1 TO Obj_TO_Move
           FOR i_counter = 1 TO (UBound(objekt) - 1)
             IF objekt(i_counter).Nummer = 0 THEN
               objekt(i_counter).Nummer = objekt(i_counter + 1).Nummer
               objekt(i_counter + 1).Nummer = 0
               objekt(i_counter).pwide = objekt(i_counter + 1).pwide
               objekt(i_counter).phigh = objekt(i_counter + 1).phigh
               objekt(i_counter).owide = objekt(i_counter + 1).owide
               objekt(i_counter).ohigh = objekt(i_counter + 1).ohigh
               objekt(i_counter).farbe = objekt(i_counter + 1).farbe
               objekt(i_counter).Grafik = objekt(i_counter + 1).Grafik
               objekt(i_counter).Text = objekt(i_counter + 1).Text
               objekt(i_counter).Textf = objekt(i_counter + 1).TextF
               objekt(i_counter).Textart = objekt(i_counter + 1).Textart
               objekt(i_counter).Serie = objekt(i_counter + 1).Serie
               objekt(i_counter).Move = objekt(i_counter + 1).Move
             END IF
           NEXT i_counter
         NEXT i_objekt
 
         ' tmp wieder zurueck (ans Ende)      8 + 3 = 11 - 10 = 1
         FOR i_objekt = (UBound(objekt) - Obj_TO_Move) + 1 TO UBound(objekt)
           objekt(i_objekt).Nummer = ob_tmp((i_objekt + Obj_TO_Move) - UBound(objekt)).Nummer
           objekt(i_objekt).pwide = ob_tmp((i_objekt + Obj_TO_Move) - UBound(objekt)).pwide
           objekt(i_objekt).phigh = ob_tmp((i_objekt + Obj_TO_Move) - UBound(objekt)).phigh
           objekt(i_objekt).owide = ob_tmp((i_objekt + Obj_TO_Move) - UBound(objekt)).owide
           objekt(i_objekt).ohigh = ob_tmp((i_objekt + Obj_TO_Move) - UBound(objekt)).ohigh
           objekt(i_objekt).farbe = ob_tmp((i_objekt + Obj_TO_Move) - UBound(objekt)).farbe
           objekt(i_objekt).Grafik = ob_tmp((i_objekt + Obj_TO_Move) - UBound(objekt)).Grafik
           objekt(i_objekt).Text = ob_tmp((i_objekt + Obj_TO_Move) - UBound(objekt)).Text
           objekt(i_objekt).Textf = ob_tmp((i_objekt + Obj_TO_Move) - UBound(objekt)).TextF
           objekt(i_objekt).Textart = ob_tmp((i_objekt + Obj_TO_Move) - UBound(objekt)).Textart
           objekt(i_objekt).Serie = ob_tmp((i_objekt + Obj_TO_Move) - UBound(objekt)).Serie
           objekt(i_objekt).Move = ob_tmp((i_objekt + Obj_TO_Move) - UBound(objekt)).Move
           IF (i_objekt + Obj_TO_Move) - UBound(objekt) = 1 THEN TALAS1 = i_objekt
         NEXT i_objekt
         click_on_Obj = 0: EXIT Function
      END IF
      i_array -= 1
    LOOP Until i_array < 1
  END IF
END Function
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden MSN Messenger
ThePuppetMaster



Anmeldungsdatum: 18.02.2007
Beiträge: 1839
Wohnort: [JN58JR]

BeitragVerfasst am: 06.02.2013, 14:06    Titel: Antworten mit Zitat

hab mir jetzt nicht genau angesehen, wie du das gemacht hast, aber als idee könnte ich dir bezüglich dem verschieben vorschlagen:

* detektiere das unter der maus liegende objekt. gebe diesem objekt (wenn es das noch nicht besitzt) eine eindeutige ID.
* speichere diese id in einer shared udn setze eine mode variable auf "move" oder ähnliches.
* prüfe in deiner maus-schleife, welche aktion du gerade ausführst. z.B. move, oder nix. Wenn move, dann überspringe den ganzen anderen kram und bewege statdessen das objekt welches in deiner shared gespeichert ist.

hierbei kannst du als grundlage für das moving die koordinaten der maus zum zeitpunkt des klicks auf das obejkt speichern. dann ziehst du davon die aktuellen daten ab, und hast die neue position des objektes. um die mausposition im objekt beizubehalten speicherst du zusätzlich noch den offset der maus zum objekt ab, und rechnest ihn beim bewegen hinzu.

dann hast du keine ruckelein beim verschieben und auch kein problem bezüglich dem verlieren mehr.

MfG
TPM
_________________
[ WebFBC ][ OPS ][ ToOFlo ][ Wiemann.TV ]
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
braesident



Anmeldungsdatum: 15.04.2008
Beiträge: 189
Wohnort: Berlin

BeitragVerfasst am: 06.02.2013, 14:48    Titel: Antworten mit Zitat

So in der art hab ich mir das auch gedacht - habs blos nicht so hin bekommen.

Hab nochmal die SUB fuer das bewegen rauskopiert und mit nen paar infos versehen.
Code:

SUB ObjMove
  DIM AS Integer Obj_maus_Wa, Obj_maus_Ha,dif_W, dif_H
 
  GetMouse (Obj_maus_W, Obj_maus_H, , Obj_maus_B)

  '' bei aufruf der Sub wird x/y gespeichert
  Obj_maus_Wa = Obj_maus_W
  Obj_maus_Ha = Obj_maus_H
 
  '' in_Focus prueft ob die maus auf einem objekt liegt
  '' in TALAS1 ist die Arraynummer des objektes gespeichert
  IF Obj_maus_B = 0 THEN
    Obj_in_Move = 0: EXIT SUB
  ELSEIF (in_Focus) AND (Obj_maus_B = 1) AND (objekt(TALAS1).Move) THEN
    Sleep 300  '' kurz warten und pruefen ob maus x/y sich verändert hat
    '' ohne oder mit kleinerem SLEEP passiert so gut wie nichts mehr
    GetMouse (Obj_maus_W, Obj_maus_H, , Obj_maus_B)

    Obj_in_Move = 1  '' markiert das jetzt ein obj. in bewegung ist und legt störende funktinen lahm
    dif_W = Obj_maus_W - Obj_maus_Wa  '' die differenz der mauskoor.
    dif_H = Obj_maus_H - Obj_maus_Ha    '' wird gespeichert

   '' folgende IFs pruefen das die objekte nicht ueber den bildschirm geschoben werden
   ''addiert die alten obj.koord. mit der maus differenz
   '' und falls es verknuepfte objekte gibt werden dessen koord. ebenf. addiert
    IF objekt(TALAS1).pwide + dif_W < 1 THEN
      objekt(TALAS1).pwide = 1
    ELSEIF (objekt(TALAS1).pwide + dif_W) + objekt(TALAS1).owide > info_W THEN
      objekt(TALAS1).pwide = info_W - objekt(TALAS1).owide
    ELSE
      objekt(TALAS1).pwide += dif_W
    END IF
    IF objekt(TALAS1).phigh + dif_H < 1 THEN
      objekt(TALAS1).phigh = 1
    ELSEIF (objekt(TALAS1).phigh + dif_H) + objekt(TALAS1).ohigh > info_H THEN
      objekt(TALAS1).phigh = info_H - objekt(TALAS1).ohigh
    ELSE
      objekt(TALAS1).phigh += dif_H
    END IF
   
    IF TALAS1 < UBound(objekt) THEN
      FOR i_objekt = (TALAS1 + 1) TO UBound(objekt)
        IF objekt(TALAS1).pwide + dif_W < 1 THEN
          objekt(TALAS1).pwide = 1
        ELSEIF (objekt(TALAS1).pwide + dif_W) + objekt(TALAS1).owide > info_W THEN
          objekt(TALAS1).pwide = info_W - objekt(TALAS1).owide
        ELSE
          objekt(TALAS1).pwide += dif_W
        END IF
        IF objekt(TALAS1).phigh + dif_H < 1 THEN
          objekt(TALAS1).phigh = 1
        ELSEIF (objekt(TALAS1).phigh + dif_H) + objekt(TALAS1).ohigh > info_H THEN
          objekt(TALAS1).phigh = info_H - objekt(TALAS1).ohigh
        ELSE
          objekt(TALAS1).phigh += dif_H
        END IF
      NEXT i_objekt
    END IF
  END IF
END SUB


deinen letzten absatz lese ich so: nicht nur andere subs und func. sollen erkennen ob sich was bewegt sondern sie selbst auch - und speichert so nur die klick-koor. im objekt beim ersten durchlauf und bei jedem weiteren werden nur noch die nun aktuellen ausgerechnet.

Denn momentan wird ja bei jedem aufruf die aktuelle pos als alt gespeichert - kurz gewartet - und dann die neue pos abgerufen.

hoffe das war jetzt noch verstaendlich verwundert
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden MSN Messenger
Beiträge der letzten Zeit anzeigen:   
Neues Thema eröffnen   Neue Antwort erstellen    Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht -> Allgemeine Fragen zu FreeBASIC. Alle Zeiten sind GMT + 1 Stunde
Seite 1 von 1

 
Gehe zu:  
Du kannst keine Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.

 Impressum :: Datenschutz