After analyzing it, it seems that the interface uses the "thiscall" calling convention, which causes an error when compiling in PB x86.
Therefore, to make it work properly, the method must be called with a series of assembly instructions, as shown in the code below.
I don't know how to call it in the C backend.
When using the Dialog Library, you need to specify a name in the "name" attribute of an editor gadget, and use the DialogGadget function to get the gadget number.
This is an example using the DynamicDialogs module.
Edit:
Added x86 C backend part.
Edit 2:
Added to use GCC native keyword for x86 thiscall.
https://gcc.gnu.org/onlinedocs/gcc/x86- ... 02c-x86-32
Code: Select all
Interface ITextServices Extends IUnknown
; //@cmember Generic Send Message interface
TxSendMessage.l(msg.l, wparam, lparam, *plresult)
;
; //@cmember Rendering
TxDraw.l(dwDrawAspect.l, lindex.l, *pvAspect, *ptd, hdcDraw, hicTargetDev, *lprcBounds, *lprcWBounds, *lprcUpdate, pfnContinue, dwContinue.l, lViewId.l)
;
; //@cmember Horizontal scrollbar support
TxGetHScroll.l(*plMin, *plMax, *plPos, *plPage, *pfEnabled)
;
; //@cmember Horizontal scrollbar support
TxGetVScroll.l(*plMin, *plMax, *plPos, *plPage, *pfEnabled)
;
; //@cmember Setcursor
OnTxSetCursor.l(dwDrawAspect.l, lindex.l, *pvAspect, *ptd, hdcDraw, hicTargetDev, *lprcClient, x.l, y.l)
;
; //@cmember Hit-test
TxQueryHitPoint.l(dwDrawAspect.l, lindex.l, *pvAspect, *ptd, hdcDraw, hicTargetDev, *lprcClient, x.l, y.l, *pHitResult)
;
; //@cmember Inplace activate notification
OnTxInPlaceActivate.l(*prcClient)
;
; //@cmember Inplace deactivate notification
OnTxInPlaceDeactivate.l()
;
; //@cmember UI activate notification
OnTxUIActivate.l()
;
; //@cmember UI deactivate notification
OnTxUIDeactivate.l()
;
; //@cmember Get text in control
TxGetText.l(*pbstrText)
;
; //@cmember Set text in control
TxSetText.l(pszText.s)
;
; //@cmember Get x position of
TxGetCurTargetX.l(*result)
;
; //@cmember Get baseline position
TxGetBaseLinePos.l(*result)
;
; //@cmember Get Size to fit / Natural size
TxGetNaturalSize.l(dwAspect.l, hdcDraw, hicTargetDev, *ptd, dwMode.l, *psizelExtent, *pwidth, *pheight)
;
; //@cmember Drag & drop
TxGetDropTarget.l(*ppDropTarget)
;
; //@cmember Bulk bit property change notifications
OnTxPropertyBitsChange.l(dwMask.l, dwBits.l)
;
; //@cmember Fetch the cached drawing size .l(logical not physical)
TxGetCachedSize.l(*pdwWidth, *pdwHeight)
EndInterface
#TXTBIT_ALLOWBEEP = 2048
DataSection
IID_ITextServices: ; 8d33f740-cf58-11ce-a89d-00aa006cadc5
Data.l $8d33f740
Data.w $cf58, $11ce
Data.b $a8, $9d, $00, $aa, $00, $6c, $ad, $c5
EndDataSection
Procedure TurnOffRichEditBeep(Gadget)
Protected Unk.IUnknown, TxtSrv.ITextServices
Protected result
If IsGadget(Gadget) And GadgetType(Gadget) = #PB_GadgetType_Editor
If SendMessage_(GadgetID(Gadget), #EM_GETOLEINTERFACE, 0, @Unk)
If Unk
If Unk\QueryInterface(?IID_ITextServices, @TxtSrv) = #S_OK
If TxtSrv
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
Protected Func = @TxtSrv\OnTxPropertyBitsChange()
; thiscall
CompilerIf #PB_Compiler_Backend = #PB_Backend_Asm
EnableASM
mov eax, Func
mov ecx, TxtSrv
push 0
push 2048
call eax
mov result, eax
DisableASM
CompilerElse
;! int __attribute__ ((thiscall)) (*func)(int, int, int) = v_func;
! int __thiscall (*func)(int, int, int) = v_func;
! v_result = func(v_txtsrv, 2048, 0);
; !__asm__ __volatile__ (
; !".intel_syntax noprefix;"
;
; !"mov eax, %1;"
; !"mov ecx, %2;"
; !"push 0;"
; !"push 2048;"
; !"call eax;"
; !"mov %0, eax;"
;
; !".att_syntax"
; !:"=r" (v_result)
; !:"r" (v_func), "r" (v_txtsrv)
; !:"eax", "ecx"
; !);
CompilerEndIf
result = Bool(result = #S_OK)
CompilerElse
If TxtSrv\OnTxPropertyBitsChange(#TXTBIT_ALLOWBEEP, 0) = #S_OK
result = 1
EndIf
CompilerEndIf
TxtSrv\Release()
EndIf
EndIf
Unk\Release()
EndIf
EndIf
EndIf
ProcedureReturn result
EndProcedure
XIncludeFile "../DynamicDialogs_suffixed.pbi"
UseModule DynamicDialogs ; to enable the 'general' commands
UseModule DynamicDialogs_suffixed ; to enable the XML-Elements with 'suffixed' syntax
ClearXML() ; make sure, the XML-Dialog is empty before you begin a new one
; --- Create the Dialog ---
Window__(#PB_Any, "", "DynamicDialog Example", #PB_Window_SizeGadget | #PB_Window_SystemMenu) ; create a resizeable window
vBox__(1) ; create a vertical-Box, where only the first Element in the vBox will be auto-resized
Editor__(#PB_Ignore, "myEditorGadget","",0,0,180) ; create an EditorGadget() with the 'Name': "myEditorGadget"
Button__(1,"","Click me ...") ; create a Button with Gadget-Number = 1
EndVBox__() ; End-Tag for the previously opened vBox
EndWindow__() ; End-Tag for the window
UnuseModule DynamicDialogs_suffixed ; we don't need the XML-Elements any more
If OpenDialogWindow(1, GetXML()) ; Open the last created Window (or specify the Window by ID or Name$)
MyEdGadget = DialogGadget(1,"myEditorGadget")
If TurnOffRichEditBeep(MyEdGadget)
Debug "OK"
EndIf
For n = 1 To 10 ; Fill Editor-Gadget with some content. Adress the Editor-Gadget by using its Name => "myEditorGadget"
SetGadgetText(DialogGadget(1,"myEditorGadget"),GetGadgetText(DialogGadget(1,"myEditorGadget"))+"Line "+Str(n)+#LF$)
Next
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf