Posted: Sun Apr 22, 2007 1:52 pm
The optional parameter hWnd doesn't exist in original Disphelper This
addition works only for some ocx, that embeddeble in browser.
addition works only for some ocx, that embeddeble in browser.
http://www.purebasic.com
https://www.purebasic.fr/english/
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.The optional parameter hWnd doesn't exist in original Disphelper This
addition works only for some ocx, that embeddeble in browser.
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
Code: Select all
dhGetValue("%s", @HoldString, ExcelApp, ".Workbooks(1).Name")
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
Code: Select all
Define.l iCount
Define.s HoldString
Define.l adr
dhGetValue("%s", @adr, ExcelApp, @".Workbooks(1).Name")
HoldString=PeekS(adr)
Yeppers!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.
Code: Select all
...ExcelApp, ".Workbooks(%d).Name", 1)
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