FaT3oYCG Posted January 28, 2010 Share Posted January 28, 2010 Hello everyone I am having a problem with implementing calls to a DLL more notably the Scintilla DLL. I have seen another implementation of using the Lexer in AutoIT but the examples and samples dont seem to work or are confusing also using an older version of the DLL (I know this as there are some deprecated functions included), so I decided to do what I usually do when I want to learn something that confuses me... Resarch it and make my own version. O.K. so I have spent quite a while playing arround with the origional samples that I found and some other searching on the Scintilla website, this revealed to me some enlightened information (Quoted below). http://www.scintilla.org/Steps.html The fast way to control Scintilla The fast way of controlling the Scintilla Edit Control is to call message handling function by yourself. You can retrieve a pointer to the message handling function of the Scintilla Edit Control and call it directly to execute a command. This way is much more faster than the SendMessage() way. 1st you have to use the SCI_GETDIRECTFUNCTION and SCI_GETDIRECTPOINTER commands to retrieve the pointer to the function and a pointer which must be the first parameter when calling the retrieved function pointer. You have to do this with the SendMessage way The whole thing has to look like this: int (*fn)(void*,int,int,int); void * ptr; int canundo; fn = (int (__cdecl *)(void *,int,int,int))SendMessage( hwndScintilla,SCI_GETDIRECTFUNCTION,0,0); ptr = (void *)SendMessage(hwndScintilla,SCI_GETDIRECTPOINTER,0,0); canundo = fn(ptr,SCI_CANUNDO,0,0); with "fn" as the function pointer to the message handling function of the Scintilla Control and "ptr" as the pointer that must be used as 1st parameter. The next parameters are the Scintilla Command with its two (optional) parameters. Upon readin this information I returned to the examples that I had been looking at and see that they do not use this method, now I wondered if that was because this metod cant be used in AutoIT (Which I dbout) or that the developer of the samples didn't know about this or how to do it. Now I know about this information it seems ignorant of me to not try and use this method which would provide benefits in the long run. I have attempted to find the relevant information about how I would use this in AutoIT but to no avail, I don't know if it would be better to use DLLCall directly which I used a while back when I was playing arround with bluetooth but as I do not know the name of the function and simply have a pointer (I hope) I fail to see how that would help. Here is the code I have at the moment: SciLexer.au3 expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.4.0 Author: Craig Gilhooley Script Function: Scintilla 2.02 Functions. #ce ---------------------------------------------------------------------------- ; Script Start #Include <WinAPI.au3> #include <SendMessage.au3> Global Const $SCI_GETDIRECTFUNCTION=2184 Global Const $SCI_GETDIRECTPOINTER=2185 ;Dim $SciDirectFunction ;Dim $SciDirectPointer Func Sci_CreateEditor($hwnd, $x, $y, $w, $h) local $hmod = _WinAPI_LoadLibrary("SciLexer.dll") If $hmod Then ; sucessfully loaded $hwndSci = _WinAPI_CreateWindowEx(0, "Scintilla", "SciLexer", BitOR($WS_CHILD, $WS_VISIBLE, $WS_TABSTOP, $WS_CLIPCHILDREN), _ $x, $y, $w, $h, $hwnd, 0, 0, 0) ;$SciDirectFunction = _SendMessage($hwndSci, $SCI_GETDIRECTFUNCTION, 0, 0) ;$SciDirectPointer = _SendMessage($hwndSci, $SCI_GETDIRECTPOINTER, 0, 0) Return $hwndSci Else MsgBox(48, "Error loading Scintilla", "The Scintilla DLL could not be loaded.", 30, $hwnd) Return 0 EndIf EndFunc Func Sci_SendMessage() EndFunc SciPad.au3 #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.4.0 Author: Craig Gilhooley Script Function: SciPad - A Scintilla based editor. #ce ---------------------------------------------------------------------------- ; Script Start #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "SciLexer.au3" local $SciPadWidth = 600 local $SciPadHeight = 450 $hwndSciPad = GUICreate("SciPad - A Scintilla based editor", $SciPadWidth, $SciPadHeight, (@DesktopWidth - $SciPadWidth) / 2, (@DesktopHeight - $SciPadHeight) / 2) $Sci = Sci_CreateEditor($hwndSciPad, 10, 10, $SciPadWidth - 20, $SciPadHeight - 20) GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg(1) Switch $Msg[0] Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd So I am throwing this out there in hope that one of the more experienced and / or frequent users will be bale to help although any information that may help is welcome. Thanks, Craig.SciLexer.dll Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right. Link to comment Share on other sites More sharing options...
FaT3oYCG Posted January 29, 2010 Author Share Posted January 29, 2010 Any ideas on this, I hvae been searching some more and can't find how I would access a function in the DLL provided a pointer. Is there something I am missing. Thanks, Craig. Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now