It is currently Mon May 20, 2013 8:16 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: Sat Feb 23, 2008 4:06 am 
Offline
Addict
Addict
User avatar

Joined: Fri Jul 02, 2004 6:49 pm
Posts: 833
Location: Australia
Thought I might just throw a little simple sample code on here using this lib to give some ppl's an idea for using. ( Obviouly you will need ABBKLAUS's lib intsalled & the dll to use it. ) fwiw, the included csv files are an output extract from a little Db app project I am working on for myself atm.

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

Regards,
Baldrick :mrgreen:

_________________
Microgateways


Last edited by Baldrick on Tue Feb 26, 2008 3:03 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 25, 2008 5:09 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jul 01, 2004 2:51 am
Posts: 905
Location: Tacoma, WA
ABBKlaus,

Sure. I took your last example and changed it slightly.

Code:
;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


So the panel gadget is in the container gadget - which is how my program is currently set up.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 25, 2008 5:38 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jul 01, 2004 2:51 am
Posts: 905
Location: Tacoma, WA
Hah! I think I have it. I messed around with the callback a bit and when I set the callback on the panel itself, I noticed it worked if the mouse was in the header area. Then I thought, "Oh - I bet the container part of the panel gadget has it's own handle." So, I did a quick search on the forum and found a post by srod that confirmed it - http://www.purebasic.fr/english/viewtopic.php?t=28479

So I used the handle of the tab itself when creating the chart and I got my events back :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 26, 2008 12:28 am 
Offline
Addict
Addict

Joined: Sat Apr 10, 2004 1:20 pm
Posts: 1069
Location: Germany
Xombie wrote:
So I used the handle of the tab itself when creating the chart and I got my events back :)

Thanks,
i added yours (with srods enhancement) and baldricks Rainguage Chartmaker Test to the sources.
Download see first post.

_________________
http://www.PureBasicPower.de


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 09, 2008 7:03 pm 
Offline
Addict
Addict

Joined: Sat Apr 10, 2004 1:20 pm
Posts: 1069
Location: Germany
small update :
Quote:
Apr 9th 2008 RMChart Library V1.01 for PB4.10
- fixed missing parameter 'ExportOnly' in RMC_CreateChartOnDC


see first post for more details

_________________
http://www.PureBasicPower.de


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 11, 2008 4:28 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jul 01, 2004 2:51 am
Posts: 905
Location: Tacoma, WA
ABBKlaus,

Do you know how I can hide and show the chart without resizing it?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2009 7:31 pm 
Offline
Addict
Addict

Joined: Sat Apr 10, 2004 1:20 pm
Posts: 1069
Location: Germany
updated RMChart to work with PB4.30X86.

Download see first post.

_________________
http://www.PureBasicPower.de


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 08, 2009 8:36 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Sep 12, 2003 10:40 pm
Posts: 677
Location: Tallahassee, Florida
Since I struggled with this control for the last 2 days, I figure Id post an easy way to get an image from the control WITHOUT having to draw and draw and draw all over again.

Code:
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



Now if you have multiple charts on the same window, this will always return the FIRST one. If someone can kindly tell us HOW to actually find the RMChart Hwnd that Windows uses without having to use FindWindowEx, i'd appreciate it.

_________________
Code:
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 08, 2009 9:49 pm 
Offline
Addict
Addict

Joined: Sat Apr 10, 2004 1:20 pm
Posts: 1069
Location: Germany
here´s a better solution that finds all RMC-childwindows :
Code:
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:
    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

_________________
http://www.PureBasicPower.de


Top
 Profile  
 
 Post subject: Re: RMChart UserLib V4.12 for PB4.30
PostPosted: Mon Apr 05, 2010 9:29 pm 
Offline
Addict
Addict

Joined: Sat Apr 10, 2004 1:20 pm
Posts: 1069
Location: Germany
Update : RMChart version 1.01 for PureBasic 4.5x x86

Regards Klaus

_________________
http://www.PureBasicPower.de


Top
 Profile  
 
 Post subject: Re: RMChart UserLib V4.12
PostPosted: Fri May 20, 2011 11:52 pm 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2852
Location: Wales, UK
Playing with the ContainerGadget-in-PanelGadget example, I replaced the Container with a ScrollAreaGadget. Chart looks fine until a scroll bar is used, whereupon it becomes completely scrambled. So, I plonked RMC_Draw(#ID_CHART) on case of the ScrollArea being the EventGadget. This isn't a great idea though as it's easy to lock-up trying to scroll. Also, let's say you have scrolled all the way to the bottom right - the redraw takes you back to top left!

Code:
;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


Has someone hit this issue before and found a solution? I was thinking that for the app I'm working on, the graph will not be dynamic so I could export it as an image and then load the image into an ImageGadget instead........

I noticed also that RMChart does not seem to be alive in the outside world any more - the website has 'gone' and many links to the download are broken. Has the author stopped development?

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: RMChart UserLib V4.12
PostPosted: Sat May 21, 2011 7:33 am 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 1468
Hello Mate

Code:
;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


_________________
Egypt my love


Top
 Profile  
 
 Post subject: Re: RMChart UserLib V4.12
PostPosted: Sat May 21, 2011 12:47 pm 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2852
Location: Wales, UK
Hi Rashad

Thanks for the code, I had already figured out that I could do it that way and it suites my requirements absolutely fine. RMChart is a very nice lib. I hope it's not going to disappear.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: RMChart UserLib V4.12
PostPosted: Sat May 21, 2011 4:28 pm 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 1468
@IdeasVacuum Hi :D
Sorry mate as usual I do not read carefully
Accept my apology

Next is a workable snippet using your code ( Windows Callback )

Code:
;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


Edit :Code improved

_________________
Egypt my love


Top
 Profile  
 
 Post subject: Re: RMChart UserLib V4.12
PostPosted: Sat May 21, 2011 10:09 pm 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2852
Location: Wales, UK
...That's another top-notch Rashad solution! The comments are much appreciated too, easy to follow. I'm sure a lot of people will be delighted when they need to use this lib and discover your code Rashad, thank you for taking the time to do it.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: Exabot [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye