Download files here < Link removed as sample is now included in lib download.
Regards,
Baldrick

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))
ContainerGadget(#ID_CONT1, 8, 8, 800-24, 600-40, #PB_Container_Raised)
PanelGadget(#ID_PANEL1,0,0,800,600)
AddGadgetItem (#ID_PANEL1, -1, "Panel 1")
CloseGadgetList()
CloseGadgetList()
EndIf
If RMC_CreateChart(GadgetID(#ID_PANEL1), #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
Code: Select all
Global RMChartHandle.l= FindWindowEx_(ParentHwndID,0,"RMC","")
;;Need to find a child window of the parent with the "RMC" szClassName
Procedure GetRMChartImage(RMCharHandle.l) ;HWND of the chart
Protected RMrect.RECT
getwindowrect_(RMCharHandle,@RMrect.RECT) ;get the rect
RMwidth= RMrect\right-RMrect\left ;;calculate the sizes
RMheight=RMrect\bottom-RMrect\top
RMImage.l=CreateImage(#PB_Any,RMwidth, RMheight) ;create an image
If RMImage
IMGhdc=StartDrawing(ImageOutput(RMImage)) use the hdc of the new image
RMDC.l=GetDC_(RMCharHandle) ;get chart dc
BitBlt_(IMGhdc,0,0,RMwidth, RMheight,RMDC,0,0,#SRCCOPY) ;just copy all
StopDrawing()
ReleaseDC_(RMCharHandle, RMDC)
ProcedureReturn RMImage ;BOOM-there's our new freaking image
Else
ProcedureReturn 0
EndIf
EndProcedure
Code: Select all
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Code: Select all
Global NewList RMC_Handle.l()
Procedure RMC_Enum(hwnd,lparam)
Protected classname.s=Space(512)
result=GetClassName_(hwnd,@classname,Len(classname))
If result And classname="RMC"
idchild = GetWindowLong_(hwnd,#GWL_ID)
;Debug "RMC-ID : "+Str(idchild)
;Debug "RMC-Handle : "+Str(hwnd)
AddElement(RMC_Handle())
RMC_Handle()=hwnd
EndIf
ProcedureReturn 1 ; 1= Continue / 0= stop enumeration
EndProcedure
Procedure.l RMC_EnumWindows()
ClearList(RMC_Handle())
EnumChildWindows_(WindowID(#ID_WINDOW),@RMC_Enum(),0)
ProcedureReturn ListSize(RMC_Handle())
EndProcedure
Code: Select all
Count = RMC_EnumWindows()
If Count
Debug "Found "+Str(Count)+" RMC-Windows"
ForEach RMC_Handle()
Debug "RMC-Handle = "+Str(RMC_Handle())
Next
Else
Debug "No RMC-Windows found"
EndIf
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_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered)
PanelGadget(#ID_PANEL1,0,0,800,600)
AddGadgetItem (#ID_PANEL1, -1, "Panel 1")
ScrollAreaGadget(#ID_CONT1, 8, 8, 750, 550, 1200, 1200, 10, #PB_ScrollArea_Flat)
CloseGadgetList()
If RMC_CreateChart(GadgetID(#ID_CONT1), #ID_CHART, 10, 10, 1000, 1000) = #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
; If RMC_CreateChartFromFile(GadgetID(#ID_CONT1), #ID_CHART, 5, 5,#False,sChartDefinition) = #RMC_NO_ERROR
; RMC_AddXYSeries(#ID_CHART, #ID_REGION, ?LabX, 10, ?LabY, 10, #Black, #RMC_XY_LINE, #RMC_LSTYLE_SPLINE,0,0,0,0)
; EndIf
SetWindowCallback(@MyCallback())
Repeat
Event=WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
;Debug "Gadget "+Str(EventGadget())
Select EventGadget()
Case #ID_CONT1: RMC_Draw(#ID_CHART)
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
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_SizeGadget| #PB_Window_MinimizeGadget|#PB_Window_TitleBar| #PB_Window_MaximizeGadget| #PB_Window_ScreenCentered)
PanelGadget(#ID_PANEL1,0,0,800,600)
AddGadgetItem (#ID_PANEL1, -1, "Panel 1")
ScrollAreaGadget(#ID_CONT1, 8, 8, 750, 550, 1200, 1200, 10, #PB_ScrollArea_Flat)
CreateImage(0,4,4)
ImageGadget(10,0,0,1000,1000,ImageID(0))
CloseGadgetList()
CloseGadgetList()
If RMC_CreateChart(GadgetID(#ID_CONT1), #ID_CHART, 10, 10, 1000, 1000) = #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_Draw2Clipboard (#ID_CHART,RMC_BMP)
FreeImage(0)
GetClipboardImage(0)
ClearClipboard()
SetGadgetState(10,ImageID(0))
;RMC_Draw(#ID_CHART)
EndIf
; If RMC_CreateChartFromFile(GadgetID(#ID_CONT1), #ID_CHART, 5, 5,#False,sChartDefinition) = #RMC_NO_ERROR
; RMC_AddXYSeries(#ID_CHART, #ID_REGION, ?LabX, 10, ?LabY, 10, #Black, #RMC_XY_LINE, #RMC_LSTYLE_SPLINE,0,0,0,0)
; EndIf
SetWindowCallback(@MyCallback())
Repeat
Event=WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
;Debug "Gadget "+Str(EventGadget())
Select EventGadget()
Case #ID_CONT1
EndSelect
EndSelect
Until Quit = 1
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
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,0)
; 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_SizeGadget| #PB_Window_MinimizeGadget|#PB_Window_TitleBar| #PB_Window_MaximizeGadget|#PB_Window_ScreenCentered)
PanelGadget(#ID_PANEL1,0,0,800,600)
AddGadgetItem (#ID_PANEL1, -1, "Panel 1")
hWnd = ScrollAreaGadget(#ID_CONT1, 8, 8, 750, 550, 1200, 1200, 10, #PB_ScrollArea_Flat)
chWnd = GetWindow_(hWnd,#GW_CHILD)
CloseGadgetList()
CloseGadgetList()
If RMC_CreateChart(chWnd, #ID_CHART, 10, 10, 1000, 1000) = #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
; If RMC_CreateChartFromFile(GadgetID(#ID_CONT1), #ID_CHART, 5, 5,#False,sChartDefinition) = #RMC_NO_ERROR
; RMC_AddXYSeries(#ID_CHART, #ID_REGION, ?LabX, 10, ?LabY, 10, #Black, #RMC_XY_LINE, #RMC_LSTYLE_SPLINE,0,0,0,0)
; EndIf
SetWindowCallback(@MyCallback())
Repeat
Event=WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
;Debug "Gadget "+Str(EventGadget())
Select EventGadget()
Case #ID_CONT1
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