TC官方合作论坛

标题: 界面 [打印本页]

作者: q273814    时间: 2015-6-2 17:45
标题: 界面
大部分的游戏登陆器是嵌套的网页来做界面研究大半天了

终于搞出来了
过些日子抽时间研究TC的写法
然后就可以把界面完全使用简单华丽的HTML了

[attach]20653[/attach]

作者: q273814    时间: 2015-6-2 20:10
本帖最后由 q273814 于 2015-6-2 20:12 编辑

  1. unit Unit2;
  2. interface
  3. uses Windows, Classes;
  4. type
  5. TDHTMLEvent = class (TObject, IUnknown, IDispatch)
  6. private
  7. FRefCount: Integer;
  8. FOldEvent: IDispatch;
  9. FElementEvent: TNotifyEvent;
  10. // IUnknown
  11. function QueryInterface(c**t IID: TGUID; out Obj): Integer; stdcall;
  12. function _AddRef: Integer; stdcall;
  13. function _Release: Integer; stdcall;
  14. // IDispatch
  15. function GetTypeInfoCount(out Count: Integer): HResult; stdcall;
  16. function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;
  17. function GetIDsOfNames(c**t IID: TGUID; Names: Pointer;
  18. NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; stdcall;
  19. function Invoke(DispID: Integer; c**t IID: TGUID; LocaleID: Integer;
  20. Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;
  21. public
  22. { Public declarati** }
  23. function HookEventHandler(CallerHandler: TNotifyEvent): IDispatch;
  24. property ElementEvent: TNotifyEvent read FElementEvent write FElementEvent;
  25. end;
  26. implementation
  27. { TDHTMLEvent }
  28. function TDHTMLEvent._AddRef: Integer;
  29. begin
  30. Inc(FRefCount);
  31. Result := FRefCount;
  32. end;
  33. function TDHTMLEvent._Release: Integer;
  34. begin
  35. Dec(FRefCount);
  36. Result := FRefCount;
  37. end;
  38. function TDHTMLEvent.GetIDsOfNames(c**t IID: TGUID; Names: Pointer;
  39. NameCount, LocaleID: Integer; DispIDs: Pointer): HResult;
  40. begin
  41. if FOldEvent <> nil then
  42. Result := FOldEvent.GetIDsOfNames(IID, Names, NameCount, LocaleID, DispIDs)
  43. else
  44. Result := E_NOTIMPL;
  45. end;
  46. function TDHTMLEvent.GetTypeInfo(Index, LocaleID: Integer;
  47. out TypeInfo): HResult;
  48. begin
  49. if FOldEvent <> nil then
  50. Result := FOldEvent.GetTypeInfo(Index, LocaleID, TypeInfo)
  51. else begin
  52. Pointer(TypeInfo) := nil;
  53. Result := E_NOTIMPL;
  54. end
  55. end;
  56. function TDHTMLEvent.GetTypeInfoCount(out Count: Integer): HResult;
  57. begin
  58. if FOldEvent <> nil then
  59. Result := FOldEvent.GetTypeInfoCount(Count)
  60. else begin
  61. Count := 0;
  62. Result := S_OK;
  63. end;
  64. end;
  65. function TDHTMLEvent.QueryInterface(c**t IID: TGUID; out Obj): Integer;
  66. begin
  67. if GetInterface(IID, Obj) then
  68. Result := S_OK
  69. else
  70. Result := E_NOINTERFACE;
  71. end;
  72. function TDHTMLEvent.Invoke(DispID: Integer; c**t IID: TGUID;
  73. LocaleID: Integer; Flags: Word; var Params; VarResult, ExcepInfo,
  74. ArgErr: Pointer): HResult;
  75. begin
  76. try
  77. if Assigned(FElementEvent) then FElementEvent(Self);
  78. finally
  79. if FOldEvent <> nil then
  80. Result := FOldEvent.Invoke(DispID, IID, LocaleID, Flags, Params,
  81. VarResult, ExcepInfo, ArgErr)
  82. else
  83. Result := E_NOTIMPL;
  84. end;
  85. end;
  86. function TDHTMLEvent.HookEventHandler(CallerHandler: TNotifyEvent): IDispatch;
  87. begin
  88. FOldEvent:=nil;
  89. ElementEvent:=CallerHandler;
  90. Result:=Self;
  91. end;
  92. end.
复制代码

作者: q273814    时间: 2015-6-2 20:12
本帖最后由 q273814 于 2015-6-2 20:14 编辑

复制代码

作者: 忆辰辅助    时间: 2015-6-3 07:59
腻害




欢迎光临 TC官方合作论坛 (http://bbs.52tc.co/) Powered by Discuz! X3.1