Home

Add

Edit

Without Linenumbers

Code in Textfield

Download

  1. #DEFINE Quit Inkey=Chr(255,107)
    
  2. Dim Shared As Integer mx,my,mb,anz_win,move_win
    
  3. 
    
  4. Type WizWindow
    
  5. As Integer id
    
  6. As String title
    
  7. As Integer x
    
  8. As Integer y
    
  9. As Integer w
    
  10. As Integer h
    
  11. End Type
    
  12. 
    
  13. Dim Shared As WizWindow win()
    
  14. Dim Shared As Uinteger winZ()
    
  15. 
    
  16. Declare Sub InitGUI()
    
  17. Declare Sub DrawGadgets()
    
  18. Declare Sub DrawWindow(id As Integer)
    
  19. Declare Sub WinAdd()
    
  20. 
    
  21. Screenres 640,480,32
    
  22. InitGUI()
    
  23. 
    
  24. Dim Shared anz_alloc As Uinteger
    
  25. Sub WinAdd()
    
  26.     anz_win+=1
    
  27.     If anz_win > anz_alloc Then
    
  28.         anz_alloc += 25
    
  29.         Redim Preserve win(anz_alloc) As WizWindow
    
  30.         Redim Preserve winZ(anz_alloc) As Uinteger
    
  31.     End If
    
  32.     With win(anz_win)
    
  33.     .id=1
    
  34.     .title="Testwindow-" & Str(anz_win)
    
  35.     .x=anz_win * 25
    
  36.     .y=anz_win * 25
    
  37.     .w=300
    
  38.     .h=200
    
  39.     End With
    
  40.     winZ(anz_win) = anz_win
    
  41. End Sub
    
  42. 
    
  43. Dim oldMouseX As Integer
    
  44. Dim oldMouseY As Integer
    
  45. 
    
  46. Do
    
  47.     oldMouseX = mx
    
  48.     oldMouseY = my
    
  49.     Getmouse mx,my,,mb
    
  50.     
    
  51.     move_win = 0 'erstma zurücksetzen, denn wir prüfen ja (hier leider) jedes mal
    
  52.     For i As Integer= anz_win To 1 Step -1
    
  53.         If (mx>win(winZ(i)).x And mx<win(winZ(i)).w+win(winZ(i)).x) And (my>win(winZ(i)).y And my<win(winZ(i)).h+win(winZ(i)).y) And mb=1 Then
    
  54.             If i < anz_win Then 'ist ganz sinvoll, um nicht jedes mal die liste zu durchlaufen, wenn das fenster sowieso schon am ende is.
    
  55.                 Dim TWinID As Uinteger = winZ(i)
    
  56.                 For X As Uinteger = i To anz_win -1
    
  57.                     winZ(x) = winZ(x + 1)
    
  58.                 Next
    
  59.                 winZ(anz_win) = TWinID
    
  60.             End If
    
  61.             'einfach noch eine prüfung hinzu fügen (kann man natürlich optimieren)
    
  62.             'welche prüft, ob man auf das ""bar klickt.
    
  63.             If (mx>win(winZ(i)).x And mx<win(winZ(i)).w+win(winZ(i)).x) And (my>win(winZ(i)).y And my<24+win(winZ(i)).y) And mb=1 Then
    
  64.                 'wen dem so ist, dann:
    
  65.                 'move
    
  66.                 move_win = winZ(i)
    
  67.             End If
    
  68.             Exit For 'exit danach
    
  69.         End If
    
  70.     Next
    
  71.     'wenn move gesetzt, dann move es
    
  72.     If move_win <> 0 Then
    
  73.         'move variante ist SEHR unschön!!!
    
  74.         win(move_win).x += mx - oldmousex
    
  75.         win(move_win).y += my - oldmousey
    
  76.     End If
    
  77.     
    
  78.     Sleep 10,1
    
  79.     Screenlock
    
  80.         Cls
    
  81.         Line (0,0)-(640,480),&h376ea5,BF
    
  82.         DrawGadgets()
    
  83.     Screenunlock
    
  84. Loop Until Quit
    
  85. End
    
  86. 
    
  87. 
    
  88. Sub InitGUI()
    
  89.     For X As Uinteger = 1 To 10
    
  90.         WinAdd()
    
  91.     Next
    
  92. End Sub
    
  93. 
    
  94. 
    
  95. Sub DrawGadgets()
    
  96. For i As Integer=1 To anz_win
    
  97.     If win(winZ(i)).id=1 Then DrawWindow(winZ(i))
    
  98. Next
    
  99. End Sub
    
  100. 
    
  101. Sub DrawWindow(id As Integer)
    
  102. If id=winZ(anz_win) Then
    
  103.     Line (win(id).x,win(id).y)-(win(id).w+win(id).x,win(id).h+win(id).y),&hFFFFFF,BF
    
  104.     Line (win(id).x,win(id).y)-(win(id).w+win(id).x,win(id).h+win(id).y),&h000000,B
    
  105. Else
    
  106.     Line (win(id).x,win(id).y)-(win(id).w+win(id).x,win(id).h+win(id).y),&hc0c0c0,BF
    
  107.     Line (win(id).x,win(id).y)-(win(id).w+win(id).x,win(id).h+win(id).y),&h000000,B
    
  108. End If
    
  109. End Sub
    
  110. 
    
  111.