PureDispHelper UserLib - Update with Includefile for Unicode

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

The optional parameter hWnd doesn't exist in original Disphelper This
addition works only for some ocx, that embeddeble in browser.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

WoW! Very nice...thank you very much. :)
r_hyde
Enthusiast
Enthusiast
Posts: 155
Joined: Wed Jul 05, 2006 12:40 am

Post 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.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post 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?
Dare2 cut down to size
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Agents speaks only with some extra stuff from MS.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

Ah. Thanks ts-soft.
Dare2 cut down to size
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post 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.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Sorry, but i can't help you, i haven't ms-office installed.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Kiffi
Addict
Addict
Posts: 1484
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post 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
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post 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. :)
Dare2 cut down to size
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post 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.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post 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! :)
Dare2 cut down to size
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post 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!
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post 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:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post 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
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply