The use of the D language has been almost 20 days, has completed the project needs the basic functions, but also needs to be further improved.
In the last two or three days, several window widgets have been ported based on Dgui, with treelist (tree + list view), DataList (data list), Mdifrom (Multi-window), Iewebbrowser (IE), scieditor ( Sci Source Code Editor), DockPanel (Notpad docking plugin), Sysheader (table header Control),
Several standard Windows controls such as Syslink.
Thanks to the author of Dgui, the layout management and encapsulation of Windows controls is truly exceptional.
An issue was found that could not be overloaded when using the Windows interface. The code is as follows:
ImportStd.stdio;ImportCore.sys.windows.unknwn;Importcore.sys.windows.windows;classmyclass:iunknown{HRESULT QueryInterface (IID* riid,void* * Pvobject) {return0;} ULONG AddRef () {return0;} ULONG Release () {return0;} Overrideintopcmp (Object o) {return Super. OPCMP (o); }}intMain (string[] argv) {MyClass my=NewMyClass (); return0;}
Error at compile time:
Error 1 error:function Main. MYCLASS.OPCMP does not override any function, do you mean to override ' object. OBJECT.OPCMP '? D:\TEMP\CONSOLEAPP8\CONSOLEAPP8\MAIN.D 11
Prompt cannot be overloaded.
This is because when MyClass inherits from the IUnknown interface, because IUnknown is an extern (Windows) type, MyClass is also an extern (Windows) type, this time override int opcmp (Object o) cannot be overloaded because the symbol uses the extern (Windows) format and cannot correspond to the Object.opcomp method. Causes compilation to fail.
To solve this problem, you only need to explicitly specify that the Opcomp method is an extern (D) type. As follows:
ImportStd.stdio;ImportCore.sys.windows.unknwn;Importcore.sys.windows.windows;classmyclass:iunknown{HRESULT QueryInterface (IID* riid,void* * Pvobject) {return0;} ULONG AddRef () {return0;} ULONG Release () {return0;} extern (D) overrideintopcmp (Object o) {return Super. OPCMP (o); }}intMain (string[] argv) {MyClass my=NewMyClass (); return0;}
--------------------------------------------------------------------------------------------------------------- ----
Another problem to think about is that in the D language, constructors in C + + cannot be called, and implementations that might need to parse the new function in C + + implement the constructs of classes in C + + in the D language.
Wan Hong Nan
Problems when using the extern (Windows) class to overload the object method in the D language