Details
ID: LvdXK
Author: westor
Desc: SOURCE.pas
Language: delphi
Size: 4.4KB
Hits: 1386
Public: Yes
Added: 11/9/19 (4y ago)
Last Edited: 11/9/19 (4y ago)
Expires: No

Raw
DL
Copy
Wrap
Details
  1. library cnick;
  2. uses
  3.   Windows,
  4.   messages;
  5.  
  6. type
  7. Twin = record
  8. window:hwnd;
  9. proc:pointer;
  10. end;
  11.  
  12. var
  13. mHwnd:hwnd;
  14. WC,idle,dmu:integer;
  15. op:pointer;
  16. p:array [1..200] of twin;
  17.  
  18. type LoadInfo = packed record
  19. mVersion: DWORD;
  20. mHwnd: HWND;
  21. mKeep: BOOL;
  22. end;
  23. PLoadInfo =  ^LoadInfo;
  24.  
  25. function Str2int(s:string) : integer;
  26. var i,e:integer;
  27. begin
  28. val(s,i,e);
  29. result:=i;
  30. end;
  31.  
  32. function int2str(i:integer) : string;
  33. var s:string;
  34. begin
  35. str(i,s);
  36. result:=s;
  37. end;
  38.  
  39. function smsg(const S: string;i:integer):string;
  40. var
  41. MapFile:Integer;
  42. Command:Pointer;
  43. WM:cardinal;
  44. begin
  45. wm:=WM_USER+200;
  46. if (i = 1) then wm:=WM_USER+201;
  47. MapFile:=CreateFileMapping(INVALID_HANDLE_VALUE, nil, PAGE_READWRITE, 0, 1024, 'mIRC');
  48. Command:=MapViewOfFile(MapFile, FILE_MAP_ALL_ACCESS, 0, 0, 0);
  49. lstrcpy(Command, PChar(S));
  50. SendMessage(mhwnd,wm,0,0);
  51. if i = 1 then result:=pchar(command);
  52. UnmapViewOfFile(Command);
  53. CloseHandle(MapFile);
  54. end;
  55.  
  56. Function mIRCProc(wnd:HWnd;msg:Cardinal;wparam,lparam:LongInt):LongInt;stdcall;
  57. var
  58. txt: Array[0..255] of char;
  59. Begin
  60. if (msg = WM_ENABLE) and (idle = 1) then begin
  61. idle:=0;
  62. smsg('//if ($chan($active)) //window -a $active',0);
  63. end
  64. else if (msg = WM_ENTERIDLE) and (idle <> 1) then begin
  65. GetWindowText(lparam,txt,1000);
  66. if (txt = 'mIRC Address Book') then idle:=1;
  67. end;
  68. result:=callWindowProc(op, wnd, msg, wparam, lparam);
  69. end;
  70.  
  71. procedure LoadDll(Info: PLoadInfo); stdcall;
  72. begin
  73. WC:=1;
  74. idle:=0;
  75. Info.mKeep := true;
  76. mhwnd:=info.mHwnd;
  77. dmu:=str2int(smsg('$iif($dll(ktools.dll) || $dll(dmu.dll),1,0)',1));
  78. if (dmu = 0) then op:=Pointer(SetWindowLong(info.mHwnd,GWL_WNDPROC,LongInt(@mIRCProc)))
  79. else begin
  80. smsg('//.timer 1 1 var %t = $input(Dmu.dll or Ktools.dll is already loaded. $cr $+ CNICK.DLL MUST be loaded before these. Please consult the CNICK.dll documentation. $cr $+ CNICK.dll will now be Unloaded,ow,Warning)',0);
  81. info.mKeep:=false;
  82. end;
  83. end;
  84.  
  85. function UnloadDll(mTimeout: Integer): Integer; stdcall;
  86. var i:integer;
  87. begin
  88. result:=0;
  89. if (mTimeout = 0) then begin
  90. for i:=1 to wc do begin
  91. SetWindowLong(p[i].window,GWL_WNDPROC,LongInt(p[i].proc));
  92. end;
  93. smsg('//if ($chan($active)) //window -a $active',0);
  94. if (dmu = 0) then SetWindowLong(mhwnd,GWL_WNDPROC,LongInt(op));
  95. wc:=1;
  96. result:=1;
  97. end;
  98. end;
  99.  
  100. function MakeRect( Left, Top, Right, Bottom: Integer ): TRect; stdcall;
  101. begin
  102. Result.Left:=Left+2;
  103. Result.Top:=Top;
  104. Result.Right:=Right;
  105. Result.Bottom:=Bottom;
  106. end;
  107.  
  108. function states(s,a:cardinal):boolean;
  109. begin
  110. result:=false;
  111. if (a and ODA_FOCUS <> 0) and (s and ODS_SELECTED <> 0) and (s and ODS_FOCUS <> 0) then result:=true;
  112. if (a and ODA_DRAWENTIRE <> 0) and (s and ODS_SELECTED <> 0) and (s and ODS_FOCUS <> 0) then result:=true;
  113. end;
  114.  
  115. Function NlistProc(wnd:HWnd;msg:Cardinal;wparam,lparam:LongInt):LongInt;stdcall;
  116. var
  117. e,c,i,col,ocol,n:integer;
  118. DIS: PDrawItemStruct;
  119. r:trect;
  120. m,s:string;
  121. CharBuffer: array[0..1024] of Char;
  122. Begin
  123. FillChar(Charbuffer, SizeOf(CharBuffer), #0);
  124. Result:=0;
  125. e:=0;
  126. n:=1;
  127. while (p[n].window <> wnd) do n:=n+1;
  128. if (msg = WM_DRAWITEM) then begin
  129. DIS:=Pointer(lParam);
  130. SendMessage(dis.hwndItem,LB_GETTEXT,dis.itemID,integer(@CharBuffer));
  131. if (dis.itemState and ODS_SELECTED <> 1) then begin
  132. m:=copy(charbuffer,1,1);
  133. if (m = '!') or (m = '~') or (m = '&') or (m = '@') or (m = '%') or (m = '+') then begin
  134. callWindowProc(p[n].proc,wnd,msg,wparam,lparam);
  135. e:=1;
  136. c:=str2int(smsg('$cnick(0)',1));
  137. s:='x';
  138. for i:=1 to c do begin
  139. s:=smsg('$cnick('+int2str(i)+')',1);
  140. if (s = m) then break;
  141. end;
  142. if (s = m) then begin
  143. r:=dis.rcItem;
  144. r:=MakeRect(r.Left,r.Top,r.Right,r.Bottom);
  145. setbkmode(dis.hDC,TRANSPARENT);
  146. col:=str2int(smsg('$color($cnick('+int2str(i)+').color)',1));
  147. ocol:=settextcolor(dis.hDC,col);
  148. drawtext(dis.hDC,pchar(m),1,r,0);
  149. settextcolor(dis.hDC,ocol);
  150. end;
  151. end;
  152. end;
  153. if (dis.itemState and ODS_FOCUS <> 0) then begin
  154. drawfocusrect(dis.hDC,dis.rcItem);
  155. e:=1;
  156. end;
  157. end;
  158. if (e = 0) then Result:=callWindowProc(p[n].proc, wnd, msg, wparam, lparam );
  159. End;
  160.  
  161. function GetTok(Str,Num,Tok:string):String;
  162. begin
  163. result:=smsg('$gettok('+str+','+num+','+tok+')',1);
  164. end;
  165.  
  166. FUNCTION JOIN(mWnd: hWnd; aWnd: hWnd; Data: pchar; Parms: PChar;
  167. Show: Boolean; NoPause: Boolean ): Integer; export; stdcall;
  168. var
  169. s:String;
  170. swnd:hwnd;
  171. begin
  172. mhwnd:=mwnd;
  173. s:='OK';
  174. swnd:=str2int(smsg('$window('+Gettok(data,'1','32')+').hwnd',1));
  175. if not(iswindow(swnd)) or (wc > 199) then s:='ERR'
  176. else begin
  177. p[wc].window:=swnd;
  178. p[wc].proc:=Pointer(SetWindowLong(swnd,GWL_WNDPROC,LongInt(@NlistProc)));
  179. wc:=wc+1;
  180. end;
  181. lstrcpy(data, pchar(s));
  182. result:= 3;
  183. end;
  184.  
  185. exports
  186. LoadDll,
  187. UnloadDll,
  188. JOIN;
  189.  
  190. end.
  191.  

 0  0 Login to vote.

Login to comment.