 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
SKAN
Joined: 26 Dec 2005 Posts: 6223
|
Posted: Wed Apr 11, 2007 5:59 pm Post subject: Help needed on a 3rd party DLL : RmChart.dll |
|
|
Dear Sean,
Further to my private message, I am posting here the details:
I am trying to create and embed a chart control with help of a 3rd party dll provided by rmchart.com
See the introduction: Basic concepts RMChart.dll
The problem:
The RMC_CREATECHART function requires the hwnd of the control before it is created ( atleast that is what I understand ).
I took a peek into the various Basic code provided in the package. They just create a picture control and pass its ID to the function. In one example they declare the control hwnd as a constant 10001 ?!
The DllCall fails and returns a -6 ( RMC_ERROR_CTRLID Wrong control ID (0) )
| Code: | /*
nResult (LONG) = RMC_CreateChart(
ByVal nParentHndl (LONG),
ByVal nCtrlId (LONG),
ByVal nX (LONG),
ByVal nY (LONG),
ByVal nWidth (LONG),
ByVal nHeight (LONG),
Optional ByVal nBackColor (LONG),
Optional ByVal nCtrlStyle (LONG),
Optional ByVal nExportOnly (LONG),
Optional ByRef sBgImage (ASCIIZ),
Optional ByRef sFontName (ASCIIZ),
Optional ByVal nToolTipWidth (LONG),
Optional ByVal nBitmapBKColor (LONG)
)
*/
Gui +LastFound
hGui := WinExist()
hCtrl := 0
MsgBox, % DllCall( "rmchart.dll\RMC_CREATECHART"
, UInt, hGui ; Parent
, UInt, hCtrl ; CtrlId
, UInt, 0 ; X
, UInt, 0 ; Y
, UInt, 300 ; W
, UInt, 300 ; h
, UInt, 0 ;
, UInt, 0 ;
, UInt, 0 ;
, Str , "" ;
, Str , "" ;
, UInt, 0 ;
, UInt, 0 )
MsgBox, % Errorlevel
Gui, Show, w400 h300, RM Chart
Return
GuiClose:
GuiEscape:
ExitApp
Return |
I thought, maybe I should create the control beforehand with CreateWindowEx() , but I could not as I do not know how to register a Class Name:
| Code: | WS_CHILD := 0x40000000 , WS_VISIBLE := 0x10000000
hCtrl := DLLCall("CreateWindowEx"
, UInt, 0 ; Style
, UInt, 0 ; Class Name
, UInt, 0 ; Window name
, UInt, WS_CHILD|WS_VISIBLE|0x00000400 ; window style
, Int , 5 ; Left
, Int , 5 ; Top
, Int , 290 ; Right
, Int , 200 ; Bottom
, UInt, hGui ; Handle of parent
, Int , 0 ; Menu
, UInt, 0 ; hInstance
, UInt, 0 )
MsgBox, % hCtrl "`n" errorlevel "`n" A_LastError |
There is also a way to create the control with a Device context, again it requires CtrlHwnd beforehand.
A Snapshot of the control:
Documentation links for Control Creation:
RMC_CREATECHART
RMC_CREATECHARTFROMFILE
RMC_CREATECHARTFROMFILEONDC
RMC_CREATECHARTI
RMC_CREATECHARTONDC
RMC_CREATECHARTONDCI
The CHM Documentation file: RMChart.chm [580 KB]
The DLL : RMChart.dll [128 KB]
Dependency: GDIPlus.dll [1570 KB] ( Only for OS older than XP )
RMChart Download Page: http://www.rmchart.com/rmc/Downloads.htm
I would be grateful if you help me just to get kickstarted. That would help me very much in writing the wrapper.
Thank you.  |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1388
|
Posted: Wed Apr 11, 2007 10:18 pm Post subject: |
|
|
You seem to almost get there already, just missed two points. First load rmchart.dll before using it:
| Code: | | hModule := DllCall("LoadLibrary", "str", "rmchart.dll") |
And, ControlID is not a window handle, it's just (custom) identifier of the control. I guess AHK's usage of the terminology ID for hWnd confused you here. So, use any (positive) integer here: 1, 2, ..., 10001
I succeeded to create the control, i.e., the return value was 0, however, it was started as hidden. There may be other condition to make it visible, I haven't read the help file except about the return code.
Here is the code I used, which is just a litte modification of yours.
| Code: | Gui +LastFound
hGui := WinExist()
hModule := DllCall("LoadLibrary", "str", "rmchart.dll")
MsgBox, % DllCall("rmchart.dll\RMC_CREATECHART"
, UInt, hGui ; Parent
, UInt, 1001 ; CtrlId
, UInt, 0 ; X
, UInt, 0 ; Y
, UInt, 300 ; W
, UInt, 300 ; h
, UInt, 0 ;
, UInt, 0 ;
, UInt, 0 ;
, UInt, 0 ;
, UInt, 0 ;
, UInt, 0 ;
, UInt, 0 )
Gui, Show, w400 h330, RM Chart
Return
GuiClose:
GuiEscape:
ExitApp
Return
|
|
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6856 Location: Pacific Northwest, US
|
Posted: Wed Apr 11, 2007 10:45 pm Post subject: |
|
|
tested! nice!
| Code: |
hModule := DllCall("LoadLibrary", "str", "rmchart.dll")
Gui +LastFound
hGui := WinExist()
result := DllCall("rmchart.dll\RMC_CREATECHARTFROMFILE"
, "UInt", hGui ; Parent
, "UInt", 1001 ; CtrlId
, "UInt", 5 ; X
, "UInt", 5 ; Y
, "UInt", 0 ; ExportOnly
, "Str", "candlesticks.rmc" ) ; RMCFile
result := DllCall("rmchart.dll\RMC_DRAW"
, "UInt", 1001) ; CtrlId
Gui, Show, w700 h500, RM Chart
Return
GuiClose:
GuiEscape:
ExitApp
Return
|
this script uses one of the examples that came with the dll. my script is in the same folder as the dll and rmc file. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6223
|
Posted: Wed Apr 11, 2007 11:22 pm Post subject: |
|
|
Dear Sean,
| Quote: | | ControlID is not a window handle, it's just (custom) identifier of the control. I guess AHK's usage of the terminology ID for hWnd confused you here. So, use any (positive) integer here: 1, 2, ..., 10001 |
| Quote: | | I succeeded to create the control, i.e., the return value was 0 |
I do not have enough words to express my gratitude.
Many Thanks.!
| engunneer wrote: | | tested! nice! |
Ooh! Thanks for the code .. Today is my lucky day, I guess
 |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6856 Location: Pacific Northwest, US
|
Posted: Wed Apr 11, 2007 11:33 pm Post subject: |
|
|
also, keep in mind that RMC_CREATECHARTFROMFILE can take the contents of a file instead of the filename, so you can have AHK dynamically generate the code. (assuming you can figure out the format.) _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1388
|
Posted: Thu Apr 12, 2007 2:48 am Post subject: |
|
|
| Skan wrote: |  |
We have already the closest ID's among the forum members: Skan, Sean  |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6856 Location: Pacific Northwest, US
|
Posted: Thu Apr 12, 2007 2:54 am Post subject: |
|
|
regex: S[ek]an
I will have to use that when I want to ask you both a question.
I wonder how flexible this control is, maybe it can be a general purpose graphics control with the right wrappers. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Thu Apr 12, 2007 7:00 am Post subject: |
|
|
Really nice.
Hope the threads outcome is already transfered to the Scripts & Functions Section, so it won't drown within the sea of BF2 requests ???  |
|
| Back to top |
|
 |
Swan Guest
|
Posted: Mon May 05, 2008 9:55 am Post subject: Chart update |
|
|
I need to update a chart made with rmchart.dll.
It works rebuilding every time the chart (calling RMC_CREATECHARTFROMFILE and then RMC_DRAW) but in this way i see it blinking on the screen. I'd like to update it only. I red on the dll help that to rewrite the chart once it's created, it's enough to call RMC_DRAW only: in this way my updating process is not working (i rewrite the rmc file and i call RMC_DRAW). Can you help me updating the chart?
This is the chart creation function
AddChart( GuiID, DesignFile ) {
; Load RMChart DLL
ChartModule := DllCall("LoadLibrary", "str", "rmchart.dll")
; Build the chart based on the RMC file
result := DllCall("rmchart.dll\RMC_CREATECHARTFROMFILE"
,UInt,GuiID
,UInt,1000 ; ctrl id of the chart window
,UInt,10 ; x
,UInt,50 ; y
,UInt,0 ; display only
,Str,DesignFile ) ; RMCFile
; Draw the chart
; result := DllCall("rmchart.dll\RMC_DRAW",UInt,1000 ) ; CtrlId
}
This is the instruction i call repetively to update the chart
(and that it is not working)
result := DllCall("rmchart.dll\RMC_DRAW",UInt,1000 ) ; CtrlId
Thanx |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|