Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
Enum Equates Singular
IDC_Graphic = 500
ID_Timer
End Enum
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Oscilloscope",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Graphic, hDlg, %IDC_Graphic,"", 0,0,200,200
Graphic Attach hDlg, %IDC_Graphic, ReDraw
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local w,h As Long
Select Case Cb.Msg
Case %WM_InitDialog
SetTimer hDlg, %ID_Timer, 25,0
Case %WM_Timer
DrawScreen
Case %WM_Size
Dialog Get Client hDlg To w,h
Control Set Size hDlg, %IDC_Graphic, w,h
DrawScreen
End Select
End Function
Sub DrawScreen
Local x,y,j,w,h As Long, Theta As Single
Static startX As Long
Graphic Get Client To w,h
Graphic Clear
'draw lines
Graphic Color %Red, %Black
Graphic Style 2
For j = 0 To h Step 20 : Graphic Line (0,j)-(w,j) : Next j
For j = 0 To w Step 20 : Graphic Line (j,0)-(j,h) : Next j
'draw sine wave
Graphic Style 0
Theta = 0.05
For x = 0 To w
y = h/2 + (0.4*h)*Sin((startX+x)*Theta)
Graphic Set Pixel (x,y),%Green
Next x
Graphic ReDraw
Incr startX
End Sub
'gbs_01419
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm