home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 18.ddi / SAMPLES / DDEML / SERVER / DDEMLSV.C_ / DDEMLSV.C
Encoding:
C/C++ Source or Header  |  1993-02-08  |  21.9 KB  |  636 lines

  1. /****************************************************************************
  2.  
  3.     PROGRAM: DDEMLSV.c
  4.  
  5.     PURPOSE: Server template for Windows applications
  6.  
  7.     FUNCTIONS:
  8.  
  9.         WinMain() - calls initialization function, processes message loop
  10.         InitApplication() - initializes window data and registers window
  11.         InitInstance() - saves instance handle and creates main window
  12.         MainWndProc() - processes messages
  13.         About() - processes messages for "About" dialog box
  14.  
  15.     COMMENTS:
  16.  
  17.         Windows can have several copies of your application running at the
  18.         same time.  The variable hInst keeps track of which instance this
  19.         application is so that processing will be to the correct window.
  20.  
  21. ****************************************************************************/
  22. #include "ddemlsv.h"               /* specific to this program         */
  23. #include "huge.h"
  24. #include <string.h>
  25. #include <stdlib.h>
  26. #include <stdio.h>
  27.  
  28.  
  29. DWORD idInst = 0;
  30. CONVCONTEXT CCFilter = { sizeof(CONVCONTEXT), 0, 0, 0, 0L, 0L };
  31. HANDLE hInst;                       /* current instance                      */
  32. HWND hwndServer;
  33. RECT rcRand;
  34. RECT rcCount;
  35. RECT rcComment;
  36. RECT rcExec;
  37. RECT rcConnCount;
  38. RECT rcRndrDelay;
  39. RECT rcRunaway;
  40. RECT rcAllBlock;
  41. RECT rcNextAction;
  42. RECT rcHugeSize;
  43. RECT rcAppowned;
  44. RECT rcTopics;
  45. BOOL fAllBlocked = FALSE;
  46. BOOL fAllEnabled = TRUE;
  47. BOOL fEnableOneCB = FALSE;
  48. BOOL fBlockNextCB = FALSE;
  49. BOOL fTermNextCB = FALSE;
  50. BOOL fAppowned = FALSE;
  51. WORD cRunaway = 0;
  52. WORD RenderDelay = 0;
  53. DWORD count = 0;
  54. WORD seed = 0;
  55. HSZ hszAppName = NULL;
  56. char szClass[] = "ServerWClass";
  57. char szTopic[MAX_TOPIC] = "Test";
  58. char szServer[MAX_TOPIC] = "Server";
  59. char szComment[MAX_COMMENT];
  60. char szExec[MAX_EXEC] = "";
  61. char *pszComment;
  62. WORD cyText;
  63. WORD cServers = 0;
  64. HDDEDATA hDataHelp[CFORMATS] = {0};
  65. HDDEDATA hDataCount[CFORMATS] = {0};
  66. HDDEDATA hDataRand[CFORMATS] = {0};
  67. HDDEDATA hDataHuge[CFORMATS] = {0};
  68. DWORD cbHuge = 0;
  69.  
  70. char szDdeHelp[] = "DDEML test server help:\r\n\n"\
  71.     "The 'Server'(service) and 'Test'(topic) names may change.\r\n\n"\
  72.     "Items supported under the 'Test' topic are:\r\n"\
  73.     "\tCount:\tThis value increments on each data change.\r\n"\
  74.     "\tRand:\tThis value is randomly generated each data change.\r\n"\
  75.     "\tHuge:\tThis is randomlly generated text data >64k that the\r\n"\
  76.     "\t\tDDEML test client can verify.\r\n"\
  77.     "The above items change after any request if in Runaway mode and \r\n"\
  78.     "can bo POKEed in order to change their values.  POKEed Huge data \r\n"\
  79.     "must be in a special format to verify the correctness of the data \r\n"\
  80.     "or it will not be accepted.\r\n"\
  81.     "If the server is set to use app owned data handles, all data sent \r\n"\
  82.     "uses HDATA_APPOWNED data handles."\
  83.     ;
  84.  
  85. FORMATINFO aFormats[CFORMATS] = {
  86.     { 0, "TEXT" },      // exception!  predefined format, note:
  87.                         // we use the standard imposed by EXCEL of not including
  88.                         // the "CF_" and use all UPPERCASE.
  89.     { 0, "Dummy1"  },
  90.     { 0, "Dummy2"  },
  91. };
  92.  
  93.  
  94. /*
  95.  *          Topic and Item tables supported by this application.
  96.  */
  97.  
  98. /*   HSZ    PROCEDURE       PSZ        */
  99.  
  100. ITEMLIST SystemTopicItemList[CSYSTEMITEMS] = {
  101.  
  102.     { 0, TopicListXfer,  SZDDESYS_ITEM_TOPICS   },
  103.     { 0, ItemListXfer,   SZDDESYS_ITEM_SYSITEMS },
  104.     { 0, sysFormatsXfer, SZDDESYS_ITEM_FORMATS  },
  105.     { 0, HelpXfer,       SZDDESYS_ITEM_HELP},
  106.   };
  107.  
  108.  
  109. ITEMLIST TestTopicItemList[CTESTITEMS] = {
  110.  
  111.     { 0, TestRandomXfer, "Rand" },   // 0 index
  112.     { 0, TestCountXfer,  "Count"},   // 1 index
  113.     { 0, TestHugeXfer,   "Huge" },   // 2 index
  114.     { 0, ItemListXfer,   SZDDESYS_ITEM_SYSITEMS },  // 3 index
  115.   };
  116.  
  117.  
  118. /* The system topic is always assumed to be first. */
  119. /*   HSZ   PROCEDURE            #ofITEMS        PSZ     */
  120. TOPICLIST topicList[CTOPICS] = {
  121.  
  122.     { 0, SystemTopicItemList,   CSYSTEMITEMS,   SZDDESYS_TOPIC},    // 0 index
  123.     { 0, TestTopicItemList,     CTESTITEMS,     szTopic},           // 1 index
  124.   };
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131. /****************************************************************************
  132.  
  133.     FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
  134.  
  135.     PURPOSE: calls initialization function, processes message loop
  136.  
  137.     COMMENTS:
  138.  
  139.         Windows recognizes this function by name as the initial entry point
  140.         for the program.  This function calls the application initialization
  141.         routine, if no other instance of the program is running, and always
  142.         calls the instance initialization routine.  It then executes a message
  143.         retrieval and dispatch loop that is the top-level control structure
  144.         for the remainder of execution.  The loop is terminated when a WM_QUIT
  145.         message is received, at which time this function exits the application
  146.         instance by returning the value passed by PostQuitMessage().
  147.  
  148.         If this function must abort before entering the message loop, it
  149.         returns the conventional value NULL.
  150.  
  151. ****************************************************************************/
  152.  
  153. int PASCAL WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow)
  154. HANDLE hInstance;                            /* current instance             */
  155. HANDLE hPrevInstance;                        /* previous instance            */
  156. LPSTR lpCmdLine;                             /* command line                 */
  157. int nCmdShow;                                /* show-window type (open/icon) */
  158. {
  159.     MSG msg;                                 /* message                      */
  160.  
  161.     if (!hPrevInstance)                  /* Other instances of app running? */
  162.         if (!InitApplication(hInstance)) /* Initialize shared things */
  163.             return (FALSE);              /* Exits if unable to initialize     */
  164.  
  165.     /* Perform initializations that apply to a specific instance */
  166.  
  167.     if (!InitInstance(hInstance, nCmdShow))
  168.         return (FALSE);
  169.  
  170.     /* Acquire and dispatch messages until a WM_QUIT message is received. */
  171.  
  172.     while (GetMessage(&msg,        /* message structure                      */
  173.             NULL,                  /* handle of window receiving the message */
  174.             NULL,                  /* lowest message to examine              */
  175.             NULL))                 /* highest message to examine             */
  176.         {
  177.         TranslateMessage(&msg);    /* Translates virtual key codes           */
  178.         DispatchMessage(&msg);     /* Dispatches message to window           */
  179.     }
  180.  
  181.     UnregisterClass(szClass, hInstance);
  182.     return (msg.wParam);           /* Returns the value from PostQuitMessage */
  183. }
  184.  
  185.  
  186. /****************************************************************************
  187.  
  188.     FUNCTION: InitApplication(HANDLE)
  189.  
  190.     PURPOSE: Initializes window data and registers window class
  191.  
  192.     COMMENTS:
  193.  
  194.         This function is called at initialization time only if no other
  195.         instances of the application are running.  This function performs
  196.         initialization tasks that can be done once for any number of running
  197.         instances.
  198.  
  199.         In this case, we initialize a window class by filling out a data
  200.         structure of type WNDCLASS and calling the Windows RegisterClass()
  201.         function.  Since all instances of this application use the same window
  202.         class, we only need to do this when the first instance is initialized.
  203.  
  204.  
  205. ****************************************************************************/
  206.  
  207. BOOL InitApplication(hInstance)
  208. HANDLE hInstance;                              /* current instance           */
  209. {
  210.     WNDCLASS  wc;
  211.  
  212.     /* Fill in window class structure with parameters that describe the       */
  213.     /* main window.                                                           */
  214.  
  215.     wc.style = NULL;                    /* Class style(s).                    */
  216.     wc.lpfnWndProc = MainWndProc;       /* Function to retrieve messages for  */
  217.                                         /* windows of this class.             */
  218.     wc.cbClsExtra = 0;                  /* No per-class extra data.           */
  219.     wc.cbWndExtra = 0;                  /* No per-window extra data.          */
  220.     wc.hInstance = hInstance;           /* Application that owns the class.   */
  221.     wc.hIcon = LoadIcon(hInstance, "server");
  222.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  223.     wc.hbrBackground = COLOR_APPWORKSPACE+1;
  224.     wc.lpszMenuName =  "ServerMenu";   /* Name of menu resource in .RC file. */
  225.     wc.lpszClassName = "ServerWClass"; /* Name used in call to CreateWindow. */
  226.  
  227.     /* Register the window class and return success/failure code. */
  228.  
  229.     return (RegisterClass(&wc));
  230.  
  231. }
  232.  
  233.  
  234. /****************************************************************************
  235.  
  236.     FUNCTION:  InitInstance(HANDLE, int)
  237.  
  238.     PURPOSE:  Saves instance handle and creates main window
  239.  
  240.     COMMENTS:
  241.  
  242.         This function is called at initialization time for every instance of
  243.         this application.  This function performs initialization tasks that
  244.         cannot be shared by multiple instances.
  245.  
  246.         In this case, we save the instance handle in a static variable and
  247.         create and display the main program window.
  248.  
  249. ****************************************************************************/
  250.  
  251. BOOL InitInstance(hInstance, nCmdShow)
  252.     HANDLE          hInstance;          /* Current instance identifier.       */
  253.     int             nCmdShow;           /* Param for first ShowWindow() call. */
  254. {
  255.     int i;
  256.     RECT Rect;
  257.     TEXTMETRIC metrics;
  258.     HDC hdc;
  259.  
  260.     /* Save the instance handle in static variable, which will be used in  */
  261.     /* many subsequence calls from this application to Windows.            */
  262.  
  263.     hInst = hInstance;
  264.  
  265.  
  266.     /* Create a main window for this application instance.  */
  267.  
  268.     hwndServer = CreateWindow(
  269.         "ServerWClass",                /* See RegisterClass() call.          */
  270.         "Server|Test",
  271.         WS_OVERLAPPEDWINDOW,            /* Window style.                      */
  272.         CW_USEDEFAULT,                  /* Default horizontal position.       */
  273.         CW_USEDEFAULT,                  /* Default vertical position.         */
  274.         400,
  275.         200,
  276.         NULL,                           /* Overlapped windows have no parent. */
  277.         NULL,                           /* Use the window class menu.         */
  278.         hInstance,                      /* This instance owns this window.    */
  279.         NULL                            /* Pointer not needed.                */
  280.     );
  281.  
  282.     GetClientRect(hwndServer, (LPRECT) &Rect);
  283.  
  284.     /* If window could not be created, return "failure" */
  285.  
  286.     if (!hwndServer)
  287.         return (FALSE);
  288.  
  289.     hdc = GetDC(hwndServer);
  290.     GetTextMetrics(hdc, &metrics);
  291.     cyText = metrics.tmHeight + metrics.tmExternalLeading;
  292.     ReleaseDC(hwndServer, hdc);
  293.  
  294.     aFormats[0].atom = CF_TEXT; // exception - predefined.
  295.     for (i = 1; i < CFORMATS; i++) {
  296.         aFormats[i].atom = RegisterClipboardFormat(aFormats[i].sz);
  297.     }
  298.  
  299.     /* Make the window visible; update its client area; and return "success" */
  300.  
  301.     ShowWindow(hwndServer, nCmdShow);  /* Show the window                        */
  302.     UpdateWindow(hwndServer);          /* Sends WM_PAINT message                 */
  303.     seed = 1;
  304.     srand(1);
  305.     CCFilter.iCodePage = CP_WINANSI;   // initial default codepage
  306.     if (!DdeInitialize(&idInst, (PFNCALLBACK)MakeProcInstance((FARPROC)DdeCallback,
  307.                 hInstance), APPCMD_FILTERINITS, NULL)) {
  308.         Hszize();
  309.         DdeNameService(idInst, hszAppName, NULL, DNS_REGISTER);
  310.         return(TRUE);
  311.     }
  312.     return (FALSE);
  313.  
  314. }
  315.  
  316. /****************************************************************************
  317.  
  318.     FUNCTION: MainWndProc(HWND, UINT, WPARAM, LPARAM)
  319.  
  320.     PURPOSE:  Processes messages
  321.  
  322.     MESSAGES:
  323.  
  324.         WM_COMMAND    - application menu (About dialog box)
  325.         WM_DESTROY    - destroy window
  326.  
  327.     COMMENTS:
  328.  
  329.         To process the IDM_ABOUT message, call MakeProcInstance() to get the
  330.         current instance address of the About() function.  Then call Dialog
  331.         box which will create the box according to the information in your
  332.         server.rc file and turn control over to the About() function.   When
  333.         it returns, free the intance address.
  334.  
  335. ****************************************************************************/
  336.  
  337. long FAR PASCAL __export MainWndProc(hWnd, message, wParam, lParam)
  338. HWND hWnd;                                /* window handle                   */
  339. UINT message;                  /* type of message         */
  340. WPARAM wParam;                    /* additional information           */
  341. LPARAM lParam;                    /* additional information           */
  342. {
  343.     switch (message) {
  344.     case WM_INITMENU:
  345.         if (GetMenu(hWnd) != wParam)
  346.             break;
  347.  
  348.         CheckMenuItem(wParam, IDM_BLOCKALLCBS,
  349.                 fAllBlocked ? MF_CHECKED : MF_UNCHECKED);
  350.         CheckMenuItem(wParam, IDM_UNBLOCKALLCBS,
  351.                 fAllEnabled ? MF_CHECKED : MF_UNCHECKED);
  352.         CheckMenuItem(wParam, IDM_BLOCKNEXTCB,
  353.                 fBlockNextCB ? MF_CHECKED : MF_UNCHECKED);
  354.         CheckMenuItem(wParam, IDM_TERMNEXTCB,
  355.                 fTermNextCB ? MF_CHECKED : MF_UNCHECKED);
  356.         CheckMenuItem(wParam, IDM_RUNAWAY,
  357.                 cRunaway ? MF_CHECKED : MF_UNCHECKED);
  358.         CheckMenuItem(wParam, IDM_APPOWNED,
  359.                 fAppowned ? MF_CHECKED : MF_UNCHECKED);
  360.         break;
  361.  
  362.     case WM_COMMAND:           /* message: command from application menu */
  363.         switch (wParam) {
  364.         case IDM_ENABLEONECB:
  365.             DdeEnableCallback(idInst, NULL, EC_ENABLEONE);
  366.             fAllBlocked = FALSE;
  367.             fAllEnabled = FALSE;
  368.             InvalidateRect(hwndServer, &rcAllBlock, TRUE);
  369.             break;
  370.  
  371.         case IDM_TERMNEXTCB:
  372.             fTermNextCB = !fTermNextCB;
  373.             InvalidateRect(hwndServer, &rcNextAction, TRUE);
  374.             break;
  375.  
  376.         case IDM_BLOCKNEXTCB:
  377.             fBlockNextCB = !fBlockNextCB;
  378.             InvalidateRect(hwndServer, &rcNextAction, TRUE);
  379.             break;
  380.  
  381.         case IDM_BLOCKALLCBS:
  382.             DdeEnableCallback(idInst, NULL, EC_DISABLE);
  383.             fAllBlocked = TRUE;
  384.             fAllEnabled = FALSE;
  385.             InvalidateRect(hwndServer, &rcAllBlock, TRUE);
  386.             break;
  387.  
  388.         case IDM_UNBLOCKALLCBS:
  389.             DdeEnableCallback(idInst, NULL, EC_ENABLEALL);
  390.             fAllEnabled = TRUE;
  391.             fAllBlocked = FALSE;
  392.             InvalidateRect(hwndServer, &rcAllBlock, TRUE);
  393.             break;
  394.  
  395.         case IDM_APPOWNED:
  396.             fAppowned = !fAppowned;
  397.             if (!fAppowned) {
  398.                 WORD iFmt;
  399.                 for (iFmt = 0; iFmt < CFORMATS; iFmt++) {
  400.                     if (hDataHuge[iFmt]) {
  401.                         DdeFreeDataHandle(hDataHuge[iFmt]);
  402.                         hDataHuge[iFmt] = 0;
  403.                         InvalidateRect(hwndServer, &rcHugeSize, TRUE);
  404.                     }
  405.                     if (hDataCount[iFmt]) {
  406.                         DdeFreeDataHandle(hDataCount[iFmt]);
  407.                         hDataCount[iFmt] = 0;
  408.                     }
  409.                     if (hDataRand[iFmt]) {
  410.                         DdeFreeDataHandle(hDataRand[iFmt]);
  411.                         hDataRand[iFmt] = 0;
  412.                     }
  413.                     if (hDataHelp[iFmt]) {
  414.                         DdeFreeDataHandle(hDataHelp[iFmt]);
  415.                         hDataHelp[iFmt] = 0;
  416.                     }
  417.                 }
  418.             }
  419.             InvalidateRect(hwndServer, &rcAppowned, TRUE);
  420.             break;
  421.  
  422.         case IDM_RUNAWAY:
  423.             cRunaway = !cRunaway;
  424.             InvalidateRect(hwndServer, &rcRunaway, TRUE);
  425.             if (!cRunaway) {
  426.                 break;
  427.             }
  428.             // fall through
  429.  
  430.         case IDM_CHANGEDATA:
  431.             PostMessage(hwndServer, UM_CHGDATA, 1, 0);  // rand
  432.             PostMessage(hwndServer, UM_CHGDATA, 1, 1);  // count
  433.             break;
  434.  
  435.         case IDM_RENDERDELAY:
  436.             DoDialog("VALUEENTRY", RenderDelayDlgProc, 0, TRUE);
  437.             InvalidateRect(hwndServer, &rcRndrDelay, TRUE);
  438.             break;
  439.  
  440.         case IDM_SETSERVER:
  441.             DoDialog("VALUEENTRY", SetServerDlgProc, 0, TRUE);
  442.             break;
  443.  
  444.         case IDM_SETTOPIC:
  445.             DoDialog("VALUEENTRY", SetTopicDlgProc, 0, TRUE);
  446.             break;
  447.  
  448.         case IDM_CONTEXT:
  449.             DoDialog("CONTEXT", ContextDlgProc, 0, TRUE);
  450.             break;
  451.  
  452.         case IDM_ABOUT:
  453.             DoDialog("ABOUT", About, 0, TRUE);
  454.             break;
  455.  
  456.         case IDM_HELP:
  457.            break;
  458.  
  459.         default:
  460.             return (DefWindowProc(hWnd, message, wParam, lParam));
  461.         }
  462.         break;
  463.  
  464.     case WM_PAINT:
  465.         PaintServer(hWnd);
  466.         break;
  467.  
  468.     case UM_CHGDATA:
  469.         {
  470.             WORD iFmt;
  471.  
  472.             // wParam = TopicIndex,
  473.             // LOWORD(lParam) = ItemIndex
  474.             // We asynchronously do DdePostAdvise() calls to prevent infinite
  475.             // loops when in runaway mode.
  476.             if (wParam == 1) {  // test topic
  477.                 if (lParam == 0) {  // rand item
  478.                     seed = rand();
  479.                     for (iFmt = 0; iFmt < CFORMATS ; iFmt++) {
  480.                         if (hDataRand[iFmt]) {
  481.                             DdeFreeDataHandle(hDataRand[iFmt]);
  482.                             hDataRand[iFmt] = 0;
  483.                         }
  484.                     }
  485.                     InvalidateRect(hwndServer, &rcRand, TRUE);
  486.                     DdePostAdvise(idInst, topicList[wParam].hszTopic,
  487.                             (HSZ)topicList[wParam].pItemList[lParam].hszItem);
  488.                 }
  489.                 if (lParam == 1) {  // count item
  490.                     count++;
  491.                     for (iFmt = 0; iFmt < CFORMATS ; iFmt++) {
  492.                         if (hDataCount[iFmt]) {
  493.                             DdeFreeDataHandle(hDataCount[iFmt]);
  494.                             hDataCount[iFmt] = 0;
  495.                         }
  496.                     }
  497.                     InvalidateRect(hwndServer, &rcCount, TRUE);
  498.                     DdePostAdvise(idInst, topicList[wParam].hszTopic,
  499.                             (HSZ)topicList[wParam].pItemList[lParam].hszItem);
  500.                 }
  501.                 // Huge item does not runaway - too slow.
  502.             }
  503.             if (cRunaway) {
  504.                 Delay(50, TRUE);
  505.                         // This gives enough time for the system to remain
  506.                         // useable in runaway mode.
  507.                 PostMessage(hwndServer, UM_CHGDATA, wParam, lParam);
  508.             }
  509.         }
  510.         break;
  511.  
  512.     case WM_DESTROY:                  /* message: window being destroyed */
  513.         if (fAppowned)
  514.             SendMessage(hwndServer, WM_COMMAND, IDM_APPOWNED, 0);
  515.         DdeNameService(idInst, NULL, NULL, DNS_UNREGISTER); // unregister all services
  516.         UnHszize();
  517.         DdeUninitialize(idInst);
  518.         PostQuitMessage(0);
  519.         break;
  520.  
  521.     default:
  522.         return (DefWindowProc(hWnd, message, wParam, lParam));
  523.     }
  524.     return (NULL);
  525. }
  526.  
  527.  
  528.  
  529.  
  530.  
  531. void Delay(
  532. DWORD delay,
  533. BOOL fModal)
  534. {
  535.     MSG msg;
  536.     delay = GetCurrentTime() + delay;
  537.     while (GetCurrentTime() < delay) {
  538.         if (fModal && PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE)) {
  539.             TranslateMessage(&msg);
  540.             DispatchMessage(&msg);
  541.         }
  542.     }
  543. }
  544.  
  545.  
  546.  
  547. /*
  548.  * This function not only paints the server client area with current info,
  549.  * it also has the side effect of setting the global RECTs that bound each
  550.  * info area.  This way flashing is reduced.
  551.  */
  552. VOID PaintServer(
  553. HWND hwnd)
  554. {
  555.     PAINTSTRUCT ps;
  556.     RECT rc;
  557.     char szT[MAX_COMMENT];
  558.  
  559.     BeginPaint(hwnd, &ps);
  560.     SetBkMode(ps.hdc, TRANSPARENT);
  561.     GetClientRect(hwnd, &rc);
  562.     rc.bottom = rc.top + cyText;    // all rects are cyText in height.
  563.  
  564.     wsprintf(szT, "Items available on the %s topic: Count, Rand, Huge.", (LPSTR)szTopic);
  565.     rcTopics = rc;
  566.     DrawTextLine(ps.hdc, &ps.rcPaint, &rc, szT);
  567.  
  568.     rcComment = rc;
  569.     DrawTextLine(ps.hdc, &ps.rcPaint, &rc, pszComment);
  570.  
  571.     wsprintf(szT, "# of connections:%d", cServers);
  572.     rcConnCount = rc;
  573.     DrawTextLine(ps.hdc, &ps.rcPaint, &rc, szT);
  574.  
  575.     szT[0] = '\0';
  576.     rcAllBlock = rc;
  577.     if (fAllEnabled)
  578.         DrawTextLine(ps.hdc, &ps.rcPaint, &rc, "All Conversations are Enabled.");
  579.     else if (fAllBlocked)
  580.         DrawTextLine(ps.hdc, &ps.rcPaint, &rc, "All Conversations are Blocked.");
  581.     else
  582.         DrawTextLine(ps.hdc, &ps.rcPaint, &rc, szT);
  583.  
  584.     rcNextAction = rc;
  585.     if (fBlockNextCB)
  586.         DrawTextLine(ps.hdc, &ps.rcPaint, &rc, "Next callback will block.");
  587.     else if (fTermNextCB)
  588.         DrawTextLine(ps.hdc, &ps.rcPaint, &rc, "Next callback will terminate.");
  589.     else
  590.         DrawTextLine(ps.hdc, &ps.rcPaint, &rc, szT);
  591.  
  592.     wsprintf(szT, "Count item = %ld", count);
  593.     rcCount = rc;
  594.     DrawTextLine(ps.hdc, &ps.rcPaint, &rc, szT);
  595.  
  596.     wsprintf(szT, "Rand item = %d", seed);
  597.     rcRand = rc;
  598.     DrawTextLine(ps.hdc, &ps.rcPaint, &rc, szT);
  599.  
  600.     wsprintf(szT, "Huge item size = %ld", cbHuge);
  601.     rcHugeSize = rc;
  602.     DrawTextLine(ps.hdc, &ps.rcPaint, &rc, szT);
  603.  
  604.     wsprintf(szT, "Render delay is %d milliseconds.", RenderDelay);
  605.     rcRndrDelay = rc;
  606.     DrawTextLine(ps.hdc, &ps.rcPaint, &rc, szT);
  607.  
  608.     rcExec = rc;
  609.     DrawTextLine(ps.hdc, &ps.rcPaint, &rc, szExec);
  610.  
  611.     rcRunaway = rc;
  612.     DrawTextLine(ps.hdc, &ps.rcPaint, &rc, cRunaway ? "Runaway active." : "");
  613.  
  614.     rcAppowned = rc;
  615.     DrawTextLine(ps.hdc, &ps.rcPaint, &rc, fAppowned ? "Using AppOwned Data Handles." : "");
  616.  
  617.     EndPaint(hwnd, &ps);
  618. }
  619.  
  620.  
  621. VOID DrawTextLine(
  622. HDC hdc,
  623. RECT *prcClip,
  624. RECT *prcText,
  625. PSTR psz)
  626. {
  627.     RECT rc;
  628.  
  629.     if (IntersectRect(&rc, prcText, prcClip)) {
  630.         DrawText(hdc, psz, -1, prcText,
  631.                 DT_LEFT | DT_EXTERNALLEADING | DT_SINGLELINE | DT_EXPANDTABS |
  632.                 DT_NOCLIP | DT_NOPREFIX);
  633.     }
  634.     OffsetRect(prcText, 0, cyText);
  635. }
  636.