Announcement

Collapse
No announcement yet.

layers?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • layers?

    I'm writing a program to communicate with the Millenium 3 from Crouzet. Communication works and I can send and receive data. I now want to progam a trending. My intention is to see a kind of oscilloscope sreen on the computer screen, a green rectangle with square divisions in black. At the utmost right side of the scope a point is set at a height corresponding to the amplitude of the Millenium signal. Then it's my intention to copy the trending already written and to move it one pixel to the left. Afterwards a new point is set at the right side, and so on. But when I do this, the background moves also what is obviously not the intention. How can I move only the signal line without changing the scope screen view itself and without unquiet display? Using bitmaps? Layers would be usefull but I doubt this is possible with Powerbasic. Is there a good handbook of Powerbasic 9 in which this topic is mentioned? Thanks.

  • #2
    Here's some rough code that does something similar to what you're describing. Create a grid on your 'scope', draw onto a memory bitmap, copy the bitmap to the appropriate location on your 'scope' and redraw the grid.. repeat.
    Code:
    #PBForms CREATED V1.51
    #Compile Exe
    #Dim All
     
    #PBForms BEGIN INCLUDES
    #If Not %Def(%WINAPI)
      #Include "WIN32API.INC"
    #EndIf
    #If Not %Def(%COMMCTRL_INC)
      #Include "COMMCTRL.INC"
    #EndIf
    #Include "PBForms.INC"
    #PBForms END INCLUDES
     
    #PBForms BEGIN CONSTANTS
    %IDD_DIALOG1 =  101
    %GFX_Scope   = 1001
    %BTN_Start   = 1002
    %BTN_Exit    = 1003
    #PBForms END CONSTANTS
     
    Declare CallBack Function ShowDIALOG1Proc()
    Declare Function ShowDIALOG1(ByVal hParent As Dword) As Long
    #PBForms DECLARATIONS
    '------------------/
     
    Function PBMain()
      PBFormsInitComCtls (%ICC_WIN95_CLASSES Or %ICC_DATE_CLASSES Or %ICC_INTERNET_CLASSES)
     
      ShowDIALOG1 %HWND_Desktop
    End Function
    '------------------/
     
    Sub DrawGrid(ByVal hWin As Dword, ByVal nID As Long, ByVal x As Long, ByVal y As Long)
     Local Clx, Cly, n As Long 
     
      Graphic Attach hWin, nID
      Graphic Attach hWin, nID, ReDraw
      Graphic Get Client To Clx, Cly
      x = Clx \ x : y = Cly \ y
      n = 1
      Do Until n*x > Clx
        Graphic Line (n*x, 0) - (n*x, Cly), %rgb_LightGray
        Incr n
      Loop
     
      n = 1
      Do Until n*y > Cly
        Graphic Line (0, n*y) - (Clx, n*y), %rgb_LightGray
        Incr n
      Loop
      Graphic Redraw
     
    End Sub
    '------------------/
     
    Sub PlotPoints (hWin As Dword, nID As Long)
     Local hBmp As Dword
     Local x, y As Long, hzRadDeg, Pi As Double
     
      Pi     = 4 * Atn(1)                         ' Calculate Pi
      hzRadDeg = Pi / 180
     
      Graphic Bitmap New 300, 300 To hBmp         ' create memory bitmap
      Graphic Attach hBmp, 0
      Graphic Clear %RGB_PALEGREEN
      Graphic Set Pos (0, 150)
        For x = 0 To 360                          ' draw on it
            y = Sin(hzRadDeg * x) * 148
            Graphic Line Step - (x, 150 + y)
        Next
        Graphic Attach hWin, nID
        For x = 0 To 300                          ' copy it to the graphic control
          Graphic Copy hBmp, 0 To (300 -x, 0)
          Sleep 50
          DrawGrid hWin, nID, 10, 10              ' redraw the grid
        Next
     
    End Sub
    '------------------/
     
    CallBack Function ShowDIALOG1Proc()
     
      Select Case As Long CbMsg
        Case %WM_InitDialog
          Graphic Attach CbHndl, %GFX_Scope
          Graphic Clear %RGB_PALEGREEN
          DrawGrid Cb.Hndl, %GFX_Scope, 10, 10
     
        Case %WM_NCActivate
          Static hWndSaveFocus As Dword
          If IsFalse CbWParam Then
            hWndSaveFocus = GetFocus()
          ElseIf hWndSaveFocus Then
            SetFocus(hWndSaveFocus)
            hWndSaveFocus = 0
          End If
     
        Case %WM_Command
          Select Case As Long CbCtl
            Case %GFX_Scope
     
            Case %BTN_Start
              If CbCtlMsg = %BN_Clicked Or CbCtlMsg = 1 Then
                PlotPoints Cb.Hndl, %GFX_Scope
                DrawGrid Cb.Hndl, %GFX_Scope, 10, 10
              End If
     
            Case %BTN_Exit
              If CbCtlMsg = %BN_Clicked Or CbCtlMsg = 1 Then
                Dialog End CbHndl
              End If
     
          End Select
      End Select
    End Function
    '------------------/
     
    Function ShowDIALOG1(ByVal hParent As Dword) As Long
      Local lRslt As Long
     
    #PBForms BEGIN DIALOG %IDD_DIALOG1->->
      Local hDlg  As Dword
     
      Dialog New Pixels, hParent, "Test", 105, 114, 390, 390, To hDlg
      Control Add Graphic, hDlg, %GFX_Scope, "", 45, 16, 302, 302, %WS_Child Or %WS_Visible Or %WS_Border
      Control Add Button,  hDlg, %BTN_Start, "Start", 90, 333, 75, 25
      Control Add Button,  hDlg, %BTN_Exit, "Exit", 210, 333, 75, 25
    #PBForms END DIALOG
     
      Dialog Show Modal hDlg, Call ShowDIALOG1Proc To lRslt
     
    #PBForms BEGIN CLEANUP %IDD_DIALOG1
    #PBForms END CLEANUP
     
      Function = lRslt
    End Function
    '------------------/
    Rgds, Dave

    Comment

    Working...
    X