Page 4 of 18

Posted: Sun Apr 22, 2007 1:52 pm
by ts-soft
The optional parameter hWnd doesn't exist in original Disphelper This
addition works only for some ocx, that embeddeble in browser.

Posted: Sun Apr 22, 2007 2:06 pm
by SFSxOI
WoW! Very nice...thank you very much. :)

Posted: Mon Apr 23, 2007 12:41 am
by r_hyde
The optional parameter hWnd doesn't exist in original Disphelper This
addition works only for some ocx, that embeddeble in browser.
The Image Edit control is a visual control; if I don't supply an hWnd it doesn't attach itself to the window. If I comment out the dhPutValue line, it works - meaning that I can see the control in the window - but trying to set any of its properties or call any of its functions results in a memory access error.

There must be a way to get this control working in PB, though. I have tried aXend Interface Generator, Stefan Moebius' OLE/COM Interface Generator, and both of these tools fail to expose the object's properties (only its methods are exposed). I thought PureDispHelper would finally be the solution.

BTW, I mean no offense to ts-soft or the creator of Disphelper, I think PureDispHelper is awesome! It's only frustrating that nothing seems to work for the one control I really want to use.

Posted: Mon Apr 23, 2007 1:28 pm
by Dare
Thanks again!


For the ADO interface alone this is worth heaps to me!



@srod: You going to make a requests/wishlist post for an interfaces/com/activex type board?



Aside:

Anyone using agents like Merlin, etc, do you guys hear anything with the "speak" or do you just see the balloon and the words typed out real slow?
And do you just get Merlin?

Posted: Mon Apr 23, 2007 1:38 pm
by ts-soft
Agents speaks only with some extra stuff from MS.

Posted: Mon Apr 23, 2007 2:18 pm
by Dare
Ah. Thanks ts-soft.

Posted: Mon Apr 23, 2007 3:58 pm
by Xombie
ts-soft,

This will do absolute wonders for stuff I'm doing at work.

One thing - I can't seem to get any of the examples to work when it uses dhGetValue("%s"....) with a string.

Here's an example...

Code: Select all

; example by Kiffi

EnableExplicit

Define.l ExcelApp, Workbook

dhToggleExceptions(#True)

ExcelApp = dhCreateObject("Excel.Application")

If ExcelApp
  
  dhPutValue(ExcelApp, ".Visible = %b", #True)
  
  dhGetValue("%o", @Workbook, ExcelApp, ".Workbooks.Add")
  
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 1, 1, @"Feel")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 2, 1, @"the")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 3, 1, @"pure")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 4, 1, @"Power")
  
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 1, 2, @"the")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 1, 3, @"pure")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 1, 4, @"Power")
  dhPutValue(ExcelApp, "Cells(%d, %d).Formula = %s", 10, 10, @"=1+1")

  Define.l iCount
  Define.s HoldString
  dhGetValue("%s", @HoldString, ExcelApp, ".Workbooks(1).Name")
  dhGetValue("%d", @iCount, ExcelApp, ".Workbooks.Count")
  MessageRequester(Trim(HoldString), Str(iCount))
  
  dhFreeString(@HoldString)
  dhReleaseObject(Workbook) : Workbook = 0
  dhReleaseObject(ExcelApp) : ExcelApp = 0
  
Else
  
  MessageRequester("PureDispHelper-ExcelDemo", "Couldn't create Excel-Object")
  
EndIf
I get a "The Parameter Is Incorrect" every time on the...

Code: Select all

dhGetValue("%s", @HoldString, ExcelApp, ".Workbooks(1).Name")
... line. Any thoughts? Thanks again - this is a tremendous piece of work.

Posted: Mon Apr 23, 2007 4:11 pm
by ts-soft
Sorry, but i can't help you, i haven't ms-office installed.

Posted: Mon Apr 23, 2007 4:22 pm
by Kiffi
Hello Xombie,

this one works for me:

Code: Select all

Define.l HoldString
dhGetValue("%s", @HoldString, ExcelApp, ".Workbooks(%d).Name", 1)
If HoldString
  MessageRequester(".Workbooks(1).Name", PeekS(HoldString))
  dhFreeString(HoldString) : HoldString = 0
EndIf
Greetings ... Kiffi

Posted: Mon Apr 23, 2007 4:23 pm
by Dare

Code: Select all

  Define.l iCount
  Define.s HoldString
  Define.l adr

  dhGetValue("%s", @adr, ExcelApp, @".Workbooks(1).Name")
  HoldString=PeekS(adr)
Would that do it? (Taking a punt here).

@adr and peeking
@"Workbooks(1).Name"



EDIT:

Kiffi was too fast.

AND freed the string "adr"

AND got the workbooks string right.

:D

Scrub my answer. :)

Posted: Mon Apr 23, 2007 4:32 pm
by ts-soft
@Dare
for stringresults, you give a pointer to a long and peeks the string. after this
you should always free the long, that's hold the string, with dhFreeString() to
avoid memoryleaks.

Posted: Mon Apr 23, 2007 4:38 pm
by Dare
ts-soft wrote:@Dare
for stringresults, you give a pointer to a long and peeks the string. after this
you should always free the long, that's hold the string, with dhFreeString() to
avoid memoryleaks.
Yeppers! :)

Posted: Mon Apr 23, 2007 5:28 pm
by Xombie
Thanks, kiffi. That worked.

I can understand passing a long variable to get the string but why would it need...

Code: Select all

...ExcelApp, ".Workbooks(%d).Name", 1)
... to work? Why doesn't it like me to ...... ohhh... is it because the Workbooks() property expects a variable and the %d fakes it out by passing the "1" as a variable to the Workbooks() property?

Maybe the help file could be updated a little bit to add this clarification if so?

Thanks again!

Posted: Mon Apr 23, 2007 5:38 pm
by ts-soft
>> I can understand passing a long variable to get the string but why would it need...
Strings intern converted to OleString (bstr). OleStrings will always freed!
There is a memory allocated with SysAllocString_(). This memory a
automatic converted to ANSI-String, but not freed by the lib.

I don't parse the parameters, so no automatic available.

Sorry for the small-helpfile, but i doesn't speak good english. I can write a
better one in german, if required :wink:

Posted: Mon Apr 23, 2007 7:09 pm
by ts-soft
Next example :wink:
GetBiosVersion, using wmi in vbscript

Code: Select all

EnableExplicit

Procedure.s GetBiosVersion()

  Protected Script$
  
  Script$ = "Set objWMIService = GetObject(" + #DQUOTE$ + "winmgmts:\\.\root\CIMV2" + #DQUOTE$ + ")" + #CRLF$
  Script$ + "Set colItems = objWMIService.ExecQuery(" + #DQUOTE$ + "SELECT * FROM Win32_BIOS" + #DQUOTE$ + ",,48)" + #CRLF$
  Script$ + "For Each objItem in colItems" + #CRLF$
  Script$ + "If isNull(objItem.BIOSVersion) Then" + #CRLF$
  Script$ + "myBios = I'm sure, I don't know" + #CRLF$
  Script$ + "Else" + #CRLF$
  Script$ + "myBios = Join(objItem.BIOSVersion, " + #DQUOTE$ + "," + #DQUOTE$ + ")" + #CRLF$
  Script$ + "End If" + #CRLF$
  Script$ + "Next"

  ProcedureReturn Script$

EndProcedure

dhToggleExceptions(#True)

Define.l Result, obj = dhCreateObject("MSScriptControl.ScriptControl")
Define.s Script

If obj

  dhPutValue(obj, "Language = %s", @"VBScript")
  Script = GetBiosVersion()
  dhCallMethod(obj, "AddCode(%s)", @Script)
  dhGetValue("%s", @Result, obj, "Eval(%s)", @"myBios")
  
  If Result

    MessageRequester("BIOSVersion:", PeekS(Result), #MB_ICONINFORMATION)
    dhFreeString(Result) : Result = 0
  
  EndIf  
  
  dhReleaseObject(obj) : obj = 0
  
EndIf