Code: Select all
;XIncludeFile "RMChart.pbi"
;RMC_Init()
#ID_WINDOW = 1
#ID_CHART = 1
#ID_REGION = 1
#ID_CONT1 = 1
#ID_PANEL1 = 2
Procedure MyCallback(hWnd, CBMSG, CBWPARAM, CBLPARAM)
Protected *TINFO.RMC_INFO
Protected CBCTL.w,CBCTLMSG.w
Protected Text$
Static z.l
CBCTL = PeekW(@CBWPARAM+0)
CBCTLMSG = PeekW(@CBWPARAM+2)
Select CBMSG
Case #WM_RBUTTONDOWN ; right mouse button was clicked
; CBLPARAM holds always the X/Y-position within the dialog,
; even you've clicked onto the chart
Text$="X-Pos in the dialog:"+Str(PeekW(@CBLPARAM+0))+Chr(13)
Text$+"Y-Pos in the dialog:"+Str(PeekW(@CBLPARAM+2))
MessageRequester("RMChart",Text$,0)
Case #WM_COMMAND
Select CBCTL
Case #ID_CHART ;message from the chart control
Select CBCTLMSG ;identify the message
Case #RMC_LBUTTONDOWN ;left mouse button
z = 1 ;set flag for left mouse button pressed
Case #RMC_LBUTTONUP
z = 0 ;reset the flag for left mouse button pressed
Case #RMC_CTRLRBUTTONDOWN ;Ctrl and right mouse button
*TINFO = CBLPARAM ;CBLPARAM holds a pointer to a tRMC_INFO structure
Text$="X-Pos in the chart:"+Str(*TINFO\nXPos)+Chr(13)
Text$+"Y-Pos in the chart:"+Str(*TINFO\nYPos)
MessageRequester("RMChart",Text$,0)
Case #RMC_MOUSEMOVE ;mouse was moved in the chart control
Debug "#RMC_MOUSEMOVE"
*TINFO = CBLPARAM ;CBLPARAM holds a pointer to a tRMC_INFO structure
If z ;if the left mouse button is pressed
;move the chart control within your dialog
RMC_SetCtrlPos(#ID_CHART,*TINFO\nXMove,*TINFO\nYMove,1)
EndIf
EndSelect
EndSelect
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Procedure PBMain()
If OpenWindow(#ID_WINDOW, 0, 0, 800, 600, "RMCHART.DLL", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(#ID_WINDOW))
PanelGadget(#ID_PANEL1,0,0,800,600)
AddGadgetItem (#ID_PANEL1, -1, "Panel 1")
ContainerGadget(#ID_CONT1, 8, 8, 800-24, 600-40, #PB_Container_Raised)
CloseGadgetList()
EndIf
If RMC_CreateChart(GadgetID(#ID_CONT1), #ID_CHART, 0, 0, 800, 600) = #RMC_NO_ERROR
RMC_AddRegion(#ID_CHART, 5, 5, -5, -5,"Test")
RMC_AddGrid(#ID_CHART, #ID_REGION)
RMC_AddXAxis(#ID_CHART, #ID_REGION, #RMC_XAXISBOTTOM)
RMC_AddYAxis(#ID_CHART, #ID_REGION, #RMC_YAXISLEFT)
RMC_AddXYSeries(#ID_CHART, #ID_REGION, ?LabX, 10, ?LabY, 10, #Black, #RMC_XY_LINE, #RMC_LSTYLE_SPLINE,0,0,0,0)
RMC_SetCaptionBGColor(#ID_CHART,#ID_REGION,0)
RMC_Draw(#ID_CHART)
EndIf
SetWindowCallback(@MyCallback())
Repeat
Event=WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
;Debug "Gadget "+Str(EventGadget())
Select EventGadget()
EndSelect
EndSelect
Until Event=#PB_Event_CloseWindow
CloseWindow(#ID_WINDOW)
EndIf
EndProcedure
PBMain()
DataSection
LabX: Data.d 10,20,20,30,40,50,60,70,80,90
LabY: Data.d 10,20,30,30,30,40,90,65,80,10
EndDataSection