Gibt es sowas schon?
Manchmal kommt es vor, das man im Prg eine Aktion auslöst,
bei der es keine Rückmeldung gibt.
(Z.B. einen kurzen Text ins Clipboard übergeben).
Um grafisch darzustellen, das gerade eine Aktion gelaufen ist,
habe ich einen kleinen Aktionsrahmen gebastelt.
Der Rahmen läuft von Punkt A nach Punkt B.
Z.B. vom Listicongadget zum Auslösebutton.
Man kann auch eigene Punkte bestimmen.
Z.B. einen Linksklick ins Listicongadget.
Das Prg habe ich geschrieben,
weil ich selber sowas brauche und um zu sehen,
ob ich das mit der Zeigerübergabe an Proceduren verstanden habe.
Vieleicht kann der eine oder ander sowas ja gebrauchen.
Oder hat Verbesserungsvorschläge?
Gruß: BSP
Code: Alles auswählen
EnableExplicit
; ===== Ins Programm einbauen
Structure Rahmen
x1.i
x2.i
x3.i
x4.i
y1.i
y2.i
y3.i
y4.i
EndStructure
Procedure AktionsRahmen(IDWin,*p1.rahmen,*p2.rahmen)
; p1 / p2 steht für punkte1 / punkte2
Protected x1 , x2 , y1 , y4 ,w , h , i , st
Protected a1= *p2\x1 - *p1\x1
Protected b1= *p2\y1 - *p1\y1
Protected l1= Sqr(a1*a1 + b1*b1)
Protected a2= *p2\x2 - *p1\x2
Protected b2= *p2\y2 - *p1\y2
Protected l2= Sqr(a2*a2 + b2*b2)
Protected a4= *p2\x4 - *p1\x4
Protected b4= *p2\y4 - *p1\y4
Protected l4= Sqr(a4*a4 + b4*b4)
Protected fw.d= l2/l1
Protected fh.d= l4/l1
StartDrawing(WindowOutput(IDWin))
DrawingMode(#PB_2DDrawing_XOr|#PB_2DDrawing_Outlined )
st=l1/50
If st=0:st=1:EndIf
;For I = 0 To l1 Step 4
While i<l1
x1= *p1\x1 + a1*I/l1
y1= *p1\y1 + b1*I/l1
x2= *p1\x2 + a2*I*fw/l2
w= x2-x1
y4= *p1\y4 + b4*I*fh/l4
h= y4-y1
Box(x1,y1,w,h)
Delay(4)
Box(x1,y1,w,h)
i+st
While WindowEvent():Wend
;Next
Wend
StopDrawing()
; For i=4000 To 2000 Step -200
; Beep_( i, 6)
; Next
EndProcedure
; =====
Procedure Get_GadgRahmen(*pos.rahmen , gadg)
*pos\x1=GadgetX(gadg)
*pos\y1=GadgetY(gadg)
*pos\x2=GadgetX(gadg)+GadgetWidth(gadg)
*pos\y2=GadgetY(gadg)
*pos\x3=GadgetX(gadg)+GadgetWidth(gadg)
*pos\y3=GadgetY(gadg)+GadgetHeight(gadg)
*pos\x4=GadgetX(gadg)
*pos\y4=GadgetY(gadg)+GadgetHeight(gadg)
EndProcedure
; ab hier das Testprogramm
Define _Flag.i , ende.i
Define.i x,y,w,h
Enumeration
#HWnd
EndEnumeration
Enumeration
#LiGadg
#Butt
EndEnumeration
_Flag = #PB_Window_SystemMenu
_Flag | #PB_Window_MaximizeGadget
_Flag | #PB_Window_MinimizeGadget
_Flag | #PB_Window_ScreenCentered
;_Flag | #PB_Window_Maximize
OpenWindow(#HWnd, 0, 0, 800,400,"Fenster", _Flag)
;SetClassLongPtr_(WindowID(#HWnd),#GCL_HCURSOR,LoadCursor_(0,#IDC_WAIT))
;AddKeyboardShortcut(#HWnd,#PB_Shortcut_Space,#TSpace)
x=4
y=4
w=WindowWidth(#HWnd)-8
h=WindowHeight(#HWnd)-50
ListIconGadget(#LiGadg,x,y,w,h,"Test",w,#PB_ListIcon_GridLines|#PB_ListIcon_AlwaysShowSelection)
AddGadgetItem(#LiGadg,-1,"Eine Zeile")
SetGadgetState(#LiGadg,0)
x=WindowWidth(#HWnd)/2
x-50
y=WindowHeight(#HWnd)-40
w=100
h=30
ButtonGadget(#Butt,x/2,y,w,h,"ClipBoard")
Define Gadg1.rahmen
Get_GadgRahmen(@Gadg1 , #LiGadg)
Define Gadg2.rahmen
Repeat
Select WaitWindowEvent()
Case #WM_CLOSE: ende=1
Case #PB_Event_Gadget
Select EventGadget()
Case #butt
Get_GadgRahmen(@Gadg2 , #butt)
AktionsRahmen(#HWnd,@Gadg1,@Gadg2)
Case #LiGadg
If EventType()=#PB_EventType_LeftClick
Gadg2\x1=WindowMouseX(#HWnd)
Gadg2\y1=WindowMouseY(#HWnd)
Gadg2\x2=WindowMouseX(#HWnd)
Gadg2\y2=WindowMouseY(#HWnd)
Gadg2\x3=WindowMouseX(#HWnd)
Gadg2\y3=WindowMouseY(#HWnd)
Gadg2\x4=WindowMouseX(#HWnd)
Gadg2\y4=WindowMouseY(#HWnd)
AktionsRahmen(#HWnd,@Gadg1,@Gadg2)
EndIf
EndSelect
EndSelect
Until ende
Thread verschoben
Grafik & Sound - Programmierung>Code, Tipps und Tricks
08.02.2012
RSBasic