Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1372 lines
31 KiB

  1. #include <windows.h>
  2. #include <port1632.h>
  3. #include <ddeml.h>
  4. #include <string.h>
  5. #include "wrapper.h"
  6. #include "ddestrs.h"
  7. extern BOOL UpdateCount(HWND,INT,INT);
  8. BOOL Balance(INT);
  9. /*
  10. * Service routines
  11. */
  12. /*************************** Private Function ******************************\
  13. GetHINSTANCE
  14. \***************************************************************************/
  15. HINSTANCE GetHINSTANCE( HWND hwnd ) {
  16. HINSTANCE hInstance;
  17. #ifdef WIN32
  18. hInstance=(HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE);
  19. #else
  20. hInstance=(HINSTANCE)GetWindowWord(hwnd,GWW_HINSTANCE);
  21. #endif
  22. return hInstance;
  23. }
  24. //*****************************************************************************
  25. //************************** DispWndProc **************************
  26. //*****************************************************************************
  27. LONG FAR PASCAL DispWndProc( HWND hwnd , UINT msg, WPARAM wp, LONG lp) {
  28. return DefWindowProc(hwnd,msg,wp,lp);
  29. }
  30. /*************************** Private Function ******************************\
  31. *
  32. * CreateDisplayWindow
  33. *
  34. \***************************************************************************/
  35. HWND CreateDisplayWindow( HWND hwndParent, int nPosIndex ) {
  36. WNDCLASS wc,wcc;
  37. LPWNDCLASS lpWndClass=&wc;
  38. HWND hwnd;
  39. RECT r;
  40. int stpy,stpx,cy;
  41. char sz[100];
  42. LPSTR lpstr=&sz[0];
  43. #ifdef WIN32
  44. LPCTSTR lpsz;
  45. #else
  46. LPSTR lpsz;
  47. #endif
  48. char szname[100];
  49. strcpy(&szname[0],"Display Window");
  50. wc.style = 0;
  51. wc.lpfnWndProc = DispWndProc;
  52. wc.cbClsExtra = 0;
  53. wc.cbWndExtra = 0;
  54. wc.hInstance = GetHINSTANCE(hwndParent);
  55. wc.hIcon = LoadIcon(NULL,IDI_EXCLAMATION );
  56. wc.hCursor = LoadCursor(NULL,IDC_ARROW );
  57. wc.lpszMenuName = NULL;
  58. wc.lpszClassName = "Display Window";
  59. wc.hbrBackground = CreateSolidBrush(RGB(0,255,255));
  60. lpsz=(LPSTR)wc.lpszClassName;
  61. if(!GetClassInfo(wc.hInstance,lpsz,&wcc)) {
  62. RegisterClass(lpWndClass);
  63. }
  64. GetClientRect(hwndParent,&r);
  65. stpx =r.right-r.left;
  66. stpy =((r.bottom-r.top)/3);
  67. switch(nPosIndex) {
  68. case 1: cy=r.bottom-(3*cyText);
  69. break;
  70. case 2: cy=r.bottom-(6*cyText);
  71. break;
  72. case 3: cy=r.bottom-(9*cyText);
  73. break;
  74. case 4: cy=r.bottom-(12*cyText);
  75. break;
  76. case 5: cy=r.bottom-(15*cyText);
  77. break;
  78. default: cy=r.bottom-(18*cyText);
  79. break;
  80. }
  81. if (!IsWindow(hwndParent)) DOut((HWND)NULL,"DdeStrs.exe -- ERR:Bad parent hwnd=%u!\r\n",0,(LONG)hwndParent);
  82. hwnd = CreateWindowEx(WS_EX_DLGMODALFRAME,
  83. "Display Window",
  84. &szname[0],
  85. WS_CHILD|WS_VISIBLE|WS_CAPTION|WS_DISABLED,
  86. 0,
  87. cy,
  88. stpx,
  89. 3*cyText,
  90. hwndParent,
  91. NULL,
  92. lpWndClass->hInstance,
  93. NULL );
  94. if ( !IsWindow(hwnd) )
  95. {
  96. DDEMLERROR("DdeStrs.Exe -- ERR:Display window not created\r\n");
  97. UnregisterClass("Display Window",wc.hInstance);
  98. }
  99. return hwnd;
  100. }
  101. BOOL PokeTestItem_Text(
  102. HDDEDATA hData)
  103. {
  104. LPBYTE lpData;
  105. HDC hdc;
  106. HBRUSH hBrush;
  107. PAINTSTRUCT ps;
  108. RECT rc;
  109. DWORD cbData;
  110. HWND hwndDisplay;
  111. Balance(OFFSET_CLIENT);
  112. hwndDisplay=(HWND)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HWNDDISPLAY);
  113. SetWindowText(hwndDisplay,"Client - CF_TEXT");
  114. lpData = (LPBYTE) DdeAccessData( hData, &cbData );
  115. hdc = GetDC(hwndDisplay);
  116. if(!hdc) {
  117. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hdc ret from GetDC (client:CF_TEXT)!\r\n");
  118. DdeUnaccessData(hData); //JOHNSP:CHANGE
  119. return 0;
  120. }
  121. hBrush=CreateSolidBrush(WHITE);
  122. if(!hBrush) {
  123. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hBrush ret from CreateSolidBrush (client:CF_TEXT)!\r\n");
  124. DdeUnaccessData(hData); //JOHNSP:CHANGE
  125. EndPaint(hwndDisplay,&ps);
  126. return 0;
  127. }
  128. GetClientRect(hwndDisplay,&rc);
  129. FillRect(hdc,&rc,hBrush);
  130. DeleteObject(hBrush);
  131. DrawText(hdc, lpData, -1, &rc, DT_LEFT|DT_TOP);
  132. ReleaseDC(hwndDisplay,hdc);
  133. DdeUnaccessData(hData); //JOHNSP:CHANGE
  134. return(TRUE);
  135. }
  136. BOOL PokeTestItem_DIB(
  137. HDDEDATA hData)
  138. {
  139. HWND hwnd;
  140. HDC hdc;
  141. RECT r;
  142. INT width,height;
  143. LPBITMAPINFO lpbitinfo;
  144. LPBYTE lpbits;
  145. HANDLE hmem;
  146. LPBYTE lpData;
  147. DWORD cbData;
  148. LPBYTE lp;
  149. int iexRGB;
  150. Balance(OFFSET_CLIENT);
  151. lpData = (LPBYTE) DdeAccessData( hData, &cbData );
  152. hwnd=(HWND)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HWNDDISPLAY);
  153. SetWindowText(hwnd,"Client - CF_DIB");
  154. hdc = GetDC(hwnd);
  155. if(!hdc) {
  156. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hdc (client)\r\n");
  157. DdeUnaccessData(hData); //JOHNSP:CHANGE
  158. return 0;
  159. }
  160. GetClientRect(hwnd,&r);
  161. width=r.right-r.left;
  162. height=r.bottom-r.top;
  163. #ifdef WIN32
  164. memcpy(&hmem,lpData,sizeof(HANDLE));
  165. #else
  166. _fmemcpy(&hmem,lpData,sizeof(HANDLE));
  167. #endif
  168. if(!hmem) {
  169. DDEMLERROR("DdeStrs.Exe -- ERR:hmem recieved from server=NULL (client)\r\n");
  170. DdeUnaccessData(hData); //JOHNSP:CHANGE
  171. ReleaseDC(hwnd,hdc);
  172. return 0;
  173. }
  174. lp =(LPBYTE)GlobalLock(hmem);
  175. lpbitinfo=(LPBITMAPINFO)lp;
  176. // iexRGB is ((2^n)-1) where n=biBitCount and we are computing the
  177. // number of RGBQUAD structures. Remember that part of the
  178. // BITMAPINFO structure contains 1 RGBQUAD already.
  179. iexRGB =((0x0001<<lpbitinfo->bmiHeader.biBitCount)-1)*sizeof(RGBQUAD);
  180. lpbits=lp+(sizeof(BITMAPINFO)+iexRGB);
  181. SetDIBitsToDevice(hdc,
  182. 0,
  183. 0,
  184. (UINT)lpbitinfo->bmiHeader.biWidth,
  185. (UINT)lpbitinfo->bmiHeader.biHeight,
  186. 0,
  187. 0,
  188. 0,
  189. (UINT)(lpbitinfo->bmiHeader.biHeight),
  190. lpbits,
  191. lpbitinfo,
  192. DIB_RGB_COLORS);
  193. ReleaseDC(hwnd,hdc);
  194. DdeUnaccessData(hData); //JOHNSP:CHANGE
  195. return(TRUE);
  196. }
  197. BOOL PokeTestItem_BITMAP(
  198. HDDEDATA hData)
  199. {
  200. HWND hwnd;
  201. HDC hdc,hdcMem;
  202. RECT r;
  203. INT width,height;
  204. HBITMAP hbmap;
  205. HANDLE hobj;
  206. LPBYTE lpData;
  207. DWORD cbData;
  208. Balance(OFFSET_CLIENT);
  209. hwnd=(HWND)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HWNDDISPLAY);
  210. SetWindowText(hwnd,"Client - CF_BITMAP");
  211. lpData = (LPBYTE) DdeAccessData( hData, &cbData );
  212. #ifdef WIN32
  213. memcpy(&hbmap,lpData,sizeof(HBITMAP));
  214. #else
  215. _fmemcpy(&hbmap,lpData,sizeof(HBITMAP));
  216. #endif
  217. hdc = GetDC(hwnd);
  218. hdcMem = CreateCompatibleDC(hdc);
  219. if(!hdc||!hdcMem) {
  220. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hdc (client)\r\n");
  221. DdeUnaccessData(hData); //JOHNSP:CHANGE
  222. if(hdc) ReleaseDC(hwndMain,hdc);
  223. if(hdcMem) DeleteDC(hdcMem);
  224. return 0;
  225. }
  226. if(!hbmap) {
  227. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hbmap (client)\r\n");
  228. DdeUnaccessData(hData); //JOHNSP:CHANGE
  229. DeleteDC(hdcMem);
  230. ReleaseDC(hwndMain,hdc);
  231. return 0;
  232. }
  233. GetClientRect(hwnd,&r);
  234. width=r.right-r.left;
  235. height=r.bottom-r.top;
  236. hobj=SelectObject(hdcMem,hbmap);
  237. if(!hobj) {
  238. DDEMLERROR("DdeStrs.Exe -- ERR:SelectObject failed (client)\r\n");
  239. DdeUnaccessData(hData); //JOHNSP:CHANGE
  240. DeleteDC(hdcMem);
  241. ReleaseDC(hwndMain,hdc);
  242. return 0;
  243. }
  244. if(!BitBlt(hdc,0,0,width,height,hdcMem,0,0,SRCCOPY))
  245. DDEMLERROR("DdeStrs.Exe -- ERR:BitBlt failed (client)\r\n");
  246. hobj=SelectObject(hdcMem,hobj);
  247. DeleteDC(hdcMem);
  248. ReleaseDC(hwnd,hdc);
  249. DdeUnaccessData(hData); //JOHNSP:CHANGE
  250. return(TRUE);
  251. }
  252. #ifdef WIN32
  253. BOOL PokeTestItem_ENHMETA(
  254. HDDEDATA hData)
  255. {
  256. LPBYTE lpData;
  257. HWND hwnd;
  258. HDC hdc;
  259. HANDLE hemf;
  260. DWORD cbData;
  261. RECT r;
  262. Balance(OFFSET_CLIENT);
  263. hwnd=(HWND)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HWNDDISPLAY);
  264. SetWindowText(hwnd,"Client - CF_ENHMETAFILE");
  265. lpData = (LPBYTE) DdeAccessData( hData, &cbData );
  266. hdc = GetDC(hwnd);
  267. if(!hdc) {
  268. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hdc (client)\r\n");
  269. DdeUnaccessData(hData); //JOHNSP:CHANGE
  270. return 0;
  271. }
  272. #ifdef WIN32
  273. memcpy(&hemf,lpData,sizeof(HANDLE));
  274. #else
  275. _fmemcpy(&hemf,lpData,sizeof(HANDLE));
  276. #endif
  277. GetClientRect(hwnd,&r);
  278. if(!PlayEnhMetaFile(hdc,hemf,&r))
  279. DDEMLERROR("DdeStrs.Exe -- ERR:PlayMetaFile failed (client)\r\n");
  280. ReleaseDC(hwnd,hdc);
  281. DdeUnaccessData(hData); //JOHNSP:CHANGE
  282. return(TRUE);
  283. }
  284. #endif
  285. BOOL PokeTestItem_METAPICT(
  286. HDDEDATA hData)
  287. {
  288. LPBYTE lpData;
  289. HWND hwnd;
  290. HDC hdc;
  291. HANDLE hmf;
  292. LPMETAFILEPICT lpMfp;
  293. HANDLE hmem;
  294. DWORD cbData;
  295. Balance(OFFSET_CLIENT);
  296. hwnd=(HWND)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HWNDDISPLAY);
  297. SetWindowText(hwnd,"Client - CF_METAFILEPICT");
  298. lpData = (LPBYTE) DdeAccessData( hData, &cbData );
  299. hdc = GetDC(hwnd);
  300. if(!hdc) {
  301. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hdc (client)\r\n");
  302. DdeUnaccessData(hData); //JOHNSP:CHANGE
  303. return 0;
  304. }
  305. #ifdef WIN32
  306. memcpy(&hmem,lpData,sizeof(HANDLE));
  307. #else
  308. _fmemcpy(&hmem,lpData,sizeof(HANDLE));
  309. #endif
  310. lpMfp=(LPMETAFILEPICT)GlobalLock(hmem);
  311. hmf=lpMfp->hMF;
  312. if(!PlayMetaFile(hdc,hmf))
  313. DDEMLERROR("DdeStrs.Exe -- ERR:PlayMetaFile failed (client)\r\n");
  314. ReleaseDC(hwnd,hdc);
  315. DdeUnaccessData(hData); //JOHNSP:CHANGE
  316. return(TRUE);
  317. }
  318. BOOL PokeTestItem_PALETTE(
  319. HDDEDATA hData)
  320. {
  321. LPBYTE lpData;
  322. HWND hwnd;
  323. HPALETTE hpal;
  324. HDC hdc;
  325. RECT r;
  326. HANDLE hobj;
  327. HANDLE hbrush;
  328. DWORD cbData;
  329. Balance(OFFSET_CLIENT);
  330. hwnd=(HWND)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HWNDDISPLAY);
  331. SetWindowText(hwnd,"Client - CF_PALETTE");
  332. lpData = (LPBYTE) DdeAccessData( hData, &cbData );
  333. GetClientRect(hwnd,&r);
  334. hdc=GetDC(hwnd);
  335. if(!hdc) {
  336. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hdc (client)\r\n");
  337. DdeUnaccessData(hData); //JOHNSP:CHANGE
  338. return 0;
  339. }
  340. #ifdef WIN32
  341. memcpy(&hpal,lpData,sizeof(HPALETTE));
  342. #else
  343. _fmemcpy(&hpal,lpData,sizeof(HPALETTE));
  344. #endif
  345. hobj=(HPALETTE)SelectPalette(hdc,hpal,FALSE);
  346. if(!hobj) {
  347. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hobj:SelectPalette failed (client)\r\n");
  348. DdeUnaccessData(hData); //JOHNSP:CHANGE
  349. ReleaseDC(hwnd,hdc);
  350. return 0;
  351. }
  352. RealizePalette(hdc);
  353. hbrush=CreateSolidBrush(PALETTEINDEX(0));
  354. if(!hbrush) {
  355. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hbrush ret from CreatSolidBrush (client)\r\n");
  356. DdeUnaccessData(hData); //JOHNSP:CHANGE
  357. SelectPalette(hdc,(HPALETTE)hobj,FALSE);
  358. ReleaseDC(hwnd,hdc);
  359. return 0;
  360. }
  361. FillRect(hdc,&r,hbrush);
  362. DeleteObject(hbrush);
  363. SelectPalette(hdc,(HPALETTE)hobj,FALSE);
  364. ReleaseDC(hwnd,hdc);
  365. DdeUnaccessData(hData); //JOHNSP:CHANGE
  366. return(TRUE);
  367. }
  368. HDDEDATA RenderTestItem_Text(
  369. HDDEDATA hData)
  370. {
  371. HDC hdc;
  372. HBRUSH hBrush;
  373. PAINTSTRUCT ps;
  374. RECT rc;
  375. HDDEDATA hddedata;
  376. LONG l;
  377. HDDEDATA FAR *hAppOwned;
  378. HANDLE hmem;
  379. HWND hwndDisplay;
  380. Balance(OFFSET_SERVER);
  381. hwndDisplay=(HWND)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HWNDDISPLAY);
  382. SetWindowText(hwndDisplay,"Server - CF_TEXT");
  383. // if we are running app owned then we just reuse our
  384. // last handle.
  385. hmem=(HANDLE)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HAPPOWNED);
  386. hAppOwned=(HDDEDATA FAR *)GlobalLock(hmem);
  387. if(hAppOwned[TXT]!=0L) {
  388. hddedata=hAppOwned[TXT];
  389. GlobalUnlock(hmem);
  390. return hddedata;
  391. }
  392. hdc=GetDC(hwndDisplay);
  393. if(!hdc) {
  394. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hdc ret from GetDC! (server)\r\n");
  395. GlobalUnlock(hmem);
  396. return 0;
  397. }
  398. hBrush=CreateSolidBrush(WHITE);
  399. if(!hBrush) {
  400. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hBrush ret from CreateSolidBrush! (server)\r\n");
  401. EndPaint(hwndDisplay,&ps);
  402. GlobalUnlock(hmem);
  403. return 0;
  404. }
  405. GetClientRect(hwndDisplay,&rc);
  406. FillRect(hdc,&rc,hBrush);
  407. DeleteObject(hBrush);
  408. DrawText(hdc, "Data:CF_TEXT format", -1, &rc, DT_LEFT|DT_TOP);
  409. ReleaseDC(hwndDisplay,hdc);
  410. hddedata=DdeAddData(hData, "Data:CF_TEXT format", 20, 0);
  411. l=GetWindowLong(hwndMain,OFFSET_FLAGS);
  412. if(l&FLAG_APPOWNED) {
  413. hAppOwned[TXT]=hddedata;
  414. }
  415. GlobalUnlock(hmem);
  416. return hddedata;
  417. }
  418. HDDEDATA RenderTestItem_DIB(
  419. HDDEDATA hData)
  420. {
  421. HWND hwnd;
  422. LONG length;
  423. HDC hdc,hdcMem;
  424. RECT r;
  425. INT width,height,dibhdr;
  426. HBITMAP hbmap;
  427. HANDLE hobj;
  428. LPBITMAPINFO lpbitinfo;
  429. LPBITMAPINFOHEADER lpbithdr;
  430. LPBYTE lpbits;
  431. LPBYTE lpdata;
  432. HDDEDATA hddedata;
  433. INT ip,ibpp;
  434. CHAR sz[100];
  435. LONG l;
  436. HDDEDATA FAR *hAppOwned;
  437. HANDLE hmem,hm;
  438. Balance(OFFSET_SERVER);
  439. hwnd=(HWND)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HWNDDISPLAY);
  440. SetWindowText(hwnd,"Server - CF_DIB");
  441. // if we are running app owned then we just reuse our
  442. // last handle.
  443. hmem=(HANDLE)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HAPPOWNED);
  444. hAppOwned=(HDDEDATA FAR *)GlobalLock(hmem);
  445. if(hAppOwned[DIB]!=0L) {
  446. hddedata=hAppOwned[DIB];
  447. GlobalUnlock(hmem);
  448. return hddedata;
  449. }
  450. length = sizeof(HBITMAP);
  451. hdc=GetDC(hwnd);
  452. if(!hdc) {
  453. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hdc (server)\r\n");
  454. GlobalUnlock(hmem);
  455. return 0;
  456. }
  457. ibpp=GetDeviceCaps(hdc,BITSPIXEL);
  458. ip=GetDeviceCaps(hdc,PLANES);
  459. hdcMem=CreateCompatibleDC(hdc);
  460. if(!hdcMem) {
  461. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hdc (server)\r\n");
  462. ReleaseDC(hwnd,hdc);
  463. GlobalUnlock(hmem);
  464. return 0;
  465. }
  466. GetClientRect(hwnd,&r);
  467. width=r.right-r.left;
  468. height=r.bottom-r.top;
  469. hbmap=CreateCompatibleBitmap(hdcMem,width,height);
  470. if(!hbmap) {
  471. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hbmap-CreateCompatibleBitmap failed (server)\r\n");
  472. DeleteDC(hdcMem);
  473. ReleaseDC(hwnd,hdc);
  474. GlobalUnlock(hmem);
  475. return 0;
  476. }
  477. hobj=SelectObject(hdcMem,hbmap);
  478. if(!hobj) {
  479. DDEMLERROR("DdeStrs.Exe -- ERR (Server), SelectObject failed\r\n");
  480. DeleteObject(hbmap);
  481. DeleteDC(hdcMem);
  482. ReleaseDC(hwnd,hdc);
  483. GlobalUnlock(hmem);
  484. return 0;
  485. }
  486. if(!PatBlt(hdcMem,r.left,r.top,width,height,WHITENESS))
  487. DDEMLERROR("DdeStrs.Exe -- ERR (Server), PatBlt failed\r\n");
  488. // Deselect object (must be done according to docs)
  489. hobj=SelectObject(hdcMem,hobj);
  490. if(!hobj) DDEMLERROR("DdeStrs.Exe -- ERR (Server), SelectObject [call 2] failed\r\n");
  491. // Set up for a monochrome bitmap.
  492. dibhdr =sizeof(BITMAPINFO)+(sizeof(RGBQUAD));
  493. // dib header plus area for raw bits
  494. length =dibhdr+(((width*ibpp)+31)/32)*ip*height*4;
  495. // Allocate memory for the DIB
  496. hm=GlobalAlloc(GMEM_ZEROINIT|GMEM_DDESHARE,length);
  497. if(!hm) {
  498. DDEMLERROR("DdeStrs.Exe - RenderTestItem_DIB\r\n");
  499. wsprintf(sz, "DdeStrs.Exe - GobalAlloc failed, allocation size = %d\r\n", length );
  500. DDEMLERROR(&sz[0]);
  501. DeleteObject(hbmap);
  502. DeleteDC(hdcMem);
  503. ReleaseDC(hwnd,hdc);
  504. GlobalUnlock(hmem);
  505. return 0;
  506. }
  507. lpdata=(LPBYTE)GlobalLock(hm);
  508. lpbitinfo=(LPBITMAPINFO)lpdata;
  509. lpbithdr=&(lpbitinfo->bmiHeader);
  510. lpbits=lpdata+dibhdr;
  511. lpbitinfo->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
  512. lpbitinfo->bmiHeader.biWidth=width;
  513. lpbitinfo->bmiHeader.biHeight=height;
  514. lpbitinfo->bmiHeader.biPlanes=1;
  515. lpbitinfo->bmiHeader.biBitCount=1;
  516. // I allocated zero init memory so the other values should
  517. // be 0 and will use the default.
  518. if(!GetDIBits(hdcMem,
  519. hbmap,
  520. 0,
  521. height,
  522. lpbits,
  523. lpbitinfo,
  524. DIB_RGB_COLORS))
  525. {
  526. DDEMLERROR("DdeStrs.Exe -- ERR (Server), GetDIBits failed\r\n");
  527. }
  528. SetDIBitsToDevice(hdc,
  529. 0,
  530. 0,
  531. (UINT)lpbitinfo->bmiHeader.biWidth,
  532. (UINT)lpbitinfo->bmiHeader.biHeight,
  533. 0,
  534. 0,
  535. 0,
  536. (UINT)(lpbitinfo->bmiHeader.biHeight),
  537. lpbits,
  538. lpbitinfo,
  539. DIB_RGB_COLORS);
  540. hddedata=DdeAddData(hData, &hm, sizeof(HANDLE), 0);
  541. GlobalUnlock(hm);
  542. DeleteObject(hbmap);
  543. DeleteDC(hdcMem);
  544. ReleaseDC(hwnd,hdc);
  545. l=GetWindowLong(hwndMain,OFFSET_FLAGS);
  546. if(l&FLAG_APPOWNED) {
  547. hAppOwned[DIB]=hddedata;
  548. }
  549. GlobalUnlock(hmem);
  550. return hddedata;
  551. }
  552. HDDEDATA RenderTestItem_BITMAP(
  553. HDDEDATA hData)
  554. {
  555. HWND hwnd;
  556. LONG length;
  557. HDC hdc,hdcMem;
  558. RECT r;
  559. INT width,height;
  560. HBITMAP hbmap;
  561. HANDLE hobj;
  562. HDDEDATA hddedata;
  563. DWORD d;
  564. LPBYTE lpdata=(LPBYTE)&d;
  565. LONG l;
  566. HDDEDATA FAR *hAppOwned;
  567. HANDLE hmem;
  568. Balance(OFFSET_SERVER);
  569. hwnd=(HWND)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HWNDDISPLAY);
  570. SetWindowText(hwnd,"Server - CF_BITMAP");
  571. // if we are running app owned then we just reuse our
  572. // last handle.
  573. hmem=(HANDLE)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HAPPOWNED);
  574. hAppOwned=(HDDEDATA FAR *)GlobalLock(hmem);
  575. if(hAppOwned[BITMAP]!=0L) {
  576. hddedata=hAppOwned[BITMAP];
  577. GlobalUnlock(hmem);
  578. return hddedata;
  579. }
  580. length = sizeof(HBITMAP);
  581. hdc=GetDC(hwnd);
  582. hdcMem=CreateCompatibleDC(hdc);
  583. if(!hdc) {
  584. DDEMLERROR("DdeStrs.Exe -- ERR (Server), NULL hdc\r\n");
  585. GlobalUnlock(hmem);
  586. return 0;
  587. }
  588. if(!hdcMem) {
  589. DDEMLERROR("DdeStrs.Exe -- ERR (Server), NULL hdc\r\n");
  590. ReleaseDC(hwnd,hdc);
  591. GlobalUnlock(hmem);
  592. return 0;
  593. }
  594. GetClientRect(hwnd,&r);
  595. width=r.right-r.left;
  596. height=r.bottom-r.top;
  597. hbmap=CreateCompatibleBitmap(hdcMem,width,height);
  598. if(!hbmap) {
  599. DDEMLERROR("DdeStrs.Exe -- ERR (Server), NULL hbmap\r\n");
  600. DeleteDC(hdcMem);
  601. ReleaseDC(hwnd,hdc);
  602. GlobalUnlock(hmem);
  603. return 0;
  604. }
  605. hobj=SelectObject(hdcMem,hbmap);
  606. if(!hobj) {
  607. DDEMLERROR("DdeStrs.Exe -- ERR (Server), SelectObject failed\r\n");
  608. DeleteObject(hbmap);
  609. DeleteDC(hdcMem);
  610. ReleaseDC(hwnd,hdc);
  611. GlobalUnlock(hmem);
  612. return 0;
  613. }
  614. if(!PatBlt(hdcMem,r.left,r.top,width,height,WHITENESS))
  615. DDEMLERROR("DdeStrs.Exe -- ERR (Server), PatBlt failed\r\n");
  616. if(!BitBlt(hdc,0,0,width,height,hdcMem,0,0,SRCCOPY))
  617. DDEMLERROR("DdeStrs.Exe -- ERR (Server), BitBlt failed\r\n");
  618. #ifdef WIN32
  619. memcpy(lpdata,&hbmap,(INT)length);
  620. #else
  621. _fmemcpy(lpdata,&hbmap,(INT)length);
  622. #endif
  623. hddedata=DdeAddData(hData, lpdata, length, 0);
  624. // Object will be deleted by client! Not server.
  625. SelectObject(hdcMem,hobj);
  626. DeleteDC(hdcMem);
  627. ReleaseDC(hwnd,hdc);
  628. l=GetWindowLong(hwndMain,OFFSET_FLAGS);
  629. if(l&FLAG_APPOWNED) {
  630. hAppOwned[BITMAP]=hddedata;
  631. }
  632. GlobalUnlock(hmem);
  633. return hddedata;
  634. }
  635. #ifdef WIN32
  636. HDDEDATA RenderTestItem_ENHMETA(
  637. HDDEDATA hData)
  638. {
  639. HWND hwnd;
  640. HDDEDATA hddedata;
  641. HDC hdc,hdcMem;
  642. INT width,height,length;
  643. RECT r;
  644. HANDLE hemf;
  645. DWORD d;
  646. LPBYTE lpdata=(LPBYTE)&d;
  647. LONG l;
  648. HDDEDATA FAR *hAppOwned;
  649. HANDLE hmem;
  650. #ifdef WIN32
  651. XFORM xp;
  652. LPXFORM lpxform=&xp;
  653. #endif
  654. Balance(OFFSET_SERVER);
  655. hwnd=GetThreadLong(GETCURRENTTHREADID(),OFFSET_HWNDDISPLAY);
  656. SetWindowText(hwnd,"Server - CF_ENHMETAFILE");
  657. // if we are running app owned then we just reuse our
  658. // last handle.
  659. hmem=(HANDLE)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HAPPOWNED);
  660. hAppOwned=GlobalLock(hmem);
  661. if(hAppOwned[ENHMETA]!=0L) {
  662. hddedata=hAppOwned[ENHMETA];
  663. GlobalUnlock(hmem);
  664. return hddedata;
  665. }
  666. hdc=GetDC(hwnd); //JOHNSP:CHANGE - below few lines
  667. if(!hdc) {
  668. DDEMLERROR("DdeStrs.Exe -- ERR (Server), NULL hdc\r\n");
  669. GlobalUnlock(hmem);
  670. return 0;
  671. }
  672. hdcMem=CreateEnhMetaFile(hdc,NULL,NULL,NULL);
  673. if(!hdcMem) {
  674. DDEMLERROR("DdeStrs.Exe -- ERR (Server), NULL hdc\r\n");
  675. ReleaseDC(hwnd,hdc);
  676. GlobalUnlock(hmem);
  677. return 0;
  678. }
  679. length=sizeof(HANDLE);
  680. GetClientRect(hwnd,&r);
  681. width=r.right-r.left;
  682. height=r.bottom-r.top;
  683. if(!PatBlt(hdcMem,r.left,r.top,width,height,WHITENESS))
  684. DDEMLERROR("DdeStrs.Exe -- ERR:PatBlt failed (server)\r\n");
  685. hemf=CloseEnhMetaFile(hdcMem);
  686. if(!hemf) {
  687. DDEMLERROR("DdeStrs.Exe -- ERR:CloseEnhMetaFile failed (server)\r\n");
  688. ReleaseDC(hwnd,hdc);
  689. GlobalUnlock(hmem);
  690. return 0;
  691. }
  692. #ifdef WIN32
  693. memcpy(lpdata,&hemf,length);
  694. #else
  695. _fmemcpy(lpdata,&hemf,length);
  696. #endif
  697. if(!PlayEnhMetaFile(hdc,hemf,&r))
  698. DDEMLERROR("DdeStrs.Exe -- ERR:PlayEnhMetaFile failed (server)\r\n");
  699. hddedata=DdeAddData(hData, lpdata, length, 0);
  700. ReleaseDC(hwnd,hdc);
  701. l=GetWindowLong(hwndMain,OFFSET_FLAGS);
  702. if(l&FLAG_APPOWNED) {
  703. hAppOwned[ENHMETA]=hddedata;
  704. }
  705. GlobalUnlock(hmem);
  706. return hddedata;
  707. }
  708. #endif
  709. HDDEDATA RenderTestItem_METAPICT(
  710. HDDEDATA hData)
  711. {
  712. HWND hwnd;
  713. HDDEDATA hddedata;
  714. HDC hdc,hdcMem;
  715. INT width,height,length;
  716. RECT r;
  717. HANDLE hmf;
  718. LPMETAFILEPICT lpMfp;
  719. DWORD d;
  720. LPBYTE lpdata=(LPBYTE)&d;
  721. CHAR sz[100];
  722. LONG l;
  723. HDDEDATA FAR *hAppOwned;
  724. HANDLE hmem,hm;
  725. Balance(OFFSET_SERVER);
  726. hwnd=(HWND)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HWNDDISPLAY);
  727. SetWindowText(hwnd,"Server - CF_METAFILEPICT");
  728. // if we are running app owned then we just reuse our
  729. // last handle.
  730. hmem=(HANDLE)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HAPPOWNED);
  731. hAppOwned=(HDDEDATA FAR *)GlobalLock(hmem);
  732. if(hAppOwned[METAPICT]!=0L) {
  733. hddedata=hAppOwned[METAPICT];
  734. GlobalUnlock(hmem);
  735. return hddedata;
  736. }
  737. hdcMem=CreateMetaFile(NULL);
  738. if(!hdcMem) {
  739. DDEMLERROR("DdeStrs.Exe -- ERR: NULL hdc ret from CreateMetaFile, (Server)\r\n");
  740. GlobalUnlock(hmem);
  741. return 0;
  742. }
  743. length=sizeof(HANDLE);
  744. GetClientRect(hwnd,&r);
  745. width=r.right-r.left;
  746. height=r.bottom-r.top;
  747. if(!PatBlt(hdcMem,r.left,r.top,width,height,WHITENESS))
  748. DDEMLERROR("DdeStrs.Exe -- ERR:PatBlt failed (server)\r\n");
  749. hmf=CloseMetaFile(hdcMem);
  750. if(!hmf) {
  751. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hmf ret CloseMetaFile! (Server)\r\n");
  752. GlobalUnlock(hmem);
  753. return 0;
  754. }
  755. hm=GlobalAlloc(GMEM_ZEROINIT|GMEM_DDESHARE,sizeof(METAFILEPICT));
  756. if(!hm) {
  757. DDEMLERROR("DdeStrs.Exe - RenderTestItem_METAPICT\r\n");
  758. wsprintf(sz, "DdeStrs.Exe - GlobalAlloc failed, allocation size = %d\r\n", sizeof(METAFILEPICT) );
  759. DDEMLERROR(&sz[0]);
  760. DeleteMetaFile(hmf); //JOHNSP:CHANGE
  761. GlobalUnlock(hmem);
  762. return 0;
  763. }
  764. lpMfp=(LPMETAFILEPICT)GlobalLock(hm);
  765. lpMfp->mm = MM_TEXT;
  766. lpMfp->xExt = width;
  767. lpMfp->yExt = height;
  768. lpMfp->hMF = hmf;
  769. GlobalUnlock(hm);
  770. #ifdef WIN32
  771. memcpy(lpdata,&hm,length);
  772. #else
  773. _fmemcpy(lpdata,&hm,length);
  774. #endif
  775. hdc=GetDC(hwnd);
  776. if(!hdc) {
  777. DDEMLERROR("DdeStrs.Exe -- ERR:NULL hdc ret from GetDC, (Server)\r\n");
  778. GlobalFree(hm); //JOHNSP:CHANGE
  779. DeleteMetaFile(hmf); //JOHNSP:CHANGE
  780. GlobalUnlock(hmem);
  781. return 0;
  782. }
  783. else {
  784. hddedata=DdeAddData(hData, lpdata, length, 0); //JOHNSP:CHANGE
  785. PlayMetaFile(hdc,hmf);
  786. ReleaseDC(hwnd,hdc);
  787. }
  788. l=GetWindowLong(hwndMain,OFFSET_FLAGS);
  789. if(l&FLAG_APPOWNED) {
  790. hAppOwned[METAPICT]=hddedata;
  791. }
  792. GlobalUnlock(hmem);
  793. return hddedata;
  794. }
  795. HDDEDATA RenderTestItem_PALETTE(
  796. HDDEDATA hData)
  797. {
  798. HWND hwnd;
  799. HPALETTE hpal;
  800. LPLOGPALETTE lppal;
  801. HDDEDATA hddedata;
  802. INT length;
  803. DWORD d;
  804. LPBYTE lpdata=(LPBYTE)&d;
  805. CHAR sz[100];
  806. LONG l;
  807. HDDEDATA FAR *hAppOwned;
  808. HANDLE hmem,hm;
  809. HDC hdc;
  810. HANDLE hobj;
  811. HANDLE hbrush;
  812. RECT r;
  813. Balance(OFFSET_SERVER);
  814. hwnd=(HWND)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HWNDDISPLAY);
  815. SetWindowText(hwnd,"Server - CF_PALETTE");
  816. // if we are running app owned then we just reuse our
  817. // last handle.
  818. hmem=(HANDLE)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HAPPOWNED);
  819. hAppOwned=(HDDEDATA FAR *)GlobalLock(hmem);
  820. if(hAppOwned[PALETTE]!=0L) {
  821. hddedata=hAppOwned[PALETTE];
  822. GlobalUnlock(hmem);
  823. return hddedata;
  824. }
  825. length=sizeof(LOGPALETTE)+sizeof(PALETTEENTRY);
  826. lppal=(LPLOGPALETTE)GetMem(length,&hm);
  827. if(!hm) {
  828. DDEMLERROR("DdeStrs.Exe - RenderTestItem_PALETTE\r\n");
  829. wsprintf(sz, "DdeStrs.Exe - GlobalAlloc failed, allocation size = %d\r\n", length );
  830. DDEMLERROR(&sz[0]);
  831. GlobalUnlock(hmem);
  832. return 0;
  833. }
  834. lppal->palNumEntries=1;
  835. lppal->palVersion=0x0300;
  836. lppal->palPalEntry[0].peRed =(BYTE)255;
  837. lppal->palPalEntry[0].peGreen=(BYTE)255;
  838. lppal->palPalEntry[0].peBlue =(BYTE)255;
  839. lppal->palPalEntry[0].peFlags=(BYTE)0;
  840. hpal=CreatePalette(lppal);
  841. if(!hpal) {
  842. DDEMLERROR("DdeStrs.Exe - NULL hpal ret CreatePalette! (server)\r\n");
  843. FreeMem(hm);
  844. GlobalUnlock(hmem);
  845. return 0;
  846. }
  847. FreeMem(hm);
  848. #ifdef WIN32
  849. memcpy(lpdata,&hpal,sizeof(HANDLE));
  850. #else
  851. _fmemcpy(lpdata,&hpal,sizeof(HANDLE));
  852. #endif
  853. hddedata=DdeAddData(hData, lpdata, sizeof(HPALETTE), 0);
  854. // Show that palette works.
  855. // NOTE: From here down if we get a failure we don't abort but
  856. // return hddedata to pass to the client. More basically if
  857. // an error is encountered below it only affects the display
  858. // on the server side!
  859. GetClientRect(hwnd,&r);
  860. hdc=GetDC(hwnd);
  861. if(!hdc) {
  862. DDEMLERROR("DdeStrs.Exe -- ERR:Null hdc (client)\r\n");
  863. return hddedata;
  864. }
  865. hobj=(HPALETTE)SelectPalette(hdc,hpal,FALSE);
  866. if(!hobj) {
  867. DDEMLERROR("DdeStrs.Exe -- ERR:Null hobj:SelectPalette failed (client)\r\n");
  868. ReleaseDC(hwnd,hdc);
  869. return hddedata;
  870. }
  871. RealizePalette(hdc);
  872. hbrush=CreateSolidBrush(PALETTEINDEX(0));
  873. if(!hbrush) {
  874. DDEMLERROR("DdeStrs.Exe -- ERR:Null hbrush ret from CreatSolidBrush (client)\r\n");
  875. SelectPalette(hdc,(HPALETTE)hobj,FALSE);
  876. ReleaseDC(hwnd,hdc);
  877. return hddedata;
  878. }
  879. FillRect(hdc,&r,hbrush);
  880. DeleteObject(hbrush);
  881. SelectPalette(hdc,(HPALETTE)hobj,FALSE);
  882. ReleaseDC(hwnd,hdc);
  883. // if we are running appowned, save first created handle
  884. // away for futher use.
  885. l=GetWindowLong(hwndMain,OFFSET_FLAGS);
  886. if(l&FLAG_APPOWNED) {
  887. hAppOwned[PALETTE]=hddedata;
  888. }
  889. GlobalUnlock(hmem);
  890. return hddedata;
  891. }
  892. BOOL Execute(
  893. HDDEDATA hData)
  894. {
  895. LPSTR psz,psz2;
  896. BOOL fRet = FALSE;
  897. LONG cServerhConvs;
  898. int i;
  899. HANDLE hmem;
  900. HCONV FAR *pServerhConvs;
  901. psz = DdeAccessData(hData, NULL);
  902. #ifdef WIN16
  903. if (!_fstricmp(psz, szExecDie)) {
  904. #else
  905. if (!stricmp(psz, szExecDie)) {
  906. #endif
  907. psz2=(LPSTR)-1;
  908. *psz; // GP Fault!
  909. fRet = TRUE;
  910. #ifdef WIN16
  911. } else if (!_fstricmp(psz, szExecRefresh)) {
  912. #else
  913. } else if (!stricmp(psz, szExecRefresh)) {
  914. #endif
  915. if (!DdePostAdvise(GetThreadLong(GETCURRENTTHREADID(),OFFSET_IDINST), 0, 0)) {
  916. DDEMLERROR("DdeStrs.Exe -- ERR DdePostAdvise failed\r\n");
  917. }
  918. fRet = TRUE;
  919. #ifdef WIN16
  920. } else if (!_fstricmp(psz, szExecDisconnect)) {
  921. #else
  922. } else if (!stricmp(psz, szExecDisconnect)) {
  923. #endif
  924. cServerhConvs=(INT)GetThreadLong(GETCURRENTTHREADID(),OFFSET_CSERVERCONVS);
  925. hmem=(HANDLE)GetThreadLong(GETCURRENTTHREADID(),OFFSET_HSERVERCONVS);
  926. pServerhConvs=(HCONV FAR *)GlobalLock(hmem);
  927. for (i = 0; i < cServerhConvs; i++) {
  928. if (!DdeDisconnect(pServerhConvs[i])) {
  929. DDEMLERROR("DdeStrs.Exe -- ERR DdeDisconnect failed\r\n");
  930. }
  931. }
  932. GlobalUnlock(hmem);
  933. SetThreadLong(GETCURRENTTHREADID(),OFFSET_CSERVERCONVS,0L);
  934. UpdateCount(hwndMain,OFFSET_SERVER_CONNECT,PNT);
  935. fRet = TRUE;
  936. }
  937. DdeUnaccessData(hData);
  938. return(fRet);
  939. }
  940. VOID PaintServer(
  941. HWND hwnd,
  942. PAINTSTRUCT *pps)
  943. {
  944. RECT rc;
  945. static CHAR szT[40];
  946. GetClientRect(hwnd, &rc);
  947. if (fServer) {
  948. rc.left += (rc.right - rc.left) >> 1; // server info is on right half
  949. }
  950. rc.bottom = rc.top + cyText;
  951. wsprintf(szT, "%d server connections", GetThreadLong(GETCURRENTTHREADID(),OFFSET_CSERVERCONVS));
  952. DrawText(pps->hdc, szT, -1, &rc, DT_RIGHT);
  953. OffsetRect(&rc, 0, cyText);
  954. wsprintf(szT, "%d server count", GetWindowLong(hwnd,OFFSET_SERVER));
  955. DrawText(pps->hdc, szT, -1, &rc, DT_RIGHT);
  956. OffsetRect(&rc, 0, cyText);
  957. }
  958. HDDEDATA FAR PASCAL CustomCallback(
  959. UINT wType,
  960. UINT wFmt,
  961. HCONV hConv,
  962. HSZ hsz1,
  963. HSZ hsz2,
  964. HDDEDATA hData,
  965. DWORD dwData1,
  966. DWORD dwData2)
  967. {
  968. LONG cServerhConvs,cClienthConvs;
  969. int i;
  970. HANDLE hmem;
  971. HCONV FAR *pServerhConvs;
  972. HCONV hC;
  973. HCONVLIST hConvList=0;
  974. DWORD dwid;
  975. LONG lflags;
  976. dwid=GETCURRENTTHREADID();
  977. cServerhConvs=(INT)GetThreadLong(dwid,OFFSET_CSERVERCONVS);
  978. switch (wType) {
  979. case XTYP_CONNECT_CONFIRM:
  980. hmem=(HANDLE)GetThreadLong(dwid,OFFSET_HSERVERCONVS);
  981. pServerhConvs=(HCONV FAR *)GlobalLock(hmem);
  982. pServerhConvs[cServerhConvs] = hConv;
  983. cServerhConvs++;
  984. SetThreadLong(dwid,OFFSET_CSERVERCONVS,cServerhConvs);
  985. UpdateCount(hwndMain,OFFSET_SERVER_CONNECT,PNT);
  986. if (cServerhConvs >= MAX_SERVER_HCONVS) {
  987. LOGDDEMLERROR("DdeStrs.Exe -- ERR-Number of connections > MAX\r\n");
  988. cServerhConvs--;
  989. SetThreadLong(dwid,OFFSET_CSERVERCONVS,cServerhConvs);
  990. UpdateCount(hwndMain,OFFSET_SERVER_CONNECT,PNT);
  991. }
  992. GlobalUnlock(hmem);
  993. break;
  994. case XTYP_DISCONNECT:
  995. if(fServer)
  996. {
  997. hmem=(HANDLE)GetThreadLong(dwid,OFFSET_HSERVERCONVS);
  998. pServerhConvs=(HCONV FAR *)GlobalLock(hmem);
  999. for (i = 0; i < cServerhConvs; i++)
  1000. {
  1001. if (pServerhConvs[i] == hConv)
  1002. {
  1003. cServerhConvs--;
  1004. SetThreadLong(dwid,OFFSET_CSERVERCONVS,cServerhConvs);
  1005. UpdateCount(hwndMain,OFFSET_SERVER_CONNECT,PNT);
  1006. for (; i < cServerhConvs; i++)
  1007. {
  1008. pServerhConvs[i] = pServerhConvs[i+1];
  1009. } // for
  1010. break;
  1011. } // if pServerhConvs
  1012. } // for i
  1013. GlobalUnlock(hmem);
  1014. } // fServer
  1015. // If the server is shutting down the conversation then we need
  1016. // to change our client connection count. Remember that the
  1017. // current conversation is valid until we return from this callback
  1018. // so don't count the current conversation.
  1019. if(fClient)
  1020. {
  1021. // *** Count Client Connections ****
  1022. cClienthConvs = 0;
  1023. hConvList=GetThreadLong(dwid,OFFSET_HCONVLIST);
  1024. if (hConvList)
  1025. {
  1026. hC = 0;
  1027. while (hC = DdeQueryNextServer(hConvList, hC))
  1028. {
  1029. if (hC!=hConv) cClienthConvs++;
  1030. } // while
  1031. } // if hConvList
  1032. SetThreadLong(dwid,OFFSET_CCLIENTCONVS,cClienthConvs);
  1033. } // if fClient
  1034. InvalidateRect(hwndMain, NULL, TRUE);
  1035. break;
  1036. case XTYP_REGISTER:
  1037. case XTYP_UNREGISTER:
  1038. lflags=GetWindowLong(hwndMain,OFFSET_FLAGS);
  1039. if(fClient && (FLAG_STOP!=(lflags&FLAG_STOP)))
  1040. {
  1041. ReconnectList();
  1042. }
  1043. break;
  1044. }
  1045. return(0);
  1046. }
  1047. BOOL Balance( INT itype ) {
  1048. if(itype==OFFSET_SERVER) {
  1049. UpdateCount(hwndMain,OFFSET_SERVER,INC);
  1050. }
  1051. else {
  1052. UpdateCount(hwndMain,OFFSET_CLIENT,INC);
  1053. }
  1054. return TRUE;
  1055. }
  1056.