代码拉取完成,页面将自动刷新
package api
import (
"reflect"
"unsafe"
. "github.com/ying32/govcl/vcl/types"
)
type TGoParam struct {
Type uint8
Value uintptr
}
var (
CallbackMap = map[uintptr]interface{}{}
)
func DBoolToGoBool(val uintptr) bool {
if val != 0 {
return true
}
return false
}
func GoBoolToDBool(val bool) uintptr {
if val {
return 1
}
return 0
}
func addEventToMap(f interface{}) uintptr {
p := reflect.ValueOf(f).Pointer()
CallbackMap[p] = f
return p
}
func SetEventCallback(ptr uintptr) {
setEventCallback.Call(ptr)
}
func DGetParam(index int, ptr uintptr) TGoParam {
p := TGoParam{}
dGetParam.Call(uintptr(index), ptr, uintptr(unsafe.Pointer(&p)))
return p
}
func DGetStringArrOf(p uintptr, index int) string {
r, _, _ := dGetStringArrOf.Call(p, uintptr(index))
return DStrToGoStr(r)
}
func DStrLen(p uintptr) int {
ret, _, _ := dStrLen.Call(p)
return int(ret)
}
func DMove(src, dest uintptr, llen int) {
dMove.Call(src, dest, uintptr(llen))
}
func DShowMessage(s string) {
dShowMessage.Call(GoStrToDStr(s))
}
func DGetMainInstance() uintptr {
ret, _, _ := dGetMainInstance.Call()
return ret
}
func DMessageDlg(Msg string, DlgType TMsgDlgType, Buttons TMsgDlgButtons, HelpCtx int32) int32 {
ret, _, _ := dMessageDlg.Call(GoStrToDStr(Msg), uintptr(DlgType), uintptr(Buttons), uintptr(HelpCtx))
return int32(ret)
}
func DSetReportMemoryLeaksOnShutdown(v bool) {
dSetReportMemoryLeaksOnShutdown.Call(GoBoolToDBool(v))
}
func DTextToShortCut(val string) TShortCut {
ret, _, _ := dTextToShortCut.Call(GoStrToDStr(val))
return TShortCut(ret)
}
func DShortCutToText(val TShortCut) string {
ret, _, _ := dShortCutToText.Call(uintptr(val))
return DStrToGoStr(ret)
}
func DSysOpen(filename string) {
dSysOpen.Call(GoStrToDStr(filename))
}
func DExtractFilePath(filename string) string {
r, _, _ := dExtractFilePath.Call(GoStrToDStr(filename))
return DStrToGoStr(r)
}
func DFileExists(filename string) bool {
r, _, _ := dFileExists.Call(GoStrToDStr(filename))
return DBoolToGoBool(r)
}
func DInheritsFromControl(obj uintptr) bool {
r, _, _ := dInheritsFromControl.Call(obj)
return r != 0
}
func DInheritsFromWinControl(obj uintptr) bool {
r, _, _ := dInheritsFromWinControl.Call(obj)
return r != 0
}
func DInheritsFromComponent(obj uintptr) bool {
r, _, _ := dInheritsFromComponent.Call(obj)
return r != 0
}
func DSelectDirectory1(options TSelectDirOpts) (bool, string) {
var ptr uintptr
r, _, _ := dSelectDirectory1.Call(uintptr(unsafe.Pointer(&ptr)), uintptr(options), 0)
v := DBoolToGoBool(r)
if v {
return true, DStrToGoStr(ptr)
}
return false, ""
}
func DSelectDirectory2(caption, root string, options TSelectDirExtOpts, parent uintptr) (bool, string) {
var ptr uintptr
r, _, _ := dSelectDirectory2.Call(GoStrToDStr(caption), GoStrToDStr(root), uintptr(unsafe.Pointer(&ptr)),
uintptr(options), parent)
v := DBoolToGoBool(r)
if v {
return true, DStrToGoStr(ptr)
}
return false, ""
}
func DSynchronize(fn interface{}) {
dSynchronize.Call(addEventToMap(fn))
}
func DInputBox(aCaption, aPrompt, aDefault string) string {
r, _, _ := dInputBox.Call(GoStrToDStr(aCaption), GoStrToDStr(aPrompt), GoStrToDStr(aDefault))
return DStrToGoStr(r)
}
func DInputQuery(aCaption, aPrompt string, value *string) bool {
if value == nil {
return false
}
var strPtr uintptr
r, _, _ := dInputQuery.Call(GoStrToDStr(aCaption), GoStrToDStr(aPrompt), GoStrToDStr(*value), uintptr(unsafe.Pointer(&strPtr)))
if strPtr != 0 {
*value = DStrToGoStr(strPtr)
}
return DBoolToGoBool(r)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。